babylon.module.d.ts 5.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867
  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. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module "babylonjs/Misc/logger" {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module "babylonjs/Misc/typeStore" {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module "babylonjs/Misc/deepCopier" {
  377. /**
  378. * Class containing a set of static utilities functions for deep copy.
  379. */
  380. export class DeepCopier {
  381. /**
  382. * Tries to copy an object by duplicating every property
  383. * @param source defines the source object
  384. * @param destination defines the target object
  385. * @param doNotCopyList defines a list of properties to avoid
  386. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  387. */
  388. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  389. }
  390. }
  391. declare module "babylonjs/Misc/precisionDate" {
  392. /**
  393. * Class containing a set of static utilities functions for precision date
  394. */
  395. export class PrecisionDate {
  396. /**
  397. * Gets either window.performance.now() if supported or Date.now() else
  398. */
  399. static readonly Now: number;
  400. }
  401. }
  402. declare module "babylonjs/Misc/devTools" {
  403. /** @hidden */
  404. export class _DevTools {
  405. static WarnImport(name: string): string;
  406. }
  407. }
  408. declare module "babylonjs/Misc/webRequest" {
  409. /**
  410. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  411. */
  412. export class WebRequest {
  413. private _xhr;
  414. /**
  415. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  416. * i.e. when loading files, where the server/service expects an Authorization header
  417. */
  418. static CustomRequestHeaders: {
  419. [key: string]: string;
  420. };
  421. /**
  422. * Add callback functions in this array to update all the requests before they get sent to the network
  423. */
  424. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  425. private _injectCustomRequestHeaders;
  426. /**
  427. * Gets or sets a function to be called when loading progress changes
  428. */
  429. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  430. /**
  431. * Returns client's state
  432. */
  433. readonly readyState: number;
  434. /**
  435. * Returns client's status
  436. */
  437. readonly status: number;
  438. /**
  439. * Returns client's status as a text
  440. */
  441. readonly statusText: string;
  442. /**
  443. * Returns client's response
  444. */
  445. readonly response: any;
  446. /**
  447. * Returns client's response url
  448. */
  449. readonly responseURL: string;
  450. /**
  451. * Returns client's response as text
  452. */
  453. readonly responseText: string;
  454. /**
  455. * Gets or sets the expected response type
  456. */
  457. responseType: XMLHttpRequestResponseType;
  458. /** @hidden */
  459. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  460. /** @hidden */
  461. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  462. /**
  463. * Cancels any network activity
  464. */
  465. abort(): void;
  466. /**
  467. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  468. * @param body defines an optional request body
  469. */
  470. send(body?: Document | BodyInit | null): void;
  471. /**
  472. * Sets the request method, request URL
  473. * @param method defines the method to use (GET, POST, etc..)
  474. * @param url defines the url to connect with
  475. */
  476. open(method: string, url: string): void;
  477. }
  478. }
  479. declare module "babylonjs/Misc/fileRequest" {
  480. import { Observable } from "babylonjs/Misc/observable";
  481. /**
  482. * File request interface
  483. */
  484. export interface IFileRequest {
  485. /**
  486. * Raised when the request is complete (success or error).
  487. */
  488. onCompleteObservable: Observable<IFileRequest>;
  489. /**
  490. * Aborts the request for a file.
  491. */
  492. abort: () => void;
  493. }
  494. }
  495. declare module "babylonjs/Meshes/dataBuffer" {
  496. /**
  497. * Class used to store gfx data (like WebGLBuffer)
  498. */
  499. export class DataBuffer {
  500. /**
  501. * Gets or sets the number of objects referencing this buffer
  502. */
  503. references: number;
  504. /** Gets or sets the size of the underlying buffer */
  505. capacity: number;
  506. /**
  507. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  508. */
  509. is32Bits: boolean;
  510. /**
  511. * Gets the underlying buffer
  512. */
  513. readonly underlyingResource: any;
  514. }
  515. }
  516. declare module "babylonjs/Meshes/buffer" {
  517. import { Nullable, DataArray } from "babylonjs/types";
  518. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  519. /**
  520. * Class used to store data that will be store in GPU memory
  521. */
  522. export class Buffer {
  523. private _engine;
  524. private _buffer;
  525. /** @hidden */
  526. _data: Nullable<DataArray>;
  527. private _updatable;
  528. private _instanced;
  529. /**
  530. * Gets the byte stride.
  531. */
  532. readonly byteStride: number;
  533. /**
  534. * Constructor
  535. * @param engine the engine
  536. * @param data the data to use for this buffer
  537. * @param updatable whether the data is updatable
  538. * @param stride the stride (optional)
  539. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  540. * @param instanced whether the buffer is instanced (optional)
  541. * @param useBytes set to true if the stride in in bytes (optional)
  542. */
  543. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  544. /**
  545. * Create a new VertexBuffer based on the current buffer
  546. * @param kind defines the vertex buffer kind (position, normal, etc.)
  547. * @param offset defines offset in the buffer (0 by default)
  548. * @param size defines the size in floats of attributes (position is 3 for instance)
  549. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  550. * @param instanced defines if the vertex buffer contains indexed data
  551. * @param useBytes defines if the offset and stride are in bytes
  552. * @returns the new vertex buffer
  553. */
  554. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  555. /**
  556. * Gets a boolean indicating if the Buffer is updatable?
  557. * @returns true if the buffer is updatable
  558. */
  559. isUpdatable(): boolean;
  560. /**
  561. * Gets current buffer's data
  562. * @returns a DataArray or null
  563. */
  564. getData(): Nullable<DataArray>;
  565. /**
  566. * Gets underlying native buffer
  567. * @returns underlying native buffer
  568. */
  569. getBuffer(): Nullable<DataBuffer>;
  570. /**
  571. * Gets the stride in float32 units (i.e. byte stride / 4).
  572. * May not be an integer if the byte stride is not divisible by 4.
  573. * DEPRECATED. Use byteStride instead.
  574. * @returns the stride in float32 units
  575. */
  576. getStrideSize(): number;
  577. /**
  578. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  579. * @param data defines the data to store
  580. */
  581. create(data?: Nullable<DataArray>): void;
  582. /** @hidden */
  583. _rebuild(): void;
  584. /**
  585. * Update current buffer data
  586. * @param data defines the data to store
  587. */
  588. update(data: DataArray): void;
  589. /**
  590. * Updates the data directly.
  591. * @param data the new data
  592. * @param offset the new offset
  593. * @param vertexCount the vertex count (optional)
  594. * @param useBytes set to true if the offset is in bytes
  595. */
  596. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  597. /**
  598. * Release all resources
  599. */
  600. dispose(): void;
  601. }
  602. /**
  603. * Specialized buffer used to store vertex data
  604. */
  605. export class VertexBuffer {
  606. /** @hidden */
  607. _buffer: Buffer;
  608. private _kind;
  609. private _size;
  610. private _ownsBuffer;
  611. private _instanced;
  612. private _instanceDivisor;
  613. /**
  614. * The byte type.
  615. */
  616. static readonly BYTE: number;
  617. /**
  618. * The unsigned byte type.
  619. */
  620. static readonly UNSIGNED_BYTE: number;
  621. /**
  622. * The short type.
  623. */
  624. static readonly SHORT: number;
  625. /**
  626. * The unsigned short type.
  627. */
  628. static readonly UNSIGNED_SHORT: number;
  629. /**
  630. * The integer type.
  631. */
  632. static readonly INT: number;
  633. /**
  634. * The unsigned integer type.
  635. */
  636. static readonly UNSIGNED_INT: number;
  637. /**
  638. * The float type.
  639. */
  640. static readonly FLOAT: number;
  641. /**
  642. * Gets or sets the instance divisor when in instanced mode
  643. */
  644. instanceDivisor: number;
  645. /**
  646. * Gets the byte stride.
  647. */
  648. readonly byteStride: number;
  649. /**
  650. * Gets the byte offset.
  651. */
  652. readonly byteOffset: number;
  653. /**
  654. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  655. */
  656. readonly normalized: boolean;
  657. /**
  658. * Gets the data type of each component in the array.
  659. */
  660. readonly type: number;
  661. /**
  662. * Constructor
  663. * @param engine the engine
  664. * @param data the data to use for this vertex buffer
  665. * @param kind the vertex buffer kind
  666. * @param updatable whether the data is updatable
  667. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  668. * @param stride the stride (optional)
  669. * @param instanced whether the buffer is instanced (optional)
  670. * @param offset the offset of the data (optional)
  671. * @param size the number of components (optional)
  672. * @param type the type of the component (optional)
  673. * @param normalized whether the data contains normalized data (optional)
  674. * @param useBytes set to true if stride and offset are in bytes (optional)
  675. */
  676. 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);
  677. /** @hidden */
  678. _rebuild(): void;
  679. /**
  680. * Returns the kind of the VertexBuffer (string)
  681. * @returns a string
  682. */
  683. getKind(): string;
  684. /**
  685. * Gets a boolean indicating if the VertexBuffer is updatable?
  686. * @returns true if the buffer is updatable
  687. */
  688. isUpdatable(): boolean;
  689. /**
  690. * Gets current buffer's data
  691. * @returns a DataArray or null
  692. */
  693. getData(): Nullable<DataArray>;
  694. /**
  695. * Gets underlying native buffer
  696. * @returns underlying native buffer
  697. */
  698. getBuffer(): Nullable<DataBuffer>;
  699. /**
  700. * Gets the stride in float32 units (i.e. byte stride / 4).
  701. * May not be an integer if the byte stride is not divisible by 4.
  702. * DEPRECATED. Use byteStride instead.
  703. * @returns the stride in float32 units
  704. */
  705. getStrideSize(): number;
  706. /**
  707. * Returns the offset as a multiple of the type byte length.
  708. * DEPRECATED. Use byteOffset instead.
  709. * @returns the offset in bytes
  710. */
  711. getOffset(): number;
  712. /**
  713. * Returns the number of components per vertex attribute (integer)
  714. * @returns the size in float
  715. */
  716. getSize(): number;
  717. /**
  718. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  719. * @returns true if this buffer is instanced
  720. */
  721. getIsInstanced(): boolean;
  722. /**
  723. * Returns the instancing divisor, zero for non-instanced (integer).
  724. * @returns a number
  725. */
  726. getInstanceDivisor(): number;
  727. /**
  728. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  729. * @param data defines the data to store
  730. */
  731. create(data?: DataArray): void;
  732. /**
  733. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  734. * This function will create a new buffer if the current one is not updatable
  735. * @param data defines the data to store
  736. */
  737. update(data: DataArray): void;
  738. /**
  739. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  740. * Returns the directly updated WebGLBuffer.
  741. * @param data the new data
  742. * @param offset the new offset
  743. * @param useBytes set to true if the offset is in bytes
  744. */
  745. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  746. /**
  747. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  748. */
  749. dispose(): void;
  750. /**
  751. * Enumerates each value of this vertex buffer as numbers.
  752. * @param count the number of values to enumerate
  753. * @param callback the callback function called for each value
  754. */
  755. forEach(count: number, callback: (value: number, index: number) => void): void;
  756. /**
  757. * Positions
  758. */
  759. static readonly PositionKind: string;
  760. /**
  761. * Normals
  762. */
  763. static readonly NormalKind: string;
  764. /**
  765. * Tangents
  766. */
  767. static readonly TangentKind: string;
  768. /**
  769. * Texture coordinates
  770. */
  771. static readonly UVKind: string;
  772. /**
  773. * Texture coordinates 2
  774. */
  775. static readonly UV2Kind: string;
  776. /**
  777. * Texture coordinates 3
  778. */
  779. static readonly UV3Kind: string;
  780. /**
  781. * Texture coordinates 4
  782. */
  783. static readonly UV4Kind: string;
  784. /**
  785. * Texture coordinates 5
  786. */
  787. static readonly UV5Kind: string;
  788. /**
  789. * Texture coordinates 6
  790. */
  791. static readonly UV6Kind: string;
  792. /**
  793. * Colors
  794. */
  795. static readonly ColorKind: string;
  796. /**
  797. * Matrix indices (for bones)
  798. */
  799. static readonly MatricesIndicesKind: string;
  800. /**
  801. * Matrix weights (for bones)
  802. */
  803. static readonly MatricesWeightsKind: string;
  804. /**
  805. * Additional matrix indices (for bones)
  806. */
  807. static readonly MatricesIndicesExtraKind: string;
  808. /**
  809. * Additional matrix weights (for bones)
  810. */
  811. static readonly MatricesWeightsExtraKind: string;
  812. /**
  813. * Deduces the stride given a kind.
  814. * @param kind The kind string to deduce
  815. * @returns The deduced stride
  816. */
  817. static DeduceStride(kind: string): number;
  818. /**
  819. * Gets the byte length of the given type.
  820. * @param type the type
  821. * @returns the number of bytes
  822. */
  823. static GetTypeByteLength(type: number): number;
  824. /**
  825. * Enumerates each value of the given parameters as numbers.
  826. * @param data the data to enumerate
  827. * @param byteOffset the byte offset of the data
  828. * @param byteStride the byte stride of the data
  829. * @param componentCount the number of components per element
  830. * @param componentType the type of the component
  831. * @param count the number of values to enumerate
  832. * @param normalized whether the data is normalized
  833. * @param callback the callback function called for each value
  834. */
  835. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  836. private static _GetFloatValue;
  837. }
  838. }
  839. declare module "babylonjs/Maths/math.scalar" {
  840. /**
  841. * Scalar computation library
  842. */
  843. export class Scalar {
  844. /**
  845. * Two pi constants convenient for computation.
  846. */
  847. static TwoPi: number;
  848. /**
  849. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  850. * @param a number
  851. * @param b number
  852. * @param epsilon (default = 1.401298E-45)
  853. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  854. */
  855. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  856. /**
  857. * Returns a string : the upper case translation of the number i to hexadecimal.
  858. * @param i number
  859. * @returns the upper case translation of the number i to hexadecimal.
  860. */
  861. static ToHex(i: number): string;
  862. /**
  863. * Returns -1 if value is negative and +1 is value is positive.
  864. * @param value the value
  865. * @returns the value itself if it's equal to zero.
  866. */
  867. static Sign(value: number): number;
  868. /**
  869. * Returns the value itself if it's between min and max.
  870. * Returns min if the value is lower than min.
  871. * Returns max if the value is greater than max.
  872. * @param value the value to clmap
  873. * @param min the min value to clamp to (default: 0)
  874. * @param max the max value to clamp to (default: 1)
  875. * @returns the clamped value
  876. */
  877. static Clamp(value: number, min?: number, max?: number): number;
  878. /**
  879. * the log2 of value.
  880. * @param value the value to compute log2 of
  881. * @returns the log2 of value.
  882. */
  883. static Log2(value: number): number;
  884. /**
  885. * Loops the value, so that it is never larger than length and never smaller than 0.
  886. *
  887. * This is similar to the modulo operator but it works with floating point numbers.
  888. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  889. * With t = 5 and length = 2.5, the result would be 0.0.
  890. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  891. * @param value the value
  892. * @param length the length
  893. * @returns the looped value
  894. */
  895. static Repeat(value: number, length: number): number;
  896. /**
  897. * Normalize the value between 0.0 and 1.0 using min and max values
  898. * @param value value to normalize
  899. * @param min max to normalize between
  900. * @param max min to normalize between
  901. * @returns the normalized value
  902. */
  903. static Normalize(value: number, min: number, max: number): number;
  904. /**
  905. * Denormalize the value from 0.0 and 1.0 using min and max values
  906. * @param normalized value to denormalize
  907. * @param min max to denormalize between
  908. * @param max min to denormalize between
  909. * @returns the denormalized value
  910. */
  911. static Denormalize(normalized: number, min: number, max: number): number;
  912. /**
  913. * Calculates the shortest difference between two given angles given in degrees.
  914. * @param current current angle in degrees
  915. * @param target target angle in degrees
  916. * @returns the delta
  917. */
  918. static DeltaAngle(current: number, target: number): number;
  919. /**
  920. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  921. * @param tx value
  922. * @param length length
  923. * @returns The returned value will move back and forth between 0 and length
  924. */
  925. static PingPong(tx: number, length: number): number;
  926. /**
  927. * Interpolates between min and max with smoothing at the limits.
  928. *
  929. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  930. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  931. * @param from from
  932. * @param to to
  933. * @param tx value
  934. * @returns the smooth stepped value
  935. */
  936. static SmoothStep(from: number, to: number, tx: number): number;
  937. /**
  938. * Moves a value current towards target.
  939. *
  940. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  941. * Negative values of maxDelta pushes the value away from target.
  942. * @param current current value
  943. * @param target target value
  944. * @param maxDelta max distance to move
  945. * @returns resulting value
  946. */
  947. static MoveTowards(current: number, target: number, maxDelta: number): number;
  948. /**
  949. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  950. *
  951. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  952. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  953. * @param current current value
  954. * @param target target value
  955. * @param maxDelta max distance to move
  956. * @returns resulting angle
  957. */
  958. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  959. /**
  960. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  961. * @param start start value
  962. * @param end target value
  963. * @param amount amount to lerp between
  964. * @returns the lerped value
  965. */
  966. static Lerp(start: number, end: number, amount: number): number;
  967. /**
  968. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  969. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  970. * @param start start value
  971. * @param end target value
  972. * @param amount amount to lerp between
  973. * @returns the lerped value
  974. */
  975. static LerpAngle(start: number, end: number, amount: number): number;
  976. /**
  977. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  978. * @param a start value
  979. * @param b target value
  980. * @param value value between a and b
  981. * @returns the inverseLerp value
  982. */
  983. static InverseLerp(a: number, b: number, value: number): number;
  984. /**
  985. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  986. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  987. * @param value1 spline value
  988. * @param tangent1 spline value
  989. * @param value2 spline value
  990. * @param tangent2 spline value
  991. * @param amount input value
  992. * @returns hermite result
  993. */
  994. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  995. /**
  996. * Returns a random float number between and min and max values
  997. * @param min min value of random
  998. * @param max max value of random
  999. * @returns random value
  1000. */
  1001. static RandomRange(min: number, max: number): number;
  1002. /**
  1003. * This function returns percentage of a number in a given range.
  1004. *
  1005. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1006. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1007. * @param number to convert to percentage
  1008. * @param min min range
  1009. * @param max max range
  1010. * @returns the percentage
  1011. */
  1012. static RangeToPercent(number: number, min: number, max: number): number;
  1013. /**
  1014. * This function returns number that corresponds to the percentage in a given range.
  1015. *
  1016. * PercentToRange(0.34,0,100) will return 34.
  1017. * @param percent to convert to number
  1018. * @param min min range
  1019. * @param max max range
  1020. * @returns the number
  1021. */
  1022. static PercentToRange(percent: number, min: number, max: number): number;
  1023. /**
  1024. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1025. * @param angle The angle to normalize in radian.
  1026. * @return The converted angle.
  1027. */
  1028. static NormalizeRadians(angle: number): number;
  1029. }
  1030. }
  1031. declare module "babylonjs/Maths/math.constants" {
  1032. /**
  1033. * Constant used to convert a value to gamma space
  1034. * @ignorenaming
  1035. */
  1036. export const ToGammaSpace: number;
  1037. /**
  1038. * Constant used to convert a value to linear space
  1039. * @ignorenaming
  1040. */
  1041. export const ToLinearSpace = 2.2;
  1042. /**
  1043. * Constant used to define the minimal number value in Babylon.js
  1044. * @ignorenaming
  1045. */
  1046. let Epsilon: number;
  1047. export { Epsilon };
  1048. }
  1049. declare module "babylonjs/Maths/math.viewport" {
  1050. /**
  1051. * Class used to represent a viewport on screen
  1052. */
  1053. export class Viewport {
  1054. /** viewport left coordinate */
  1055. x: number;
  1056. /** viewport top coordinate */
  1057. y: number;
  1058. /**viewport width */
  1059. width: number;
  1060. /** viewport height */
  1061. height: number;
  1062. /**
  1063. * Creates a Viewport object located at (x, y) and sized (width, height)
  1064. * @param x defines viewport left coordinate
  1065. * @param y defines viewport top coordinate
  1066. * @param width defines the viewport width
  1067. * @param height defines the viewport height
  1068. */
  1069. constructor(
  1070. /** viewport left coordinate */
  1071. x: number,
  1072. /** viewport top coordinate */
  1073. y: number,
  1074. /**viewport width */
  1075. width: number,
  1076. /** viewport height */
  1077. height: number);
  1078. /**
  1079. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1080. * @param renderWidth defines the rendering width
  1081. * @param renderHeight defines the rendering height
  1082. * @returns a new Viewport
  1083. */
  1084. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1085. /**
  1086. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1087. * @param renderWidth defines the rendering width
  1088. * @param renderHeight defines the rendering height
  1089. * @param ref defines the target viewport
  1090. * @returns the current viewport
  1091. */
  1092. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1093. /**
  1094. * Returns a new Viewport copied from the current one
  1095. * @returns a new Viewport
  1096. */
  1097. clone(): Viewport;
  1098. }
  1099. }
  1100. declare module "babylonjs/Misc/arrayTools" {
  1101. /**
  1102. * Class containing a set of static utilities functions for arrays.
  1103. */
  1104. export class ArrayTools {
  1105. /**
  1106. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1107. * @param size the number of element to construct and put in the array
  1108. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1109. * @returns a new array filled with new objects
  1110. */
  1111. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1112. }
  1113. }
  1114. declare module "babylonjs/Maths/math.like" {
  1115. import { float, int, DeepImmutable } from "babylonjs/types";
  1116. /**
  1117. * @hidden
  1118. */
  1119. export interface IColor4Like {
  1120. r: float;
  1121. g: float;
  1122. b: float;
  1123. a: float;
  1124. }
  1125. /**
  1126. * @hidden
  1127. */
  1128. export interface IColor3Like {
  1129. r: float;
  1130. g: float;
  1131. b: float;
  1132. }
  1133. /**
  1134. * @hidden
  1135. */
  1136. export interface IVector4Like {
  1137. x: float;
  1138. y: float;
  1139. z: float;
  1140. w: float;
  1141. }
  1142. /**
  1143. * @hidden
  1144. */
  1145. export interface IVector3Like {
  1146. x: float;
  1147. y: float;
  1148. z: float;
  1149. }
  1150. /**
  1151. * @hidden
  1152. */
  1153. export interface IVector2Like {
  1154. x: float;
  1155. y: float;
  1156. }
  1157. /**
  1158. * @hidden
  1159. */
  1160. export interface IMatrixLike {
  1161. toArray(): DeepImmutable<Float32Array>;
  1162. updateFlag: int;
  1163. }
  1164. /**
  1165. * @hidden
  1166. */
  1167. export interface IViewportLike {
  1168. x: float;
  1169. y: float;
  1170. width: float;
  1171. height: float;
  1172. }
  1173. /**
  1174. * @hidden
  1175. */
  1176. export interface IPlaneLike {
  1177. normal: IVector3Like;
  1178. d: float;
  1179. normalize(): void;
  1180. }
  1181. }
  1182. declare module "babylonjs/Maths/math.vector" {
  1183. import { Viewport } from "babylonjs/Maths/math.viewport";
  1184. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1185. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1186. /**
  1187. * Class representing a vector containing 2 coordinates
  1188. */
  1189. export class Vector2 {
  1190. /** defines the first coordinate */
  1191. x: number;
  1192. /** defines the second coordinate */
  1193. y: number;
  1194. /**
  1195. * Creates a new Vector2 from the given x and y coordinates
  1196. * @param x defines the first coordinate
  1197. * @param y defines the second coordinate
  1198. */
  1199. constructor(
  1200. /** defines the first coordinate */
  1201. x?: number,
  1202. /** defines the second coordinate */
  1203. y?: number);
  1204. /**
  1205. * Gets a string with the Vector2 coordinates
  1206. * @returns a string with the Vector2 coordinates
  1207. */
  1208. toString(): string;
  1209. /**
  1210. * Gets class name
  1211. * @returns the string "Vector2"
  1212. */
  1213. getClassName(): string;
  1214. /**
  1215. * Gets current vector hash code
  1216. * @returns the Vector2 hash code as a number
  1217. */
  1218. getHashCode(): number;
  1219. /**
  1220. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1221. * @param array defines the source array
  1222. * @param index defines the offset in source array
  1223. * @returns the current Vector2
  1224. */
  1225. toArray(array: FloatArray, index?: number): Vector2;
  1226. /**
  1227. * Copy the current vector to an array
  1228. * @returns a new array with 2 elements: the Vector2 coordinates.
  1229. */
  1230. asArray(): number[];
  1231. /**
  1232. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1233. * @param source defines the source Vector2
  1234. * @returns the current updated Vector2
  1235. */
  1236. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1237. /**
  1238. * Sets the Vector2 coordinates with the given floats
  1239. * @param x defines the first coordinate
  1240. * @param y defines the second coordinate
  1241. * @returns the current updated Vector2
  1242. */
  1243. copyFromFloats(x: number, y: number): Vector2;
  1244. /**
  1245. * Sets the Vector2 coordinates with the given floats
  1246. * @param x defines the first coordinate
  1247. * @param y defines the second coordinate
  1248. * @returns the current updated Vector2
  1249. */
  1250. set(x: number, y: number): Vector2;
  1251. /**
  1252. * Add another vector with the current one
  1253. * @param otherVector defines the other vector
  1254. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1255. */
  1256. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1257. /**
  1258. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1259. * @param otherVector defines the other vector
  1260. * @param result defines the target vector
  1261. * @returns the unmodified current Vector2
  1262. */
  1263. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1264. /**
  1265. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1266. * @param otherVector defines the other vector
  1267. * @returns the current updated Vector2
  1268. */
  1269. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1270. /**
  1271. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1272. * @param otherVector defines the other vector
  1273. * @returns a new Vector2
  1274. */
  1275. addVector3(otherVector: Vector3): Vector2;
  1276. /**
  1277. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1278. * @param otherVector defines the other vector
  1279. * @returns a new Vector2
  1280. */
  1281. subtract(otherVector: Vector2): Vector2;
  1282. /**
  1283. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1284. * @param otherVector defines the other vector
  1285. * @param result defines the target vector
  1286. * @returns the unmodified current Vector2
  1287. */
  1288. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1289. /**
  1290. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1291. * @param otherVector defines the other vector
  1292. * @returns the current updated Vector2
  1293. */
  1294. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1295. /**
  1296. * Multiplies in place the current Vector2 coordinates by the given ones
  1297. * @param otherVector defines the other vector
  1298. * @returns the current updated Vector2
  1299. */
  1300. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1301. /**
  1302. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1303. * @param otherVector defines the other vector
  1304. * @returns a new Vector2
  1305. */
  1306. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1307. /**
  1308. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1309. * @param otherVector defines the other vector
  1310. * @param result defines the target vector
  1311. * @returns the unmodified current Vector2
  1312. */
  1313. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1314. /**
  1315. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1316. * @param x defines the first coordinate
  1317. * @param y defines the second coordinate
  1318. * @returns a new Vector2
  1319. */
  1320. multiplyByFloats(x: number, y: number): Vector2;
  1321. /**
  1322. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1323. * @param otherVector defines the other vector
  1324. * @returns a new Vector2
  1325. */
  1326. divide(otherVector: Vector2): Vector2;
  1327. /**
  1328. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1329. * @param otherVector defines the other vector
  1330. * @param result defines the target vector
  1331. * @returns the unmodified current Vector2
  1332. */
  1333. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1334. /**
  1335. * Divides the current Vector2 coordinates by the given ones
  1336. * @param otherVector defines the other vector
  1337. * @returns the current updated Vector2
  1338. */
  1339. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1340. /**
  1341. * Gets a new Vector2 with current Vector2 negated coordinates
  1342. * @returns a new Vector2
  1343. */
  1344. negate(): Vector2;
  1345. /**
  1346. * Multiply the Vector2 coordinates by scale
  1347. * @param scale defines the scaling factor
  1348. * @returns the current updated Vector2
  1349. */
  1350. scaleInPlace(scale: number): Vector2;
  1351. /**
  1352. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1353. * @param scale defines the scaling factor
  1354. * @returns a new Vector2
  1355. */
  1356. scale(scale: number): Vector2;
  1357. /**
  1358. * Scale the current Vector2 values by a factor to a given Vector2
  1359. * @param scale defines the scale factor
  1360. * @param result defines the Vector2 object where to store the result
  1361. * @returns the unmodified current Vector2
  1362. */
  1363. scaleToRef(scale: number, result: Vector2): Vector2;
  1364. /**
  1365. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1366. * @param scale defines the scale factor
  1367. * @param result defines the Vector2 object where to store the result
  1368. * @returns the unmodified current Vector2
  1369. */
  1370. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1371. /**
  1372. * Gets a boolean if two vectors are equals
  1373. * @param otherVector defines the other vector
  1374. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1375. */
  1376. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1377. /**
  1378. * Gets a boolean if two vectors are equals (using an epsilon value)
  1379. * @param otherVector defines the other vector
  1380. * @param epsilon defines the minimal distance to consider equality
  1381. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1382. */
  1383. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1384. /**
  1385. * Gets a new Vector2 from current Vector2 floored values
  1386. * @returns a new Vector2
  1387. */
  1388. floor(): Vector2;
  1389. /**
  1390. * Gets a new Vector2 from current Vector2 floored values
  1391. * @returns a new Vector2
  1392. */
  1393. fract(): Vector2;
  1394. /**
  1395. * Gets the length of the vector
  1396. * @returns the vector length (float)
  1397. */
  1398. length(): number;
  1399. /**
  1400. * Gets the vector squared length
  1401. * @returns the vector squared length (float)
  1402. */
  1403. lengthSquared(): number;
  1404. /**
  1405. * Normalize the vector
  1406. * @returns the current updated Vector2
  1407. */
  1408. normalize(): Vector2;
  1409. /**
  1410. * Gets a new Vector2 copied from the Vector2
  1411. * @returns a new Vector2
  1412. */
  1413. clone(): Vector2;
  1414. /**
  1415. * Gets a new Vector2(0, 0)
  1416. * @returns a new Vector2
  1417. */
  1418. static Zero(): Vector2;
  1419. /**
  1420. * Gets a new Vector2(1, 1)
  1421. * @returns a new Vector2
  1422. */
  1423. static One(): Vector2;
  1424. /**
  1425. * Gets a new Vector2 set from the given index element of the given array
  1426. * @param array defines the data source
  1427. * @param offset defines the offset in the data source
  1428. * @returns a new Vector2
  1429. */
  1430. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1431. /**
  1432. * Sets "result" from the given index element of the given array
  1433. * @param array defines the data source
  1434. * @param offset defines the offset in the data source
  1435. * @param result defines the target vector
  1436. */
  1437. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1438. /**
  1439. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1440. * @param value1 defines 1st point of control
  1441. * @param value2 defines 2nd point of control
  1442. * @param value3 defines 3rd point of control
  1443. * @param value4 defines 4th point of control
  1444. * @param amount defines the interpolation factor
  1445. * @returns a new Vector2
  1446. */
  1447. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1448. /**
  1449. * 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".
  1450. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1451. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1452. * @param value defines the value to clamp
  1453. * @param min defines the lower limit
  1454. * @param max defines the upper limit
  1455. * @returns a new Vector2
  1456. */
  1457. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1458. /**
  1459. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1460. * @param value1 defines the 1st control point
  1461. * @param tangent1 defines the outgoing tangent
  1462. * @param value2 defines the 2nd control point
  1463. * @param tangent2 defines the incoming tangent
  1464. * @param amount defines the interpolation factor
  1465. * @returns a new Vector2
  1466. */
  1467. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1468. /**
  1469. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1470. * @param start defines the start vector
  1471. * @param end defines the end vector
  1472. * @param amount defines the interpolation factor
  1473. * @returns a new Vector2
  1474. */
  1475. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1476. /**
  1477. * Gets the dot product of the vector "left" and the vector "right"
  1478. * @param left defines first vector
  1479. * @param right defines second vector
  1480. * @returns the dot product (float)
  1481. */
  1482. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1483. /**
  1484. * Returns a new Vector2 equal to the normalized given vector
  1485. * @param vector defines the vector to normalize
  1486. * @returns a new Vector2
  1487. */
  1488. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1489. /**
  1490. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1491. * @param left defines 1st vector
  1492. * @param right defines 2nd vector
  1493. * @returns a new Vector2
  1494. */
  1495. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1496. /**
  1497. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1498. * @param left defines 1st vector
  1499. * @param right defines 2nd vector
  1500. * @returns a new Vector2
  1501. */
  1502. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1503. /**
  1504. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1505. * @param vector defines the vector to transform
  1506. * @param transformation defines the matrix to apply
  1507. * @returns a new Vector2
  1508. */
  1509. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1510. /**
  1511. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1512. * @param vector defines the vector to transform
  1513. * @param transformation defines the matrix to apply
  1514. * @param result defines the target vector
  1515. */
  1516. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1517. /**
  1518. * Determines if a given vector is included in a triangle
  1519. * @param p defines the vector to test
  1520. * @param p0 defines 1st triangle point
  1521. * @param p1 defines 2nd triangle point
  1522. * @param p2 defines 3rd triangle point
  1523. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1524. */
  1525. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1526. /**
  1527. * Gets the distance between the vectors "value1" and "value2"
  1528. * @param value1 defines first vector
  1529. * @param value2 defines second vector
  1530. * @returns the distance between vectors
  1531. */
  1532. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1533. /**
  1534. * Returns the squared distance between the vectors "value1" and "value2"
  1535. * @param value1 defines first vector
  1536. * @param value2 defines second vector
  1537. * @returns the squared distance between vectors
  1538. */
  1539. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1540. /**
  1541. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1542. * @param value1 defines first vector
  1543. * @param value2 defines second vector
  1544. * @returns a new Vector2
  1545. */
  1546. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1547. /**
  1548. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1549. * @param p defines the middle point
  1550. * @param segA defines one point of the segment
  1551. * @param segB defines the other point of the segment
  1552. * @returns the shortest distance
  1553. */
  1554. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1555. }
  1556. /**
  1557. * Classed used to store (x,y,z) vector representation
  1558. * A Vector3 is the main object used in 3D geometry
  1559. * It can represent etiher the coordinates of a point the space, either a direction
  1560. * Reminder: js uses a left handed forward facing system
  1561. */
  1562. export class Vector3 {
  1563. /**
  1564. * Defines the first coordinates (on X axis)
  1565. */
  1566. x: number;
  1567. /**
  1568. * Defines the second coordinates (on Y axis)
  1569. */
  1570. y: number;
  1571. /**
  1572. * Defines the third coordinates (on Z axis)
  1573. */
  1574. z: number;
  1575. private static _UpReadOnly;
  1576. private static _ZeroReadOnly;
  1577. /**
  1578. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1579. * @param x defines the first coordinates (on X axis)
  1580. * @param y defines the second coordinates (on Y axis)
  1581. * @param z defines the third coordinates (on Z axis)
  1582. */
  1583. constructor(
  1584. /**
  1585. * Defines the first coordinates (on X axis)
  1586. */
  1587. x?: number,
  1588. /**
  1589. * Defines the second coordinates (on Y axis)
  1590. */
  1591. y?: number,
  1592. /**
  1593. * Defines the third coordinates (on Z axis)
  1594. */
  1595. z?: number);
  1596. /**
  1597. * Creates a string representation of the Vector3
  1598. * @returns a string with the Vector3 coordinates.
  1599. */
  1600. toString(): string;
  1601. /**
  1602. * Gets the class name
  1603. * @returns the string "Vector3"
  1604. */
  1605. getClassName(): string;
  1606. /**
  1607. * Creates the Vector3 hash code
  1608. * @returns a number which tends to be unique between Vector3 instances
  1609. */
  1610. getHashCode(): number;
  1611. /**
  1612. * Creates an array containing three elements : the coordinates of the Vector3
  1613. * @returns a new array of numbers
  1614. */
  1615. asArray(): number[];
  1616. /**
  1617. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1618. * @param array defines the destination array
  1619. * @param index defines the offset in the destination array
  1620. * @returns the current Vector3
  1621. */
  1622. toArray(array: FloatArray, index?: number): Vector3;
  1623. /**
  1624. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1625. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1626. */
  1627. toQuaternion(): Quaternion;
  1628. /**
  1629. * Adds the given vector to the current Vector3
  1630. * @param otherVector defines the second operand
  1631. * @returns the current updated Vector3
  1632. */
  1633. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1634. /**
  1635. * Adds the given coordinates to the current Vector3
  1636. * @param x defines the x coordinate of the operand
  1637. * @param y defines the y coordinate of the operand
  1638. * @param z defines the z coordinate of the operand
  1639. * @returns the current updated Vector3
  1640. */
  1641. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1642. /**
  1643. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1644. * @param otherVector defines the second operand
  1645. * @returns the resulting Vector3
  1646. */
  1647. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1648. /**
  1649. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1650. * @param otherVector defines the second operand
  1651. * @param result defines the Vector3 object where to store the result
  1652. * @returns the current Vector3
  1653. */
  1654. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1655. /**
  1656. * Subtract the given vector from the current Vector3
  1657. * @param otherVector defines the second operand
  1658. * @returns the current updated Vector3
  1659. */
  1660. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1661. /**
  1662. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1663. * @param otherVector defines the second operand
  1664. * @returns the resulting Vector3
  1665. */
  1666. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1667. /**
  1668. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1669. * @param otherVector defines the second operand
  1670. * @param result defines the Vector3 object where to store the result
  1671. * @returns the current Vector3
  1672. */
  1673. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1674. /**
  1675. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1676. * @param x defines the x coordinate of the operand
  1677. * @param y defines the y coordinate of the operand
  1678. * @param z defines the z coordinate of the operand
  1679. * @returns the resulting Vector3
  1680. */
  1681. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1682. /**
  1683. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1684. * @param x defines the x coordinate of the operand
  1685. * @param y defines the y coordinate of the operand
  1686. * @param z defines the z coordinate of the operand
  1687. * @param result defines the Vector3 object where to store the result
  1688. * @returns the current Vector3
  1689. */
  1690. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1691. /**
  1692. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1693. * @returns a new Vector3
  1694. */
  1695. negate(): Vector3;
  1696. /**
  1697. * Multiplies the Vector3 coordinates by the float "scale"
  1698. * @param scale defines the multiplier factor
  1699. * @returns the current updated Vector3
  1700. */
  1701. scaleInPlace(scale: number): Vector3;
  1702. /**
  1703. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1704. * @param scale defines the multiplier factor
  1705. * @returns a new Vector3
  1706. */
  1707. scale(scale: number): Vector3;
  1708. /**
  1709. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1710. * @param scale defines the multiplier factor
  1711. * @param result defines the Vector3 object where to store the result
  1712. * @returns the current Vector3
  1713. */
  1714. scaleToRef(scale: number, result: Vector3): Vector3;
  1715. /**
  1716. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1717. * @param scale defines the scale factor
  1718. * @param result defines the Vector3 object where to store the result
  1719. * @returns the unmodified current Vector3
  1720. */
  1721. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1722. /**
  1723. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1724. * @param otherVector defines the second operand
  1725. * @returns true if both vectors are equals
  1726. */
  1727. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1728. /**
  1729. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1730. * @param otherVector defines the second operand
  1731. * @param epsilon defines the minimal distance to define values as equals
  1732. * @returns true if both vectors are distant less than epsilon
  1733. */
  1734. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1735. /**
  1736. * Returns true if the current Vector3 coordinates equals the given floats
  1737. * @param x defines the x coordinate of the operand
  1738. * @param y defines the y coordinate of the operand
  1739. * @param z defines the z coordinate of the operand
  1740. * @returns true if both vectors are equals
  1741. */
  1742. equalsToFloats(x: number, y: number, z: number): boolean;
  1743. /**
  1744. * Multiplies the current Vector3 coordinates by the given ones
  1745. * @param otherVector defines the second operand
  1746. * @returns the current updated Vector3
  1747. */
  1748. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1749. /**
  1750. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1751. * @param otherVector defines the second operand
  1752. * @returns the new Vector3
  1753. */
  1754. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1755. /**
  1756. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1757. * @param otherVector defines the second operand
  1758. * @param result defines the Vector3 object where to store the result
  1759. * @returns the current Vector3
  1760. */
  1761. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1762. /**
  1763. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1764. * @param x defines the x coordinate of the operand
  1765. * @param y defines the y coordinate of the operand
  1766. * @param z defines the z coordinate of the operand
  1767. * @returns the new Vector3
  1768. */
  1769. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1770. /**
  1771. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1772. * @param otherVector defines the second operand
  1773. * @returns the new Vector3
  1774. */
  1775. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1776. /**
  1777. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1778. * @param otherVector defines the second operand
  1779. * @param result defines the Vector3 object where to store the result
  1780. * @returns the current Vector3
  1781. */
  1782. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1783. /**
  1784. * Divides the current Vector3 coordinates by the given ones.
  1785. * @param otherVector defines the second operand
  1786. * @returns the current updated Vector3
  1787. */
  1788. divideInPlace(otherVector: Vector3): Vector3;
  1789. /**
  1790. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1791. * @param other defines the second operand
  1792. * @returns the current updated Vector3
  1793. */
  1794. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1795. /**
  1796. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1797. * @param other defines the second operand
  1798. * @returns the current updated Vector3
  1799. */
  1800. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1801. /**
  1802. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1803. * @param x defines the x coordinate of the operand
  1804. * @param y defines the y coordinate of the operand
  1805. * @param z defines the z coordinate of the operand
  1806. * @returns the current updated Vector3
  1807. */
  1808. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1809. /**
  1810. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1811. * @param x defines the x coordinate of the operand
  1812. * @param y defines the y coordinate of the operand
  1813. * @param z defines the z coordinate of the operand
  1814. * @returns the current updated Vector3
  1815. */
  1816. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1817. /**
  1818. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1819. * Check if is non uniform within a certain amount of decimal places to account for this
  1820. * @param epsilon the amount the values can differ
  1821. * @returns if the the vector is non uniform to a certain number of decimal places
  1822. */
  1823. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1824. /**
  1825. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1826. */
  1827. readonly isNonUniform: boolean;
  1828. /**
  1829. * Gets a new Vector3 from current Vector3 floored values
  1830. * @returns a new Vector3
  1831. */
  1832. floor(): Vector3;
  1833. /**
  1834. * Gets a new Vector3 from current Vector3 floored values
  1835. * @returns a new Vector3
  1836. */
  1837. fract(): Vector3;
  1838. /**
  1839. * Gets the length of the Vector3
  1840. * @returns the length of the Vector3
  1841. */
  1842. length(): number;
  1843. /**
  1844. * Gets the squared length of the Vector3
  1845. * @returns squared length of the Vector3
  1846. */
  1847. lengthSquared(): number;
  1848. /**
  1849. * Normalize the current Vector3.
  1850. * Please note that this is an in place operation.
  1851. * @returns the current updated Vector3
  1852. */
  1853. normalize(): Vector3;
  1854. /**
  1855. * Reorders the x y z properties of the vector in place
  1856. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1857. * @returns the current updated vector
  1858. */
  1859. reorderInPlace(order: string): this;
  1860. /**
  1861. * Rotates the vector around 0,0,0 by a quaternion
  1862. * @param quaternion the rotation quaternion
  1863. * @param result vector to store the result
  1864. * @returns the resulting vector
  1865. */
  1866. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1867. /**
  1868. * Rotates a vector around a given point
  1869. * @param quaternion the rotation quaternion
  1870. * @param point the point to rotate around
  1871. * @param result vector to store the result
  1872. * @returns the resulting vector
  1873. */
  1874. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1875. /**
  1876. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  1877. * The cross product is then orthogonal to both current and "other"
  1878. * @param other defines the right operand
  1879. * @returns the cross product
  1880. */
  1881. cross(other: Vector3): Vector3;
  1882. /**
  1883. * Normalize the current Vector3 with the given input length.
  1884. * Please note that this is an in place operation.
  1885. * @param len the length of the vector
  1886. * @returns the current updated Vector3
  1887. */
  1888. normalizeFromLength(len: number): Vector3;
  1889. /**
  1890. * Normalize the current Vector3 to a new vector
  1891. * @returns the new Vector3
  1892. */
  1893. normalizeToNew(): Vector3;
  1894. /**
  1895. * Normalize the current Vector3 to the reference
  1896. * @param reference define the Vector3 to update
  1897. * @returns the updated Vector3
  1898. */
  1899. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1900. /**
  1901. * Creates a new Vector3 copied from the current Vector3
  1902. * @returns the new Vector3
  1903. */
  1904. clone(): Vector3;
  1905. /**
  1906. * Copies the given vector coordinates to the current Vector3 ones
  1907. * @param source defines the source Vector3
  1908. * @returns the current updated Vector3
  1909. */
  1910. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1911. /**
  1912. * Copies the given floats to the current Vector3 coordinates
  1913. * @param x defines the x coordinate of the operand
  1914. * @param y defines the y coordinate of the operand
  1915. * @param z defines the z coordinate of the operand
  1916. * @returns the current updated Vector3
  1917. */
  1918. copyFromFloats(x: number, y: number, z: number): Vector3;
  1919. /**
  1920. * Copies the given floats to the current Vector3 coordinates
  1921. * @param x defines the x coordinate of the operand
  1922. * @param y defines the y coordinate of the operand
  1923. * @param z defines the z coordinate of the operand
  1924. * @returns the current updated Vector3
  1925. */
  1926. set(x: number, y: number, z: number): Vector3;
  1927. /**
  1928. * Copies the given float to the current Vector3 coordinates
  1929. * @param v defines the x, y and z coordinates of the operand
  1930. * @returns the current updated Vector3
  1931. */
  1932. setAll(v: number): Vector3;
  1933. /**
  1934. * Get the clip factor between two vectors
  1935. * @param vector0 defines the first operand
  1936. * @param vector1 defines the second operand
  1937. * @param axis defines the axis to use
  1938. * @param size defines the size along the axis
  1939. * @returns the clip factor
  1940. */
  1941. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1942. /**
  1943. * Get angle between two vectors
  1944. * @param vector0 angle between vector0 and vector1
  1945. * @param vector1 angle between vector0 and vector1
  1946. * @param normal direction of the normal
  1947. * @return the angle between vector0 and vector1
  1948. */
  1949. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1950. /**
  1951. * Returns a new Vector3 set from the index "offset" of the given array
  1952. * @param array defines the source array
  1953. * @param offset defines the offset in the source array
  1954. * @returns the new Vector3
  1955. */
  1956. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1957. /**
  1958. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1959. * This function is deprecated. Use FromArray instead
  1960. * @param array defines the source array
  1961. * @param offset defines the offset in the source array
  1962. * @returns the new Vector3
  1963. */
  1964. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1965. /**
  1966. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1967. * @param array defines the source array
  1968. * @param offset defines the offset in the source array
  1969. * @param result defines the Vector3 where to store the result
  1970. */
  1971. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1972. /**
  1973. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1974. * This function is deprecated. Use FromArrayToRef instead.
  1975. * @param array defines the source array
  1976. * @param offset defines the offset in the source array
  1977. * @param result defines the Vector3 where to store the result
  1978. */
  1979. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1980. /**
  1981. * Sets the given vector "result" with the given floats.
  1982. * @param x defines the x coordinate of the source
  1983. * @param y defines the y coordinate of the source
  1984. * @param z defines the z coordinate of the source
  1985. * @param result defines the Vector3 where to store the result
  1986. */
  1987. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1988. /**
  1989. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1990. * @returns a new empty Vector3
  1991. */
  1992. static Zero(): Vector3;
  1993. /**
  1994. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1995. * @returns a new unit Vector3
  1996. */
  1997. static One(): Vector3;
  1998. /**
  1999. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2000. * @returns a new up Vector3
  2001. */
  2002. static Up(): Vector3;
  2003. /**
  2004. * Gets a up Vector3 that must not be updated
  2005. */
  2006. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2007. /**
  2008. * Gets a zero Vector3 that must not be updated
  2009. */
  2010. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2011. /**
  2012. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2013. * @returns a new down Vector3
  2014. */
  2015. static Down(): Vector3;
  2016. /**
  2017. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2018. * @returns a new forward Vector3
  2019. */
  2020. static Forward(): Vector3;
  2021. /**
  2022. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2023. * @returns a new forward Vector3
  2024. */
  2025. static Backward(): Vector3;
  2026. /**
  2027. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2028. * @returns a new right Vector3
  2029. */
  2030. static Right(): Vector3;
  2031. /**
  2032. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2033. * @returns a new left Vector3
  2034. */
  2035. static Left(): Vector3;
  2036. /**
  2037. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2038. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2039. * @param vector defines the Vector3 to transform
  2040. * @param transformation defines the transformation matrix
  2041. * @returns the transformed Vector3
  2042. */
  2043. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2044. /**
  2045. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2046. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2047. * @param vector defines the Vector3 to transform
  2048. * @param transformation defines the transformation matrix
  2049. * @param result defines the Vector3 where to store the result
  2050. */
  2051. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2052. /**
  2053. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2054. * This method computes tranformed coordinates only, not transformed direction vectors
  2055. * @param x define the x coordinate of the source vector
  2056. * @param y define the y coordinate of the source vector
  2057. * @param z define the z coordinate of the source vector
  2058. * @param transformation defines the transformation matrix
  2059. * @param result defines the Vector3 where to store the result
  2060. */
  2061. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2062. /**
  2063. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2064. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2065. * @param vector defines the Vector3 to transform
  2066. * @param transformation defines the transformation matrix
  2067. * @returns the new Vector3
  2068. */
  2069. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2070. /**
  2071. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2072. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2073. * @param vector defines the Vector3 to transform
  2074. * @param transformation defines the transformation matrix
  2075. * @param result defines the Vector3 where to store the result
  2076. */
  2077. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2078. /**
  2079. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2080. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2081. * @param x define the x coordinate of the source vector
  2082. * @param y define the y coordinate of the source vector
  2083. * @param z define the z coordinate of the source vector
  2084. * @param transformation defines the transformation matrix
  2085. * @param result defines the Vector3 where to store the result
  2086. */
  2087. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2088. /**
  2089. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2090. * @param value1 defines the first control point
  2091. * @param value2 defines the second control point
  2092. * @param value3 defines the third control point
  2093. * @param value4 defines the fourth control point
  2094. * @param amount defines the amount on the spline to use
  2095. * @returns the new Vector3
  2096. */
  2097. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2098. /**
  2099. * 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"
  2100. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2101. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2102. * @param value defines the current value
  2103. * @param min defines the lower range value
  2104. * @param max defines the upper range value
  2105. * @returns the new Vector3
  2106. */
  2107. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2108. /**
  2109. * 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"
  2110. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2111. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2112. * @param value defines the current value
  2113. * @param min defines the lower range value
  2114. * @param max defines the upper range value
  2115. * @param result defines the Vector3 where to store the result
  2116. */
  2117. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2118. /**
  2119. * Checks if a given vector is inside a specific range
  2120. * @param v defines the vector to test
  2121. * @param min defines the minimum range
  2122. * @param max defines the maximum range
  2123. */
  2124. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2125. /**
  2126. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2127. * @param value1 defines the first control point
  2128. * @param tangent1 defines the first tangent vector
  2129. * @param value2 defines the second control point
  2130. * @param tangent2 defines the second tangent vector
  2131. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2132. * @returns the new Vector3
  2133. */
  2134. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2135. /**
  2136. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2137. * @param start defines the start value
  2138. * @param end defines the end value
  2139. * @param amount max defines amount between both (between 0 and 1)
  2140. * @returns the new Vector3
  2141. */
  2142. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2143. /**
  2144. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2145. * @param start defines the start value
  2146. * @param end defines the end value
  2147. * @param amount max defines amount between both (between 0 and 1)
  2148. * @param result defines the Vector3 where to store the result
  2149. */
  2150. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2151. /**
  2152. * Returns the dot product (float) between the vectors "left" and "right"
  2153. * @param left defines the left operand
  2154. * @param right defines the right operand
  2155. * @returns the dot product
  2156. */
  2157. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2158. /**
  2159. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2160. * The cross product is then orthogonal to both "left" and "right"
  2161. * @param left defines the left operand
  2162. * @param right defines the right operand
  2163. * @returns the cross product
  2164. */
  2165. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2166. /**
  2167. * Sets the given vector "result" with the cross product of "left" and "right"
  2168. * The cross product is then orthogonal to both "left" and "right"
  2169. * @param left defines the left operand
  2170. * @param right defines the right operand
  2171. * @param result defines the Vector3 where to store the result
  2172. */
  2173. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2174. /**
  2175. * Returns a new Vector3 as the normalization of the given vector
  2176. * @param vector defines the Vector3 to normalize
  2177. * @returns the new Vector3
  2178. */
  2179. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2180. /**
  2181. * Sets the given vector "result" with the normalization of the given first vector
  2182. * @param vector defines the Vector3 to normalize
  2183. * @param result defines the Vector3 where to store the result
  2184. */
  2185. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2186. /**
  2187. * Project a Vector3 onto screen space
  2188. * @param vector defines the Vector3 to project
  2189. * @param world defines the world matrix to use
  2190. * @param transform defines the transform (view x projection) matrix to use
  2191. * @param viewport defines the screen viewport to use
  2192. * @returns the new Vector3
  2193. */
  2194. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2195. /** @hidden */
  2196. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2197. /**
  2198. * Unproject from screen space to object space
  2199. * @param source defines the screen space Vector3 to use
  2200. * @param viewportWidth defines the current width of the viewport
  2201. * @param viewportHeight defines the current height of the viewport
  2202. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2203. * @param transform defines the transform (view x projection) matrix to use
  2204. * @returns the new Vector3
  2205. */
  2206. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2207. /**
  2208. * Unproject from screen space to object space
  2209. * @param source defines the screen space Vector3 to use
  2210. * @param viewportWidth defines the current width of the viewport
  2211. * @param viewportHeight defines the current height of the viewport
  2212. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2213. * @param view defines the view matrix to use
  2214. * @param projection defines the projection matrix to use
  2215. * @returns the new Vector3
  2216. */
  2217. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2218. /**
  2219. * Unproject from screen space to object space
  2220. * @param source defines the screen space Vector3 to use
  2221. * @param viewportWidth defines the current width of the viewport
  2222. * @param viewportHeight defines the current height of the viewport
  2223. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2224. * @param view defines the view matrix to use
  2225. * @param projection defines the projection matrix to use
  2226. * @param result defines the Vector3 where to store the result
  2227. */
  2228. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2229. /**
  2230. * Unproject from screen space to object space
  2231. * @param sourceX defines the screen space x coordinate to use
  2232. * @param sourceY defines the screen space y coordinate to use
  2233. * @param sourceZ defines the screen space z coordinate to use
  2234. * @param viewportWidth defines the current width of the viewport
  2235. * @param viewportHeight defines the current height of the viewport
  2236. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2237. * @param view defines the view matrix to use
  2238. * @param projection defines the projection matrix to use
  2239. * @param result defines the Vector3 where to store the result
  2240. */
  2241. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2242. /**
  2243. * Gets the minimal coordinate values between two Vector3
  2244. * @param left defines the first operand
  2245. * @param right defines the second operand
  2246. * @returns the new Vector3
  2247. */
  2248. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2249. /**
  2250. * Gets the maximal coordinate values between two Vector3
  2251. * @param left defines the first operand
  2252. * @param right defines the second operand
  2253. * @returns the new Vector3
  2254. */
  2255. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2256. /**
  2257. * Returns the distance between the vectors "value1" and "value2"
  2258. * @param value1 defines the first operand
  2259. * @param value2 defines the second operand
  2260. * @returns the distance
  2261. */
  2262. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2263. /**
  2264. * Returns the squared distance between the vectors "value1" and "value2"
  2265. * @param value1 defines the first operand
  2266. * @param value2 defines the second operand
  2267. * @returns the squared distance
  2268. */
  2269. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2270. /**
  2271. * Returns a new Vector3 located at the center between "value1" and "value2"
  2272. * @param value1 defines the first operand
  2273. * @param value2 defines the second operand
  2274. * @returns the new Vector3
  2275. */
  2276. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2277. /**
  2278. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2279. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2280. * to something in order to rotate it from its local system to the given target system
  2281. * Note: axis1, axis2 and axis3 are normalized during this operation
  2282. * @param axis1 defines the first axis
  2283. * @param axis2 defines the second axis
  2284. * @param axis3 defines the third axis
  2285. * @returns a new Vector3
  2286. */
  2287. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2288. /**
  2289. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2290. * @param axis1 defines the first axis
  2291. * @param axis2 defines the second axis
  2292. * @param axis3 defines the third axis
  2293. * @param ref defines the Vector3 where to store the result
  2294. */
  2295. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2296. }
  2297. /**
  2298. * Vector4 class created for EulerAngle class conversion to Quaternion
  2299. */
  2300. export class Vector4 {
  2301. /** x value of the vector */
  2302. x: number;
  2303. /** y value of the vector */
  2304. y: number;
  2305. /** z value of the vector */
  2306. z: number;
  2307. /** w value of the vector */
  2308. w: number;
  2309. /**
  2310. * Creates a Vector4 object from the given floats.
  2311. * @param x x value of the vector
  2312. * @param y y value of the vector
  2313. * @param z z value of the vector
  2314. * @param w w value of the vector
  2315. */
  2316. constructor(
  2317. /** x value of the vector */
  2318. x: number,
  2319. /** y value of the vector */
  2320. y: number,
  2321. /** z value of the vector */
  2322. z: number,
  2323. /** w value of the vector */
  2324. w: number);
  2325. /**
  2326. * Returns the string with the Vector4 coordinates.
  2327. * @returns a string containing all the vector values
  2328. */
  2329. toString(): string;
  2330. /**
  2331. * Returns the string "Vector4".
  2332. * @returns "Vector4"
  2333. */
  2334. getClassName(): string;
  2335. /**
  2336. * Returns the Vector4 hash code.
  2337. * @returns a unique hash code
  2338. */
  2339. getHashCode(): number;
  2340. /**
  2341. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2342. * @returns the resulting array
  2343. */
  2344. asArray(): number[];
  2345. /**
  2346. * Populates the given array from the given index with the Vector4 coordinates.
  2347. * @param array array to populate
  2348. * @param index index of the array to start at (default: 0)
  2349. * @returns the Vector4.
  2350. */
  2351. toArray(array: FloatArray, index?: number): Vector4;
  2352. /**
  2353. * Adds the given vector to the current Vector4.
  2354. * @param otherVector the vector to add
  2355. * @returns the updated Vector4.
  2356. */
  2357. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2358. /**
  2359. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2360. * @param otherVector the vector to add
  2361. * @returns the resulting vector
  2362. */
  2363. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2364. /**
  2365. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2366. * @param otherVector the vector to add
  2367. * @param result the vector to store the result
  2368. * @returns the current Vector4.
  2369. */
  2370. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2371. /**
  2372. * Subtract in place the given vector from the current Vector4.
  2373. * @param otherVector the vector to subtract
  2374. * @returns the updated Vector4.
  2375. */
  2376. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2377. /**
  2378. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2379. * @param otherVector the vector to add
  2380. * @returns the new vector with the result
  2381. */
  2382. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2383. /**
  2384. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2385. * @param otherVector the vector to subtract
  2386. * @param result the vector to store the result
  2387. * @returns the current Vector4.
  2388. */
  2389. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2390. /**
  2391. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2392. */
  2393. /**
  2394. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2395. * @param x value to subtract
  2396. * @param y value to subtract
  2397. * @param z value to subtract
  2398. * @param w value to subtract
  2399. * @returns new vector containing the result
  2400. */
  2401. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2402. /**
  2403. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2404. * @param x value to subtract
  2405. * @param y value to subtract
  2406. * @param z value to subtract
  2407. * @param w value to subtract
  2408. * @param result the vector to store the result in
  2409. * @returns the current Vector4.
  2410. */
  2411. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2412. /**
  2413. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2414. * @returns a new vector with the negated values
  2415. */
  2416. negate(): Vector4;
  2417. /**
  2418. * Multiplies the current Vector4 coordinates by scale (float).
  2419. * @param scale the number to scale with
  2420. * @returns the updated Vector4.
  2421. */
  2422. scaleInPlace(scale: number): Vector4;
  2423. /**
  2424. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2425. * @param scale the number to scale with
  2426. * @returns a new vector with the result
  2427. */
  2428. scale(scale: number): Vector4;
  2429. /**
  2430. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2431. * @param scale the number to scale with
  2432. * @param result a vector to store the result in
  2433. * @returns the current Vector4.
  2434. */
  2435. scaleToRef(scale: number, result: Vector4): Vector4;
  2436. /**
  2437. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2438. * @param scale defines the scale factor
  2439. * @param result defines the Vector4 object where to store the result
  2440. * @returns the unmodified current Vector4
  2441. */
  2442. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2443. /**
  2444. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2445. * @param otherVector the vector to compare against
  2446. * @returns true if they are equal
  2447. */
  2448. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2449. /**
  2450. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2451. * @param otherVector vector to compare against
  2452. * @param epsilon (Default: very small number)
  2453. * @returns true if they are equal
  2454. */
  2455. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2456. /**
  2457. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2458. * @param x x value to compare against
  2459. * @param y y value to compare against
  2460. * @param z z value to compare against
  2461. * @param w w value to compare against
  2462. * @returns true if equal
  2463. */
  2464. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2465. /**
  2466. * Multiplies in place the current Vector4 by the given one.
  2467. * @param otherVector vector to multiple with
  2468. * @returns the updated Vector4.
  2469. */
  2470. multiplyInPlace(otherVector: Vector4): Vector4;
  2471. /**
  2472. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2473. * @param otherVector vector to multiple with
  2474. * @returns resulting new vector
  2475. */
  2476. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2477. /**
  2478. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2479. * @param otherVector vector to multiple with
  2480. * @param result vector to store the result
  2481. * @returns the current Vector4.
  2482. */
  2483. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2484. /**
  2485. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2486. * @param x x value multiply with
  2487. * @param y y value multiply with
  2488. * @param z z value multiply with
  2489. * @param w w value multiply with
  2490. * @returns resulting new vector
  2491. */
  2492. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2493. /**
  2494. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2495. * @param otherVector vector to devide with
  2496. * @returns resulting new vector
  2497. */
  2498. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2499. /**
  2500. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2501. * @param otherVector vector to devide with
  2502. * @param result vector to store the result
  2503. * @returns the current Vector4.
  2504. */
  2505. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2506. /**
  2507. * Divides the current Vector3 coordinates by the given ones.
  2508. * @param otherVector vector to devide with
  2509. * @returns the updated Vector3.
  2510. */
  2511. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2512. /**
  2513. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2514. * @param other defines the second operand
  2515. * @returns the current updated Vector4
  2516. */
  2517. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2518. /**
  2519. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2520. * @param other defines the second operand
  2521. * @returns the current updated Vector4
  2522. */
  2523. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2524. /**
  2525. * Gets a new Vector4 from current Vector4 floored values
  2526. * @returns a new Vector4
  2527. */
  2528. floor(): Vector4;
  2529. /**
  2530. * Gets a new Vector4 from current Vector3 floored values
  2531. * @returns a new Vector4
  2532. */
  2533. fract(): Vector4;
  2534. /**
  2535. * Returns the Vector4 length (float).
  2536. * @returns the length
  2537. */
  2538. length(): number;
  2539. /**
  2540. * Returns the Vector4 squared length (float).
  2541. * @returns the length squared
  2542. */
  2543. lengthSquared(): number;
  2544. /**
  2545. * Normalizes in place the Vector4.
  2546. * @returns the updated Vector4.
  2547. */
  2548. normalize(): Vector4;
  2549. /**
  2550. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2551. * @returns this converted to a new vector3
  2552. */
  2553. toVector3(): Vector3;
  2554. /**
  2555. * Returns a new Vector4 copied from the current one.
  2556. * @returns the new cloned vector
  2557. */
  2558. clone(): Vector4;
  2559. /**
  2560. * Updates the current Vector4 with the given one coordinates.
  2561. * @param source the source vector to copy from
  2562. * @returns the updated Vector4.
  2563. */
  2564. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2565. /**
  2566. * Updates the current Vector4 coordinates with the given floats.
  2567. * @param x float to copy from
  2568. * @param y float to copy from
  2569. * @param z float to copy from
  2570. * @param w float to copy from
  2571. * @returns the updated Vector4.
  2572. */
  2573. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2574. /**
  2575. * Updates the current Vector4 coordinates with the given floats.
  2576. * @param x float to set from
  2577. * @param y float to set from
  2578. * @param z float to set from
  2579. * @param w float to set from
  2580. * @returns the updated Vector4.
  2581. */
  2582. set(x: number, y: number, z: number, w: number): Vector4;
  2583. /**
  2584. * Copies the given float to the current Vector3 coordinates
  2585. * @param v defines the x, y, z and w coordinates of the operand
  2586. * @returns the current updated Vector3
  2587. */
  2588. setAll(v: number): Vector4;
  2589. /**
  2590. * Returns a new Vector4 set from the starting index of the given array.
  2591. * @param array the array to pull values from
  2592. * @param offset the offset into the array to start at
  2593. * @returns the new vector
  2594. */
  2595. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2596. /**
  2597. * Updates the given vector "result" from the starting index of the given array.
  2598. * @param array the array to pull values from
  2599. * @param offset the offset into the array to start at
  2600. * @param result the vector to store the result in
  2601. */
  2602. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2603. /**
  2604. * Updates the given vector "result" from the starting index of the given Float32Array.
  2605. * @param array the array to pull values from
  2606. * @param offset the offset into the array to start at
  2607. * @param result the vector to store the result in
  2608. */
  2609. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2610. /**
  2611. * Updates the given vector "result" coordinates from the given floats.
  2612. * @param x float to set from
  2613. * @param y float to set from
  2614. * @param z float to set from
  2615. * @param w float to set from
  2616. * @param result the vector to the floats in
  2617. */
  2618. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2619. /**
  2620. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2621. * @returns the new vector
  2622. */
  2623. static Zero(): Vector4;
  2624. /**
  2625. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2626. * @returns the new vector
  2627. */
  2628. static One(): Vector4;
  2629. /**
  2630. * Returns a new normalized Vector4 from the given one.
  2631. * @param vector the vector to normalize
  2632. * @returns the vector
  2633. */
  2634. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2635. /**
  2636. * Updates the given vector "result" from the normalization of the given one.
  2637. * @param vector the vector to normalize
  2638. * @param result the vector to store the result in
  2639. */
  2640. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2641. /**
  2642. * Returns a vector with the minimum values from the left and right vectors
  2643. * @param left left vector to minimize
  2644. * @param right right vector to minimize
  2645. * @returns a new vector with the minimum of the left and right vector values
  2646. */
  2647. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2648. /**
  2649. * Returns a vector with the maximum values from the left and right vectors
  2650. * @param left left vector to maximize
  2651. * @param right right vector to maximize
  2652. * @returns a new vector with the maximum of the left and right vector values
  2653. */
  2654. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2655. /**
  2656. * Returns the distance (float) between the vectors "value1" and "value2".
  2657. * @param value1 value to calulate the distance between
  2658. * @param value2 value to calulate the distance between
  2659. * @return the distance between the two vectors
  2660. */
  2661. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2662. /**
  2663. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2664. * @param value1 value to calulate the distance between
  2665. * @param value2 value to calulate the distance between
  2666. * @return the distance between the two vectors squared
  2667. */
  2668. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2669. /**
  2670. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2671. * @param value1 value to calulate the center between
  2672. * @param value2 value to calulate the center between
  2673. * @return the center between the two vectors
  2674. */
  2675. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2676. /**
  2677. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2678. * This methods computes transformed normalized direction vectors only.
  2679. * @param vector the vector to transform
  2680. * @param transformation the transformation matrix to apply
  2681. * @returns the new vector
  2682. */
  2683. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2684. /**
  2685. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2686. * This methods computes transformed normalized direction vectors only.
  2687. * @param vector the vector to transform
  2688. * @param transformation the transformation matrix to apply
  2689. * @param result the vector to store the result in
  2690. */
  2691. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2692. /**
  2693. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2694. * This methods computes transformed normalized direction vectors only.
  2695. * @param x value to transform
  2696. * @param y value to transform
  2697. * @param z value to transform
  2698. * @param w value to transform
  2699. * @param transformation the transformation matrix to apply
  2700. * @param result the vector to store the results in
  2701. */
  2702. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2703. /**
  2704. * Creates a new Vector4 from a Vector3
  2705. * @param source defines the source data
  2706. * @param w defines the 4th component (default is 0)
  2707. * @returns a new Vector4
  2708. */
  2709. static FromVector3(source: Vector3, w?: number): Vector4;
  2710. }
  2711. /**
  2712. * Class used to store quaternion data
  2713. * @see https://en.wikipedia.org/wiki/Quaternion
  2714. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2715. */
  2716. export class Quaternion {
  2717. /** defines the first component (0 by default) */
  2718. x: number;
  2719. /** defines the second component (0 by default) */
  2720. y: number;
  2721. /** defines the third component (0 by default) */
  2722. z: number;
  2723. /** defines the fourth component (1.0 by default) */
  2724. w: number;
  2725. /**
  2726. * Creates a new Quaternion from the given floats
  2727. * @param x defines the first component (0 by default)
  2728. * @param y defines the second component (0 by default)
  2729. * @param z defines the third component (0 by default)
  2730. * @param w defines the fourth component (1.0 by default)
  2731. */
  2732. constructor(
  2733. /** defines the first component (0 by default) */
  2734. x?: number,
  2735. /** defines the second component (0 by default) */
  2736. y?: number,
  2737. /** defines the third component (0 by default) */
  2738. z?: number,
  2739. /** defines the fourth component (1.0 by default) */
  2740. w?: number);
  2741. /**
  2742. * Gets a string representation for the current quaternion
  2743. * @returns a string with the Quaternion coordinates
  2744. */
  2745. toString(): string;
  2746. /**
  2747. * Gets the class name of the quaternion
  2748. * @returns the string "Quaternion"
  2749. */
  2750. getClassName(): string;
  2751. /**
  2752. * Gets a hash code for this quaternion
  2753. * @returns the quaternion hash code
  2754. */
  2755. getHashCode(): number;
  2756. /**
  2757. * Copy the quaternion to an array
  2758. * @returns a new array populated with 4 elements from the quaternion coordinates
  2759. */
  2760. asArray(): number[];
  2761. /**
  2762. * Check if two quaternions are equals
  2763. * @param otherQuaternion defines the second operand
  2764. * @return true if the current quaternion and the given one coordinates are strictly equals
  2765. */
  2766. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2767. /**
  2768. * Clone the current quaternion
  2769. * @returns a new quaternion copied from the current one
  2770. */
  2771. clone(): Quaternion;
  2772. /**
  2773. * Copy a quaternion to the current one
  2774. * @param other defines the other quaternion
  2775. * @returns the updated current quaternion
  2776. */
  2777. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2778. /**
  2779. * Updates the current quaternion with the given float coordinates
  2780. * @param x defines the x coordinate
  2781. * @param y defines the y coordinate
  2782. * @param z defines the z coordinate
  2783. * @param w defines the w coordinate
  2784. * @returns the updated current quaternion
  2785. */
  2786. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2787. /**
  2788. * Updates the current quaternion from the given float coordinates
  2789. * @param x defines the x coordinate
  2790. * @param y defines the y coordinate
  2791. * @param z defines the z coordinate
  2792. * @param w defines the w coordinate
  2793. * @returns the updated current quaternion
  2794. */
  2795. set(x: number, y: number, z: number, w: number): Quaternion;
  2796. /**
  2797. * Adds two quaternions
  2798. * @param other defines the second operand
  2799. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2800. */
  2801. add(other: DeepImmutable<Quaternion>): Quaternion;
  2802. /**
  2803. * Add a quaternion to the current one
  2804. * @param other defines the quaternion to add
  2805. * @returns the current quaternion
  2806. */
  2807. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2808. /**
  2809. * Subtract two quaternions
  2810. * @param other defines the second operand
  2811. * @returns a new quaternion as the subtraction result of the given one from the current one
  2812. */
  2813. subtract(other: Quaternion): Quaternion;
  2814. /**
  2815. * Multiplies the current quaternion by a scale factor
  2816. * @param value defines the scale factor
  2817. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2818. */
  2819. scale(value: number): Quaternion;
  2820. /**
  2821. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2822. * @param scale defines the scale factor
  2823. * @param result defines the Quaternion object where to store the result
  2824. * @returns the unmodified current quaternion
  2825. */
  2826. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2827. /**
  2828. * Multiplies in place the current quaternion by a scale factor
  2829. * @param value defines the scale factor
  2830. * @returns the current modified quaternion
  2831. */
  2832. scaleInPlace(value: number): Quaternion;
  2833. /**
  2834. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2835. * @param scale defines the scale factor
  2836. * @param result defines the Quaternion object where to store the result
  2837. * @returns the unmodified current quaternion
  2838. */
  2839. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2840. /**
  2841. * Multiplies two quaternions
  2842. * @param q1 defines the second operand
  2843. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2844. */
  2845. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2846. /**
  2847. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2848. * @param q1 defines the second operand
  2849. * @param result defines the target quaternion
  2850. * @returns the current quaternion
  2851. */
  2852. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2853. /**
  2854. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2855. * @param q1 defines the second operand
  2856. * @returns the currentupdated quaternion
  2857. */
  2858. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2859. /**
  2860. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2861. * @param ref defines the target quaternion
  2862. * @returns the current quaternion
  2863. */
  2864. conjugateToRef(ref: Quaternion): Quaternion;
  2865. /**
  2866. * Conjugates in place (1-q) the current quaternion
  2867. * @returns the current updated quaternion
  2868. */
  2869. conjugateInPlace(): Quaternion;
  2870. /**
  2871. * Conjugates in place (1-q) the current quaternion
  2872. * @returns a new quaternion
  2873. */
  2874. conjugate(): Quaternion;
  2875. /**
  2876. * Gets length of current quaternion
  2877. * @returns the quaternion length (float)
  2878. */
  2879. length(): number;
  2880. /**
  2881. * Normalize in place the current quaternion
  2882. * @returns the current updated quaternion
  2883. */
  2884. normalize(): Quaternion;
  2885. /**
  2886. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2887. * @param order is a reserved parameter and is ignore for now
  2888. * @returns a new Vector3 containing the Euler angles
  2889. */
  2890. toEulerAngles(order?: string): Vector3;
  2891. /**
  2892. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2893. * @param result defines the vector which will be filled with the Euler angles
  2894. * @param order is a reserved parameter and is ignore for now
  2895. * @returns the current unchanged quaternion
  2896. */
  2897. toEulerAnglesToRef(result: Vector3): Quaternion;
  2898. /**
  2899. * Updates the given rotation matrix with the current quaternion values
  2900. * @param result defines the target matrix
  2901. * @returns the current unchanged quaternion
  2902. */
  2903. toRotationMatrix(result: Matrix): Quaternion;
  2904. /**
  2905. * Updates the current quaternion from the given rotation matrix values
  2906. * @param matrix defines the source matrix
  2907. * @returns the current updated quaternion
  2908. */
  2909. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2910. /**
  2911. * Creates a new quaternion from a rotation matrix
  2912. * @param matrix defines the source matrix
  2913. * @returns a new quaternion created from the given rotation matrix values
  2914. */
  2915. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2916. /**
  2917. * Updates the given quaternion with the given rotation matrix values
  2918. * @param matrix defines the source matrix
  2919. * @param result defines the target quaternion
  2920. */
  2921. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2922. /**
  2923. * Returns the dot product (float) between the quaternions "left" and "right"
  2924. * @param left defines the left operand
  2925. * @param right defines the right operand
  2926. * @returns the dot product
  2927. */
  2928. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2929. /**
  2930. * Checks if the two quaternions are close to each other
  2931. * @param quat0 defines the first quaternion to check
  2932. * @param quat1 defines the second quaternion to check
  2933. * @returns true if the two quaternions are close to each other
  2934. */
  2935. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2936. /**
  2937. * Creates an empty quaternion
  2938. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2939. */
  2940. static Zero(): Quaternion;
  2941. /**
  2942. * Inverse a given quaternion
  2943. * @param q defines the source quaternion
  2944. * @returns a new quaternion as the inverted current quaternion
  2945. */
  2946. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2947. /**
  2948. * Inverse a given quaternion
  2949. * @param q defines the source quaternion
  2950. * @param result the quaternion the result will be stored in
  2951. * @returns the result quaternion
  2952. */
  2953. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2954. /**
  2955. * Creates an identity quaternion
  2956. * @returns the identity quaternion
  2957. */
  2958. static Identity(): Quaternion;
  2959. /**
  2960. * Gets a boolean indicating if the given quaternion is identity
  2961. * @param quaternion defines the quaternion to check
  2962. * @returns true if the quaternion is identity
  2963. */
  2964. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2965. /**
  2966. * Creates a quaternion from a rotation around an axis
  2967. * @param axis defines the axis to use
  2968. * @param angle defines the angle to use
  2969. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2970. */
  2971. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2972. /**
  2973. * Creates a rotation around an axis and stores it into the given quaternion
  2974. * @param axis defines the axis to use
  2975. * @param angle defines the angle to use
  2976. * @param result defines the target quaternion
  2977. * @returns the target quaternion
  2978. */
  2979. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2980. /**
  2981. * Creates a new quaternion from data stored into an array
  2982. * @param array defines the data source
  2983. * @param offset defines the offset in the source array where the data starts
  2984. * @returns a new quaternion
  2985. */
  2986. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2987. /**
  2988. * Create a quaternion from Euler rotation angles
  2989. * @param x Pitch
  2990. * @param y Yaw
  2991. * @param z Roll
  2992. * @returns the new Quaternion
  2993. */
  2994. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2995. /**
  2996. * Updates a quaternion from Euler rotation angles
  2997. * @param x Pitch
  2998. * @param y Yaw
  2999. * @param z Roll
  3000. * @param result the quaternion to store the result
  3001. * @returns the updated quaternion
  3002. */
  3003. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3004. /**
  3005. * Create a quaternion from Euler rotation vector
  3006. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3007. * @returns the new Quaternion
  3008. */
  3009. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3010. /**
  3011. * Updates a quaternion from Euler rotation vector
  3012. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3013. * @param result the quaternion to store the result
  3014. * @returns the updated quaternion
  3015. */
  3016. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3017. /**
  3018. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3019. * @param yaw defines the rotation around Y axis
  3020. * @param pitch defines the rotation around X axis
  3021. * @param roll defines the rotation around Z axis
  3022. * @returns the new quaternion
  3023. */
  3024. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3025. /**
  3026. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3027. * @param yaw defines the rotation around Y axis
  3028. * @param pitch defines the rotation around X axis
  3029. * @param roll defines the rotation around Z axis
  3030. * @param result defines the target quaternion
  3031. */
  3032. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3033. /**
  3034. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3035. * @param alpha defines the rotation around first axis
  3036. * @param beta defines the rotation around second axis
  3037. * @param gamma defines the rotation around third axis
  3038. * @returns the new quaternion
  3039. */
  3040. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3041. /**
  3042. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3043. * @param alpha defines the rotation around first axis
  3044. * @param beta defines the rotation around second axis
  3045. * @param gamma defines the rotation around third axis
  3046. * @param result defines the target quaternion
  3047. */
  3048. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3049. /**
  3050. * 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)
  3051. * @param axis1 defines the first axis
  3052. * @param axis2 defines the second axis
  3053. * @param axis3 defines the third axis
  3054. * @returns the new quaternion
  3055. */
  3056. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3057. /**
  3058. * 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
  3059. * @param axis1 defines the first axis
  3060. * @param axis2 defines the second axis
  3061. * @param axis3 defines the third axis
  3062. * @param ref defines the target quaternion
  3063. */
  3064. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3065. /**
  3066. * Interpolates between two quaternions
  3067. * @param left defines first quaternion
  3068. * @param right defines second quaternion
  3069. * @param amount defines the gradient to use
  3070. * @returns the new interpolated quaternion
  3071. */
  3072. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3073. /**
  3074. * Interpolates between two quaternions and stores it into a target quaternion
  3075. * @param left defines first quaternion
  3076. * @param right defines second quaternion
  3077. * @param amount defines the gradient to use
  3078. * @param result defines the target quaternion
  3079. */
  3080. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3081. /**
  3082. * Interpolate between two quaternions using Hermite interpolation
  3083. * @param value1 defines first quaternion
  3084. * @param tangent1 defines the incoming tangent
  3085. * @param value2 defines second quaternion
  3086. * @param tangent2 defines the outgoing tangent
  3087. * @param amount defines the target quaternion
  3088. * @returns the new interpolated quaternion
  3089. */
  3090. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3091. }
  3092. /**
  3093. * Class used to store matrix data (4x4)
  3094. */
  3095. export class Matrix {
  3096. private static _updateFlagSeed;
  3097. private static _identityReadOnly;
  3098. private _isIdentity;
  3099. private _isIdentityDirty;
  3100. private _isIdentity3x2;
  3101. private _isIdentity3x2Dirty;
  3102. /**
  3103. * Gets the update flag of the matrix which is an unique number for the matrix.
  3104. * It will be incremented every time the matrix data change.
  3105. * You can use it to speed the comparison between two versions of the same matrix.
  3106. */
  3107. updateFlag: number;
  3108. private readonly _m;
  3109. /**
  3110. * Gets the internal data of the matrix
  3111. */
  3112. readonly m: DeepImmutable<Float32Array>;
  3113. /** @hidden */
  3114. _markAsUpdated(): void;
  3115. /** @hidden */
  3116. private _updateIdentityStatus;
  3117. /**
  3118. * Creates an empty matrix (filled with zeros)
  3119. */
  3120. constructor();
  3121. /**
  3122. * Check if the current matrix is identity
  3123. * @returns true is the matrix is the identity matrix
  3124. */
  3125. isIdentity(): boolean;
  3126. /**
  3127. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3128. * @returns true is the matrix is the identity matrix
  3129. */
  3130. isIdentityAs3x2(): boolean;
  3131. /**
  3132. * Gets the determinant of the matrix
  3133. * @returns the matrix determinant
  3134. */
  3135. determinant(): number;
  3136. /**
  3137. * Returns the matrix as a Float32Array
  3138. * @returns the matrix underlying array
  3139. */
  3140. toArray(): DeepImmutable<Float32Array>;
  3141. /**
  3142. * Returns the matrix as a Float32Array
  3143. * @returns the matrix underlying array.
  3144. */
  3145. asArray(): DeepImmutable<Float32Array>;
  3146. /**
  3147. * Inverts the current matrix in place
  3148. * @returns the current inverted matrix
  3149. */
  3150. invert(): Matrix;
  3151. /**
  3152. * Sets all the matrix elements to zero
  3153. * @returns the current matrix
  3154. */
  3155. reset(): Matrix;
  3156. /**
  3157. * Adds the current matrix with a second one
  3158. * @param other defines the matrix to add
  3159. * @returns a new matrix as the addition of the current matrix and the given one
  3160. */
  3161. add(other: DeepImmutable<Matrix>): Matrix;
  3162. /**
  3163. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3164. * @param other defines the matrix to add
  3165. * @param result defines the target matrix
  3166. * @returns the current matrix
  3167. */
  3168. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3169. /**
  3170. * Adds in place the given matrix to the current matrix
  3171. * @param other defines the second operand
  3172. * @returns the current updated matrix
  3173. */
  3174. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3175. /**
  3176. * Sets the given matrix to the current inverted Matrix
  3177. * @param other defines the target matrix
  3178. * @returns the unmodified current matrix
  3179. */
  3180. invertToRef(other: Matrix): Matrix;
  3181. /**
  3182. * add a value at the specified position in the current Matrix
  3183. * @param index the index of the value within the matrix. between 0 and 15.
  3184. * @param value the value to be added
  3185. * @returns the current updated matrix
  3186. */
  3187. addAtIndex(index: number, value: number): Matrix;
  3188. /**
  3189. * mutiply the specified position in the current Matrix by a value
  3190. * @param index the index of the value within the matrix. between 0 and 15.
  3191. * @param value the value to be added
  3192. * @returns the current updated matrix
  3193. */
  3194. multiplyAtIndex(index: number, value: number): Matrix;
  3195. /**
  3196. * Inserts the translation vector (using 3 floats) in the current matrix
  3197. * @param x defines the 1st component of the translation
  3198. * @param y defines the 2nd component of the translation
  3199. * @param z defines the 3rd component of the translation
  3200. * @returns the current updated matrix
  3201. */
  3202. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3203. /**
  3204. * Adds the translation vector (using 3 floats) in the current matrix
  3205. * @param x defines the 1st component of the translation
  3206. * @param y defines the 2nd component of the translation
  3207. * @param z defines the 3rd component of the translation
  3208. * @returns the current updated matrix
  3209. */
  3210. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3211. /**
  3212. * Inserts the translation vector in the current matrix
  3213. * @param vector3 defines the translation to insert
  3214. * @returns the current updated matrix
  3215. */
  3216. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3217. /**
  3218. * Gets the translation value of the current matrix
  3219. * @returns a new Vector3 as the extracted translation from the matrix
  3220. */
  3221. getTranslation(): Vector3;
  3222. /**
  3223. * Fill a Vector3 with the extracted translation from the matrix
  3224. * @param result defines the Vector3 where to store the translation
  3225. * @returns the current matrix
  3226. */
  3227. getTranslationToRef(result: Vector3): Matrix;
  3228. /**
  3229. * Remove rotation and scaling part from the matrix
  3230. * @returns the updated matrix
  3231. */
  3232. removeRotationAndScaling(): Matrix;
  3233. /**
  3234. * Multiply two matrices
  3235. * @param other defines the second operand
  3236. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3237. */
  3238. multiply(other: DeepImmutable<Matrix>): Matrix;
  3239. /**
  3240. * Copy the current matrix from the given one
  3241. * @param other defines the source matrix
  3242. * @returns the current updated matrix
  3243. */
  3244. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3245. /**
  3246. * Populates the given array from the starting index with the current matrix values
  3247. * @param array defines the target array
  3248. * @param offset defines the offset in the target array where to start storing values
  3249. * @returns the current matrix
  3250. */
  3251. copyToArray(array: Float32Array, offset?: number): Matrix;
  3252. /**
  3253. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3254. * @param other defines the second operand
  3255. * @param result defines the matrix where to store the multiplication
  3256. * @returns the current matrix
  3257. */
  3258. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3259. /**
  3260. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3261. * @param other defines the second operand
  3262. * @param result defines the array where to store the multiplication
  3263. * @param offset defines the offset in the target array where to start storing values
  3264. * @returns the current matrix
  3265. */
  3266. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3267. /**
  3268. * Check equality between this matrix and a second one
  3269. * @param value defines the second matrix to compare
  3270. * @returns true is the current matrix and the given one values are strictly equal
  3271. */
  3272. equals(value: DeepImmutable<Matrix>): boolean;
  3273. /**
  3274. * Clone the current matrix
  3275. * @returns a new matrix from the current matrix
  3276. */
  3277. clone(): Matrix;
  3278. /**
  3279. * Returns the name of the current matrix class
  3280. * @returns the string "Matrix"
  3281. */
  3282. getClassName(): string;
  3283. /**
  3284. * Gets the hash code of the current matrix
  3285. * @returns the hash code
  3286. */
  3287. getHashCode(): number;
  3288. /**
  3289. * Decomposes the current Matrix into a translation, rotation and scaling components
  3290. * @param scale defines the scale vector3 given as a reference to update
  3291. * @param rotation defines the rotation quaternion given as a reference to update
  3292. * @param translation defines the translation vector3 given as a reference to update
  3293. * @returns true if operation was successful
  3294. */
  3295. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3296. /**
  3297. * Gets specific row of the matrix
  3298. * @param index defines the number of the row to get
  3299. * @returns the index-th row of the current matrix as a new Vector4
  3300. */
  3301. getRow(index: number): Nullable<Vector4>;
  3302. /**
  3303. * Sets the index-th row of the current matrix to the vector4 values
  3304. * @param index defines the number of the row to set
  3305. * @param row defines the target vector4
  3306. * @returns the updated current matrix
  3307. */
  3308. setRow(index: number, row: Vector4): Matrix;
  3309. /**
  3310. * Compute the transpose of the matrix
  3311. * @returns the new transposed matrix
  3312. */
  3313. transpose(): Matrix;
  3314. /**
  3315. * Compute the transpose of the matrix and store it in a given matrix
  3316. * @param result defines the target matrix
  3317. * @returns the current matrix
  3318. */
  3319. transposeToRef(result: Matrix): Matrix;
  3320. /**
  3321. * Sets the index-th row of the current matrix with the given 4 x float values
  3322. * @param index defines the row index
  3323. * @param x defines the x component to set
  3324. * @param y defines the y component to set
  3325. * @param z defines the z component to set
  3326. * @param w defines the w component to set
  3327. * @returns the updated current matrix
  3328. */
  3329. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3330. /**
  3331. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3332. * @param scale defines the scale factor
  3333. * @returns a new matrix
  3334. */
  3335. scale(scale: number): Matrix;
  3336. /**
  3337. * Scale the current matrix values by a factor to a given result matrix
  3338. * @param scale defines the scale factor
  3339. * @param result defines the matrix to store the result
  3340. * @returns the current matrix
  3341. */
  3342. scaleToRef(scale: number, result: Matrix): Matrix;
  3343. /**
  3344. * Scale the current matrix values by a factor and add the result to a given matrix
  3345. * @param scale defines the scale factor
  3346. * @param result defines the Matrix to store the result
  3347. * @returns the current matrix
  3348. */
  3349. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3350. /**
  3351. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3352. * @param ref matrix to store the result
  3353. */
  3354. toNormalMatrix(ref: Matrix): void;
  3355. /**
  3356. * Gets only rotation part of the current matrix
  3357. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3358. */
  3359. getRotationMatrix(): Matrix;
  3360. /**
  3361. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3362. * @param result defines the target matrix to store data to
  3363. * @returns the current matrix
  3364. */
  3365. getRotationMatrixToRef(result: Matrix): Matrix;
  3366. /**
  3367. * Toggles model matrix from being right handed to left handed in place and vice versa
  3368. */
  3369. toggleModelMatrixHandInPlace(): void;
  3370. /**
  3371. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3372. */
  3373. toggleProjectionMatrixHandInPlace(): void;
  3374. /**
  3375. * Creates a matrix from an array
  3376. * @param array defines the source array
  3377. * @param offset defines an offset in the source array
  3378. * @returns a new Matrix set from the starting index of the given array
  3379. */
  3380. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3381. /**
  3382. * Copy the content of an array into a given matrix
  3383. * @param array defines the source array
  3384. * @param offset defines an offset in the source array
  3385. * @param result defines the target matrix
  3386. */
  3387. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3388. /**
  3389. * Stores an array into a matrix after having multiplied each component by a given factor
  3390. * @param array defines the source array
  3391. * @param offset defines the offset in the source array
  3392. * @param scale defines the scaling factor
  3393. * @param result defines the target matrix
  3394. */
  3395. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3396. /**
  3397. * Gets an identity matrix that must not be updated
  3398. */
  3399. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3400. /**
  3401. * Stores a list of values (16) inside a given matrix
  3402. * @param initialM11 defines 1st value of 1st row
  3403. * @param initialM12 defines 2nd value of 1st row
  3404. * @param initialM13 defines 3rd value of 1st row
  3405. * @param initialM14 defines 4th value of 1st row
  3406. * @param initialM21 defines 1st value of 2nd row
  3407. * @param initialM22 defines 2nd value of 2nd row
  3408. * @param initialM23 defines 3rd value of 2nd row
  3409. * @param initialM24 defines 4th value of 2nd row
  3410. * @param initialM31 defines 1st value of 3rd row
  3411. * @param initialM32 defines 2nd value of 3rd row
  3412. * @param initialM33 defines 3rd value of 3rd row
  3413. * @param initialM34 defines 4th value of 3rd row
  3414. * @param initialM41 defines 1st value of 4th row
  3415. * @param initialM42 defines 2nd value of 4th row
  3416. * @param initialM43 defines 3rd value of 4th row
  3417. * @param initialM44 defines 4th value of 4th row
  3418. * @param result defines the target matrix
  3419. */
  3420. 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;
  3421. /**
  3422. * Creates new matrix from a list of values (16)
  3423. * @param initialM11 defines 1st value of 1st row
  3424. * @param initialM12 defines 2nd value of 1st row
  3425. * @param initialM13 defines 3rd value of 1st row
  3426. * @param initialM14 defines 4th value of 1st row
  3427. * @param initialM21 defines 1st value of 2nd row
  3428. * @param initialM22 defines 2nd value of 2nd row
  3429. * @param initialM23 defines 3rd value of 2nd row
  3430. * @param initialM24 defines 4th value of 2nd row
  3431. * @param initialM31 defines 1st value of 3rd row
  3432. * @param initialM32 defines 2nd value of 3rd row
  3433. * @param initialM33 defines 3rd value of 3rd row
  3434. * @param initialM34 defines 4th value of 3rd row
  3435. * @param initialM41 defines 1st value of 4th row
  3436. * @param initialM42 defines 2nd value of 4th row
  3437. * @param initialM43 defines 3rd value of 4th row
  3438. * @param initialM44 defines 4th value of 4th row
  3439. * @returns the new matrix
  3440. */
  3441. 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;
  3442. /**
  3443. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3444. * @param scale defines the scale vector3
  3445. * @param rotation defines the rotation quaternion
  3446. * @param translation defines the translation vector3
  3447. * @returns a new matrix
  3448. */
  3449. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3450. /**
  3451. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3452. * @param scale defines the scale vector3
  3453. * @param rotation defines the rotation quaternion
  3454. * @param translation defines the translation vector3
  3455. * @param result defines the target matrix
  3456. */
  3457. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3458. /**
  3459. * Creates a new identity matrix
  3460. * @returns a new identity matrix
  3461. */
  3462. static Identity(): Matrix;
  3463. /**
  3464. * Creates a new identity matrix and stores the result in a given matrix
  3465. * @param result defines the target matrix
  3466. */
  3467. static IdentityToRef(result: Matrix): void;
  3468. /**
  3469. * Creates a new zero matrix
  3470. * @returns a new zero matrix
  3471. */
  3472. static Zero(): Matrix;
  3473. /**
  3474. * Creates a new rotation matrix for "angle" radians around the X axis
  3475. * @param angle defines the angle (in radians) to use
  3476. * @return the new matrix
  3477. */
  3478. static RotationX(angle: number): Matrix;
  3479. /**
  3480. * Creates a new matrix as the invert of a given matrix
  3481. * @param source defines the source matrix
  3482. * @returns the new matrix
  3483. */
  3484. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3485. /**
  3486. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3487. * @param angle defines the angle (in radians) to use
  3488. * @param result defines the target matrix
  3489. */
  3490. static RotationXToRef(angle: number, result: Matrix): void;
  3491. /**
  3492. * Creates a new rotation matrix for "angle" radians around the Y axis
  3493. * @param angle defines the angle (in radians) to use
  3494. * @return the new matrix
  3495. */
  3496. static RotationY(angle: number): Matrix;
  3497. /**
  3498. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3499. * @param angle defines the angle (in radians) to use
  3500. * @param result defines the target matrix
  3501. */
  3502. static RotationYToRef(angle: number, result: Matrix): void;
  3503. /**
  3504. * Creates a new rotation matrix for "angle" radians around the Z axis
  3505. * @param angle defines the angle (in radians) to use
  3506. * @return the new matrix
  3507. */
  3508. static RotationZ(angle: number): Matrix;
  3509. /**
  3510. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3511. * @param angle defines the angle (in radians) to use
  3512. * @param result defines the target matrix
  3513. */
  3514. static RotationZToRef(angle: number, result: Matrix): void;
  3515. /**
  3516. * Creates a new rotation matrix for "angle" radians around the given axis
  3517. * @param axis defines the axis to use
  3518. * @param angle defines the angle (in radians) to use
  3519. * @return the new matrix
  3520. */
  3521. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3522. /**
  3523. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3524. * @param axis defines the axis to use
  3525. * @param angle defines the angle (in radians) to use
  3526. * @param result defines the target matrix
  3527. */
  3528. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3529. /**
  3530. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3531. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3532. * @param from defines the vector to align
  3533. * @param to defines the vector to align to
  3534. * @param result defines the target matrix
  3535. */
  3536. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3537. /**
  3538. * Creates a rotation matrix
  3539. * @param yaw defines the yaw angle in radians (Y axis)
  3540. * @param pitch defines the pitch angle in radians (X axis)
  3541. * @param roll defines the roll angle in radians (X axis)
  3542. * @returns the new rotation matrix
  3543. */
  3544. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3545. /**
  3546. * Creates a rotation matrix and stores it in a given matrix
  3547. * @param yaw defines the yaw angle in radians (Y axis)
  3548. * @param pitch defines the pitch angle in radians (X axis)
  3549. * @param roll defines the roll angle in radians (X axis)
  3550. * @param result defines the target matrix
  3551. */
  3552. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3553. /**
  3554. * Creates a scaling matrix
  3555. * @param x defines the scale factor on X axis
  3556. * @param y defines the scale factor on Y axis
  3557. * @param z defines the scale factor on Z axis
  3558. * @returns the new matrix
  3559. */
  3560. static Scaling(x: number, y: number, z: number): Matrix;
  3561. /**
  3562. * Creates a scaling matrix and stores it in a given matrix
  3563. * @param x defines the scale factor on X axis
  3564. * @param y defines the scale factor on Y axis
  3565. * @param z defines the scale factor on Z axis
  3566. * @param result defines the target matrix
  3567. */
  3568. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3569. /**
  3570. * Creates a translation matrix
  3571. * @param x defines the translation on X axis
  3572. * @param y defines the translation on Y axis
  3573. * @param z defines the translationon Z axis
  3574. * @returns the new matrix
  3575. */
  3576. static Translation(x: number, y: number, z: number): Matrix;
  3577. /**
  3578. * Creates a translation matrix and stores it in a given matrix
  3579. * @param x defines the translation on X axis
  3580. * @param y defines the translation on Y axis
  3581. * @param z defines the translationon Z axis
  3582. * @param result defines the target matrix
  3583. */
  3584. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3585. /**
  3586. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3587. * @param startValue defines the start value
  3588. * @param endValue defines the end value
  3589. * @param gradient defines the gradient factor
  3590. * @returns the new matrix
  3591. */
  3592. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3593. /**
  3594. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3595. * @param startValue defines the start value
  3596. * @param endValue defines the end value
  3597. * @param gradient defines the gradient factor
  3598. * @param result defines the Matrix object where to store data
  3599. */
  3600. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3601. /**
  3602. * Builds a new matrix whose values are computed by:
  3603. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3604. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3605. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3606. * @param startValue defines the first matrix
  3607. * @param endValue defines the second matrix
  3608. * @param gradient defines the gradient between the two matrices
  3609. * @returns the new matrix
  3610. */
  3611. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3612. /**
  3613. * Update a matrix to values which are computed by:
  3614. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3615. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3616. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3617. * @param startValue defines the first matrix
  3618. * @param endValue defines the second matrix
  3619. * @param gradient defines the gradient between the two matrices
  3620. * @param result defines the target matrix
  3621. */
  3622. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3623. /**
  3624. * 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"
  3625. * This function works in left handed mode
  3626. * @param eye defines the final position of the entity
  3627. * @param target defines where the entity should look at
  3628. * @param up defines the up vector for the entity
  3629. * @returns the new matrix
  3630. */
  3631. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3632. /**
  3633. * 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".
  3634. * This function works in left handed mode
  3635. * @param eye defines the final position of the entity
  3636. * @param target defines where the entity should look at
  3637. * @param up defines the up vector for the entity
  3638. * @param result defines the target matrix
  3639. */
  3640. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3641. /**
  3642. * 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"
  3643. * This function works in right handed mode
  3644. * @param eye defines the final position of the entity
  3645. * @param target defines where the entity should look at
  3646. * @param up defines the up vector for the entity
  3647. * @returns the new matrix
  3648. */
  3649. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3650. /**
  3651. * 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".
  3652. * This function works in right handed mode
  3653. * @param eye defines the final position of the entity
  3654. * @param target defines where the entity should look at
  3655. * @param up defines the up vector for the entity
  3656. * @param result defines the target matrix
  3657. */
  3658. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3659. /**
  3660. * Create a left-handed orthographic projection matrix
  3661. * @param width defines the viewport width
  3662. * @param height defines the viewport height
  3663. * @param znear defines the near clip plane
  3664. * @param zfar defines the far clip plane
  3665. * @returns a new matrix as a left-handed orthographic projection matrix
  3666. */
  3667. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3668. /**
  3669. * Store a left-handed orthographic projection to a given matrix
  3670. * @param width defines the viewport width
  3671. * @param height defines the viewport height
  3672. * @param znear defines the near clip plane
  3673. * @param zfar defines the far clip plane
  3674. * @param result defines the target matrix
  3675. */
  3676. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3677. /**
  3678. * Create a left-handed orthographic projection matrix
  3679. * @param left defines the viewport left coordinate
  3680. * @param right defines the viewport right coordinate
  3681. * @param bottom defines the viewport bottom coordinate
  3682. * @param top defines the viewport top coordinate
  3683. * @param znear defines the near clip plane
  3684. * @param zfar defines the far clip plane
  3685. * @returns a new matrix as a left-handed orthographic projection matrix
  3686. */
  3687. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3688. /**
  3689. * Stores a left-handed orthographic projection into a given matrix
  3690. * @param left defines the viewport left coordinate
  3691. * @param right defines the viewport right coordinate
  3692. * @param bottom defines the viewport bottom coordinate
  3693. * @param top defines the viewport top coordinate
  3694. * @param znear defines the near clip plane
  3695. * @param zfar defines the far clip plane
  3696. * @param result defines the target matrix
  3697. */
  3698. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3699. /**
  3700. * Creates a right-handed orthographic projection matrix
  3701. * @param left defines the viewport left coordinate
  3702. * @param right defines the viewport right coordinate
  3703. * @param bottom defines the viewport bottom coordinate
  3704. * @param top defines the viewport top coordinate
  3705. * @param znear defines the near clip plane
  3706. * @param zfar defines the far clip plane
  3707. * @returns a new matrix as a right-handed orthographic projection matrix
  3708. */
  3709. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3710. /**
  3711. * Stores a right-handed orthographic projection into a given matrix
  3712. * @param left defines the viewport left coordinate
  3713. * @param right defines the viewport right coordinate
  3714. * @param bottom defines the viewport bottom coordinate
  3715. * @param top defines the viewport top coordinate
  3716. * @param znear defines the near clip plane
  3717. * @param zfar defines the far clip plane
  3718. * @param result defines the target matrix
  3719. */
  3720. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3721. /**
  3722. * Creates a left-handed perspective projection matrix
  3723. * @param width defines the viewport width
  3724. * @param height defines the viewport height
  3725. * @param znear defines the near clip plane
  3726. * @param zfar defines the far clip plane
  3727. * @returns a new matrix as a left-handed perspective projection matrix
  3728. */
  3729. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3730. /**
  3731. * Creates a left-handed perspective projection matrix
  3732. * @param fov defines the horizontal field of view
  3733. * @param aspect defines the aspect ratio
  3734. * @param znear defines the near clip plane
  3735. * @param zfar defines the far clip plane
  3736. * @returns a new matrix as a left-handed perspective projection matrix
  3737. */
  3738. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3739. /**
  3740. * Stores a left-handed perspective projection into a given matrix
  3741. * @param fov defines the horizontal field of view
  3742. * @param aspect defines the aspect ratio
  3743. * @param znear defines the near clip plane
  3744. * @param zfar defines the far clip plane
  3745. * @param result defines the target matrix
  3746. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3747. */
  3748. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3749. /**
  3750. * Creates a right-handed perspective projection matrix
  3751. * @param fov defines the horizontal field of view
  3752. * @param aspect defines the aspect ratio
  3753. * @param znear defines the near clip plane
  3754. * @param zfar defines the far clip plane
  3755. * @returns a new matrix as a right-handed perspective projection matrix
  3756. */
  3757. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3758. /**
  3759. * Stores a right-handed perspective projection into a given matrix
  3760. * @param fov defines the horizontal field of view
  3761. * @param aspect defines the aspect ratio
  3762. * @param znear defines the near clip plane
  3763. * @param zfar defines the far clip plane
  3764. * @param result defines the target matrix
  3765. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3766. */
  3767. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3768. /**
  3769. * Stores a perspective projection for WebVR info a given matrix
  3770. * @param fov defines the field of view
  3771. * @param znear defines the near clip plane
  3772. * @param zfar defines the far clip plane
  3773. * @param result defines the target matrix
  3774. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3775. */
  3776. static PerspectiveFovWebVRToRef(fov: {
  3777. upDegrees: number;
  3778. downDegrees: number;
  3779. leftDegrees: number;
  3780. rightDegrees: number;
  3781. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3782. /**
  3783. * Computes a complete transformation matrix
  3784. * @param viewport defines the viewport to use
  3785. * @param world defines the world matrix
  3786. * @param view defines the view matrix
  3787. * @param projection defines the projection matrix
  3788. * @param zmin defines the near clip plane
  3789. * @param zmax defines the far clip plane
  3790. * @returns the transformation matrix
  3791. */
  3792. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3793. /**
  3794. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3795. * @param matrix defines the matrix to use
  3796. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3797. */
  3798. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3799. /**
  3800. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3801. * @param matrix defines the matrix to use
  3802. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3803. */
  3804. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3805. /**
  3806. * Compute the transpose of a given matrix
  3807. * @param matrix defines the matrix to transpose
  3808. * @returns the new matrix
  3809. */
  3810. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3811. /**
  3812. * Compute the transpose of a matrix and store it in a target matrix
  3813. * @param matrix defines the matrix to transpose
  3814. * @param result defines the target matrix
  3815. */
  3816. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3817. /**
  3818. * Computes a reflection matrix from a plane
  3819. * @param plane defines the reflection plane
  3820. * @returns a new matrix
  3821. */
  3822. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3823. /**
  3824. * Computes a reflection matrix from a plane
  3825. * @param plane defines the reflection plane
  3826. * @param result defines the target matrix
  3827. */
  3828. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  3829. /**
  3830. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3831. * @param xaxis defines the value of the 1st axis
  3832. * @param yaxis defines the value of the 2nd axis
  3833. * @param zaxis defines the value of the 3rd axis
  3834. * @param result defines the target matrix
  3835. */
  3836. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3837. /**
  3838. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3839. * @param quat defines the quaternion to use
  3840. * @param result defines the target matrix
  3841. */
  3842. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3843. }
  3844. /**
  3845. * @hidden
  3846. */
  3847. export class TmpVectors {
  3848. static Vector2: Vector2[];
  3849. static Vector3: Vector3[];
  3850. static Vector4: Vector4[];
  3851. static Quaternion: Quaternion[];
  3852. static Matrix: Matrix[];
  3853. }
  3854. }
  3855. declare module "babylonjs/Engines/constants" {
  3856. /** Defines the cross module used constants to avoid circular dependncies */
  3857. export class Constants {
  3858. /** Defines that alpha blending is disabled */
  3859. static readonly ALPHA_DISABLE: number;
  3860. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  3861. static readonly ALPHA_ADD: number;
  3862. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  3863. static readonly ALPHA_COMBINE: number;
  3864. /** Defines that alpha blending to DEST - SRC * DEST */
  3865. static readonly ALPHA_SUBTRACT: number;
  3866. /** Defines that alpha blending to SRC * DEST */
  3867. static readonly ALPHA_MULTIPLY: number;
  3868. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  3869. static readonly ALPHA_MAXIMIZED: number;
  3870. /** Defines that alpha blending to SRC + DEST */
  3871. static readonly ALPHA_ONEONE: number;
  3872. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  3873. static readonly ALPHA_PREMULTIPLIED: number;
  3874. /**
  3875. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  3876. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  3877. */
  3878. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  3879. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  3880. static readonly ALPHA_INTERPOLATE: number;
  3881. /**
  3882. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  3883. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  3884. */
  3885. static readonly ALPHA_SCREENMODE: number;
  3886. /**
  3887. * Defines that alpha blending to SRC + DST
  3888. * Alpha will be set to SRC ALPHA + DST ALPHA
  3889. */
  3890. static readonly ALPHA_ONEONE_ONEONE: number;
  3891. /**
  3892. * Defines that alpha blending to SRC * DST ALPHA + DST
  3893. * Alpha will be set to 0
  3894. */
  3895. static readonly ALPHA_ALPHATOCOLOR: number;
  3896. /**
  3897. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  3898. */
  3899. static readonly ALPHA_REVERSEONEMINUS: number;
  3900. /**
  3901. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  3902. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  3903. */
  3904. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  3905. /**
  3906. * Defines that alpha blending to SRC + DST
  3907. * Alpha will be set to SRC ALPHA
  3908. */
  3909. static readonly ALPHA_ONEONE_ONEZERO: number;
  3910. /** Defines that alpha blending equation a SUM */
  3911. static readonly ALPHA_EQUATION_ADD: number;
  3912. /** Defines that alpha blending equation a SUBSTRACTION */
  3913. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  3914. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  3915. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  3916. /** Defines that alpha blending equation a MAX operation */
  3917. static readonly ALPHA_EQUATION_MAX: number;
  3918. /** Defines that alpha blending equation a MIN operation */
  3919. static readonly ALPHA_EQUATION_MIN: number;
  3920. /**
  3921. * Defines that alpha blending equation a DARKEN operation:
  3922. * It takes the min of the src and sums the alpha channels.
  3923. */
  3924. static readonly ALPHA_EQUATION_DARKEN: number;
  3925. /** Defines that the ressource is not delayed*/
  3926. static readonly DELAYLOADSTATE_NONE: number;
  3927. /** Defines that the ressource was successfully delay loaded */
  3928. static readonly DELAYLOADSTATE_LOADED: number;
  3929. /** Defines that the ressource is currently delay loading */
  3930. static readonly DELAYLOADSTATE_LOADING: number;
  3931. /** Defines that the ressource is delayed and has not started loading */
  3932. static readonly DELAYLOADSTATE_NOTLOADED: number;
  3933. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  3934. static readonly NEVER: number;
  3935. /** 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 */
  3936. static readonly ALWAYS: number;
  3937. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  3938. static readonly LESS: number;
  3939. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  3940. static readonly EQUAL: number;
  3941. /** 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 */
  3942. static readonly LEQUAL: number;
  3943. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  3944. static readonly GREATER: number;
  3945. /** 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 */
  3946. static readonly GEQUAL: number;
  3947. /** 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 */
  3948. static readonly NOTEQUAL: number;
  3949. /** Passed to stencilOperation to specify that stencil value must be kept */
  3950. static readonly KEEP: number;
  3951. /** Passed to stencilOperation to specify that stencil value must be replaced */
  3952. static readonly REPLACE: number;
  3953. /** Passed to stencilOperation to specify that stencil value must be incremented */
  3954. static readonly INCR: number;
  3955. /** Passed to stencilOperation to specify that stencil value must be decremented */
  3956. static readonly DECR: number;
  3957. /** Passed to stencilOperation to specify that stencil value must be inverted */
  3958. static readonly INVERT: number;
  3959. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  3960. static readonly INCR_WRAP: number;
  3961. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  3962. static readonly DECR_WRAP: number;
  3963. /** Texture is not repeating outside of 0..1 UVs */
  3964. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  3965. /** Texture is repeating outside of 0..1 UVs */
  3966. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  3967. /** Texture is repeating and mirrored */
  3968. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  3969. /** ALPHA */
  3970. static readonly TEXTUREFORMAT_ALPHA: number;
  3971. /** LUMINANCE */
  3972. static readonly TEXTUREFORMAT_LUMINANCE: number;
  3973. /** LUMINANCE_ALPHA */
  3974. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  3975. /** RGB */
  3976. static readonly TEXTUREFORMAT_RGB: number;
  3977. /** RGBA */
  3978. static readonly TEXTUREFORMAT_RGBA: number;
  3979. /** RED */
  3980. static readonly TEXTUREFORMAT_RED: number;
  3981. /** RED (2nd reference) */
  3982. static readonly TEXTUREFORMAT_R: number;
  3983. /** RG */
  3984. static readonly TEXTUREFORMAT_RG: number;
  3985. /** RED_INTEGER */
  3986. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  3987. /** RED_INTEGER (2nd reference) */
  3988. static readonly TEXTUREFORMAT_R_INTEGER: number;
  3989. /** RG_INTEGER */
  3990. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  3991. /** RGB_INTEGER */
  3992. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  3993. /** RGBA_INTEGER */
  3994. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  3995. /** UNSIGNED_BYTE */
  3996. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  3997. /** UNSIGNED_BYTE (2nd reference) */
  3998. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  3999. /** FLOAT */
  4000. static readonly TEXTURETYPE_FLOAT: number;
  4001. /** HALF_FLOAT */
  4002. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4003. /** BYTE */
  4004. static readonly TEXTURETYPE_BYTE: number;
  4005. /** SHORT */
  4006. static readonly TEXTURETYPE_SHORT: number;
  4007. /** UNSIGNED_SHORT */
  4008. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4009. /** INT */
  4010. static readonly TEXTURETYPE_INT: number;
  4011. /** UNSIGNED_INT */
  4012. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4013. /** UNSIGNED_SHORT_4_4_4_4 */
  4014. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4015. /** UNSIGNED_SHORT_5_5_5_1 */
  4016. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4017. /** UNSIGNED_SHORT_5_6_5 */
  4018. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4019. /** UNSIGNED_INT_2_10_10_10_REV */
  4020. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4021. /** UNSIGNED_INT_24_8 */
  4022. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4023. /** UNSIGNED_INT_10F_11F_11F_REV */
  4024. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4025. /** UNSIGNED_INT_5_9_9_9_REV */
  4026. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4027. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4028. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4029. /** nearest is mag = nearest and min = nearest and mip = linear */
  4030. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4031. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4032. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4033. /** Trilinear is mag = linear and min = linear and mip = linear */
  4034. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4035. /** nearest is mag = nearest and min = nearest and mip = linear */
  4036. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4037. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4038. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4039. /** Trilinear is mag = linear and min = linear and mip = linear */
  4040. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4041. /** mag = nearest and min = nearest and mip = nearest */
  4042. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4043. /** mag = nearest and min = linear and mip = nearest */
  4044. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4045. /** mag = nearest and min = linear and mip = linear */
  4046. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4047. /** mag = nearest and min = linear and mip = none */
  4048. static readonly TEXTURE_NEAREST_LINEAR: number;
  4049. /** mag = nearest and min = nearest and mip = none */
  4050. static readonly TEXTURE_NEAREST_NEAREST: number;
  4051. /** mag = linear and min = nearest and mip = nearest */
  4052. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4053. /** mag = linear and min = nearest and mip = linear */
  4054. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4055. /** mag = linear and min = linear and mip = none */
  4056. static readonly TEXTURE_LINEAR_LINEAR: number;
  4057. /** mag = linear and min = nearest and mip = none */
  4058. static readonly TEXTURE_LINEAR_NEAREST: number;
  4059. /** Explicit coordinates mode */
  4060. static readonly TEXTURE_EXPLICIT_MODE: number;
  4061. /** Spherical coordinates mode */
  4062. static readonly TEXTURE_SPHERICAL_MODE: number;
  4063. /** Planar coordinates mode */
  4064. static readonly TEXTURE_PLANAR_MODE: number;
  4065. /** Cubic coordinates mode */
  4066. static readonly TEXTURE_CUBIC_MODE: number;
  4067. /** Projection coordinates mode */
  4068. static readonly TEXTURE_PROJECTION_MODE: number;
  4069. /** Skybox coordinates mode */
  4070. static readonly TEXTURE_SKYBOX_MODE: number;
  4071. /** Inverse Cubic coordinates mode */
  4072. static readonly TEXTURE_INVCUBIC_MODE: number;
  4073. /** Equirectangular coordinates mode */
  4074. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4075. /** Equirectangular Fixed coordinates mode */
  4076. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4077. /** Equirectangular Fixed Mirrored coordinates mode */
  4078. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4079. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4080. static readonly SCALEMODE_FLOOR: number;
  4081. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4082. static readonly SCALEMODE_NEAREST: number;
  4083. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4084. static readonly SCALEMODE_CEILING: number;
  4085. /**
  4086. * The dirty texture flag value
  4087. */
  4088. static readonly MATERIAL_TextureDirtyFlag: number;
  4089. /**
  4090. * The dirty light flag value
  4091. */
  4092. static readonly MATERIAL_LightDirtyFlag: number;
  4093. /**
  4094. * The dirty fresnel flag value
  4095. */
  4096. static readonly MATERIAL_FresnelDirtyFlag: number;
  4097. /**
  4098. * The dirty attribute flag value
  4099. */
  4100. static readonly MATERIAL_AttributesDirtyFlag: number;
  4101. /**
  4102. * The dirty misc flag value
  4103. */
  4104. static readonly MATERIAL_MiscDirtyFlag: number;
  4105. /**
  4106. * The all dirty flag value
  4107. */
  4108. static readonly MATERIAL_AllDirtyFlag: number;
  4109. /**
  4110. * Returns the triangle fill mode
  4111. */
  4112. static readonly MATERIAL_TriangleFillMode: number;
  4113. /**
  4114. * Returns the wireframe mode
  4115. */
  4116. static readonly MATERIAL_WireFrameFillMode: number;
  4117. /**
  4118. * Returns the point fill mode
  4119. */
  4120. static readonly MATERIAL_PointFillMode: number;
  4121. /**
  4122. * Returns the point list draw mode
  4123. */
  4124. static readonly MATERIAL_PointListDrawMode: number;
  4125. /**
  4126. * Returns the line list draw mode
  4127. */
  4128. static readonly MATERIAL_LineListDrawMode: number;
  4129. /**
  4130. * Returns the line loop draw mode
  4131. */
  4132. static readonly MATERIAL_LineLoopDrawMode: number;
  4133. /**
  4134. * Returns the line strip draw mode
  4135. */
  4136. static readonly MATERIAL_LineStripDrawMode: number;
  4137. /**
  4138. * Returns the triangle strip draw mode
  4139. */
  4140. static readonly MATERIAL_TriangleStripDrawMode: number;
  4141. /**
  4142. * Returns the triangle fan draw mode
  4143. */
  4144. static readonly MATERIAL_TriangleFanDrawMode: number;
  4145. /**
  4146. * Stores the clock-wise side orientation
  4147. */
  4148. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4149. /**
  4150. * Stores the counter clock-wise side orientation
  4151. */
  4152. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4153. /**
  4154. * Nothing
  4155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4156. */
  4157. static readonly ACTION_NothingTrigger: number;
  4158. /**
  4159. * On pick
  4160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4161. */
  4162. static readonly ACTION_OnPickTrigger: number;
  4163. /**
  4164. * On left pick
  4165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4166. */
  4167. static readonly ACTION_OnLeftPickTrigger: number;
  4168. /**
  4169. * On right pick
  4170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4171. */
  4172. static readonly ACTION_OnRightPickTrigger: number;
  4173. /**
  4174. * On center pick
  4175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4176. */
  4177. static readonly ACTION_OnCenterPickTrigger: number;
  4178. /**
  4179. * On pick down
  4180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4181. */
  4182. static readonly ACTION_OnPickDownTrigger: number;
  4183. /**
  4184. * On double pick
  4185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4186. */
  4187. static readonly ACTION_OnDoublePickTrigger: number;
  4188. /**
  4189. * On pick up
  4190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4191. */
  4192. static readonly ACTION_OnPickUpTrigger: number;
  4193. /**
  4194. * On pick out.
  4195. * This trigger will only be raised if you also declared a OnPickDown
  4196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4197. */
  4198. static readonly ACTION_OnPickOutTrigger: number;
  4199. /**
  4200. * On long press
  4201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4202. */
  4203. static readonly ACTION_OnLongPressTrigger: number;
  4204. /**
  4205. * On pointer over
  4206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4207. */
  4208. static readonly ACTION_OnPointerOverTrigger: number;
  4209. /**
  4210. * On pointer out
  4211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4212. */
  4213. static readonly ACTION_OnPointerOutTrigger: number;
  4214. /**
  4215. * On every frame
  4216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4217. */
  4218. static readonly ACTION_OnEveryFrameTrigger: number;
  4219. /**
  4220. * On intersection enter
  4221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4222. */
  4223. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4224. /**
  4225. * On intersection exit
  4226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4227. */
  4228. static readonly ACTION_OnIntersectionExitTrigger: number;
  4229. /**
  4230. * On key down
  4231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4232. */
  4233. static readonly ACTION_OnKeyDownTrigger: number;
  4234. /**
  4235. * On key up
  4236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4237. */
  4238. static readonly ACTION_OnKeyUpTrigger: number;
  4239. /**
  4240. * Billboard mode will only apply to Y axis
  4241. */
  4242. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4243. /**
  4244. * Billboard mode will apply to all axes
  4245. */
  4246. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4247. /**
  4248. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4249. */
  4250. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4251. /**
  4252. * Gets or sets base Assets URL
  4253. */
  4254. static PARTICLES_BaseAssetsUrl: string;
  4255. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4256. * Test order :
  4257. * Is the bounding sphere outside the frustum ?
  4258. * If not, are the bounding box vertices outside the frustum ?
  4259. * It not, then the cullable object is in the frustum.
  4260. */
  4261. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4262. /** Culling strategy : Bounding Sphere Only.
  4263. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4264. * It's also less accurate than the standard because some not visible objects can still be selected.
  4265. * Test : is the bounding sphere outside the frustum ?
  4266. * If not, then the cullable object is in the frustum.
  4267. */
  4268. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4269. /** Culling strategy : Optimistic Inclusion.
  4270. * This in an inclusion test first, then the standard exclusion test.
  4271. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4272. * 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.
  4273. * Anyway, it's as accurate as the standard strategy.
  4274. * Test :
  4275. * Is the cullable object bounding sphere center in the frustum ?
  4276. * If not, apply the default culling strategy.
  4277. */
  4278. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4279. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4280. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4281. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4282. * 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.
  4283. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4284. * Test :
  4285. * Is the cullable object bounding sphere center in the frustum ?
  4286. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4287. */
  4288. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4289. /**
  4290. * No logging while loading
  4291. */
  4292. static readonly SCENELOADER_NO_LOGGING: number;
  4293. /**
  4294. * Minimal logging while loading
  4295. */
  4296. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4297. /**
  4298. * Summary logging while loading
  4299. */
  4300. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4301. /**
  4302. * Detailled logging while loading
  4303. */
  4304. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4305. }
  4306. }
  4307. declare module "babylonjs/Engines/IPipelineContext" {
  4308. /**
  4309. * Class used to store and describe the pipeline context associated with an effect
  4310. */
  4311. export interface IPipelineContext {
  4312. /**
  4313. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4314. */
  4315. isAsync: boolean;
  4316. /**
  4317. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4318. */
  4319. isReady: boolean;
  4320. /** @hidden */
  4321. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4322. }
  4323. }
  4324. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4325. /** @hidden */
  4326. export interface IShaderProcessor {
  4327. attributeProcessor?: (attribute: string) => string;
  4328. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4329. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4330. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4331. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4332. lineProcessor?: (line: string, isFragment: boolean) => string;
  4333. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4334. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4335. }
  4336. }
  4337. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4338. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4339. /** @hidden */
  4340. export interface ProcessingOptions {
  4341. defines: string[];
  4342. indexParameters: any;
  4343. isFragment: boolean;
  4344. shouldUseHighPrecisionShader: boolean;
  4345. supportsUniformBuffers: boolean;
  4346. shadersRepository: string;
  4347. includesShadersStore: {
  4348. [key: string]: string;
  4349. };
  4350. processor?: IShaderProcessor;
  4351. version: string;
  4352. platformName: string;
  4353. lookForClosingBracketForUniformBuffer?: boolean;
  4354. }
  4355. }
  4356. declare module "babylonjs/Misc/stringTools" {
  4357. /**
  4358. * Helper to manipulate strings
  4359. */
  4360. export class StringTools {
  4361. /**
  4362. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4363. * @param str Source string
  4364. * @param suffix Suffix to search for in the source string
  4365. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4366. */
  4367. static EndsWith(str: string, suffix: string): boolean;
  4368. /**
  4369. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4370. * @param str Source string
  4371. * @param suffix Suffix to search for in the source string
  4372. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4373. */
  4374. static StartsWith(str: string, suffix: string): boolean;
  4375. }
  4376. }
  4377. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4378. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4379. /** @hidden */
  4380. export class ShaderCodeNode {
  4381. line: string;
  4382. children: ShaderCodeNode[];
  4383. additionalDefineKey?: string;
  4384. additionalDefineValue?: string;
  4385. isValid(preprocessors: {
  4386. [key: string]: string;
  4387. }): boolean;
  4388. process(preprocessors: {
  4389. [key: string]: string;
  4390. }, options: ProcessingOptions): string;
  4391. }
  4392. }
  4393. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4394. /** @hidden */
  4395. export class ShaderCodeCursor {
  4396. private _lines;
  4397. lineIndex: number;
  4398. readonly currentLine: string;
  4399. readonly canRead: boolean;
  4400. lines: string[];
  4401. }
  4402. }
  4403. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4404. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4405. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4406. /** @hidden */
  4407. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4408. process(preprocessors: {
  4409. [key: string]: string;
  4410. }, options: ProcessingOptions): string;
  4411. }
  4412. }
  4413. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4414. /** @hidden */
  4415. export class ShaderDefineExpression {
  4416. isTrue(preprocessors: {
  4417. [key: string]: string;
  4418. }): boolean;
  4419. }
  4420. }
  4421. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4422. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4423. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4424. /** @hidden */
  4425. export class ShaderCodeTestNode extends ShaderCodeNode {
  4426. testExpression: ShaderDefineExpression;
  4427. isValid(preprocessors: {
  4428. [key: string]: string;
  4429. }): boolean;
  4430. }
  4431. }
  4432. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4433. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4434. /** @hidden */
  4435. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4436. define: string;
  4437. not: boolean;
  4438. constructor(define: string, not?: boolean);
  4439. isTrue(preprocessors: {
  4440. [key: string]: string;
  4441. }): boolean;
  4442. }
  4443. }
  4444. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4445. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4446. /** @hidden */
  4447. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4448. leftOperand: ShaderDefineExpression;
  4449. rightOperand: ShaderDefineExpression;
  4450. isTrue(preprocessors: {
  4451. [key: string]: string;
  4452. }): boolean;
  4453. }
  4454. }
  4455. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4456. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4457. /** @hidden */
  4458. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4459. leftOperand: ShaderDefineExpression;
  4460. rightOperand: ShaderDefineExpression;
  4461. isTrue(preprocessors: {
  4462. [key: string]: string;
  4463. }): boolean;
  4464. }
  4465. }
  4466. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4467. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4468. /** @hidden */
  4469. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4470. define: string;
  4471. operand: string;
  4472. testValue: string;
  4473. constructor(define: string, operand: string, testValue: string);
  4474. isTrue(preprocessors: {
  4475. [key: string]: string;
  4476. }): boolean;
  4477. }
  4478. }
  4479. declare module "babylonjs/Misc/loadFileError" {
  4480. import { WebRequest } from "babylonjs/Misc/webRequest";
  4481. /**
  4482. * @ignore
  4483. * Application error to support additional information when loading a file
  4484. */
  4485. export class LoadFileError extends Error {
  4486. /** defines the optional web request */
  4487. request?: WebRequest | undefined;
  4488. private static _setPrototypeOf;
  4489. /**
  4490. * Creates a new LoadFileError
  4491. * @param message defines the message of the error
  4492. * @param request defines the optional web request
  4493. */
  4494. constructor(message: string,
  4495. /** defines the optional web request */
  4496. request?: WebRequest | undefined);
  4497. }
  4498. }
  4499. declare module "babylonjs/Offline/IOfflineProvider" {
  4500. /**
  4501. * Class used to enable access to offline support
  4502. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4503. */
  4504. export interface IOfflineProvider {
  4505. /**
  4506. * Gets a boolean indicating if scene must be saved in the database
  4507. */
  4508. enableSceneOffline: boolean;
  4509. /**
  4510. * Gets a boolean indicating if textures must be saved in the database
  4511. */
  4512. enableTexturesOffline: boolean;
  4513. /**
  4514. * Open the offline support and make it available
  4515. * @param successCallback defines the callback to call on success
  4516. * @param errorCallback defines the callback to call on error
  4517. */
  4518. open(successCallback: () => void, errorCallback: () => void): void;
  4519. /**
  4520. * Loads an image from the offline support
  4521. * @param url defines the url to load from
  4522. * @param image defines the target DOM image
  4523. */
  4524. loadImage(url: string, image: HTMLImageElement): void;
  4525. /**
  4526. * Loads a file from offline support
  4527. * @param url defines the URL to load from
  4528. * @param sceneLoaded defines a callback to call on success
  4529. * @param progressCallBack defines a callback to call when progress changed
  4530. * @param errorCallback defines a callback to call on error
  4531. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4532. */
  4533. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4534. }
  4535. }
  4536. declare module "babylonjs/Misc/filesInputStore" {
  4537. /**
  4538. * Class used to help managing file picking and drag'n'drop
  4539. * File Storage
  4540. */
  4541. export class FilesInputStore {
  4542. /**
  4543. * List of files ready to be loaded
  4544. */
  4545. static FilesToLoad: {
  4546. [key: string]: File;
  4547. };
  4548. }
  4549. }
  4550. declare module "babylonjs/Misc/retryStrategy" {
  4551. import { WebRequest } from "babylonjs/Misc/webRequest";
  4552. /**
  4553. * Class used to define a retry strategy when error happens while loading assets
  4554. */
  4555. export class RetryStrategy {
  4556. /**
  4557. * Function used to defines an exponential back off strategy
  4558. * @param maxRetries defines the maximum number of retries (3 by default)
  4559. * @param baseInterval defines the interval between retries
  4560. * @returns the strategy function to use
  4561. */
  4562. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4563. }
  4564. }
  4565. declare module "babylonjs/Misc/fileTools" {
  4566. import { WebRequest } from "babylonjs/Misc/webRequest";
  4567. import { Nullable } from "babylonjs/types";
  4568. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4569. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4570. /**
  4571. * @hidden
  4572. */
  4573. export class FileTools {
  4574. /**
  4575. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4576. */
  4577. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4578. /**
  4579. * Gets or sets the base URL to use to load assets
  4580. */
  4581. static BaseUrl: string;
  4582. /**
  4583. * Default behaviour for cors in the application.
  4584. * It can be a string if the expected behavior is identical in the entire app.
  4585. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4586. */
  4587. static CorsBehavior: string | ((url: string | string[]) => string);
  4588. /**
  4589. * Gets or sets a function used to pre-process url before using them to load assets
  4590. */
  4591. static PreprocessUrl: (url: string) => string;
  4592. /**
  4593. * Removes unwanted characters from an url
  4594. * @param url defines the url to clean
  4595. * @returns the cleaned url
  4596. */
  4597. private static _CleanUrl;
  4598. /**
  4599. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4600. * @param url define the url we are trying
  4601. * @param element define the dom element where to configure the cors policy
  4602. */
  4603. static SetCorsBehavior(url: string | string[], element: {
  4604. crossOrigin: string | null;
  4605. }): void;
  4606. /**
  4607. * Loads an image as an HTMLImageElement.
  4608. * @param input url string, ArrayBuffer, or Blob to load
  4609. * @param onLoad callback called when the image successfully loads
  4610. * @param onError callback called when the image fails to load
  4611. * @param offlineProvider offline provider for caching
  4612. * @returns the HTMLImageElement of the loaded image
  4613. */
  4614. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4615. /**
  4616. * Loads a file
  4617. * @param fileToLoad defines the file to load
  4618. * @param callback defines the callback to call when data is loaded
  4619. * @param progressCallBack defines the callback to call during loading process
  4620. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4621. * @returns a file request object
  4622. */
  4623. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4624. /**
  4625. * Loads a file
  4626. * @param url url string, ArrayBuffer, or Blob to load
  4627. * @param onSuccess callback called when the file successfully loads
  4628. * @param onProgress callback called while file is loading (if the server supports this mode)
  4629. * @param offlineProvider defines the offline provider for caching
  4630. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4631. * @param onError callback called when the file fails to load
  4632. * @returns a file request object
  4633. */
  4634. 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;
  4635. /**
  4636. * Checks if the loaded document was accessed via `file:`-Protocol.
  4637. * @returns boolean
  4638. */
  4639. static IsFileURL(): boolean;
  4640. }
  4641. }
  4642. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4643. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4644. /** @hidden */
  4645. export class ShaderProcessor {
  4646. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4647. private static _ProcessPrecision;
  4648. private static _ExtractOperation;
  4649. private static _BuildSubExpression;
  4650. private static _BuildExpression;
  4651. private static _MoveCursorWithinIf;
  4652. private static _MoveCursor;
  4653. private static _EvaluatePreProcessors;
  4654. private static _PreparePreProcessors;
  4655. private static _ProcessShaderConversion;
  4656. private static _ProcessIncludes;
  4657. }
  4658. }
  4659. declare module "babylonjs/Maths/math.color" {
  4660. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4661. /**
  4662. * Class used to hold a RBG color
  4663. */
  4664. export class Color3 {
  4665. /**
  4666. * Defines the red component (between 0 and 1, default is 0)
  4667. */
  4668. r: number;
  4669. /**
  4670. * Defines the green component (between 0 and 1, default is 0)
  4671. */
  4672. g: number;
  4673. /**
  4674. * Defines the blue component (between 0 and 1, default is 0)
  4675. */
  4676. b: number;
  4677. /**
  4678. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4679. * @param r defines the red component (between 0 and 1, default is 0)
  4680. * @param g defines the green component (between 0 and 1, default is 0)
  4681. * @param b defines the blue component (between 0 and 1, default is 0)
  4682. */
  4683. constructor(
  4684. /**
  4685. * Defines the red component (between 0 and 1, default is 0)
  4686. */
  4687. r?: number,
  4688. /**
  4689. * Defines the green component (between 0 and 1, default is 0)
  4690. */
  4691. g?: number,
  4692. /**
  4693. * Defines the blue component (between 0 and 1, default is 0)
  4694. */
  4695. b?: number);
  4696. /**
  4697. * Creates a string with the Color3 current values
  4698. * @returns the string representation of the Color3 object
  4699. */
  4700. toString(): string;
  4701. /**
  4702. * Returns the string "Color3"
  4703. * @returns "Color3"
  4704. */
  4705. getClassName(): string;
  4706. /**
  4707. * Compute the Color3 hash code
  4708. * @returns an unique number that can be used to hash Color3 objects
  4709. */
  4710. getHashCode(): number;
  4711. /**
  4712. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4713. * @param array defines the array where to store the r,g,b components
  4714. * @param index defines an optional index in the target array to define where to start storing values
  4715. * @returns the current Color3 object
  4716. */
  4717. toArray(array: FloatArray, index?: number): Color3;
  4718. /**
  4719. * Returns a new Color4 object from the current Color3 and the given alpha
  4720. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4721. * @returns a new Color4 object
  4722. */
  4723. toColor4(alpha?: number): Color4;
  4724. /**
  4725. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4726. * @returns the new array
  4727. */
  4728. asArray(): number[];
  4729. /**
  4730. * Returns the luminance value
  4731. * @returns a float value
  4732. */
  4733. toLuminance(): number;
  4734. /**
  4735. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4736. * @param otherColor defines the second operand
  4737. * @returns the new Color3 object
  4738. */
  4739. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4740. /**
  4741. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4742. * @param otherColor defines the second operand
  4743. * @param result defines the Color3 object where to store the result
  4744. * @returns the current Color3
  4745. */
  4746. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4747. /**
  4748. * Determines equality between Color3 objects
  4749. * @param otherColor defines the second operand
  4750. * @returns true if the rgb values are equal to the given ones
  4751. */
  4752. equals(otherColor: DeepImmutable<Color3>): boolean;
  4753. /**
  4754. * Determines equality between the current Color3 object and a set of r,b,g values
  4755. * @param r defines the red component to check
  4756. * @param g defines the green component to check
  4757. * @param b defines the blue component to check
  4758. * @returns true if the rgb values are equal to the given ones
  4759. */
  4760. equalsFloats(r: number, g: number, b: number): boolean;
  4761. /**
  4762. * Multiplies in place each rgb value by scale
  4763. * @param scale defines the scaling factor
  4764. * @returns the updated Color3
  4765. */
  4766. scale(scale: number): Color3;
  4767. /**
  4768. * Multiplies the rgb values by scale and stores the result into "result"
  4769. * @param scale defines the scaling factor
  4770. * @param result defines the Color3 object where to store the result
  4771. * @returns the unmodified current Color3
  4772. */
  4773. scaleToRef(scale: number, result: Color3): Color3;
  4774. /**
  4775. * Scale the current Color3 values by a factor and add the result to a given Color3
  4776. * @param scale defines the scale factor
  4777. * @param result defines color to store the result into
  4778. * @returns the unmodified current Color3
  4779. */
  4780. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4781. /**
  4782. * Clamps the rgb values by the min and max values and stores the result into "result"
  4783. * @param min defines minimum clamping value (default is 0)
  4784. * @param max defines maximum clamping value (default is 1)
  4785. * @param result defines color to store the result into
  4786. * @returns the original Color3
  4787. */
  4788. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4789. /**
  4790. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4791. * @param otherColor defines the second operand
  4792. * @returns the new Color3
  4793. */
  4794. add(otherColor: DeepImmutable<Color3>): Color3;
  4795. /**
  4796. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4797. * @param otherColor defines the second operand
  4798. * @param result defines Color3 object to store the result into
  4799. * @returns the unmodified current Color3
  4800. */
  4801. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4802. /**
  4803. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4804. * @param otherColor defines the second operand
  4805. * @returns the new Color3
  4806. */
  4807. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4808. /**
  4809. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4810. * @param otherColor defines the second operand
  4811. * @param result defines Color3 object to store the result into
  4812. * @returns the unmodified current Color3
  4813. */
  4814. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4815. /**
  4816. * Copy the current object
  4817. * @returns a new Color3 copied the current one
  4818. */
  4819. clone(): Color3;
  4820. /**
  4821. * Copies the rgb values from the source in the current Color3
  4822. * @param source defines the source Color3 object
  4823. * @returns the updated Color3 object
  4824. */
  4825. copyFrom(source: DeepImmutable<Color3>): Color3;
  4826. /**
  4827. * Updates the Color3 rgb values from the given floats
  4828. * @param r defines the red component to read from
  4829. * @param g defines the green component to read from
  4830. * @param b defines the blue component to read from
  4831. * @returns the current Color3 object
  4832. */
  4833. copyFromFloats(r: number, g: number, b: number): Color3;
  4834. /**
  4835. * Updates the Color3 rgb values from the given floats
  4836. * @param r defines the red component to read from
  4837. * @param g defines the green component to read from
  4838. * @param b defines the blue component to read from
  4839. * @returns the current Color3 object
  4840. */
  4841. set(r: number, g: number, b: number): Color3;
  4842. /**
  4843. * Compute the Color3 hexadecimal code as a string
  4844. * @returns a string containing the hexadecimal representation of the Color3 object
  4845. */
  4846. toHexString(): string;
  4847. /**
  4848. * Computes a new Color3 converted from the current one to linear space
  4849. * @returns a new Color3 object
  4850. */
  4851. toLinearSpace(): Color3;
  4852. /**
  4853. * Converts current color in rgb space to HSV values
  4854. * @returns a new color3 representing the HSV values
  4855. */
  4856. toHSV(): Color3;
  4857. /**
  4858. * Converts current color in rgb space to HSV values
  4859. * @param result defines the Color3 where to store the HSV values
  4860. */
  4861. toHSVToRef(result: Color3): void;
  4862. /**
  4863. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  4864. * @param convertedColor defines the Color3 object where to store the linear space version
  4865. * @returns the unmodified Color3
  4866. */
  4867. toLinearSpaceToRef(convertedColor: Color3): Color3;
  4868. /**
  4869. * Computes a new Color3 converted from the current one to gamma space
  4870. * @returns a new Color3 object
  4871. */
  4872. toGammaSpace(): Color3;
  4873. /**
  4874. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  4875. * @param convertedColor defines the Color3 object where to store the gamma space version
  4876. * @returns the unmodified Color3
  4877. */
  4878. toGammaSpaceToRef(convertedColor: Color3): Color3;
  4879. private static _BlackReadOnly;
  4880. /**
  4881. * Convert Hue, saturation and value to a Color3 (RGB)
  4882. * @param hue defines the hue
  4883. * @param saturation defines the saturation
  4884. * @param value defines the value
  4885. * @param result defines the Color3 where to store the RGB values
  4886. */
  4887. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  4888. /**
  4889. * Creates a new Color3 from the string containing valid hexadecimal values
  4890. * @param hex defines a string containing valid hexadecimal values
  4891. * @returns a new Color3 object
  4892. */
  4893. static FromHexString(hex: string): Color3;
  4894. /**
  4895. * Creates a new Color3 from the starting index of the given array
  4896. * @param array defines the source array
  4897. * @param offset defines an offset in the source array
  4898. * @returns a new Color3 object
  4899. */
  4900. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  4901. /**
  4902. * Creates a new Color3 from integer values (< 256)
  4903. * @param r defines the red component to read from (value between 0 and 255)
  4904. * @param g defines the green component to read from (value between 0 and 255)
  4905. * @param b defines the blue component to read from (value between 0 and 255)
  4906. * @returns a new Color3 object
  4907. */
  4908. static FromInts(r: number, g: number, b: number): Color3;
  4909. /**
  4910. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  4911. * @param start defines the start Color3 value
  4912. * @param end defines the end Color3 value
  4913. * @param amount defines the gradient value between start and end
  4914. * @returns a new Color3 object
  4915. */
  4916. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  4917. /**
  4918. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  4919. * @param left defines the start value
  4920. * @param right defines the end value
  4921. * @param amount defines the gradient factor
  4922. * @param result defines the Color3 object where to store the result
  4923. */
  4924. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  4925. /**
  4926. * Returns a Color3 value containing a red color
  4927. * @returns a new Color3 object
  4928. */
  4929. static Red(): Color3;
  4930. /**
  4931. * Returns a Color3 value containing a green color
  4932. * @returns a new Color3 object
  4933. */
  4934. static Green(): Color3;
  4935. /**
  4936. * Returns a Color3 value containing a blue color
  4937. * @returns a new Color3 object
  4938. */
  4939. static Blue(): Color3;
  4940. /**
  4941. * Returns a Color3 value containing a black color
  4942. * @returns a new Color3 object
  4943. */
  4944. static Black(): Color3;
  4945. /**
  4946. * Gets a Color3 value containing a black color that must not be updated
  4947. */
  4948. static readonly BlackReadOnly: DeepImmutable<Color3>;
  4949. /**
  4950. * Returns a Color3 value containing a white color
  4951. * @returns a new Color3 object
  4952. */
  4953. static White(): Color3;
  4954. /**
  4955. * Returns a Color3 value containing a purple color
  4956. * @returns a new Color3 object
  4957. */
  4958. static Purple(): Color3;
  4959. /**
  4960. * Returns a Color3 value containing a magenta color
  4961. * @returns a new Color3 object
  4962. */
  4963. static Magenta(): Color3;
  4964. /**
  4965. * Returns a Color3 value containing a yellow color
  4966. * @returns a new Color3 object
  4967. */
  4968. static Yellow(): Color3;
  4969. /**
  4970. * Returns a Color3 value containing a gray color
  4971. * @returns a new Color3 object
  4972. */
  4973. static Gray(): Color3;
  4974. /**
  4975. * Returns a Color3 value containing a teal color
  4976. * @returns a new Color3 object
  4977. */
  4978. static Teal(): Color3;
  4979. /**
  4980. * Returns a Color3 value containing a random color
  4981. * @returns a new Color3 object
  4982. */
  4983. static Random(): Color3;
  4984. }
  4985. /**
  4986. * Class used to hold a RBGA color
  4987. */
  4988. export class Color4 {
  4989. /**
  4990. * Defines the red component (between 0 and 1, default is 0)
  4991. */
  4992. r: number;
  4993. /**
  4994. * Defines the green component (between 0 and 1, default is 0)
  4995. */
  4996. g: number;
  4997. /**
  4998. * Defines the blue component (between 0 and 1, default is 0)
  4999. */
  5000. b: number;
  5001. /**
  5002. * Defines the alpha component (between 0 and 1, default is 1)
  5003. */
  5004. a: number;
  5005. /**
  5006. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5007. * @param r defines the red component (between 0 and 1, default is 0)
  5008. * @param g defines the green component (between 0 and 1, default is 0)
  5009. * @param b defines the blue component (between 0 and 1, default is 0)
  5010. * @param a defines the alpha component (between 0 and 1, default is 1)
  5011. */
  5012. constructor(
  5013. /**
  5014. * Defines the red component (between 0 and 1, default is 0)
  5015. */
  5016. r?: number,
  5017. /**
  5018. * Defines the green component (between 0 and 1, default is 0)
  5019. */
  5020. g?: number,
  5021. /**
  5022. * Defines the blue component (between 0 and 1, default is 0)
  5023. */
  5024. b?: number,
  5025. /**
  5026. * Defines the alpha component (between 0 and 1, default is 1)
  5027. */
  5028. a?: number);
  5029. /**
  5030. * Adds in place the given Color4 values to the current Color4 object
  5031. * @param right defines the second operand
  5032. * @returns the current updated Color4 object
  5033. */
  5034. addInPlace(right: DeepImmutable<Color4>): Color4;
  5035. /**
  5036. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5037. * @returns the new array
  5038. */
  5039. asArray(): number[];
  5040. /**
  5041. * Stores from the starting index in the given array the Color4 successive values
  5042. * @param array defines the array where to store the r,g,b components
  5043. * @param index defines an optional index in the target array to define where to start storing values
  5044. * @returns the current Color4 object
  5045. */
  5046. toArray(array: number[], index?: number): Color4;
  5047. /**
  5048. * Determines equality between Color4 objects
  5049. * @param otherColor defines the second operand
  5050. * @returns true if the rgba values are equal to the given ones
  5051. */
  5052. equals(otherColor: DeepImmutable<Color4>): boolean;
  5053. /**
  5054. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5055. * @param right defines the second operand
  5056. * @returns a new Color4 object
  5057. */
  5058. add(right: DeepImmutable<Color4>): Color4;
  5059. /**
  5060. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5061. * @param right defines the second operand
  5062. * @returns a new Color4 object
  5063. */
  5064. subtract(right: DeepImmutable<Color4>): Color4;
  5065. /**
  5066. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5067. * @param right defines the second operand
  5068. * @param result defines the Color4 object where to store the result
  5069. * @returns the current Color4 object
  5070. */
  5071. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5072. /**
  5073. * Creates a new Color4 with the current Color4 values multiplied by scale
  5074. * @param scale defines the scaling factor to apply
  5075. * @returns a new Color4 object
  5076. */
  5077. scale(scale: number): Color4;
  5078. /**
  5079. * Multiplies the current Color4 values by scale and stores the result in "result"
  5080. * @param scale defines the scaling factor to apply
  5081. * @param result defines the Color4 object where to store the result
  5082. * @returns the current unmodified Color4
  5083. */
  5084. scaleToRef(scale: number, result: Color4): Color4;
  5085. /**
  5086. * Scale the current Color4 values by a factor and add the result to a given Color4
  5087. * @param scale defines the scale factor
  5088. * @param result defines the Color4 object where to store the result
  5089. * @returns the unmodified current Color4
  5090. */
  5091. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5092. /**
  5093. * Clamps the rgb values by the min and max values and stores the result into "result"
  5094. * @param min defines minimum clamping value (default is 0)
  5095. * @param max defines maximum clamping value (default is 1)
  5096. * @param result defines color to store the result into.
  5097. * @returns the cuurent Color4
  5098. */
  5099. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5100. /**
  5101. * Multipy an Color4 value by another and return a new Color4 object
  5102. * @param color defines the Color4 value to multiply by
  5103. * @returns a new Color4 object
  5104. */
  5105. multiply(color: Color4): Color4;
  5106. /**
  5107. * Multipy a Color4 value by another and push the result in a reference value
  5108. * @param color defines the Color4 value to multiply by
  5109. * @param result defines the Color4 to fill the result in
  5110. * @returns the result Color4
  5111. */
  5112. multiplyToRef(color: Color4, result: Color4): Color4;
  5113. /**
  5114. * Creates a string with the Color4 current values
  5115. * @returns the string representation of the Color4 object
  5116. */
  5117. toString(): string;
  5118. /**
  5119. * Returns the string "Color4"
  5120. * @returns "Color4"
  5121. */
  5122. getClassName(): string;
  5123. /**
  5124. * Compute the Color4 hash code
  5125. * @returns an unique number that can be used to hash Color4 objects
  5126. */
  5127. getHashCode(): number;
  5128. /**
  5129. * Creates a new Color4 copied from the current one
  5130. * @returns a new Color4 object
  5131. */
  5132. clone(): Color4;
  5133. /**
  5134. * Copies the given Color4 values into the current one
  5135. * @param source defines the source Color4 object
  5136. * @returns the current updated Color4 object
  5137. */
  5138. copyFrom(source: Color4): Color4;
  5139. /**
  5140. * Copies the given float values into the current one
  5141. * @param r defines the red component to read from
  5142. * @param g defines the green component to read from
  5143. * @param b defines the blue component to read from
  5144. * @param a defines the alpha component to read from
  5145. * @returns the current updated Color4 object
  5146. */
  5147. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5148. /**
  5149. * Copies the given float values into the current one
  5150. * @param r defines the red component to read from
  5151. * @param g defines the green component to read from
  5152. * @param b defines the blue component to read from
  5153. * @param a defines the alpha component to read from
  5154. * @returns the current updated Color4 object
  5155. */
  5156. set(r: number, g: number, b: number, a: number): Color4;
  5157. /**
  5158. * Compute the Color4 hexadecimal code as a string
  5159. * @returns a string containing the hexadecimal representation of the Color4 object
  5160. */
  5161. toHexString(): string;
  5162. /**
  5163. * Computes a new Color4 converted from the current one to linear space
  5164. * @returns a new Color4 object
  5165. */
  5166. toLinearSpace(): Color4;
  5167. /**
  5168. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5169. * @param convertedColor defines the Color4 object where to store the linear space version
  5170. * @returns the unmodified Color4
  5171. */
  5172. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5173. /**
  5174. * Computes a new Color4 converted from the current one to gamma space
  5175. * @returns a new Color4 object
  5176. */
  5177. toGammaSpace(): Color4;
  5178. /**
  5179. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5180. * @param convertedColor defines the Color4 object where to store the gamma space version
  5181. * @returns the unmodified Color4
  5182. */
  5183. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5184. /**
  5185. * Creates a new Color4 from the string containing valid hexadecimal values
  5186. * @param hex defines a string containing valid hexadecimal values
  5187. * @returns a new Color4 object
  5188. */
  5189. static FromHexString(hex: string): Color4;
  5190. /**
  5191. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5192. * @param left defines the start value
  5193. * @param right defines the end value
  5194. * @param amount defines the gradient factor
  5195. * @returns a new Color4 object
  5196. */
  5197. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5198. /**
  5199. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5200. * @param left defines the start value
  5201. * @param right defines the end value
  5202. * @param amount defines the gradient factor
  5203. * @param result defines the Color4 object where to store data
  5204. */
  5205. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5206. /**
  5207. * Creates a new Color4 from a Color3 and an alpha value
  5208. * @param color3 defines the source Color3 to read from
  5209. * @param alpha defines the alpha component (1.0 by default)
  5210. * @returns a new Color4 object
  5211. */
  5212. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5213. /**
  5214. * Creates a new Color4 from the starting index element of the given array
  5215. * @param array defines the source array to read from
  5216. * @param offset defines the offset in the source array
  5217. * @returns a new Color4 object
  5218. */
  5219. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5220. /**
  5221. * Creates a new Color3 from integer values (< 256)
  5222. * @param r defines the red component to read from (value between 0 and 255)
  5223. * @param g defines the green component to read from (value between 0 and 255)
  5224. * @param b defines the blue component to read from (value between 0 and 255)
  5225. * @param a defines the alpha component to read from (value between 0 and 255)
  5226. * @returns a new Color3 object
  5227. */
  5228. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5229. /**
  5230. * Check the content of a given array and convert it to an array containing RGBA data
  5231. * If the original array was already containing count * 4 values then it is returned directly
  5232. * @param colors defines the array to check
  5233. * @param count defines the number of RGBA data to expect
  5234. * @returns an array containing count * 4 values (RGBA)
  5235. */
  5236. static CheckColors4(colors: number[], count: number): number[];
  5237. }
  5238. /**
  5239. * @hidden
  5240. */
  5241. export class TmpColors {
  5242. static Color3: Color3[];
  5243. static Color4: Color4[];
  5244. }
  5245. }
  5246. declare module "babylonjs/Maths/sphericalPolynomial" {
  5247. import { Vector3 } from "babylonjs/Maths/math.vector";
  5248. import { Color3 } from "babylonjs/Maths/math.color";
  5249. /**
  5250. * Class representing spherical harmonics coefficients to the 3rd degree
  5251. */
  5252. export class SphericalHarmonics {
  5253. /**
  5254. * Defines whether or not the harmonics have been prescaled for rendering.
  5255. */
  5256. preScaled: boolean;
  5257. /**
  5258. * The l0,0 coefficients of the spherical harmonics
  5259. */
  5260. l00: Vector3;
  5261. /**
  5262. * The l1,-1 coefficients of the spherical harmonics
  5263. */
  5264. l1_1: Vector3;
  5265. /**
  5266. * The l1,0 coefficients of the spherical harmonics
  5267. */
  5268. l10: Vector3;
  5269. /**
  5270. * The l1,1 coefficients of the spherical harmonics
  5271. */
  5272. l11: Vector3;
  5273. /**
  5274. * The l2,-2 coefficients of the spherical harmonics
  5275. */
  5276. l2_2: Vector3;
  5277. /**
  5278. * The l2,-1 coefficients of the spherical harmonics
  5279. */
  5280. l2_1: Vector3;
  5281. /**
  5282. * The l2,0 coefficients of the spherical harmonics
  5283. */
  5284. l20: Vector3;
  5285. /**
  5286. * The l2,1 coefficients of the spherical harmonics
  5287. */
  5288. l21: Vector3;
  5289. /**
  5290. * The l2,2 coefficients of the spherical harmonics
  5291. */
  5292. l22: Vector3;
  5293. /**
  5294. * Adds a light to the spherical harmonics
  5295. * @param direction the direction of the light
  5296. * @param color the color of the light
  5297. * @param deltaSolidAngle the delta solid angle of the light
  5298. */
  5299. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5300. /**
  5301. * Scales the spherical harmonics by the given amount
  5302. * @param scale the amount to scale
  5303. */
  5304. scaleInPlace(scale: number): void;
  5305. /**
  5306. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5307. *
  5308. * ```
  5309. * E_lm = A_l * L_lm
  5310. * ```
  5311. *
  5312. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5313. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5314. * the scaling factors are given in equation 9.
  5315. */
  5316. convertIncidentRadianceToIrradiance(): void;
  5317. /**
  5318. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5319. *
  5320. * ```
  5321. * L = (1/pi) * E * rho
  5322. * ```
  5323. *
  5324. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5325. */
  5326. convertIrradianceToLambertianRadiance(): void;
  5327. /**
  5328. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5329. * required operations at run time.
  5330. *
  5331. * This is simply done by scaling back the SH with Ylm constants parameter.
  5332. * The trigonometric part being applied by the shader at run time.
  5333. */
  5334. preScaleForRendering(): void;
  5335. /**
  5336. * Constructs a spherical harmonics from an array.
  5337. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5338. * @returns the spherical harmonics
  5339. */
  5340. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5341. /**
  5342. * Gets the spherical harmonics from polynomial
  5343. * @param polynomial the spherical polynomial
  5344. * @returns the spherical harmonics
  5345. */
  5346. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5347. }
  5348. /**
  5349. * Class representing spherical polynomial coefficients to the 3rd degree
  5350. */
  5351. export class SphericalPolynomial {
  5352. private _harmonics;
  5353. /**
  5354. * The spherical harmonics used to create the polynomials.
  5355. */
  5356. readonly preScaledHarmonics: SphericalHarmonics;
  5357. /**
  5358. * The x coefficients of the spherical polynomial
  5359. */
  5360. x: Vector3;
  5361. /**
  5362. * The y coefficients of the spherical polynomial
  5363. */
  5364. y: Vector3;
  5365. /**
  5366. * The z coefficients of the spherical polynomial
  5367. */
  5368. z: Vector3;
  5369. /**
  5370. * The xx coefficients of the spherical polynomial
  5371. */
  5372. xx: Vector3;
  5373. /**
  5374. * The yy coefficients of the spherical polynomial
  5375. */
  5376. yy: Vector3;
  5377. /**
  5378. * The zz coefficients of the spherical polynomial
  5379. */
  5380. zz: Vector3;
  5381. /**
  5382. * The xy coefficients of the spherical polynomial
  5383. */
  5384. xy: Vector3;
  5385. /**
  5386. * The yz coefficients of the spherical polynomial
  5387. */
  5388. yz: Vector3;
  5389. /**
  5390. * The zx coefficients of the spherical polynomial
  5391. */
  5392. zx: Vector3;
  5393. /**
  5394. * Adds an ambient color to the spherical polynomial
  5395. * @param color the color to add
  5396. */
  5397. addAmbient(color: Color3): void;
  5398. /**
  5399. * Scales the spherical polynomial by the given amount
  5400. * @param scale the amount to scale
  5401. */
  5402. scaleInPlace(scale: number): void;
  5403. /**
  5404. * Gets the spherical polynomial from harmonics
  5405. * @param harmonics the spherical harmonics
  5406. * @returns the spherical polynomial
  5407. */
  5408. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5409. /**
  5410. * Constructs a spherical polynomial from an array.
  5411. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5412. * @returns the spherical polynomial
  5413. */
  5414. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5415. }
  5416. }
  5417. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5418. /**
  5419. * Define options used to create a render target texture
  5420. */
  5421. export class RenderTargetCreationOptions {
  5422. /**
  5423. * Specifies is mipmaps must be generated
  5424. */
  5425. generateMipMaps?: boolean;
  5426. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5427. generateDepthBuffer?: boolean;
  5428. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5429. generateStencilBuffer?: boolean;
  5430. /** Defines texture type (int by default) */
  5431. type?: number;
  5432. /** Defines sampling mode (trilinear by default) */
  5433. samplingMode?: number;
  5434. /** Defines format (RGBA by default) */
  5435. format?: number;
  5436. }
  5437. }
  5438. declare module "babylonjs/States/alphaCullingState" {
  5439. /**
  5440. * @hidden
  5441. **/
  5442. export class _AlphaState {
  5443. private _isAlphaBlendDirty;
  5444. private _isBlendFunctionParametersDirty;
  5445. private _isBlendEquationParametersDirty;
  5446. private _isBlendConstantsDirty;
  5447. private _alphaBlend;
  5448. private _blendFunctionParameters;
  5449. private _blendEquationParameters;
  5450. private _blendConstants;
  5451. /**
  5452. * Initializes the state.
  5453. */
  5454. constructor();
  5455. readonly isDirty: boolean;
  5456. alphaBlend: boolean;
  5457. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5458. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5459. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5460. reset(): void;
  5461. apply(gl: WebGLRenderingContext): void;
  5462. }
  5463. }
  5464. declare module "babylonjs/States/depthCullingState" {
  5465. import { Nullable } from "babylonjs/types";
  5466. /**
  5467. * @hidden
  5468. **/
  5469. export class _DepthCullingState {
  5470. private _isDepthTestDirty;
  5471. private _isDepthMaskDirty;
  5472. private _isDepthFuncDirty;
  5473. private _isCullFaceDirty;
  5474. private _isCullDirty;
  5475. private _isZOffsetDirty;
  5476. private _isFrontFaceDirty;
  5477. private _depthTest;
  5478. private _depthMask;
  5479. private _depthFunc;
  5480. private _cull;
  5481. private _cullFace;
  5482. private _zOffset;
  5483. private _frontFace;
  5484. /**
  5485. * Initializes the state.
  5486. */
  5487. constructor();
  5488. readonly isDirty: boolean;
  5489. zOffset: number;
  5490. cullFace: Nullable<number>;
  5491. cull: Nullable<boolean>;
  5492. depthFunc: Nullable<number>;
  5493. depthMask: boolean;
  5494. depthTest: boolean;
  5495. frontFace: Nullable<number>;
  5496. reset(): void;
  5497. apply(gl: WebGLRenderingContext): void;
  5498. }
  5499. }
  5500. declare module "babylonjs/States/stencilState" {
  5501. /**
  5502. * @hidden
  5503. **/
  5504. export class _StencilState {
  5505. /** 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 */
  5506. static readonly ALWAYS: number;
  5507. /** Passed to stencilOperation to specify that stencil value must be kept */
  5508. static readonly KEEP: number;
  5509. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5510. static readonly REPLACE: number;
  5511. private _isStencilTestDirty;
  5512. private _isStencilMaskDirty;
  5513. private _isStencilFuncDirty;
  5514. private _isStencilOpDirty;
  5515. private _stencilTest;
  5516. private _stencilMask;
  5517. private _stencilFunc;
  5518. private _stencilFuncRef;
  5519. private _stencilFuncMask;
  5520. private _stencilOpStencilFail;
  5521. private _stencilOpDepthFail;
  5522. private _stencilOpStencilDepthPass;
  5523. readonly isDirty: boolean;
  5524. stencilFunc: number;
  5525. stencilFuncRef: number;
  5526. stencilFuncMask: number;
  5527. stencilOpStencilFail: number;
  5528. stencilOpDepthFail: number;
  5529. stencilOpStencilDepthPass: number;
  5530. stencilMask: number;
  5531. stencilTest: boolean;
  5532. constructor();
  5533. reset(): void;
  5534. apply(gl: WebGLRenderingContext): void;
  5535. }
  5536. }
  5537. declare module "babylonjs/States/index" {
  5538. export * from "babylonjs/States/alphaCullingState";
  5539. export * from "babylonjs/States/depthCullingState";
  5540. export * from "babylonjs/States/stencilState";
  5541. }
  5542. declare module "babylonjs/Instrumentation/timeToken" {
  5543. import { Nullable } from "babylonjs/types";
  5544. /**
  5545. * @hidden
  5546. **/
  5547. export class _TimeToken {
  5548. _startTimeQuery: Nullable<WebGLQuery>;
  5549. _endTimeQuery: Nullable<WebGLQuery>;
  5550. _timeElapsedQuery: Nullable<WebGLQuery>;
  5551. _timeElapsedQueryEnded: boolean;
  5552. }
  5553. }
  5554. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5555. /**
  5556. * Class used to evalaute queries containing `and` and `or` operators
  5557. */
  5558. export class AndOrNotEvaluator {
  5559. /**
  5560. * Evaluate a query
  5561. * @param query defines the query to evaluate
  5562. * @param evaluateCallback defines the callback used to filter result
  5563. * @returns true if the query matches
  5564. */
  5565. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5566. private static _HandleParenthesisContent;
  5567. private static _SimplifyNegation;
  5568. }
  5569. }
  5570. declare module "babylonjs/Misc/tags" {
  5571. /**
  5572. * Class used to store custom tags
  5573. */
  5574. export class Tags {
  5575. /**
  5576. * Adds support for tags on the given object
  5577. * @param obj defines the object to use
  5578. */
  5579. static EnableFor(obj: any): void;
  5580. /**
  5581. * Removes tags support
  5582. * @param obj defines the object to use
  5583. */
  5584. static DisableFor(obj: any): void;
  5585. /**
  5586. * Gets a boolean indicating if the given object has tags
  5587. * @param obj defines the object to use
  5588. * @returns a boolean
  5589. */
  5590. static HasTags(obj: any): boolean;
  5591. /**
  5592. * Gets the tags available on a given object
  5593. * @param obj defines the object to use
  5594. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5595. * @returns the tags
  5596. */
  5597. static GetTags(obj: any, asString?: boolean): any;
  5598. /**
  5599. * Adds tags to an object
  5600. * @param obj defines the object to use
  5601. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5602. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5603. */
  5604. static AddTagsTo(obj: any, tagsString: string): void;
  5605. /**
  5606. * @hidden
  5607. */
  5608. static _AddTagTo(obj: any, tag: string): void;
  5609. /**
  5610. * Removes specific tags from a specific object
  5611. * @param obj defines the object to use
  5612. * @param tagsString defines the tags to remove
  5613. */
  5614. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5615. /**
  5616. * @hidden
  5617. */
  5618. static _RemoveTagFrom(obj: any, tag: string): void;
  5619. /**
  5620. * Defines if tags hosted on an object match a given query
  5621. * @param obj defines the object to use
  5622. * @param tagsQuery defines the tag query
  5623. * @returns a boolean
  5624. */
  5625. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5626. }
  5627. }
  5628. declare module "babylonjs/Maths/math.path" {
  5629. import { DeepImmutable, Nullable } from "babylonjs/types";
  5630. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5631. /**
  5632. * Defines potential orientation for back face culling
  5633. */
  5634. export enum Orientation {
  5635. /**
  5636. * Clockwise
  5637. */
  5638. CW = 0,
  5639. /** Counter clockwise */
  5640. CCW = 1
  5641. }
  5642. /** Class used to represent a Bezier curve */
  5643. export class BezierCurve {
  5644. /**
  5645. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5646. * @param t defines the time
  5647. * @param x1 defines the left coordinate on X axis
  5648. * @param y1 defines the left coordinate on Y axis
  5649. * @param x2 defines the right coordinate on X axis
  5650. * @param y2 defines the right coordinate on Y axis
  5651. * @returns the interpolated value
  5652. */
  5653. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5654. }
  5655. /**
  5656. * Defines angle representation
  5657. */
  5658. export class Angle {
  5659. private _radians;
  5660. /**
  5661. * Creates an Angle object of "radians" radians (float).
  5662. * @param radians the angle in radians
  5663. */
  5664. constructor(radians: number);
  5665. /**
  5666. * Get value in degrees
  5667. * @returns the Angle value in degrees (float)
  5668. */
  5669. degrees(): number;
  5670. /**
  5671. * Get value in radians
  5672. * @returns the Angle value in radians (float)
  5673. */
  5674. radians(): number;
  5675. /**
  5676. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5677. * @param a defines first vector
  5678. * @param b defines second vector
  5679. * @returns a new Angle
  5680. */
  5681. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5682. /**
  5683. * Gets a new Angle object from the given float in radians
  5684. * @param radians defines the angle value in radians
  5685. * @returns a new Angle
  5686. */
  5687. static FromRadians(radians: number): Angle;
  5688. /**
  5689. * Gets a new Angle object from the given float in degrees
  5690. * @param degrees defines the angle value in degrees
  5691. * @returns a new Angle
  5692. */
  5693. static FromDegrees(degrees: number): Angle;
  5694. }
  5695. /**
  5696. * This represents an arc in a 2d space.
  5697. */
  5698. export class Arc2 {
  5699. /** Defines the start point of the arc */
  5700. startPoint: Vector2;
  5701. /** Defines the mid point of the arc */
  5702. midPoint: Vector2;
  5703. /** Defines the end point of the arc */
  5704. endPoint: Vector2;
  5705. /**
  5706. * Defines the center point of the arc.
  5707. */
  5708. centerPoint: Vector2;
  5709. /**
  5710. * Defines the radius of the arc.
  5711. */
  5712. radius: number;
  5713. /**
  5714. * Defines the angle of the arc (from mid point to end point).
  5715. */
  5716. angle: Angle;
  5717. /**
  5718. * Defines the start angle of the arc (from start point to middle point).
  5719. */
  5720. startAngle: Angle;
  5721. /**
  5722. * Defines the orientation of the arc (clock wise/counter clock wise).
  5723. */
  5724. orientation: Orientation;
  5725. /**
  5726. * Creates an Arc object from the three given points : start, middle and end.
  5727. * @param startPoint Defines the start point of the arc
  5728. * @param midPoint Defines the midlle point of the arc
  5729. * @param endPoint Defines the end point of the arc
  5730. */
  5731. constructor(
  5732. /** Defines the start point of the arc */
  5733. startPoint: Vector2,
  5734. /** Defines the mid point of the arc */
  5735. midPoint: Vector2,
  5736. /** Defines the end point of the arc */
  5737. endPoint: Vector2);
  5738. }
  5739. /**
  5740. * Represents a 2D path made up of multiple 2D points
  5741. */
  5742. export class Path2 {
  5743. private _points;
  5744. private _length;
  5745. /**
  5746. * If the path start and end point are the same
  5747. */
  5748. closed: boolean;
  5749. /**
  5750. * Creates a Path2 object from the starting 2D coordinates x and y.
  5751. * @param x the starting points x value
  5752. * @param y the starting points y value
  5753. */
  5754. constructor(x: number, y: number);
  5755. /**
  5756. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5757. * @param x the added points x value
  5758. * @param y the added points y value
  5759. * @returns the updated Path2.
  5760. */
  5761. addLineTo(x: number, y: number): Path2;
  5762. /**
  5763. * 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.
  5764. * @param midX middle point x value
  5765. * @param midY middle point y value
  5766. * @param endX end point x value
  5767. * @param endY end point y value
  5768. * @param numberOfSegments (default: 36)
  5769. * @returns the updated Path2.
  5770. */
  5771. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5772. /**
  5773. * Closes the Path2.
  5774. * @returns the Path2.
  5775. */
  5776. close(): Path2;
  5777. /**
  5778. * Gets the sum of the distance between each sequential point in the path
  5779. * @returns the Path2 total length (float).
  5780. */
  5781. length(): number;
  5782. /**
  5783. * Gets the points which construct the path
  5784. * @returns the Path2 internal array of points.
  5785. */
  5786. getPoints(): Vector2[];
  5787. /**
  5788. * Retreives the point at the distance aways from the starting point
  5789. * @param normalizedLengthPosition the length along the path to retreive the point from
  5790. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5791. */
  5792. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5793. /**
  5794. * Creates a new path starting from an x and y position
  5795. * @param x starting x value
  5796. * @param y starting y value
  5797. * @returns a new Path2 starting at the coordinates (x, y).
  5798. */
  5799. static StartingAt(x: number, y: number): Path2;
  5800. }
  5801. /**
  5802. * Represents a 3D path made up of multiple 3D points
  5803. */
  5804. export class Path3D {
  5805. /**
  5806. * an array of Vector3, the curve axis of the Path3D
  5807. */
  5808. path: Vector3[];
  5809. private _curve;
  5810. private _distances;
  5811. private _tangents;
  5812. private _normals;
  5813. private _binormals;
  5814. private _raw;
  5815. /**
  5816. * new Path3D(path, normal, raw)
  5817. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5818. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5819. * @param path an array of Vector3, the curve axis of the Path3D
  5820. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5821. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5822. */
  5823. constructor(
  5824. /**
  5825. * an array of Vector3, the curve axis of the Path3D
  5826. */
  5827. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5828. /**
  5829. * Returns the Path3D array of successive Vector3 designing its curve.
  5830. * @returns the Path3D array of successive Vector3 designing its curve.
  5831. */
  5832. getCurve(): Vector3[];
  5833. /**
  5834. * Returns an array populated with tangent vectors on each Path3D curve point.
  5835. * @returns an array populated with tangent vectors on each Path3D curve point.
  5836. */
  5837. getTangents(): Vector3[];
  5838. /**
  5839. * Returns an array populated with normal vectors on each Path3D curve point.
  5840. * @returns an array populated with normal vectors on each Path3D curve point.
  5841. */
  5842. getNormals(): Vector3[];
  5843. /**
  5844. * Returns an array populated with binormal vectors on each Path3D curve point.
  5845. * @returns an array populated with binormal vectors on each Path3D curve point.
  5846. */
  5847. getBinormals(): Vector3[];
  5848. /**
  5849. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5850. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5851. */
  5852. getDistances(): number[];
  5853. /**
  5854. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5855. * @param path path which all values are copied into the curves points
  5856. * @param firstNormal which should be projected onto the curve
  5857. * @returns the same object updated.
  5858. */
  5859. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5860. private _compute;
  5861. private _getFirstNonNullVector;
  5862. private _getLastNonNullVector;
  5863. private _normalVector;
  5864. }
  5865. /**
  5866. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5867. * A Curve3 is designed from a series of successive Vector3.
  5868. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5869. */
  5870. export class Curve3 {
  5871. private _points;
  5872. private _length;
  5873. /**
  5874. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5875. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5876. * @param v1 (Vector3) the control point
  5877. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5878. * @param nbPoints (integer) the wanted number of points in the curve
  5879. * @returns the created Curve3
  5880. */
  5881. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5882. /**
  5883. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5884. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5885. * @param v1 (Vector3) the first control point
  5886. * @param v2 (Vector3) the second control point
  5887. * @param v3 (Vector3) the end point of the Cubic Bezier
  5888. * @param nbPoints (integer) the wanted number of points in the curve
  5889. * @returns the created Curve3
  5890. */
  5891. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5892. /**
  5893. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5894. * @param p1 (Vector3) the origin point of the Hermite Spline
  5895. * @param t1 (Vector3) the tangent vector at the origin point
  5896. * @param p2 (Vector3) the end point of the Hermite Spline
  5897. * @param t2 (Vector3) the tangent vector at the end point
  5898. * @param nbPoints (integer) the wanted number of points in the curve
  5899. * @returns the created Curve3
  5900. */
  5901. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5902. /**
  5903. * Returns a Curve3 object along a CatmullRom Spline curve :
  5904. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5905. * @param nbPoints (integer) the wanted number of points between each curve control points
  5906. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5907. * @returns the created Curve3
  5908. */
  5909. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5910. /**
  5911. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5912. * A Curve3 is designed from a series of successive Vector3.
  5913. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5914. * @param points points which make up the curve
  5915. */
  5916. constructor(points: Vector3[]);
  5917. /**
  5918. * @returns the Curve3 stored array of successive Vector3
  5919. */
  5920. getPoints(): Vector3[];
  5921. /**
  5922. * @returns the computed length (float) of the curve.
  5923. */
  5924. length(): number;
  5925. /**
  5926. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5927. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5928. * curveA and curveB keep unchanged.
  5929. * @param curve the curve to continue from this curve
  5930. * @returns the newly constructed curve
  5931. */
  5932. continue(curve: DeepImmutable<Curve3>): Curve3;
  5933. private _computeLength;
  5934. }
  5935. }
  5936. declare module "babylonjs/Animations/easing" {
  5937. /**
  5938. * This represents the main contract an easing function should follow.
  5939. * Easing functions are used throughout the animation system.
  5940. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5941. */
  5942. export interface IEasingFunction {
  5943. /**
  5944. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5945. * of the easing function.
  5946. * The link below provides some of the most common examples of easing functions.
  5947. * @see https://easings.net/
  5948. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5949. * @returns the corresponding value on the curve defined by the easing function
  5950. */
  5951. ease(gradient: number): number;
  5952. }
  5953. /**
  5954. * Base class used for every default easing function.
  5955. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5956. */
  5957. export class EasingFunction implements IEasingFunction {
  5958. /**
  5959. * Interpolation follows the mathematical formula associated with the easing function.
  5960. */
  5961. static readonly EASINGMODE_EASEIN: number;
  5962. /**
  5963. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5964. */
  5965. static readonly EASINGMODE_EASEOUT: number;
  5966. /**
  5967. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5968. */
  5969. static readonly EASINGMODE_EASEINOUT: number;
  5970. private _easingMode;
  5971. /**
  5972. * Sets the easing mode of the current function.
  5973. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5974. */
  5975. setEasingMode(easingMode: number): void;
  5976. /**
  5977. * Gets the current easing mode.
  5978. * @returns the easing mode
  5979. */
  5980. getEasingMode(): number;
  5981. /**
  5982. * @hidden
  5983. */
  5984. easeInCore(gradient: number): number;
  5985. /**
  5986. * Given an input gradient between 0 and 1, this returns the corresponding value
  5987. * of the easing function.
  5988. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5989. * @returns the corresponding value on the curve defined by the easing function
  5990. */
  5991. ease(gradient: number): number;
  5992. }
  5993. /**
  5994. * Easing function with a circle shape (see link below).
  5995. * @see https://easings.net/#easeInCirc
  5996. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5997. */
  5998. export class CircleEase extends EasingFunction implements IEasingFunction {
  5999. /** @hidden */
  6000. easeInCore(gradient: number): number;
  6001. }
  6002. /**
  6003. * Easing function with a ease back shape (see link below).
  6004. * @see https://easings.net/#easeInBack
  6005. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6006. */
  6007. export class BackEase extends EasingFunction implements IEasingFunction {
  6008. /** Defines the amplitude of the function */
  6009. amplitude: number;
  6010. /**
  6011. * Instantiates a back ease easing
  6012. * @see https://easings.net/#easeInBack
  6013. * @param amplitude Defines the amplitude of the function
  6014. */
  6015. constructor(
  6016. /** Defines the amplitude of the function */
  6017. amplitude?: number);
  6018. /** @hidden */
  6019. easeInCore(gradient: number): number;
  6020. }
  6021. /**
  6022. * Easing function with a bouncing shape (see link below).
  6023. * @see https://easings.net/#easeInBounce
  6024. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6025. */
  6026. export class BounceEase extends EasingFunction implements IEasingFunction {
  6027. /** Defines the number of bounces */
  6028. bounces: number;
  6029. /** Defines the amplitude of the bounce */
  6030. bounciness: number;
  6031. /**
  6032. * Instantiates a bounce easing
  6033. * @see https://easings.net/#easeInBounce
  6034. * @param bounces Defines the number of bounces
  6035. * @param bounciness Defines the amplitude of the bounce
  6036. */
  6037. constructor(
  6038. /** Defines the number of bounces */
  6039. bounces?: number,
  6040. /** Defines the amplitude of the bounce */
  6041. bounciness?: number);
  6042. /** @hidden */
  6043. easeInCore(gradient: number): number;
  6044. }
  6045. /**
  6046. * Easing function with a power of 3 shape (see link below).
  6047. * @see https://easings.net/#easeInCubic
  6048. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6049. */
  6050. export class CubicEase extends EasingFunction implements IEasingFunction {
  6051. /** @hidden */
  6052. easeInCore(gradient: number): number;
  6053. }
  6054. /**
  6055. * Easing function with an elastic shape (see link below).
  6056. * @see https://easings.net/#easeInElastic
  6057. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6058. */
  6059. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6060. /** Defines the number of oscillations*/
  6061. oscillations: number;
  6062. /** Defines the amplitude of the oscillations*/
  6063. springiness: number;
  6064. /**
  6065. * Instantiates an elastic easing function
  6066. * @see https://easings.net/#easeInElastic
  6067. * @param oscillations Defines the number of oscillations
  6068. * @param springiness Defines the amplitude of the oscillations
  6069. */
  6070. constructor(
  6071. /** Defines the number of oscillations*/
  6072. oscillations?: number,
  6073. /** Defines the amplitude of the oscillations*/
  6074. springiness?: number);
  6075. /** @hidden */
  6076. easeInCore(gradient: number): number;
  6077. }
  6078. /**
  6079. * Easing function with an exponential shape (see link below).
  6080. * @see https://easings.net/#easeInExpo
  6081. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6082. */
  6083. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6084. /** Defines the exponent of the function */
  6085. exponent: number;
  6086. /**
  6087. * Instantiates an exponential easing function
  6088. * @see https://easings.net/#easeInExpo
  6089. * @param exponent Defines the exponent of the function
  6090. */
  6091. constructor(
  6092. /** Defines the exponent of the function */
  6093. exponent?: number);
  6094. /** @hidden */
  6095. easeInCore(gradient: number): number;
  6096. }
  6097. /**
  6098. * Easing function with a power shape (see link below).
  6099. * @see https://easings.net/#easeInQuad
  6100. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6101. */
  6102. export class PowerEase extends EasingFunction implements IEasingFunction {
  6103. /** Defines the power of the function */
  6104. power: number;
  6105. /**
  6106. * Instantiates an power base easing function
  6107. * @see https://easings.net/#easeInQuad
  6108. * @param power Defines the power of the function
  6109. */
  6110. constructor(
  6111. /** Defines the power of the function */
  6112. power?: number);
  6113. /** @hidden */
  6114. easeInCore(gradient: number): number;
  6115. }
  6116. /**
  6117. * Easing function with a power of 2 shape (see link below).
  6118. * @see https://easings.net/#easeInQuad
  6119. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6120. */
  6121. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6122. /** @hidden */
  6123. easeInCore(gradient: number): number;
  6124. }
  6125. /**
  6126. * Easing function with a power of 4 shape (see link below).
  6127. * @see https://easings.net/#easeInQuart
  6128. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6129. */
  6130. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6131. /** @hidden */
  6132. easeInCore(gradient: number): number;
  6133. }
  6134. /**
  6135. * Easing function with a power of 5 shape (see link below).
  6136. * @see https://easings.net/#easeInQuint
  6137. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6138. */
  6139. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6140. /** @hidden */
  6141. easeInCore(gradient: number): number;
  6142. }
  6143. /**
  6144. * Easing function with a sin shape (see link below).
  6145. * @see https://easings.net/#easeInSine
  6146. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6147. */
  6148. export class SineEase extends EasingFunction implements IEasingFunction {
  6149. /** @hidden */
  6150. easeInCore(gradient: number): number;
  6151. }
  6152. /**
  6153. * Easing function with a bezier shape (see link below).
  6154. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6155. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6156. */
  6157. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6158. /** Defines the x component of the start tangent in the bezier curve */
  6159. x1: number;
  6160. /** Defines the y component of the start tangent in the bezier curve */
  6161. y1: number;
  6162. /** Defines the x component of the end tangent in the bezier curve */
  6163. x2: number;
  6164. /** Defines the y component of the end tangent in the bezier curve */
  6165. y2: number;
  6166. /**
  6167. * Instantiates a bezier function
  6168. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6169. * @param x1 Defines the x component of the start tangent in the bezier curve
  6170. * @param y1 Defines the y component of the start tangent in the bezier curve
  6171. * @param x2 Defines the x component of the end tangent in the bezier curve
  6172. * @param y2 Defines the y component of the end tangent in the bezier curve
  6173. */
  6174. constructor(
  6175. /** Defines the x component of the start tangent in the bezier curve */
  6176. x1?: number,
  6177. /** Defines the y component of the start tangent in the bezier curve */
  6178. y1?: number,
  6179. /** Defines the x component of the end tangent in the bezier curve */
  6180. x2?: number,
  6181. /** Defines the y component of the end tangent in the bezier curve */
  6182. y2?: number);
  6183. /** @hidden */
  6184. easeInCore(gradient: number): number;
  6185. }
  6186. }
  6187. declare module "babylonjs/Animations/animationKey" {
  6188. /**
  6189. * Defines an interface which represents an animation key frame
  6190. */
  6191. export interface IAnimationKey {
  6192. /**
  6193. * Frame of the key frame
  6194. */
  6195. frame: number;
  6196. /**
  6197. * Value at the specifies key frame
  6198. */
  6199. value: any;
  6200. /**
  6201. * The input tangent for the cubic hermite spline
  6202. */
  6203. inTangent?: any;
  6204. /**
  6205. * The output tangent for the cubic hermite spline
  6206. */
  6207. outTangent?: any;
  6208. /**
  6209. * The animation interpolation type
  6210. */
  6211. interpolation?: AnimationKeyInterpolation;
  6212. }
  6213. /**
  6214. * Enum for the animation key frame interpolation type
  6215. */
  6216. export enum AnimationKeyInterpolation {
  6217. /**
  6218. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6219. */
  6220. STEP = 1
  6221. }
  6222. }
  6223. declare module "babylonjs/Animations/animationRange" {
  6224. /**
  6225. * Represents the range of an animation
  6226. */
  6227. export class AnimationRange {
  6228. /**The name of the animation range**/
  6229. name: string;
  6230. /**The starting frame of the animation */
  6231. from: number;
  6232. /**The ending frame of the animation*/
  6233. to: number;
  6234. /**
  6235. * Initializes the range of an animation
  6236. * @param name The name of the animation range
  6237. * @param from The starting frame of the animation
  6238. * @param to The ending frame of the animation
  6239. */
  6240. constructor(
  6241. /**The name of the animation range**/
  6242. name: string,
  6243. /**The starting frame of the animation */
  6244. from: number,
  6245. /**The ending frame of the animation*/
  6246. to: number);
  6247. /**
  6248. * Makes a copy of the animation range
  6249. * @returns A copy of the animation range
  6250. */
  6251. clone(): AnimationRange;
  6252. }
  6253. }
  6254. declare module "babylonjs/Animations/animationEvent" {
  6255. /**
  6256. * Composed of a frame, and an action function
  6257. */
  6258. export class AnimationEvent {
  6259. /** The frame for which the event is triggered **/
  6260. frame: number;
  6261. /** The event to perform when triggered **/
  6262. action: (currentFrame: number) => void;
  6263. /** Specifies if the event should be triggered only once**/
  6264. onlyOnce?: boolean | undefined;
  6265. /**
  6266. * Specifies if the animation event is done
  6267. */
  6268. isDone: boolean;
  6269. /**
  6270. * Initializes the animation event
  6271. * @param frame The frame for which the event is triggered
  6272. * @param action The event to perform when triggered
  6273. * @param onlyOnce Specifies if the event should be triggered only once
  6274. */
  6275. constructor(
  6276. /** The frame for which the event is triggered **/
  6277. frame: number,
  6278. /** The event to perform when triggered **/
  6279. action: (currentFrame: number) => void,
  6280. /** Specifies if the event should be triggered only once**/
  6281. onlyOnce?: boolean | undefined);
  6282. /** @hidden */
  6283. _clone(): AnimationEvent;
  6284. }
  6285. }
  6286. declare module "babylonjs/Behaviors/behavior" {
  6287. import { Nullable } from "babylonjs/types";
  6288. /**
  6289. * Interface used to define a behavior
  6290. */
  6291. export interface Behavior<T> {
  6292. /** gets or sets behavior's name */
  6293. name: string;
  6294. /**
  6295. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6296. */
  6297. init(): void;
  6298. /**
  6299. * Called when the behavior is attached to a target
  6300. * @param target defines the target where the behavior is attached to
  6301. */
  6302. attach(target: T): void;
  6303. /**
  6304. * Called when the behavior is detached from its target
  6305. */
  6306. detach(): void;
  6307. }
  6308. /**
  6309. * Interface implemented by classes supporting behaviors
  6310. */
  6311. export interface IBehaviorAware<T> {
  6312. /**
  6313. * Attach a behavior
  6314. * @param behavior defines the behavior to attach
  6315. * @returns the current host
  6316. */
  6317. addBehavior(behavior: Behavior<T>): T;
  6318. /**
  6319. * Remove a behavior from the current object
  6320. * @param behavior defines the behavior to detach
  6321. * @returns the current host
  6322. */
  6323. removeBehavior(behavior: Behavior<T>): T;
  6324. /**
  6325. * Gets a behavior using its name to search
  6326. * @param name defines the name to search
  6327. * @returns the behavior or null if not found
  6328. */
  6329. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6330. }
  6331. }
  6332. declare module "babylonjs/Misc/smartArray" {
  6333. /**
  6334. * Defines an array and its length.
  6335. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6336. */
  6337. export interface ISmartArrayLike<T> {
  6338. /**
  6339. * The data of the array.
  6340. */
  6341. data: Array<T>;
  6342. /**
  6343. * The active length of the array.
  6344. */
  6345. length: number;
  6346. }
  6347. /**
  6348. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6349. */
  6350. export class SmartArray<T> implements ISmartArrayLike<T> {
  6351. /**
  6352. * The full set of data from the array.
  6353. */
  6354. data: Array<T>;
  6355. /**
  6356. * The active length of the array.
  6357. */
  6358. length: number;
  6359. protected _id: number;
  6360. /**
  6361. * Instantiates a Smart Array.
  6362. * @param capacity defines the default capacity of the array.
  6363. */
  6364. constructor(capacity: number);
  6365. /**
  6366. * Pushes a value at the end of the active data.
  6367. * @param value defines the object to push in the array.
  6368. */
  6369. push(value: T): void;
  6370. /**
  6371. * Iterates over the active data and apply the lambda to them.
  6372. * @param func defines the action to apply on each value.
  6373. */
  6374. forEach(func: (content: T) => void): void;
  6375. /**
  6376. * Sorts the full sets of data.
  6377. * @param compareFn defines the comparison function to apply.
  6378. */
  6379. sort(compareFn: (a: T, b: T) => number): void;
  6380. /**
  6381. * Resets the active data to an empty array.
  6382. */
  6383. reset(): void;
  6384. /**
  6385. * Releases all the data from the array as well as the array.
  6386. */
  6387. dispose(): void;
  6388. /**
  6389. * Concats the active data with a given array.
  6390. * @param array defines the data to concatenate with.
  6391. */
  6392. concat(array: any): void;
  6393. /**
  6394. * Returns the position of a value in the active data.
  6395. * @param value defines the value to find the index for
  6396. * @returns the index if found in the active data otherwise -1
  6397. */
  6398. indexOf(value: T): number;
  6399. /**
  6400. * Returns whether an element is part of the active data.
  6401. * @param value defines the value to look for
  6402. * @returns true if found in the active data otherwise false
  6403. */
  6404. contains(value: T): boolean;
  6405. private static _GlobalId;
  6406. }
  6407. /**
  6408. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6409. * The data in this array can only be present once
  6410. */
  6411. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6412. private _duplicateId;
  6413. /**
  6414. * Pushes a value at the end of the active data.
  6415. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6416. * @param value defines the object to push in the array.
  6417. */
  6418. push(value: T): void;
  6419. /**
  6420. * Pushes a value at the end of the active data.
  6421. * If the data is already present, it won t be added again
  6422. * @param value defines the object to push in the array.
  6423. * @returns true if added false if it was already present
  6424. */
  6425. pushNoDuplicate(value: T): boolean;
  6426. /**
  6427. * Resets the active data to an empty array.
  6428. */
  6429. reset(): void;
  6430. /**
  6431. * Concats the active data with a given array.
  6432. * This ensures no dupplicate will be present in the result.
  6433. * @param array defines the data to concatenate with.
  6434. */
  6435. concatWithNoDuplicate(array: any): void;
  6436. }
  6437. }
  6438. declare module "babylonjs/Cameras/cameraInputsManager" {
  6439. import { Nullable } from "babylonjs/types";
  6440. import { Camera } from "babylonjs/Cameras/camera";
  6441. /**
  6442. * @ignore
  6443. * This is a list of all the different input types that are available in the application.
  6444. * Fo instance: ArcRotateCameraGamepadInput...
  6445. */
  6446. export var CameraInputTypes: {};
  6447. /**
  6448. * This is the contract to implement in order to create a new input class.
  6449. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6450. */
  6451. export interface ICameraInput<TCamera extends Camera> {
  6452. /**
  6453. * Defines the camera the input is attached to.
  6454. */
  6455. camera: Nullable<TCamera>;
  6456. /**
  6457. * Gets the class name of the current intput.
  6458. * @returns the class name
  6459. */
  6460. getClassName(): string;
  6461. /**
  6462. * Get the friendly name associated with the input class.
  6463. * @returns the input friendly name
  6464. */
  6465. getSimpleName(): string;
  6466. /**
  6467. * Attach the input controls to a specific dom element to get the input from.
  6468. * @param element Defines the element the controls should be listened from
  6469. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6470. */
  6471. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6472. /**
  6473. * Detach the current controls from the specified dom element.
  6474. * @param element Defines the element to stop listening the inputs from
  6475. */
  6476. detachControl(element: Nullable<HTMLElement>): void;
  6477. /**
  6478. * Update the current camera state depending on the inputs that have been used this frame.
  6479. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6480. */
  6481. checkInputs?: () => void;
  6482. }
  6483. /**
  6484. * Represents a map of input types to input instance or input index to input instance.
  6485. */
  6486. export interface CameraInputsMap<TCamera extends Camera> {
  6487. /**
  6488. * Accessor to the input by input type.
  6489. */
  6490. [name: string]: ICameraInput<TCamera>;
  6491. /**
  6492. * Accessor to the input by input index.
  6493. */
  6494. [idx: number]: ICameraInput<TCamera>;
  6495. }
  6496. /**
  6497. * This represents the input manager used within a camera.
  6498. * It helps dealing with all the different kind of input attached to a camera.
  6499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6500. */
  6501. export class CameraInputsManager<TCamera extends Camera> {
  6502. /**
  6503. * Defines the list of inputs attahed to the camera.
  6504. */
  6505. attached: CameraInputsMap<TCamera>;
  6506. /**
  6507. * Defines the dom element the camera is collecting inputs from.
  6508. * This is null if the controls have not been attached.
  6509. */
  6510. attachedElement: Nullable<HTMLElement>;
  6511. /**
  6512. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6513. */
  6514. noPreventDefault: boolean;
  6515. /**
  6516. * Defined the camera the input manager belongs to.
  6517. */
  6518. camera: TCamera;
  6519. /**
  6520. * Update the current camera state depending on the inputs that have been used this frame.
  6521. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6522. */
  6523. checkInputs: () => void;
  6524. /**
  6525. * Instantiate a new Camera Input Manager.
  6526. * @param camera Defines the camera the input manager blongs to
  6527. */
  6528. constructor(camera: TCamera);
  6529. /**
  6530. * Add an input method to a camera
  6531. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6532. * @param input camera input method
  6533. */
  6534. add(input: ICameraInput<TCamera>): void;
  6535. /**
  6536. * Remove a specific input method from a camera
  6537. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6538. * @param inputToRemove camera input method
  6539. */
  6540. remove(inputToRemove: ICameraInput<TCamera>): void;
  6541. /**
  6542. * Remove a specific input type from a camera
  6543. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6544. * @param inputType the type of the input to remove
  6545. */
  6546. removeByType(inputType: string): void;
  6547. private _addCheckInputs;
  6548. /**
  6549. * Attach the input controls to the currently attached dom element to listen the events from.
  6550. * @param input Defines the input to attach
  6551. */
  6552. attachInput(input: ICameraInput<TCamera>): void;
  6553. /**
  6554. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6555. * @param element Defines the dom element to collect the events from
  6556. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6557. */
  6558. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6559. /**
  6560. * Detach the current manager inputs controls from a specific dom element.
  6561. * @param element Defines the dom element to collect the events from
  6562. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6563. */
  6564. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6565. /**
  6566. * Rebuild the dynamic inputCheck function from the current list of
  6567. * defined inputs in the manager.
  6568. */
  6569. rebuildInputCheck(): void;
  6570. /**
  6571. * Remove all attached input methods from a camera
  6572. */
  6573. clear(): void;
  6574. /**
  6575. * Serialize the current input manager attached to a camera.
  6576. * This ensures than once parsed,
  6577. * the input associated to the camera will be identical to the current ones
  6578. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6579. */
  6580. serialize(serializedCamera: any): void;
  6581. /**
  6582. * Parses an input manager serialized JSON to restore the previous list of inputs
  6583. * and states associated to a camera.
  6584. * @param parsedCamera Defines the JSON to parse
  6585. */
  6586. parse(parsedCamera: any): void;
  6587. }
  6588. }
  6589. declare module "babylonjs/Collisions/intersectionInfo" {
  6590. import { Nullable } from "babylonjs/types";
  6591. /**
  6592. * @hidden
  6593. */
  6594. export class IntersectionInfo {
  6595. bu: Nullable<number>;
  6596. bv: Nullable<number>;
  6597. distance: number;
  6598. faceId: number;
  6599. subMeshId: number;
  6600. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6601. }
  6602. }
  6603. declare module "babylonjs/Maths/math.plane" {
  6604. import { DeepImmutable } from "babylonjs/types";
  6605. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6606. /**
  6607. * Represens a plane by the equation ax + by + cz + d = 0
  6608. */
  6609. export class Plane {
  6610. private static _TmpMatrix;
  6611. /**
  6612. * Normal of the plane (a,b,c)
  6613. */
  6614. normal: Vector3;
  6615. /**
  6616. * d component of the plane
  6617. */
  6618. d: number;
  6619. /**
  6620. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6621. * @param a a component of the plane
  6622. * @param b b component of the plane
  6623. * @param c c component of the plane
  6624. * @param d d component of the plane
  6625. */
  6626. constructor(a: number, b: number, c: number, d: number);
  6627. /**
  6628. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6629. */
  6630. asArray(): number[];
  6631. /**
  6632. * @returns a new plane copied from the current Plane.
  6633. */
  6634. clone(): Plane;
  6635. /**
  6636. * @returns the string "Plane".
  6637. */
  6638. getClassName(): string;
  6639. /**
  6640. * @returns the Plane hash code.
  6641. */
  6642. getHashCode(): number;
  6643. /**
  6644. * Normalize the current Plane in place.
  6645. * @returns the updated Plane.
  6646. */
  6647. normalize(): Plane;
  6648. /**
  6649. * Applies a transformation the plane and returns the result
  6650. * @param transformation the transformation matrix to be applied to the plane
  6651. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6652. */
  6653. transform(transformation: DeepImmutable<Matrix>): Plane;
  6654. /**
  6655. * Calcualtte the dot product between the point and the plane normal
  6656. * @param point point to calculate the dot product with
  6657. * @returns the dot product (float) of the point coordinates and the plane normal.
  6658. */
  6659. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6660. /**
  6661. * Updates the current Plane from the plane defined by the three given points.
  6662. * @param point1 one of the points used to contruct the plane
  6663. * @param point2 one of the points used to contruct the plane
  6664. * @param point3 one of the points used to contruct the plane
  6665. * @returns the updated Plane.
  6666. */
  6667. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6668. /**
  6669. * Checks if the plane is facing a given direction
  6670. * @param direction the direction to check if the plane is facing
  6671. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6672. * @returns True is the vector "direction" is the same side than the plane normal.
  6673. */
  6674. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6675. /**
  6676. * Calculates the distance to a point
  6677. * @param point point to calculate distance to
  6678. * @returns the signed distance (float) from the given point to the Plane.
  6679. */
  6680. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6681. /**
  6682. * Creates a plane from an array
  6683. * @param array the array to create a plane from
  6684. * @returns a new Plane from the given array.
  6685. */
  6686. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6687. /**
  6688. * Creates a plane from three points
  6689. * @param point1 point used to create the plane
  6690. * @param point2 point used to create the plane
  6691. * @param point3 point used to create the plane
  6692. * @returns a new Plane defined by the three given points.
  6693. */
  6694. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6695. /**
  6696. * Creates a plane from an origin point and a normal
  6697. * @param origin origin of the plane to be constructed
  6698. * @param normal normal of the plane to be constructed
  6699. * @returns a new Plane the normal vector to this plane at the given origin point.
  6700. * Note : the vector "normal" is updated because normalized.
  6701. */
  6702. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6703. /**
  6704. * Calculates the distance from a plane and a point
  6705. * @param origin origin of the plane to be constructed
  6706. * @param normal normal of the plane to be constructed
  6707. * @param point point to calculate distance to
  6708. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6709. */
  6710. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6711. }
  6712. }
  6713. declare module "babylonjs/Culling/boundingSphere" {
  6714. import { DeepImmutable } from "babylonjs/types";
  6715. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6716. import { Plane } from "babylonjs/Maths/math.plane";
  6717. /**
  6718. * Class used to store bounding sphere information
  6719. */
  6720. export class BoundingSphere {
  6721. /**
  6722. * Gets the center of the bounding sphere in local space
  6723. */
  6724. readonly center: Vector3;
  6725. /**
  6726. * Radius of the bounding sphere in local space
  6727. */
  6728. radius: number;
  6729. /**
  6730. * Gets the center of the bounding sphere in world space
  6731. */
  6732. readonly centerWorld: Vector3;
  6733. /**
  6734. * Radius of the bounding sphere in world space
  6735. */
  6736. radiusWorld: number;
  6737. /**
  6738. * Gets the minimum vector in local space
  6739. */
  6740. readonly minimum: Vector3;
  6741. /**
  6742. * Gets the maximum vector in local space
  6743. */
  6744. readonly maximum: Vector3;
  6745. private _worldMatrix;
  6746. private static readonly TmpVector3;
  6747. /**
  6748. * Creates a new bounding sphere
  6749. * @param min defines the minimum vector (in local space)
  6750. * @param max defines the maximum vector (in local space)
  6751. * @param worldMatrix defines the new world matrix
  6752. */
  6753. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6754. /**
  6755. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6756. * @param min defines the new minimum vector (in local space)
  6757. * @param max defines the new maximum vector (in local space)
  6758. * @param worldMatrix defines the new world matrix
  6759. */
  6760. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6761. /**
  6762. * Scale the current bounding sphere by applying a scale factor
  6763. * @param factor defines the scale factor to apply
  6764. * @returns the current bounding box
  6765. */
  6766. scale(factor: number): BoundingSphere;
  6767. /**
  6768. * Gets the world matrix of the bounding box
  6769. * @returns a matrix
  6770. */
  6771. getWorldMatrix(): DeepImmutable<Matrix>;
  6772. /** @hidden */
  6773. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6774. /**
  6775. * Tests if the bounding sphere is intersecting the frustum planes
  6776. * @param frustumPlanes defines the frustum planes to test
  6777. * @returns true if there is an intersection
  6778. */
  6779. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6780. /**
  6781. * Tests if the bounding sphere center is in between the frustum planes.
  6782. * Used for optimistic fast inclusion.
  6783. * @param frustumPlanes defines the frustum planes to test
  6784. * @returns true if the sphere center is in between the frustum planes
  6785. */
  6786. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6787. /**
  6788. * Tests if a point is inside the bounding sphere
  6789. * @param point defines the point to test
  6790. * @returns true if the point is inside the bounding sphere
  6791. */
  6792. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6793. /**
  6794. * Checks if two sphere intersct
  6795. * @param sphere0 sphere 0
  6796. * @param sphere1 sphere 1
  6797. * @returns true if the speres intersect
  6798. */
  6799. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6800. }
  6801. }
  6802. declare module "babylonjs/Culling/boundingBox" {
  6803. import { DeepImmutable } from "babylonjs/types";
  6804. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6805. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6806. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6807. import { Plane } from "babylonjs/Maths/math.plane";
  6808. /**
  6809. * Class used to store bounding box information
  6810. */
  6811. export class BoundingBox implements ICullable {
  6812. /**
  6813. * Gets the 8 vectors representing the bounding box in local space
  6814. */
  6815. readonly vectors: Vector3[];
  6816. /**
  6817. * Gets the center of the bounding box in local space
  6818. */
  6819. readonly center: Vector3;
  6820. /**
  6821. * Gets the center of the bounding box in world space
  6822. */
  6823. readonly centerWorld: Vector3;
  6824. /**
  6825. * Gets the extend size in local space
  6826. */
  6827. readonly extendSize: Vector3;
  6828. /**
  6829. * Gets the extend size in world space
  6830. */
  6831. readonly extendSizeWorld: Vector3;
  6832. /**
  6833. * Gets the OBB (object bounding box) directions
  6834. */
  6835. readonly directions: Vector3[];
  6836. /**
  6837. * Gets the 8 vectors representing the bounding box in world space
  6838. */
  6839. readonly vectorsWorld: Vector3[];
  6840. /**
  6841. * Gets the minimum vector in world space
  6842. */
  6843. readonly minimumWorld: Vector3;
  6844. /**
  6845. * Gets the maximum vector in world space
  6846. */
  6847. readonly maximumWorld: Vector3;
  6848. /**
  6849. * Gets the minimum vector in local space
  6850. */
  6851. readonly minimum: Vector3;
  6852. /**
  6853. * Gets the maximum vector in local space
  6854. */
  6855. readonly maximum: Vector3;
  6856. private _worldMatrix;
  6857. private static readonly TmpVector3;
  6858. /**
  6859. * @hidden
  6860. */
  6861. _tag: number;
  6862. /**
  6863. * Creates a new bounding box
  6864. * @param min defines the minimum vector (in local space)
  6865. * @param max defines the maximum vector (in local space)
  6866. * @param worldMatrix defines the new world matrix
  6867. */
  6868. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6869. /**
  6870. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6871. * @param min defines the new minimum vector (in local space)
  6872. * @param max defines the new maximum vector (in local space)
  6873. * @param worldMatrix defines the new world matrix
  6874. */
  6875. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6876. /**
  6877. * Scale the current bounding box by applying a scale factor
  6878. * @param factor defines the scale factor to apply
  6879. * @returns the current bounding box
  6880. */
  6881. scale(factor: number): BoundingBox;
  6882. /**
  6883. * Gets the world matrix of the bounding box
  6884. * @returns a matrix
  6885. */
  6886. getWorldMatrix(): DeepImmutable<Matrix>;
  6887. /** @hidden */
  6888. _update(world: DeepImmutable<Matrix>): void;
  6889. /**
  6890. * Tests if the bounding box is intersecting the frustum planes
  6891. * @param frustumPlanes defines the frustum planes to test
  6892. * @returns true if there is an intersection
  6893. */
  6894. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6895. /**
  6896. * Tests if the bounding box is entirely inside the frustum planes
  6897. * @param frustumPlanes defines the frustum planes to test
  6898. * @returns true if there is an inclusion
  6899. */
  6900. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6901. /**
  6902. * Tests if a point is inside the bounding box
  6903. * @param point defines the point to test
  6904. * @returns true if the point is inside the bounding box
  6905. */
  6906. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6907. /**
  6908. * Tests if the bounding box intersects with a bounding sphere
  6909. * @param sphere defines the sphere to test
  6910. * @returns true if there is an intersection
  6911. */
  6912. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6913. /**
  6914. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6915. * @param min defines the min vector to use
  6916. * @param max defines the max vector to use
  6917. * @returns true if there is an intersection
  6918. */
  6919. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6920. /**
  6921. * Tests if two bounding boxes are intersections
  6922. * @param box0 defines the first box to test
  6923. * @param box1 defines the second box to test
  6924. * @returns true if there is an intersection
  6925. */
  6926. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6927. /**
  6928. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6929. * @param minPoint defines the minimum vector of the bounding box
  6930. * @param maxPoint defines the maximum vector of the bounding box
  6931. * @param sphereCenter defines the sphere center
  6932. * @param sphereRadius defines the sphere radius
  6933. * @returns true if there is an intersection
  6934. */
  6935. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6936. /**
  6937. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6938. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6939. * @param frustumPlanes defines the frustum planes to test
  6940. * @return true if there is an inclusion
  6941. */
  6942. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6943. /**
  6944. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6945. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6946. * @param frustumPlanes defines the frustum planes to test
  6947. * @return true if there is an intersection
  6948. */
  6949. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6950. }
  6951. }
  6952. declare module "babylonjs/Collisions/collider" {
  6953. import { Nullable, IndicesArray } from "babylonjs/types";
  6954. import { Vector3 } from "babylonjs/Maths/math.vector";
  6955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6956. import { Plane } from "babylonjs/Maths/math.plane";
  6957. /** @hidden */
  6958. export class Collider {
  6959. /** Define if a collision was found */
  6960. collisionFound: boolean;
  6961. /**
  6962. * Define last intersection point in local space
  6963. */
  6964. intersectionPoint: Vector3;
  6965. /**
  6966. * Define last collided mesh
  6967. */
  6968. collidedMesh: Nullable<AbstractMesh>;
  6969. private _collisionPoint;
  6970. private _planeIntersectionPoint;
  6971. private _tempVector;
  6972. private _tempVector2;
  6973. private _tempVector3;
  6974. private _tempVector4;
  6975. private _edge;
  6976. private _baseToVertex;
  6977. private _destinationPoint;
  6978. private _slidePlaneNormal;
  6979. private _displacementVector;
  6980. /** @hidden */
  6981. _radius: Vector3;
  6982. /** @hidden */
  6983. _retry: number;
  6984. private _velocity;
  6985. private _basePoint;
  6986. private _epsilon;
  6987. /** @hidden */
  6988. _velocityWorldLength: number;
  6989. /** @hidden */
  6990. _basePointWorld: Vector3;
  6991. private _velocityWorld;
  6992. private _normalizedVelocity;
  6993. /** @hidden */
  6994. _initialVelocity: Vector3;
  6995. /** @hidden */
  6996. _initialPosition: Vector3;
  6997. private _nearestDistance;
  6998. private _collisionMask;
  6999. collisionMask: number;
  7000. /**
  7001. * Gets the plane normal used to compute the sliding response (in local space)
  7002. */
  7003. readonly slidePlaneNormal: Vector3;
  7004. /** @hidden */
  7005. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7006. /** @hidden */
  7007. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7008. /** @hidden */
  7009. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7010. /** @hidden */
  7011. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7012. /** @hidden */
  7013. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7014. /** @hidden */
  7015. _getResponse(pos: Vector3, vel: Vector3): void;
  7016. }
  7017. }
  7018. declare module "babylonjs/Culling/boundingInfo" {
  7019. import { DeepImmutable } from "babylonjs/types";
  7020. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7021. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7022. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7023. import { Plane } from "babylonjs/Maths/math.plane";
  7024. import { Collider } from "babylonjs/Collisions/collider";
  7025. /**
  7026. * Interface for cullable objects
  7027. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7028. */
  7029. export interface ICullable {
  7030. /**
  7031. * Checks if the object or part of the object is in the frustum
  7032. * @param frustumPlanes Camera near/planes
  7033. * @returns true if the object is in frustum otherwise false
  7034. */
  7035. isInFrustum(frustumPlanes: Plane[]): boolean;
  7036. /**
  7037. * Checks if a cullable object (mesh...) is in the camera frustum
  7038. * Unlike isInFrustum this cheks the full bounding box
  7039. * @param frustumPlanes Camera near/planes
  7040. * @returns true if the object is in frustum otherwise false
  7041. */
  7042. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7043. }
  7044. /**
  7045. * Info for a bounding data of a mesh
  7046. */
  7047. export class BoundingInfo implements ICullable {
  7048. /**
  7049. * Bounding box for the mesh
  7050. */
  7051. readonly boundingBox: BoundingBox;
  7052. /**
  7053. * Bounding sphere for the mesh
  7054. */
  7055. readonly boundingSphere: BoundingSphere;
  7056. private _isLocked;
  7057. private static readonly TmpVector3;
  7058. /**
  7059. * Constructs bounding info
  7060. * @param minimum min vector of the bounding box/sphere
  7061. * @param maximum max vector of the bounding box/sphere
  7062. * @param worldMatrix defines the new world matrix
  7063. */
  7064. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7065. /**
  7066. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7067. * @param min defines the new minimum vector (in local space)
  7068. * @param max defines the new maximum vector (in local space)
  7069. * @param worldMatrix defines the new world matrix
  7070. */
  7071. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7072. /**
  7073. * min vector of the bounding box/sphere
  7074. */
  7075. readonly minimum: Vector3;
  7076. /**
  7077. * max vector of the bounding box/sphere
  7078. */
  7079. readonly maximum: Vector3;
  7080. /**
  7081. * If the info is locked and won't be updated to avoid perf overhead
  7082. */
  7083. isLocked: boolean;
  7084. /**
  7085. * Updates the bounding sphere and box
  7086. * @param world world matrix to be used to update
  7087. */
  7088. update(world: DeepImmutable<Matrix>): void;
  7089. /**
  7090. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7091. * @param center New center of the bounding info
  7092. * @param extend New extend of the bounding info
  7093. * @returns the current bounding info
  7094. */
  7095. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7096. /**
  7097. * Scale the current bounding info by applying a scale factor
  7098. * @param factor defines the scale factor to apply
  7099. * @returns the current bounding info
  7100. */
  7101. scale(factor: number): BoundingInfo;
  7102. /**
  7103. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7104. * @param frustumPlanes defines the frustum to test
  7105. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7106. * @returns true if the bounding info is in the frustum planes
  7107. */
  7108. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7109. /**
  7110. * Gets the world distance between the min and max points of the bounding box
  7111. */
  7112. readonly diagonalLength: number;
  7113. /**
  7114. * Checks if a cullable object (mesh...) is in the camera frustum
  7115. * Unlike isInFrustum this cheks the full bounding box
  7116. * @param frustumPlanes Camera near/planes
  7117. * @returns true if the object is in frustum otherwise false
  7118. */
  7119. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7120. /** @hidden */
  7121. _checkCollision(collider: Collider): boolean;
  7122. /**
  7123. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7124. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7125. * @param point the point to check intersection with
  7126. * @returns if the point intersects
  7127. */
  7128. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7129. /**
  7130. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7131. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7132. * @param boundingInfo the bounding info to check intersection with
  7133. * @param precise if the intersection should be done using OBB
  7134. * @returns if the bounding info intersects
  7135. */
  7136. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7137. }
  7138. }
  7139. declare module "babylonjs/Maths/math.functions" {
  7140. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7141. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7142. /**
  7143. * Extracts minimum and maximum values from a list of indexed positions
  7144. * @param positions defines the positions to use
  7145. * @param indices defines the indices to the positions
  7146. * @param indexStart defines the start index
  7147. * @param indexCount defines the end index
  7148. * @param bias defines bias value to add to the result
  7149. * @return minimum and maximum values
  7150. */
  7151. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7152. minimum: Vector3;
  7153. maximum: Vector3;
  7154. };
  7155. /**
  7156. * Extracts minimum and maximum values from a list of positions
  7157. * @param positions defines the positions to use
  7158. * @param start defines the start index in the positions array
  7159. * @param count defines the number of positions to handle
  7160. * @param bias defines bias value to add to the result
  7161. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7162. * @return minimum and maximum values
  7163. */
  7164. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7165. minimum: Vector3;
  7166. maximum: Vector3;
  7167. };
  7168. }
  7169. declare module "babylonjs/Misc/iInspectable" {
  7170. /**
  7171. * Enum that determines the text-wrapping mode to use.
  7172. */
  7173. export enum InspectableType {
  7174. /**
  7175. * Checkbox for booleans
  7176. */
  7177. Checkbox = 0,
  7178. /**
  7179. * Sliders for numbers
  7180. */
  7181. Slider = 1,
  7182. /**
  7183. * Vector3
  7184. */
  7185. Vector3 = 2,
  7186. /**
  7187. * Quaternions
  7188. */
  7189. Quaternion = 3,
  7190. /**
  7191. * Color3
  7192. */
  7193. Color3 = 4,
  7194. /**
  7195. * String
  7196. */
  7197. String = 5
  7198. }
  7199. /**
  7200. * Interface used to define custom inspectable properties.
  7201. * This interface is used by the inspector to display custom property grids
  7202. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7203. */
  7204. export interface IInspectable {
  7205. /**
  7206. * Gets the label to display
  7207. */
  7208. label: string;
  7209. /**
  7210. * Gets the name of the property to edit
  7211. */
  7212. propertyName: string;
  7213. /**
  7214. * Gets the type of the editor to use
  7215. */
  7216. type: InspectableType;
  7217. /**
  7218. * Gets the minimum value of the property when using in "slider" mode
  7219. */
  7220. min?: number;
  7221. /**
  7222. * Gets the maximum value of the property when using in "slider" mode
  7223. */
  7224. max?: number;
  7225. /**
  7226. * Gets the setp to use when using in "slider" mode
  7227. */
  7228. step?: number;
  7229. }
  7230. }
  7231. declare module "babylonjs/Misc/timingTools" {
  7232. /**
  7233. * Class used to provide helper for timing
  7234. */
  7235. export class TimingTools {
  7236. /**
  7237. * Polyfill for setImmediate
  7238. * @param action defines the action to execute after the current execution block
  7239. */
  7240. static SetImmediate(action: () => void): void;
  7241. }
  7242. }
  7243. declare module "babylonjs/Misc/instantiationTools" {
  7244. /**
  7245. * Class used to enable instatition of objects by class name
  7246. */
  7247. export class InstantiationTools {
  7248. /**
  7249. * Use this object to register external classes like custom textures or material
  7250. * to allow the laoders to instantiate them
  7251. */
  7252. static RegisteredExternalClasses: {
  7253. [key: string]: Object;
  7254. };
  7255. /**
  7256. * Tries to instantiate a new object from a given class name
  7257. * @param className defines the class name to instantiate
  7258. * @returns the new object or null if the system was not able to do the instantiation
  7259. */
  7260. static Instantiate(className: string): any;
  7261. }
  7262. }
  7263. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7264. import { Nullable } from "babylonjs/types";
  7265. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7266. /**
  7267. * This represents the required contract to create a new type of texture loader.
  7268. */
  7269. export interface IInternalTextureLoader {
  7270. /**
  7271. * Defines wether the loader supports cascade loading the different faces.
  7272. */
  7273. supportCascades: boolean;
  7274. /**
  7275. * This returns if the loader support the current file information.
  7276. * @param extension defines the file extension of the file being loaded
  7277. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7278. * @param fallback defines the fallback internal texture if any
  7279. * @param isBase64 defines whether the texture is encoded as a base64
  7280. * @param isBuffer defines whether the texture data are stored as a buffer
  7281. * @returns true if the loader can load the specified file
  7282. */
  7283. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7284. /**
  7285. * Transform the url before loading if required.
  7286. * @param rootUrl the url of the texture
  7287. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7288. * @returns the transformed texture
  7289. */
  7290. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7291. /**
  7292. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7293. * @param rootUrl the url of the texture
  7294. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7295. * @returns the fallback texture
  7296. */
  7297. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7298. /**
  7299. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7300. * @param data contains the texture data
  7301. * @param texture defines the BabylonJS internal texture
  7302. * @param createPolynomials will be true if polynomials have been requested
  7303. * @param onLoad defines the callback to trigger once the texture is ready
  7304. * @param onError defines the callback to trigger in case of error
  7305. */
  7306. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7307. /**
  7308. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7309. * @param data contains the texture data
  7310. * @param texture defines the BabylonJS internal texture
  7311. * @param callback defines the method to call once ready to upload
  7312. */
  7313. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7314. }
  7315. }
  7316. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7317. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7318. import { Nullable } from "babylonjs/types";
  7319. import { Scene } from "babylonjs/scene";
  7320. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7321. module "babylonjs/Engines/engine" {
  7322. interface Engine {
  7323. /**
  7324. * Creates a depth stencil cube texture.
  7325. * This is only available in WebGL 2.
  7326. * @param size The size of face edge in the cube texture.
  7327. * @param options The options defining the cube texture.
  7328. * @returns The cube texture
  7329. */
  7330. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7331. /**
  7332. * Creates a cube texture
  7333. * @param rootUrl defines the url where the files to load is located
  7334. * @param scene defines the current scene
  7335. * @param files defines the list of files to load (1 per face)
  7336. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7337. * @param onLoad defines an optional callback raised when the texture is loaded
  7338. * @param onError defines an optional callback raised if there is an issue to load the texture
  7339. * @param format defines the format of the data
  7340. * @param forcedExtension defines the extension to use to pick the right loader
  7341. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7342. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7343. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7344. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7345. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7346. * @returns the cube texture as an InternalTexture
  7347. */
  7348. 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;
  7349. /**
  7350. * Creates a cube texture
  7351. * @param rootUrl defines the url where the files to load is located
  7352. * @param scene defines the current scene
  7353. * @param files defines the list of files to load (1 per face)
  7354. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7355. * @param onLoad defines an optional callback raised when the texture is loaded
  7356. * @param onError defines an optional callback raised if there is an issue to load the texture
  7357. * @param format defines the format of the data
  7358. * @param forcedExtension defines the extension to use to pick the right loader
  7359. * @returns the cube texture as an InternalTexture
  7360. */
  7361. 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;
  7362. /**
  7363. * Creates a cube texture
  7364. * @param rootUrl defines the url where the files to load is located
  7365. * @param scene defines the current scene
  7366. * @param files defines the list of files to load (1 per face)
  7367. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7368. * @param onLoad defines an optional callback raised when the texture is loaded
  7369. * @param onError defines an optional callback raised if there is an issue to load the texture
  7370. * @param format defines the format of the data
  7371. * @param forcedExtension defines the extension to use to pick the right loader
  7372. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7373. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7374. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7375. * @returns the cube texture as an InternalTexture
  7376. */
  7377. 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;
  7378. /** @hidden */
  7379. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7380. /** @hidden */
  7381. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7382. /** @hidden */
  7383. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7384. /** @hidden */
  7385. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7386. }
  7387. }
  7388. }
  7389. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7390. import { Nullable } from "babylonjs/types";
  7391. import { Scene } from "babylonjs/scene";
  7392. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7393. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7394. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7395. /**
  7396. * Class for creating a cube texture
  7397. */
  7398. export class CubeTexture extends BaseTexture {
  7399. private _delayedOnLoad;
  7400. /**
  7401. * The url of the texture
  7402. */
  7403. url: string;
  7404. /**
  7405. * Gets or sets the center of the bounding box associated with the cube texture.
  7406. * It must define where the camera used to render the texture was set
  7407. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7408. */
  7409. boundingBoxPosition: Vector3;
  7410. private _boundingBoxSize;
  7411. /**
  7412. * Gets or sets the size of the bounding box associated with the cube texture
  7413. * When defined, the cubemap will switch to local mode
  7414. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7415. * @example https://www.babylonjs-playground.com/#RNASML
  7416. */
  7417. /**
  7418. * Returns the bounding box size
  7419. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7420. */
  7421. boundingBoxSize: Vector3;
  7422. protected _rotationY: number;
  7423. /**
  7424. * Sets texture matrix rotation angle around Y axis in radians.
  7425. */
  7426. /**
  7427. * Gets texture matrix rotation angle around Y axis radians.
  7428. */
  7429. rotationY: number;
  7430. /**
  7431. * Are mip maps generated for this texture or not.
  7432. */
  7433. readonly noMipmap: boolean;
  7434. private _noMipmap;
  7435. private _files;
  7436. private _extensions;
  7437. private _textureMatrix;
  7438. private _format;
  7439. private _createPolynomials;
  7440. /** @hidden */
  7441. _prefiltered: boolean;
  7442. /**
  7443. * Creates a cube texture from an array of image urls
  7444. * @param files defines an array of image urls
  7445. * @param scene defines the hosting scene
  7446. * @param noMipmap specifies if mip maps are not used
  7447. * @returns a cube texture
  7448. */
  7449. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7450. /**
  7451. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7452. * @param url defines the url of the prefiltered texture
  7453. * @param scene defines the scene the texture is attached to
  7454. * @param forcedExtension defines the extension of the file if different from the url
  7455. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7456. * @return the prefiltered texture
  7457. */
  7458. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7459. /**
  7460. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7461. * as prefiltered data.
  7462. * @param rootUrl defines the url of the texture or the root name of the six images
  7463. * @param scene defines the scene the texture is attached to
  7464. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7465. * @param noMipmap defines if mipmaps should be created or not
  7466. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7467. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7468. * @param onError defines a callback triggered in case of error during load
  7469. * @param format defines the internal format to use for the texture once loaded
  7470. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7471. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7472. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7473. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7474. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7475. * @return the cube texture
  7476. */
  7477. 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);
  7478. /**
  7479. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7480. */
  7481. readonly isPrefiltered: boolean;
  7482. /**
  7483. * Get the current class name of the texture useful for serialization or dynamic coding.
  7484. * @returns "CubeTexture"
  7485. */
  7486. getClassName(): string;
  7487. /**
  7488. * Update the url (and optional buffer) of this texture if url was null during construction.
  7489. * @param url the url of the texture
  7490. * @param forcedExtension defines the extension to use
  7491. * @param onLoad callback called when the texture is loaded (defaults to null)
  7492. */
  7493. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7494. /**
  7495. * Delays loading of the cube texture
  7496. * @param forcedExtension defines the extension to use
  7497. */
  7498. delayLoad(forcedExtension?: string): void;
  7499. /**
  7500. * Returns the reflection texture matrix
  7501. * @returns the reflection texture matrix
  7502. */
  7503. getReflectionTextureMatrix(): Matrix;
  7504. /**
  7505. * Sets the reflection texture matrix
  7506. * @param value Reflection texture matrix
  7507. */
  7508. setReflectionTextureMatrix(value: Matrix): void;
  7509. /**
  7510. * Parses text to create a cube texture
  7511. * @param parsedTexture define the serialized text to read from
  7512. * @param scene defines the hosting scene
  7513. * @param rootUrl defines the root url of the cube texture
  7514. * @returns a cube texture
  7515. */
  7516. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7517. /**
  7518. * Makes a clone, or deep copy, of the cube texture
  7519. * @returns a new cube texture
  7520. */
  7521. clone(): CubeTexture;
  7522. }
  7523. }
  7524. declare module "babylonjs/Materials/materialDefines" {
  7525. /**
  7526. * Manages the defines for the Material
  7527. */
  7528. export class MaterialDefines {
  7529. /** @hidden */
  7530. protected _keys: string[];
  7531. private _isDirty;
  7532. /** @hidden */
  7533. _renderId: number;
  7534. /** @hidden */
  7535. _areLightsDirty: boolean;
  7536. /** @hidden */
  7537. _areLightsDisposed: boolean;
  7538. /** @hidden */
  7539. _areAttributesDirty: boolean;
  7540. /** @hidden */
  7541. _areTexturesDirty: boolean;
  7542. /** @hidden */
  7543. _areFresnelDirty: boolean;
  7544. /** @hidden */
  7545. _areMiscDirty: boolean;
  7546. /** @hidden */
  7547. _areImageProcessingDirty: boolean;
  7548. /** @hidden */
  7549. _normals: boolean;
  7550. /** @hidden */
  7551. _uvs: boolean;
  7552. /** @hidden */
  7553. _needNormals: boolean;
  7554. /** @hidden */
  7555. _needUVs: boolean;
  7556. [id: string]: any;
  7557. /**
  7558. * Specifies if the material needs to be re-calculated
  7559. */
  7560. readonly isDirty: boolean;
  7561. /**
  7562. * Marks the material to indicate that it has been re-calculated
  7563. */
  7564. markAsProcessed(): void;
  7565. /**
  7566. * Marks the material to indicate that it needs to be re-calculated
  7567. */
  7568. markAsUnprocessed(): void;
  7569. /**
  7570. * Marks the material to indicate all of its defines need to be re-calculated
  7571. */
  7572. markAllAsDirty(): void;
  7573. /**
  7574. * Marks the material to indicate that image processing needs to be re-calculated
  7575. */
  7576. markAsImageProcessingDirty(): void;
  7577. /**
  7578. * Marks the material to indicate the lights need to be re-calculated
  7579. * @param disposed Defines whether the light is dirty due to dispose or not
  7580. */
  7581. markAsLightDirty(disposed?: boolean): void;
  7582. /**
  7583. * Marks the attribute state as changed
  7584. */
  7585. markAsAttributesDirty(): void;
  7586. /**
  7587. * Marks the texture state as changed
  7588. */
  7589. markAsTexturesDirty(): void;
  7590. /**
  7591. * Marks the fresnel state as changed
  7592. */
  7593. markAsFresnelDirty(): void;
  7594. /**
  7595. * Marks the misc state as changed
  7596. */
  7597. markAsMiscDirty(): void;
  7598. /**
  7599. * Rebuilds the material defines
  7600. */
  7601. rebuild(): void;
  7602. /**
  7603. * Specifies if two material defines are equal
  7604. * @param other - A material define instance to compare to
  7605. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7606. */
  7607. isEqual(other: MaterialDefines): boolean;
  7608. /**
  7609. * Clones this instance's defines to another instance
  7610. * @param other - material defines to clone values to
  7611. */
  7612. cloneTo(other: MaterialDefines): void;
  7613. /**
  7614. * Resets the material define values
  7615. */
  7616. reset(): void;
  7617. /**
  7618. * Converts the material define values to a string
  7619. * @returns - String of material define information
  7620. */
  7621. toString(): string;
  7622. }
  7623. }
  7624. declare module "babylonjs/Materials/colorCurves" {
  7625. import { Effect } from "babylonjs/Materials/effect";
  7626. /**
  7627. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7628. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7629. * 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;
  7630. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7631. */
  7632. export class ColorCurves {
  7633. private _dirty;
  7634. private _tempColor;
  7635. private _globalCurve;
  7636. private _highlightsCurve;
  7637. private _midtonesCurve;
  7638. private _shadowsCurve;
  7639. private _positiveCurve;
  7640. private _negativeCurve;
  7641. private _globalHue;
  7642. private _globalDensity;
  7643. private _globalSaturation;
  7644. private _globalExposure;
  7645. /**
  7646. * Gets the global Hue value.
  7647. * 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).
  7648. */
  7649. /**
  7650. * Sets the global Hue value.
  7651. * 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).
  7652. */
  7653. globalHue: number;
  7654. /**
  7655. * Gets the global Density value.
  7656. * 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.
  7657. * Values less than zero provide a filter of opposite hue.
  7658. */
  7659. /**
  7660. * Sets the global Density value.
  7661. * 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.
  7662. * Values less than zero provide a filter of opposite hue.
  7663. */
  7664. globalDensity: number;
  7665. /**
  7666. * Gets the global Saturation value.
  7667. * 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.
  7668. */
  7669. /**
  7670. * Sets the global Saturation value.
  7671. * 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.
  7672. */
  7673. globalSaturation: number;
  7674. /**
  7675. * Gets the global Exposure value.
  7676. * 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.
  7677. */
  7678. /**
  7679. * Sets the global Exposure value.
  7680. * 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.
  7681. */
  7682. globalExposure: number;
  7683. private _highlightsHue;
  7684. private _highlightsDensity;
  7685. private _highlightsSaturation;
  7686. private _highlightsExposure;
  7687. /**
  7688. * Gets the highlights Hue value.
  7689. * 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).
  7690. */
  7691. /**
  7692. * Sets the highlights Hue value.
  7693. * 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).
  7694. */
  7695. highlightsHue: number;
  7696. /**
  7697. * Gets the highlights Density value.
  7698. * 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.
  7699. * Values less than zero provide a filter of opposite hue.
  7700. */
  7701. /**
  7702. * Sets the highlights Density value.
  7703. * 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.
  7704. * Values less than zero provide a filter of opposite hue.
  7705. */
  7706. highlightsDensity: number;
  7707. /**
  7708. * Gets the highlights Saturation value.
  7709. * 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.
  7710. */
  7711. /**
  7712. * Sets the highlights Saturation value.
  7713. * 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.
  7714. */
  7715. highlightsSaturation: number;
  7716. /**
  7717. * Gets the highlights Exposure value.
  7718. * 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.
  7719. */
  7720. /**
  7721. * Sets the highlights Exposure value.
  7722. * 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.
  7723. */
  7724. highlightsExposure: number;
  7725. private _midtonesHue;
  7726. private _midtonesDensity;
  7727. private _midtonesSaturation;
  7728. private _midtonesExposure;
  7729. /**
  7730. * Gets the midtones Hue value.
  7731. * 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).
  7732. */
  7733. /**
  7734. * Sets the midtones Hue value.
  7735. * 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).
  7736. */
  7737. midtonesHue: number;
  7738. /**
  7739. * Gets the midtones Density value.
  7740. * 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.
  7741. * Values less than zero provide a filter of opposite hue.
  7742. */
  7743. /**
  7744. * Sets the midtones Density value.
  7745. * 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.
  7746. * Values less than zero provide a filter of opposite hue.
  7747. */
  7748. midtonesDensity: number;
  7749. /**
  7750. * Gets the midtones Saturation value.
  7751. * 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.
  7752. */
  7753. /**
  7754. * Sets the midtones Saturation value.
  7755. * 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.
  7756. */
  7757. midtonesSaturation: number;
  7758. /**
  7759. * Gets the midtones Exposure value.
  7760. * 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.
  7761. */
  7762. /**
  7763. * Sets the midtones Exposure value.
  7764. * 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.
  7765. */
  7766. midtonesExposure: number;
  7767. private _shadowsHue;
  7768. private _shadowsDensity;
  7769. private _shadowsSaturation;
  7770. private _shadowsExposure;
  7771. /**
  7772. * Gets the shadows Hue value.
  7773. * 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).
  7774. */
  7775. /**
  7776. * Sets the shadows Hue value.
  7777. * 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).
  7778. */
  7779. shadowsHue: number;
  7780. /**
  7781. * Gets the shadows Density value.
  7782. * 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.
  7783. * Values less than zero provide a filter of opposite hue.
  7784. */
  7785. /**
  7786. * Sets the shadows Density value.
  7787. * 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.
  7788. * Values less than zero provide a filter of opposite hue.
  7789. */
  7790. shadowsDensity: number;
  7791. /**
  7792. * Gets the shadows Saturation value.
  7793. * 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.
  7794. */
  7795. /**
  7796. * Sets the shadows Saturation value.
  7797. * 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.
  7798. */
  7799. shadowsSaturation: number;
  7800. /**
  7801. * Gets the shadows Exposure value.
  7802. * 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.
  7803. */
  7804. /**
  7805. * Sets the shadows Exposure value.
  7806. * 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.
  7807. */
  7808. shadowsExposure: number;
  7809. /**
  7810. * Returns the class name
  7811. * @returns The class name
  7812. */
  7813. getClassName(): string;
  7814. /**
  7815. * Binds the color curves to the shader.
  7816. * @param colorCurves The color curve to bind
  7817. * @param effect The effect to bind to
  7818. * @param positiveUniform The positive uniform shader parameter
  7819. * @param neutralUniform The neutral uniform shader parameter
  7820. * @param negativeUniform The negative uniform shader parameter
  7821. */
  7822. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7823. /**
  7824. * Prepare the list of uniforms associated with the ColorCurves effects.
  7825. * @param uniformsList The list of uniforms used in the effect
  7826. */
  7827. static PrepareUniforms(uniformsList: string[]): void;
  7828. /**
  7829. * Returns color grading data based on a hue, density, saturation and exposure value.
  7830. * @param filterHue The hue of the color filter.
  7831. * @param filterDensity The density of the color filter.
  7832. * @param saturation The saturation.
  7833. * @param exposure The exposure.
  7834. * @param result The result data container.
  7835. */
  7836. private getColorGradingDataToRef;
  7837. /**
  7838. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7839. * @param value The input slider value in range [-100,100].
  7840. * @returns Adjusted value.
  7841. */
  7842. private static applyColorGradingSliderNonlinear;
  7843. /**
  7844. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7845. * @param hue The hue (H) input.
  7846. * @param saturation The saturation (S) input.
  7847. * @param brightness The brightness (B) input.
  7848. * @result An RGBA color represented as Vector4.
  7849. */
  7850. private static fromHSBToRef;
  7851. /**
  7852. * Returns a value clamped between min and max
  7853. * @param value The value to clamp
  7854. * @param min The minimum of value
  7855. * @param max The maximum of value
  7856. * @returns The clamped value.
  7857. */
  7858. private static clamp;
  7859. /**
  7860. * Clones the current color curve instance.
  7861. * @return The cloned curves
  7862. */
  7863. clone(): ColorCurves;
  7864. /**
  7865. * Serializes the current color curve instance to a json representation.
  7866. * @return a JSON representation
  7867. */
  7868. serialize(): any;
  7869. /**
  7870. * Parses the color curve from a json representation.
  7871. * @param source the JSON source to parse
  7872. * @return The parsed curves
  7873. */
  7874. static Parse(source: any): ColorCurves;
  7875. }
  7876. }
  7877. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  7878. import { Observable } from "babylonjs/Misc/observable";
  7879. import { Nullable } from "babylonjs/types";
  7880. import { Color4 } from "babylonjs/Maths/math.color";
  7881. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  7882. import { Effect } from "babylonjs/Materials/effect";
  7883. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7884. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  7885. /**
  7886. * Interface to follow in your material defines to integrate easily the
  7887. * Image proccessing functions.
  7888. * @hidden
  7889. */
  7890. export interface IImageProcessingConfigurationDefines {
  7891. IMAGEPROCESSING: boolean;
  7892. VIGNETTE: boolean;
  7893. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7894. VIGNETTEBLENDMODEOPAQUE: boolean;
  7895. TONEMAPPING: boolean;
  7896. TONEMAPPING_ACES: boolean;
  7897. CONTRAST: boolean;
  7898. EXPOSURE: boolean;
  7899. COLORCURVES: boolean;
  7900. COLORGRADING: boolean;
  7901. COLORGRADING3D: boolean;
  7902. SAMPLER3DGREENDEPTH: boolean;
  7903. SAMPLER3DBGRMAP: boolean;
  7904. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7905. }
  7906. /**
  7907. * @hidden
  7908. */
  7909. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7910. IMAGEPROCESSING: boolean;
  7911. VIGNETTE: boolean;
  7912. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7913. VIGNETTEBLENDMODEOPAQUE: boolean;
  7914. TONEMAPPING: boolean;
  7915. TONEMAPPING_ACES: boolean;
  7916. CONTRAST: boolean;
  7917. COLORCURVES: boolean;
  7918. COLORGRADING: boolean;
  7919. COLORGRADING3D: boolean;
  7920. SAMPLER3DGREENDEPTH: boolean;
  7921. SAMPLER3DBGRMAP: boolean;
  7922. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7923. EXPOSURE: boolean;
  7924. constructor();
  7925. }
  7926. /**
  7927. * This groups together the common properties used for image processing either in direct forward pass
  7928. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7929. * or not.
  7930. */
  7931. export class ImageProcessingConfiguration {
  7932. /**
  7933. * Default tone mapping applied in BabylonJS.
  7934. */
  7935. static readonly TONEMAPPING_STANDARD: number;
  7936. /**
  7937. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  7938. * to other engines rendering to increase portability.
  7939. */
  7940. static readonly TONEMAPPING_ACES: number;
  7941. /**
  7942. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  7943. */
  7944. colorCurves: Nullable<ColorCurves>;
  7945. private _colorCurvesEnabled;
  7946. /**
  7947. * Gets wether the color curves effect is enabled.
  7948. */
  7949. /**
  7950. * Sets wether the color curves effect is enabled.
  7951. */
  7952. colorCurvesEnabled: boolean;
  7953. private _colorGradingTexture;
  7954. /**
  7955. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7956. */
  7957. /**
  7958. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7959. */
  7960. colorGradingTexture: Nullable<BaseTexture>;
  7961. private _colorGradingEnabled;
  7962. /**
  7963. * Gets wether the color grading effect is enabled.
  7964. */
  7965. /**
  7966. * Sets wether the color grading effect is enabled.
  7967. */
  7968. colorGradingEnabled: boolean;
  7969. private _colorGradingWithGreenDepth;
  7970. /**
  7971. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  7972. */
  7973. /**
  7974. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  7975. */
  7976. colorGradingWithGreenDepth: boolean;
  7977. private _colorGradingBGR;
  7978. /**
  7979. * Gets wether the color grading texture contains BGR values.
  7980. */
  7981. /**
  7982. * Sets wether the color grading texture contains BGR values.
  7983. */
  7984. colorGradingBGR: boolean;
  7985. /** @hidden */
  7986. _exposure: number;
  7987. /**
  7988. * Gets the Exposure used in the effect.
  7989. */
  7990. /**
  7991. * Sets the Exposure used in the effect.
  7992. */
  7993. exposure: number;
  7994. private _toneMappingEnabled;
  7995. /**
  7996. * Gets wether the tone mapping effect is enabled.
  7997. */
  7998. /**
  7999. * Sets wether the tone mapping effect is enabled.
  8000. */
  8001. toneMappingEnabled: boolean;
  8002. private _toneMappingType;
  8003. /**
  8004. * Gets the type of tone mapping effect.
  8005. */
  8006. /**
  8007. * Sets the type of tone mapping effect used in BabylonJS.
  8008. */
  8009. toneMappingType: number;
  8010. protected _contrast: number;
  8011. /**
  8012. * Gets the contrast used in the effect.
  8013. */
  8014. /**
  8015. * Sets the contrast used in the effect.
  8016. */
  8017. contrast: number;
  8018. /**
  8019. * Vignette stretch size.
  8020. */
  8021. vignetteStretch: number;
  8022. /**
  8023. * Vignette centre X Offset.
  8024. */
  8025. vignetteCentreX: number;
  8026. /**
  8027. * Vignette centre Y Offset.
  8028. */
  8029. vignetteCentreY: number;
  8030. /**
  8031. * Vignette weight or intensity of the vignette effect.
  8032. */
  8033. vignetteWeight: number;
  8034. /**
  8035. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8036. * if vignetteEnabled is set to true.
  8037. */
  8038. vignetteColor: Color4;
  8039. /**
  8040. * Camera field of view used by the Vignette effect.
  8041. */
  8042. vignetteCameraFov: number;
  8043. private _vignetteBlendMode;
  8044. /**
  8045. * Gets the vignette blend mode allowing different kind of effect.
  8046. */
  8047. /**
  8048. * Sets the vignette blend mode allowing different kind of effect.
  8049. */
  8050. vignetteBlendMode: number;
  8051. private _vignetteEnabled;
  8052. /**
  8053. * Gets wether the vignette effect is enabled.
  8054. */
  8055. /**
  8056. * Sets wether the vignette effect is enabled.
  8057. */
  8058. vignetteEnabled: boolean;
  8059. private _applyByPostProcess;
  8060. /**
  8061. * Gets wether the image processing is applied through a post process or not.
  8062. */
  8063. /**
  8064. * Sets wether the image processing is applied through a post process or not.
  8065. */
  8066. applyByPostProcess: boolean;
  8067. private _isEnabled;
  8068. /**
  8069. * Gets wether the image processing is enabled or not.
  8070. */
  8071. /**
  8072. * Sets wether the image processing is enabled or not.
  8073. */
  8074. isEnabled: boolean;
  8075. /**
  8076. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8077. */
  8078. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8079. /**
  8080. * Method called each time the image processing information changes requires to recompile the effect.
  8081. */
  8082. protected _updateParameters(): void;
  8083. /**
  8084. * Gets the current class name.
  8085. * @return "ImageProcessingConfiguration"
  8086. */
  8087. getClassName(): string;
  8088. /**
  8089. * Prepare the list of uniforms associated with the Image Processing effects.
  8090. * @param uniforms The list of uniforms used in the effect
  8091. * @param defines the list of defines currently in use
  8092. */
  8093. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8094. /**
  8095. * Prepare the list of samplers associated with the Image Processing effects.
  8096. * @param samplersList The list of uniforms used in the effect
  8097. * @param defines the list of defines currently in use
  8098. */
  8099. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8100. /**
  8101. * Prepare the list of defines associated to the shader.
  8102. * @param defines the list of defines to complete
  8103. * @param forPostProcess Define if we are currently in post process mode or not
  8104. */
  8105. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8106. /**
  8107. * Returns true if all the image processing information are ready.
  8108. * @returns True if ready, otherwise, false
  8109. */
  8110. isReady(): boolean;
  8111. /**
  8112. * Binds the image processing to the shader.
  8113. * @param effect The effect to bind to
  8114. * @param aspectRatio Define the current aspect ratio of the effect
  8115. */
  8116. bind(effect: Effect, aspectRatio?: number): void;
  8117. /**
  8118. * Clones the current image processing instance.
  8119. * @return The cloned image processing
  8120. */
  8121. clone(): ImageProcessingConfiguration;
  8122. /**
  8123. * Serializes the current image processing instance to a json representation.
  8124. * @return a JSON representation
  8125. */
  8126. serialize(): any;
  8127. /**
  8128. * Parses the image processing from a json representation.
  8129. * @param source the JSON source to parse
  8130. * @return The parsed image processing
  8131. */
  8132. static Parse(source: any): ImageProcessingConfiguration;
  8133. private static _VIGNETTEMODE_MULTIPLY;
  8134. private static _VIGNETTEMODE_OPAQUE;
  8135. /**
  8136. * Used to apply the vignette as a mix with the pixel color.
  8137. */
  8138. static readonly VIGNETTEMODE_MULTIPLY: number;
  8139. /**
  8140. * Used to apply the vignette as a replacement of the pixel color.
  8141. */
  8142. static readonly VIGNETTEMODE_OPAQUE: number;
  8143. }
  8144. }
  8145. declare module "babylonjs/Shaders/postprocess.vertex" {
  8146. /** @hidden */
  8147. export var postprocessVertexShader: {
  8148. name: string;
  8149. shader: string;
  8150. };
  8151. }
  8152. declare module "babylonjs/Maths/math.axis" {
  8153. import { Vector3 } from "babylonjs/Maths/math.vector";
  8154. /** Defines supported spaces */
  8155. export enum Space {
  8156. /** Local (object) space */
  8157. LOCAL = 0,
  8158. /** World space */
  8159. WORLD = 1,
  8160. /** Bone space */
  8161. BONE = 2
  8162. }
  8163. /** Defines the 3 main axes */
  8164. export class Axis {
  8165. /** X axis */
  8166. static X: Vector3;
  8167. /** Y axis */
  8168. static Y: Vector3;
  8169. /** Z axis */
  8170. static Z: Vector3;
  8171. }
  8172. }
  8173. declare module "babylonjs/Cameras/targetCamera" {
  8174. import { Nullable } from "babylonjs/types";
  8175. import { Camera } from "babylonjs/Cameras/camera";
  8176. import { Scene } from "babylonjs/scene";
  8177. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8178. /**
  8179. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8180. * This is the base of the follow, arc rotate cameras and Free camera
  8181. * @see http://doc.babylonjs.com/features/cameras
  8182. */
  8183. export class TargetCamera extends Camera {
  8184. private static _RigCamTransformMatrix;
  8185. private static _TargetTransformMatrix;
  8186. private static _TargetFocalPoint;
  8187. /**
  8188. * Define the current direction the camera is moving to
  8189. */
  8190. cameraDirection: Vector3;
  8191. /**
  8192. * Define the current rotation the camera is rotating to
  8193. */
  8194. cameraRotation: Vector2;
  8195. /**
  8196. * When set, the up vector of the camera will be updated by the rotation of the camera
  8197. */
  8198. updateUpVectorFromRotation: boolean;
  8199. private _tmpQuaternion;
  8200. /**
  8201. * Define the current rotation of the camera
  8202. */
  8203. rotation: Vector3;
  8204. /**
  8205. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8206. */
  8207. rotationQuaternion: Quaternion;
  8208. /**
  8209. * Define the current speed of the camera
  8210. */
  8211. speed: number;
  8212. /**
  8213. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8214. * around all axis.
  8215. */
  8216. noRotationConstraint: boolean;
  8217. /**
  8218. * Define the current target of the camera as an object or a position.
  8219. */
  8220. lockedTarget: any;
  8221. /** @hidden */
  8222. _currentTarget: Vector3;
  8223. /** @hidden */
  8224. _initialFocalDistance: number;
  8225. /** @hidden */
  8226. _viewMatrix: Matrix;
  8227. /** @hidden */
  8228. _camMatrix: Matrix;
  8229. /** @hidden */
  8230. _cameraTransformMatrix: Matrix;
  8231. /** @hidden */
  8232. _cameraRotationMatrix: Matrix;
  8233. /** @hidden */
  8234. _referencePoint: Vector3;
  8235. /** @hidden */
  8236. _transformedReferencePoint: Vector3;
  8237. protected _globalCurrentTarget: Vector3;
  8238. protected _globalCurrentUpVector: Vector3;
  8239. /** @hidden */
  8240. _reset: () => void;
  8241. private _defaultUp;
  8242. /**
  8243. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8244. * This is the base of the follow, arc rotate cameras and Free camera
  8245. * @see http://doc.babylonjs.com/features/cameras
  8246. * @param name Defines the name of the camera in the scene
  8247. * @param position Defines the start position of the camera in the scene
  8248. * @param scene Defines the scene the camera belongs to
  8249. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8250. */
  8251. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8252. /**
  8253. * Gets the position in front of the camera at a given distance.
  8254. * @param distance The distance from the camera we want the position to be
  8255. * @returns the position
  8256. */
  8257. getFrontPosition(distance: number): Vector3;
  8258. /** @hidden */
  8259. _getLockedTargetPosition(): Nullable<Vector3>;
  8260. private _storedPosition;
  8261. private _storedRotation;
  8262. private _storedRotationQuaternion;
  8263. /**
  8264. * Store current camera state of the camera (fov, position, rotation, etc..)
  8265. * @returns the camera
  8266. */
  8267. storeState(): Camera;
  8268. /**
  8269. * Restored camera state. You must call storeState() first
  8270. * @returns whether it was successful or not
  8271. * @hidden
  8272. */
  8273. _restoreStateValues(): boolean;
  8274. /** @hidden */
  8275. _initCache(): void;
  8276. /** @hidden */
  8277. _updateCache(ignoreParentClass?: boolean): void;
  8278. /** @hidden */
  8279. _isSynchronizedViewMatrix(): boolean;
  8280. /** @hidden */
  8281. _computeLocalCameraSpeed(): number;
  8282. /**
  8283. * Defines the target the camera should look at.
  8284. * @param target Defines the new target as a Vector or a mesh
  8285. */
  8286. setTarget(target: Vector3): void;
  8287. /**
  8288. * Return the current target position of the camera. This value is expressed in local space.
  8289. * @returns the target position
  8290. */
  8291. getTarget(): Vector3;
  8292. /** @hidden */
  8293. _decideIfNeedsToMove(): boolean;
  8294. /** @hidden */
  8295. _updatePosition(): void;
  8296. /** @hidden */
  8297. _checkInputs(): void;
  8298. protected _updateCameraRotationMatrix(): void;
  8299. /**
  8300. * 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)
  8301. * @returns the current camera
  8302. */
  8303. private _rotateUpVectorWithCameraRotationMatrix;
  8304. private _cachedRotationZ;
  8305. private _cachedQuaternionRotationZ;
  8306. /** @hidden */
  8307. _getViewMatrix(): Matrix;
  8308. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8309. /**
  8310. * @hidden
  8311. */
  8312. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8313. /**
  8314. * @hidden
  8315. */
  8316. _updateRigCameras(): void;
  8317. private _getRigCamPositionAndTarget;
  8318. /**
  8319. * Gets the current object class name.
  8320. * @return the class name
  8321. */
  8322. getClassName(): string;
  8323. }
  8324. }
  8325. declare module "babylonjs/Events/keyboardEvents" {
  8326. /**
  8327. * Gather the list of keyboard event types as constants.
  8328. */
  8329. export class KeyboardEventTypes {
  8330. /**
  8331. * The keydown event is fired when a key becomes active (pressed).
  8332. */
  8333. static readonly KEYDOWN: number;
  8334. /**
  8335. * The keyup event is fired when a key has been released.
  8336. */
  8337. static readonly KEYUP: number;
  8338. }
  8339. /**
  8340. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8341. */
  8342. export class KeyboardInfo {
  8343. /**
  8344. * Defines the type of event (KeyboardEventTypes)
  8345. */
  8346. type: number;
  8347. /**
  8348. * Defines the related dom event
  8349. */
  8350. event: KeyboardEvent;
  8351. /**
  8352. * Instantiates a new keyboard info.
  8353. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8354. * @param type Defines the type of event (KeyboardEventTypes)
  8355. * @param event Defines the related dom event
  8356. */
  8357. constructor(
  8358. /**
  8359. * Defines the type of event (KeyboardEventTypes)
  8360. */
  8361. type: number,
  8362. /**
  8363. * Defines the related dom event
  8364. */
  8365. event: KeyboardEvent);
  8366. }
  8367. /**
  8368. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8369. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8370. */
  8371. export class KeyboardInfoPre extends KeyboardInfo {
  8372. /**
  8373. * Defines the type of event (KeyboardEventTypes)
  8374. */
  8375. type: number;
  8376. /**
  8377. * Defines the related dom event
  8378. */
  8379. event: KeyboardEvent;
  8380. /**
  8381. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8382. */
  8383. skipOnPointerObservable: boolean;
  8384. /**
  8385. * Instantiates a new keyboard pre info.
  8386. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8387. * @param type Defines the type of event (KeyboardEventTypes)
  8388. * @param event Defines the related dom event
  8389. */
  8390. constructor(
  8391. /**
  8392. * Defines the type of event (KeyboardEventTypes)
  8393. */
  8394. type: number,
  8395. /**
  8396. * Defines the related dom event
  8397. */
  8398. event: KeyboardEvent);
  8399. }
  8400. }
  8401. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8402. import { Nullable } from "babylonjs/types";
  8403. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8404. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8405. /**
  8406. * Manage the keyboard inputs to control the movement of a free camera.
  8407. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8408. */
  8409. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8410. /**
  8411. * Defines the camera the input is attached to.
  8412. */
  8413. camera: FreeCamera;
  8414. /**
  8415. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8416. */
  8417. keysUp: number[];
  8418. /**
  8419. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8420. */
  8421. keysDown: number[];
  8422. /**
  8423. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8424. */
  8425. keysLeft: number[];
  8426. /**
  8427. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8428. */
  8429. keysRight: number[];
  8430. private _keys;
  8431. private _onCanvasBlurObserver;
  8432. private _onKeyboardObserver;
  8433. private _engine;
  8434. private _scene;
  8435. /**
  8436. * Attach the input controls to a specific dom element to get the input from.
  8437. * @param element Defines the element the controls should be listened from
  8438. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8439. */
  8440. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8441. /**
  8442. * Detach the current controls from the specified dom element.
  8443. * @param element Defines the element to stop listening the inputs from
  8444. */
  8445. detachControl(element: Nullable<HTMLElement>): void;
  8446. /**
  8447. * Update the current camera state depending on the inputs that have been used this frame.
  8448. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8449. */
  8450. checkInputs(): void;
  8451. /**
  8452. * Gets the class name of the current intput.
  8453. * @returns the class name
  8454. */
  8455. getClassName(): string;
  8456. /** @hidden */
  8457. _onLostFocus(): void;
  8458. /**
  8459. * Get the friendly name associated with the input class.
  8460. * @returns the input friendly name
  8461. */
  8462. getSimpleName(): string;
  8463. }
  8464. }
  8465. declare module "babylonjs/Lights/shadowLight" {
  8466. import { Camera } from "babylonjs/Cameras/camera";
  8467. import { Scene } from "babylonjs/scene";
  8468. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8470. import { Light } from "babylonjs/Lights/light";
  8471. /**
  8472. * Interface describing all the common properties and methods a shadow light needs to implement.
  8473. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8474. * as well as binding the different shadow properties to the effects.
  8475. */
  8476. export interface IShadowLight extends Light {
  8477. /**
  8478. * The light id in the scene (used in scene.findLighById for instance)
  8479. */
  8480. id: string;
  8481. /**
  8482. * The position the shdow will be casted from.
  8483. */
  8484. position: Vector3;
  8485. /**
  8486. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8487. */
  8488. direction: Vector3;
  8489. /**
  8490. * The transformed position. Position of the light in world space taking parenting in account.
  8491. */
  8492. transformedPosition: Vector3;
  8493. /**
  8494. * The transformed direction. Direction of the light in world space taking parenting in account.
  8495. */
  8496. transformedDirection: Vector3;
  8497. /**
  8498. * The friendly name of the light in the scene.
  8499. */
  8500. name: string;
  8501. /**
  8502. * Defines the shadow projection clipping minimum z value.
  8503. */
  8504. shadowMinZ: number;
  8505. /**
  8506. * Defines the shadow projection clipping maximum z value.
  8507. */
  8508. shadowMaxZ: number;
  8509. /**
  8510. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8511. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8512. */
  8513. computeTransformedInformation(): boolean;
  8514. /**
  8515. * Gets the scene the light belongs to.
  8516. * @returns The scene
  8517. */
  8518. getScene(): Scene;
  8519. /**
  8520. * Callback defining a custom Projection Matrix Builder.
  8521. * This can be used to override the default projection matrix computation.
  8522. */
  8523. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8524. /**
  8525. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8526. * @param matrix The materix to updated with the projection information
  8527. * @param viewMatrix The transform matrix of the light
  8528. * @param renderList The list of mesh to render in the map
  8529. * @returns The current light
  8530. */
  8531. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8532. /**
  8533. * Gets the current depth scale used in ESM.
  8534. * @returns The scale
  8535. */
  8536. getDepthScale(): number;
  8537. /**
  8538. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8539. * @returns true if a cube texture needs to be use
  8540. */
  8541. needCube(): boolean;
  8542. /**
  8543. * Detects if the projection matrix requires to be recomputed this frame.
  8544. * @returns true if it requires to be recomputed otherwise, false.
  8545. */
  8546. needProjectionMatrixCompute(): boolean;
  8547. /**
  8548. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8549. */
  8550. forceProjectionMatrixCompute(): void;
  8551. /**
  8552. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8553. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8554. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8555. */
  8556. getShadowDirection(faceIndex?: number): Vector3;
  8557. /**
  8558. * Gets the minZ used for shadow according to both the scene and the light.
  8559. * @param activeCamera The camera we are returning the min for
  8560. * @returns the depth min z
  8561. */
  8562. getDepthMinZ(activeCamera: Camera): number;
  8563. /**
  8564. * Gets the maxZ used for shadow according to both the scene and the light.
  8565. * @param activeCamera The camera we are returning the max for
  8566. * @returns the depth max z
  8567. */
  8568. getDepthMaxZ(activeCamera: Camera): number;
  8569. }
  8570. /**
  8571. * Base implementation IShadowLight
  8572. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8573. */
  8574. export abstract class ShadowLight extends Light implements IShadowLight {
  8575. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8576. protected _position: Vector3;
  8577. protected _setPosition(value: Vector3): void;
  8578. /**
  8579. * Sets the position the shadow will be casted from. Also use as the light position for both
  8580. * point and spot lights.
  8581. */
  8582. /**
  8583. * Sets the position the shadow will be casted from. Also use as the light position for both
  8584. * point and spot lights.
  8585. */
  8586. position: Vector3;
  8587. protected _direction: Vector3;
  8588. protected _setDirection(value: Vector3): void;
  8589. /**
  8590. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8591. * Also use as the light direction on spot and directional lights.
  8592. */
  8593. /**
  8594. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8595. * Also use as the light direction on spot and directional lights.
  8596. */
  8597. direction: Vector3;
  8598. private _shadowMinZ;
  8599. /**
  8600. * Gets the shadow projection clipping minimum z value.
  8601. */
  8602. /**
  8603. * Sets the shadow projection clipping minimum z value.
  8604. */
  8605. shadowMinZ: number;
  8606. private _shadowMaxZ;
  8607. /**
  8608. * Sets the shadow projection clipping maximum z value.
  8609. */
  8610. /**
  8611. * Gets the shadow projection clipping maximum z value.
  8612. */
  8613. shadowMaxZ: number;
  8614. /**
  8615. * Callback defining a custom Projection Matrix Builder.
  8616. * This can be used to override the default projection matrix computation.
  8617. */
  8618. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8619. /**
  8620. * The transformed position. Position of the light in world space taking parenting in account.
  8621. */
  8622. transformedPosition: Vector3;
  8623. /**
  8624. * The transformed direction. Direction of the light in world space taking parenting in account.
  8625. */
  8626. transformedDirection: Vector3;
  8627. private _needProjectionMatrixCompute;
  8628. /**
  8629. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8630. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8631. */
  8632. computeTransformedInformation(): boolean;
  8633. /**
  8634. * Return the depth scale used for the shadow map.
  8635. * @returns the depth scale.
  8636. */
  8637. getDepthScale(): number;
  8638. /**
  8639. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8640. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8641. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8642. */
  8643. getShadowDirection(faceIndex?: number): Vector3;
  8644. /**
  8645. * Returns the ShadowLight absolute position in the World.
  8646. * @returns the position vector in world space
  8647. */
  8648. getAbsolutePosition(): Vector3;
  8649. /**
  8650. * Sets the ShadowLight direction toward the passed target.
  8651. * @param target The point to target in local space
  8652. * @returns the updated ShadowLight direction
  8653. */
  8654. setDirectionToTarget(target: Vector3): Vector3;
  8655. /**
  8656. * Returns the light rotation in euler definition.
  8657. * @returns the x y z rotation in local space.
  8658. */
  8659. getRotation(): Vector3;
  8660. /**
  8661. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8662. * @returns true if a cube texture needs to be use
  8663. */
  8664. needCube(): boolean;
  8665. /**
  8666. * Detects if the projection matrix requires to be recomputed this frame.
  8667. * @returns true if it requires to be recomputed otherwise, false.
  8668. */
  8669. needProjectionMatrixCompute(): boolean;
  8670. /**
  8671. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8672. */
  8673. forceProjectionMatrixCompute(): void;
  8674. /** @hidden */
  8675. _initCache(): void;
  8676. /** @hidden */
  8677. _isSynchronized(): boolean;
  8678. /**
  8679. * Computes the world matrix of the node
  8680. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8681. * @returns the world matrix
  8682. */
  8683. computeWorldMatrix(force?: boolean): Matrix;
  8684. /**
  8685. * Gets the minZ used for shadow according to both the scene and the light.
  8686. * @param activeCamera The camera we are returning the min for
  8687. * @returns the depth min z
  8688. */
  8689. getDepthMinZ(activeCamera: Camera): number;
  8690. /**
  8691. * Gets the maxZ used for shadow according to both the scene and the light.
  8692. * @param activeCamera The camera we are returning the max for
  8693. * @returns the depth max z
  8694. */
  8695. getDepthMaxZ(activeCamera: Camera): number;
  8696. /**
  8697. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8698. * @param matrix The materix to updated with the projection information
  8699. * @param viewMatrix The transform matrix of the light
  8700. * @param renderList The list of mesh to render in the map
  8701. * @returns The current light
  8702. */
  8703. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8704. }
  8705. }
  8706. declare module "babylonjs/Materials/materialHelper" {
  8707. import { Nullable } from "babylonjs/types";
  8708. import { Scene } from "babylonjs/scene";
  8709. import { Engine } from "babylonjs/Engines/engine";
  8710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8711. import { Light } from "babylonjs/Lights/light";
  8712. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8713. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8714. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8715. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8716. /**
  8717. * "Static Class" containing the most commonly used helper while dealing with material for
  8718. * rendering purpose.
  8719. *
  8720. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8721. *
  8722. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8723. */
  8724. export class MaterialHelper {
  8725. /**
  8726. * Bind the current view position to an effect.
  8727. * @param effect The effect to be bound
  8728. * @param scene The scene the eyes position is used from
  8729. */
  8730. static BindEyePosition(effect: Effect, scene: Scene): void;
  8731. /**
  8732. * Helps preparing the defines values about the UVs in used in the effect.
  8733. * UVs are shared as much as we can accross channels in the shaders.
  8734. * @param texture The texture we are preparing the UVs for
  8735. * @param defines The defines to update
  8736. * @param key The channel key "diffuse", "specular"... used in the shader
  8737. */
  8738. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8739. /**
  8740. * Binds a texture matrix value to its corrsponding uniform
  8741. * @param texture The texture to bind the matrix for
  8742. * @param uniformBuffer The uniform buffer receivin the data
  8743. * @param key The channel key "diffuse", "specular"... used in the shader
  8744. */
  8745. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8746. /**
  8747. * Gets the current status of the fog (should it be enabled?)
  8748. * @param mesh defines the mesh to evaluate for fog support
  8749. * @param scene defines the hosting scene
  8750. * @returns true if fog must be enabled
  8751. */
  8752. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8753. /**
  8754. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8755. * @param mesh defines the current mesh
  8756. * @param scene defines the current scene
  8757. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8758. * @param pointsCloud defines if point cloud rendering has to be turned on
  8759. * @param fogEnabled defines if fog has to be turned on
  8760. * @param alphaTest defines if alpha testing has to be turned on
  8761. * @param defines defines the current list of defines
  8762. */
  8763. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8764. /**
  8765. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8766. * @param scene defines the current scene
  8767. * @param engine defines the current engine
  8768. * @param defines specifies the list of active defines
  8769. * @param useInstances defines if instances have to be turned on
  8770. * @param useClipPlane defines if clip plane have to be turned on
  8771. */
  8772. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8773. /**
  8774. * Prepares the defines for bones
  8775. * @param mesh The mesh containing the geometry data we will draw
  8776. * @param defines The defines to update
  8777. */
  8778. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8779. /**
  8780. * Prepares the defines for morph targets
  8781. * @param mesh The mesh containing the geometry data we will draw
  8782. * @param defines The defines to update
  8783. */
  8784. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8785. /**
  8786. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8787. * @param mesh The mesh containing the geometry data we will draw
  8788. * @param defines The defines to update
  8789. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8790. * @param useBones Precise whether bones should be used or not (override mesh info)
  8791. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8792. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8793. * @returns false if defines are considered not dirty and have not been checked
  8794. */
  8795. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8796. /**
  8797. * Prepares the defines related to multiview
  8798. * @param scene The scene we are intending to draw
  8799. * @param defines The defines to update
  8800. */
  8801. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8802. /**
  8803. * Prepares the defines related to the light information passed in parameter
  8804. * @param scene The scene we are intending to draw
  8805. * @param mesh The mesh the effect is compiling for
  8806. * @param light The light the effect is compiling for
  8807. * @param lightIndex The index of the light
  8808. * @param defines The defines to update
  8809. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8810. * @param state Defines the current state regarding what is needed (normals, etc...)
  8811. */
  8812. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8813. needNormals: boolean;
  8814. needRebuild: boolean;
  8815. shadowEnabled: boolean;
  8816. specularEnabled: boolean;
  8817. lightmapMode: boolean;
  8818. }): void;
  8819. /**
  8820. * Prepares the defines related to the light information passed in parameter
  8821. * @param scene The scene we are intending to draw
  8822. * @param mesh The mesh the effect is compiling for
  8823. * @param defines The defines to update
  8824. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8825. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8826. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8827. * @returns true if normals will be required for the rest of the effect
  8828. */
  8829. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8830. /**
  8831. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8832. * @param lightIndex defines the light index
  8833. * @param uniformsList The uniform list
  8834. * @param samplersList The sampler list
  8835. * @param projectedLightTexture defines if projected texture must be used
  8836. * @param uniformBuffersList defines an optional list of uniform buffers
  8837. */
  8838. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8839. /**
  8840. * Prepares the uniforms and samplers list to be used in the effect
  8841. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8842. * @param samplersList The sampler list
  8843. * @param defines The defines helping in the list generation
  8844. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8845. */
  8846. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8847. /**
  8848. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8849. * @param defines The defines to update while falling back
  8850. * @param fallbacks The authorized effect fallbacks
  8851. * @param maxSimultaneousLights The maximum number of lights allowed
  8852. * @param rank the current rank of the Effect
  8853. * @returns The newly affected rank
  8854. */
  8855. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8856. private static _TmpMorphInfluencers;
  8857. /**
  8858. * Prepares the list of attributes required for morph targets according to the effect defines.
  8859. * @param attribs The current list of supported attribs
  8860. * @param mesh The mesh to prepare the morph targets attributes for
  8861. * @param influencers The number of influencers
  8862. */
  8863. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8864. /**
  8865. * Prepares the list of attributes required for morph targets according to the effect defines.
  8866. * @param attribs The current list of supported attribs
  8867. * @param mesh The mesh to prepare the morph targets attributes for
  8868. * @param defines The current Defines of the effect
  8869. */
  8870. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8871. /**
  8872. * Prepares the list of attributes required for bones according to the effect defines.
  8873. * @param attribs The current list of supported attribs
  8874. * @param mesh The mesh to prepare the bones attributes for
  8875. * @param defines The current Defines of the effect
  8876. * @param fallbacks The current efffect fallback strategy
  8877. */
  8878. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8879. /**
  8880. * Check and prepare the list of attributes required for instances according to the effect defines.
  8881. * @param attribs The current list of supported attribs
  8882. * @param defines The current MaterialDefines of the effect
  8883. */
  8884. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8885. /**
  8886. * Add the list of attributes required for instances to the attribs array.
  8887. * @param attribs The current list of supported attribs
  8888. */
  8889. static PushAttributesForInstances(attribs: string[]): void;
  8890. /**
  8891. * Binds the light shadow information to the effect for the given mesh.
  8892. * @param light The light containing the generator
  8893. * @param scene The scene the lights belongs to
  8894. * @param mesh The mesh we are binding the information to render
  8895. * @param lightIndex The light index in the effect used to render the mesh
  8896. * @param effect The effect we are binding the data to
  8897. */
  8898. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8899. /**
  8900. * Binds the light information to the effect.
  8901. * @param light The light containing the generator
  8902. * @param effect The effect we are binding the data to
  8903. * @param lightIndex The light index in the effect used to render
  8904. */
  8905. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8906. /**
  8907. * Binds the lights information from the scene to the effect for the given mesh.
  8908. * @param light Light to bind
  8909. * @param lightIndex Light index
  8910. * @param scene The scene where the light belongs to
  8911. * @param mesh The mesh we are binding the information to render
  8912. * @param effect The effect we are binding the data to
  8913. * @param useSpecular Defines if specular is supported
  8914. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8915. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8916. */
  8917. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8918. /**
  8919. * Binds the lights information from the scene to the effect for the given mesh.
  8920. * @param scene The scene the lights belongs to
  8921. * @param mesh The mesh we are binding the information to render
  8922. * @param effect The effect we are binding the data to
  8923. * @param defines The generated defines for the effect
  8924. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8925. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8926. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8927. */
  8928. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8929. private static _tempFogColor;
  8930. /**
  8931. * Binds the fog information from the scene to the effect for the given mesh.
  8932. * @param scene The scene the lights belongs to
  8933. * @param mesh The mesh we are binding the information to render
  8934. * @param effect The effect we are binding the data to
  8935. * @param linearSpace Defines if the fog effect is applied in linear space
  8936. */
  8937. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8938. /**
  8939. * Binds the bones information from the mesh to the effect.
  8940. * @param mesh The mesh we are binding the information to render
  8941. * @param effect The effect we are binding the data to
  8942. */
  8943. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8944. /**
  8945. * Binds the morph targets information from the mesh to the effect.
  8946. * @param abstractMesh The mesh we are binding the information to render
  8947. * @param effect The effect we are binding the data to
  8948. */
  8949. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8950. /**
  8951. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8952. * @param defines The generated defines used in the effect
  8953. * @param effect The effect we are binding the data to
  8954. * @param scene The scene we are willing to render with logarithmic scale for
  8955. */
  8956. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  8957. /**
  8958. * Binds the clip plane information from the scene to the effect.
  8959. * @param scene The scene the clip plane information are extracted from
  8960. * @param effect The effect we are binding the data to
  8961. */
  8962. static BindClipPlane(effect: Effect, scene: Scene): void;
  8963. }
  8964. }
  8965. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  8966. /** @hidden */
  8967. export var packingFunctions: {
  8968. name: string;
  8969. shader: string;
  8970. };
  8971. }
  8972. declare module "babylonjs/Shaders/shadowMap.fragment" {
  8973. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  8974. /** @hidden */
  8975. export var shadowMapPixelShader: {
  8976. name: string;
  8977. shader: string;
  8978. };
  8979. }
  8980. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  8981. /** @hidden */
  8982. export var bonesDeclaration: {
  8983. name: string;
  8984. shader: string;
  8985. };
  8986. }
  8987. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  8988. /** @hidden */
  8989. export var morphTargetsVertexGlobalDeclaration: {
  8990. name: string;
  8991. shader: string;
  8992. };
  8993. }
  8994. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  8995. /** @hidden */
  8996. export var morphTargetsVertexDeclaration: {
  8997. name: string;
  8998. shader: string;
  8999. };
  9000. }
  9001. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9002. /** @hidden */
  9003. export var instancesDeclaration: {
  9004. name: string;
  9005. shader: string;
  9006. };
  9007. }
  9008. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9009. /** @hidden */
  9010. export var helperFunctions: {
  9011. name: string;
  9012. shader: string;
  9013. };
  9014. }
  9015. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9016. /** @hidden */
  9017. export var morphTargetsVertex: {
  9018. name: string;
  9019. shader: string;
  9020. };
  9021. }
  9022. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9023. /** @hidden */
  9024. export var instancesVertex: {
  9025. name: string;
  9026. shader: string;
  9027. };
  9028. }
  9029. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9030. /** @hidden */
  9031. export var bonesVertex: {
  9032. name: string;
  9033. shader: string;
  9034. };
  9035. }
  9036. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9037. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9038. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9039. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9040. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9041. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9042. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9043. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9044. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9045. /** @hidden */
  9046. export var shadowMapVertexShader: {
  9047. name: string;
  9048. shader: string;
  9049. };
  9050. }
  9051. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9052. /** @hidden */
  9053. export var depthBoxBlurPixelShader: {
  9054. name: string;
  9055. shader: string;
  9056. };
  9057. }
  9058. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9059. import { Nullable } from "babylonjs/types";
  9060. import { Scene } from "babylonjs/scene";
  9061. import { Matrix } from "babylonjs/Maths/math.vector";
  9062. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9064. import { Mesh } from "babylonjs/Meshes/mesh";
  9065. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9066. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9067. import { Effect } from "babylonjs/Materials/effect";
  9068. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9069. import "babylonjs/Shaders/shadowMap.fragment";
  9070. import "babylonjs/Shaders/shadowMap.vertex";
  9071. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9072. import { Observable } from "babylonjs/Misc/observable";
  9073. /**
  9074. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9075. */
  9076. export interface ICustomShaderOptions {
  9077. /**
  9078. * Gets or sets the custom shader name to use
  9079. */
  9080. shaderName: string;
  9081. /**
  9082. * The list of attribute names used in the shader
  9083. */
  9084. attributes?: string[];
  9085. /**
  9086. * The list of unifrom names used in the shader
  9087. */
  9088. uniforms?: string[];
  9089. /**
  9090. * The list of sampler names used in the shader
  9091. */
  9092. samplers?: string[];
  9093. /**
  9094. * The list of defines used in the shader
  9095. */
  9096. defines?: string[];
  9097. }
  9098. /**
  9099. * Interface to implement to create a shadow generator compatible with BJS.
  9100. */
  9101. export interface IShadowGenerator {
  9102. /**
  9103. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9104. * @returns The render target texture if present otherwise, null
  9105. */
  9106. getShadowMap(): Nullable<RenderTargetTexture>;
  9107. /**
  9108. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9109. * @returns The render target texture if the shadow map is present otherwise, null
  9110. */
  9111. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9112. /**
  9113. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9114. * @param subMesh The submesh we want to render in the shadow map
  9115. * @param useInstances Defines wether will draw in the map using instances
  9116. * @returns true if ready otherwise, false
  9117. */
  9118. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9119. /**
  9120. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9121. * @param defines Defines of the material we want to update
  9122. * @param lightIndex Index of the light in the enabled light list of the material
  9123. */
  9124. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9125. /**
  9126. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9127. * defined in the generator but impacting the effect).
  9128. * It implies the unifroms available on the materials are the standard BJS ones.
  9129. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9130. * @param effect The effect we are binfing the information for
  9131. */
  9132. bindShadowLight(lightIndex: string, effect: Effect): void;
  9133. /**
  9134. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9135. * (eq to shadow prjection matrix * light transform matrix)
  9136. * @returns The transform matrix used to create the shadow map
  9137. */
  9138. getTransformMatrix(): Matrix;
  9139. /**
  9140. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9141. * Cube and 2D textures for instance.
  9142. */
  9143. recreateShadowMap(): void;
  9144. /**
  9145. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9146. * @param onCompiled Callback triggered at the and of the effects compilation
  9147. * @param options Sets of optional options forcing the compilation with different modes
  9148. */
  9149. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9150. useInstances: boolean;
  9151. }>): void;
  9152. /**
  9153. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9154. * @param options Sets of optional options forcing the compilation with different modes
  9155. * @returns A promise that resolves when the compilation completes
  9156. */
  9157. forceCompilationAsync(options?: Partial<{
  9158. useInstances: boolean;
  9159. }>): Promise<void>;
  9160. /**
  9161. * Serializes the shadow generator setup to a json object.
  9162. * @returns The serialized JSON object
  9163. */
  9164. serialize(): any;
  9165. /**
  9166. * Disposes the Shadow map and related Textures and effects.
  9167. */
  9168. dispose(): void;
  9169. }
  9170. /**
  9171. * Default implementation IShadowGenerator.
  9172. * This is the main object responsible of generating shadows in the framework.
  9173. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9174. */
  9175. export class ShadowGenerator implements IShadowGenerator {
  9176. /**
  9177. * Shadow generator mode None: no filtering applied.
  9178. */
  9179. static readonly FILTER_NONE: number;
  9180. /**
  9181. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9182. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9183. */
  9184. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9185. /**
  9186. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9187. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9188. */
  9189. static readonly FILTER_POISSONSAMPLING: number;
  9190. /**
  9191. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9192. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9193. */
  9194. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9195. /**
  9196. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9197. * edge artifacts on steep falloff.
  9198. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9199. */
  9200. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9201. /**
  9202. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9203. * edge artifacts on steep falloff.
  9204. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9205. */
  9206. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9207. /**
  9208. * Shadow generator mode PCF: Percentage Closer Filtering
  9209. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9210. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9211. */
  9212. static readonly FILTER_PCF: number;
  9213. /**
  9214. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9215. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9216. * Contact Hardening
  9217. */
  9218. static readonly FILTER_PCSS: number;
  9219. /**
  9220. * Reserved for PCF and PCSS
  9221. * Highest Quality.
  9222. *
  9223. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9224. *
  9225. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9226. */
  9227. static readonly QUALITY_HIGH: number;
  9228. /**
  9229. * Reserved for PCF and PCSS
  9230. * Good tradeoff for quality/perf cross devices
  9231. *
  9232. * Execute PCF on a 3*3 kernel.
  9233. *
  9234. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9235. */
  9236. static readonly QUALITY_MEDIUM: number;
  9237. /**
  9238. * Reserved for PCF and PCSS
  9239. * The lowest quality but the fastest.
  9240. *
  9241. * Execute PCF on a 1*1 kernel.
  9242. *
  9243. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9244. */
  9245. static readonly QUALITY_LOW: number;
  9246. /** Gets or sets the custom shader name to use */
  9247. customShaderOptions: ICustomShaderOptions;
  9248. /**
  9249. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9250. */
  9251. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9252. /**
  9253. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9254. */
  9255. onAfterShadowMapRenderObservable: Observable<Effect>;
  9256. /**
  9257. * Observable triggered before a mesh is rendered in the shadow map.
  9258. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9259. */
  9260. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9261. /**
  9262. * Observable triggered after a mesh is rendered in the shadow map.
  9263. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9264. */
  9265. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9266. private _bias;
  9267. /**
  9268. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9269. */
  9270. /**
  9271. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9272. */
  9273. bias: number;
  9274. private _normalBias;
  9275. /**
  9276. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9277. */
  9278. /**
  9279. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9280. */
  9281. normalBias: number;
  9282. private _blurBoxOffset;
  9283. /**
  9284. * Gets the blur box offset: offset applied during the blur pass.
  9285. * Only useful if useKernelBlur = false
  9286. */
  9287. /**
  9288. * Sets the blur box offset: offset applied during the blur pass.
  9289. * Only useful if useKernelBlur = false
  9290. */
  9291. blurBoxOffset: number;
  9292. private _blurScale;
  9293. /**
  9294. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9295. * 2 means half of the size.
  9296. */
  9297. /**
  9298. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9299. * 2 means half of the size.
  9300. */
  9301. blurScale: number;
  9302. private _blurKernel;
  9303. /**
  9304. * Gets the blur kernel: kernel size of the blur pass.
  9305. * Only useful if useKernelBlur = true
  9306. */
  9307. /**
  9308. * Sets the blur kernel: kernel size of the blur pass.
  9309. * Only useful if useKernelBlur = true
  9310. */
  9311. blurKernel: number;
  9312. private _useKernelBlur;
  9313. /**
  9314. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9315. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9316. */
  9317. /**
  9318. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9319. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9320. */
  9321. useKernelBlur: boolean;
  9322. private _depthScale;
  9323. /**
  9324. * Gets the depth scale used in ESM mode.
  9325. */
  9326. /**
  9327. * Sets the depth scale used in ESM mode.
  9328. * This can override the scale stored on the light.
  9329. */
  9330. depthScale: number;
  9331. private _filter;
  9332. /**
  9333. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9334. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9335. */
  9336. /**
  9337. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9338. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9339. */
  9340. filter: number;
  9341. /**
  9342. * Gets if the current filter is set to Poisson Sampling.
  9343. */
  9344. /**
  9345. * Sets the current filter to Poisson Sampling.
  9346. */
  9347. usePoissonSampling: boolean;
  9348. /**
  9349. * Gets if the current filter is set to ESM.
  9350. */
  9351. /**
  9352. * Sets the current filter is to ESM.
  9353. */
  9354. useExponentialShadowMap: boolean;
  9355. /**
  9356. * Gets if the current filter is set to filtered ESM.
  9357. */
  9358. /**
  9359. * Gets if the current filter is set to filtered ESM.
  9360. */
  9361. useBlurExponentialShadowMap: boolean;
  9362. /**
  9363. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9364. * exponential to prevent steep falloff artifacts).
  9365. */
  9366. /**
  9367. * Sets the current filter to "close ESM" (using the inverse of the
  9368. * exponential to prevent steep falloff artifacts).
  9369. */
  9370. useCloseExponentialShadowMap: boolean;
  9371. /**
  9372. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9373. * exponential to prevent steep falloff artifacts).
  9374. */
  9375. /**
  9376. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9377. * exponential to prevent steep falloff artifacts).
  9378. */
  9379. useBlurCloseExponentialShadowMap: boolean;
  9380. /**
  9381. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9382. */
  9383. /**
  9384. * Sets the current filter to "PCF" (percentage closer filtering).
  9385. */
  9386. usePercentageCloserFiltering: boolean;
  9387. private _filteringQuality;
  9388. /**
  9389. * Gets the PCF or PCSS Quality.
  9390. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9391. */
  9392. /**
  9393. * Sets the PCF or PCSS Quality.
  9394. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9395. */
  9396. filteringQuality: number;
  9397. /**
  9398. * Gets if the current filter is set to "PCSS" (contact hardening).
  9399. */
  9400. /**
  9401. * Sets the current filter to "PCSS" (contact hardening).
  9402. */
  9403. useContactHardeningShadow: boolean;
  9404. private _contactHardeningLightSizeUVRatio;
  9405. /**
  9406. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9407. * Using a ratio helps keeping shape stability independently of the map size.
  9408. *
  9409. * It does not account for the light projection as it was having too much
  9410. * instability during the light setup or during light position changes.
  9411. *
  9412. * Only valid if useContactHardeningShadow is true.
  9413. */
  9414. /**
  9415. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9416. * Using a ratio helps keeping shape stability independently of the map size.
  9417. *
  9418. * It does not account for the light projection as it was having too much
  9419. * instability during the light setup or during light position changes.
  9420. *
  9421. * Only valid if useContactHardeningShadow is true.
  9422. */
  9423. contactHardeningLightSizeUVRatio: number;
  9424. private _darkness;
  9425. /** Gets or sets the actual darkness of a shadow */
  9426. darkness: number;
  9427. /**
  9428. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9429. * 0 means strongest and 1 would means no shadow.
  9430. * @returns the darkness.
  9431. */
  9432. getDarkness(): number;
  9433. /**
  9434. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9435. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9436. * @returns the shadow generator allowing fluent coding.
  9437. */
  9438. setDarkness(darkness: number): ShadowGenerator;
  9439. private _transparencyShadow;
  9440. /** Gets or sets the ability to have transparent shadow */
  9441. transparencyShadow: boolean;
  9442. /**
  9443. * Sets the ability to have transparent shadow (boolean).
  9444. * @param transparent True if transparent else False
  9445. * @returns the shadow generator allowing fluent coding
  9446. */
  9447. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9448. private _shadowMap;
  9449. private _shadowMap2;
  9450. /**
  9451. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9452. * @returns The render target texture if present otherwise, null
  9453. */
  9454. getShadowMap(): Nullable<RenderTargetTexture>;
  9455. /**
  9456. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9457. * @returns The render target texture if the shadow map is present otherwise, null
  9458. */
  9459. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9460. /**
  9461. * Gets the class name of that object
  9462. * @returns "ShadowGenerator"
  9463. */
  9464. getClassName(): string;
  9465. /**
  9466. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9467. * @param mesh Mesh to add
  9468. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9469. * @returns the Shadow Generator itself
  9470. */
  9471. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9472. /**
  9473. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9474. * @param mesh Mesh to remove
  9475. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9476. * @returns the Shadow Generator itself
  9477. */
  9478. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9479. /**
  9480. * Controls the extent to which the shadows fade out at the edge of the frustum
  9481. * Used only by directionals and spots
  9482. */
  9483. frustumEdgeFalloff: number;
  9484. private _light;
  9485. /**
  9486. * Returns the associated light object.
  9487. * @returns the light generating the shadow
  9488. */
  9489. getLight(): IShadowLight;
  9490. /**
  9491. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9492. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9493. * It might on the other hand introduce peter panning.
  9494. */
  9495. forceBackFacesOnly: boolean;
  9496. private _scene;
  9497. private _lightDirection;
  9498. private _effect;
  9499. private _viewMatrix;
  9500. private _projectionMatrix;
  9501. private _transformMatrix;
  9502. private _cachedPosition;
  9503. private _cachedDirection;
  9504. private _cachedDefines;
  9505. private _currentRenderID;
  9506. private _boxBlurPostprocess;
  9507. private _kernelBlurXPostprocess;
  9508. private _kernelBlurYPostprocess;
  9509. private _blurPostProcesses;
  9510. private _mapSize;
  9511. private _currentFaceIndex;
  9512. private _currentFaceIndexCache;
  9513. private _textureType;
  9514. private _defaultTextureMatrix;
  9515. /** @hidden */
  9516. static _SceneComponentInitialization: (scene: Scene) => void;
  9517. /**
  9518. * Creates a ShadowGenerator object.
  9519. * A ShadowGenerator is the required tool to use the shadows.
  9520. * Each light casting shadows needs to use its own ShadowGenerator.
  9521. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9522. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9523. * @param light The light object generating the shadows.
  9524. * @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.
  9525. */
  9526. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9527. private _initializeGenerator;
  9528. private _initializeShadowMap;
  9529. private _initializeBlurRTTAndPostProcesses;
  9530. private _renderForShadowMap;
  9531. private _renderSubMeshForShadowMap;
  9532. private _applyFilterValues;
  9533. /**
  9534. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9535. * @param onCompiled Callback triggered at the and of the effects compilation
  9536. * @param options Sets of optional options forcing the compilation with different modes
  9537. */
  9538. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9539. useInstances: boolean;
  9540. }>): void;
  9541. /**
  9542. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9543. * @param options Sets of optional options forcing the compilation with different modes
  9544. * @returns A promise that resolves when the compilation completes
  9545. */
  9546. forceCompilationAsync(options?: Partial<{
  9547. useInstances: boolean;
  9548. }>): Promise<void>;
  9549. /**
  9550. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9551. * @param subMesh The submesh we want to render in the shadow map
  9552. * @param useInstances Defines wether will draw in the map using instances
  9553. * @returns true if ready otherwise, false
  9554. */
  9555. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9556. /**
  9557. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9558. * @param defines Defines of the material we want to update
  9559. * @param lightIndex Index of the light in the enabled light list of the material
  9560. */
  9561. prepareDefines(defines: any, lightIndex: number): void;
  9562. /**
  9563. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9564. * defined in the generator but impacting the effect).
  9565. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9566. * @param effect The effect we are binfing the information for
  9567. */
  9568. bindShadowLight(lightIndex: string, effect: Effect): void;
  9569. /**
  9570. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9571. * (eq to shadow prjection matrix * light transform matrix)
  9572. * @returns The transform matrix used to create the shadow map
  9573. */
  9574. getTransformMatrix(): Matrix;
  9575. /**
  9576. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9577. * Cube and 2D textures for instance.
  9578. */
  9579. recreateShadowMap(): void;
  9580. private _disposeBlurPostProcesses;
  9581. private _disposeRTTandPostProcesses;
  9582. /**
  9583. * Disposes the ShadowGenerator.
  9584. * Returns nothing.
  9585. */
  9586. dispose(): void;
  9587. /**
  9588. * Serializes the shadow generator setup to a json object.
  9589. * @returns The serialized JSON object
  9590. */
  9591. serialize(): any;
  9592. /**
  9593. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9594. * @param parsedShadowGenerator The JSON object to parse
  9595. * @param scene The scene to create the shadow map for
  9596. * @returns The parsed shadow generator
  9597. */
  9598. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9599. }
  9600. }
  9601. declare module "babylonjs/Lights/light" {
  9602. import { Nullable } from "babylonjs/types";
  9603. import { Scene } from "babylonjs/scene";
  9604. import { Vector3 } from "babylonjs/Maths/math.vector";
  9605. import { Color3 } from "babylonjs/Maths/math.color";
  9606. import { Node } from "babylonjs/node";
  9607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9608. import { Effect } from "babylonjs/Materials/effect";
  9609. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9610. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9611. /**
  9612. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9613. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9614. * 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.
  9615. */
  9616. export abstract class Light extends Node {
  9617. /**
  9618. * Falloff Default: light is falling off following the material specification:
  9619. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9620. */
  9621. static readonly FALLOFF_DEFAULT: number;
  9622. /**
  9623. * Falloff Physical: light is falling off following the inverse squared distance law.
  9624. */
  9625. static readonly FALLOFF_PHYSICAL: number;
  9626. /**
  9627. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9628. * to enhance interoperability with other engines.
  9629. */
  9630. static readonly FALLOFF_GLTF: number;
  9631. /**
  9632. * Falloff Standard: light is falling off like in the standard material
  9633. * to enhance interoperability with other materials.
  9634. */
  9635. static readonly FALLOFF_STANDARD: number;
  9636. /**
  9637. * If every light affecting the material is in this lightmapMode,
  9638. * material.lightmapTexture adds or multiplies
  9639. * (depends on material.useLightmapAsShadowmap)
  9640. * after every other light calculations.
  9641. */
  9642. static readonly LIGHTMAP_DEFAULT: number;
  9643. /**
  9644. * material.lightmapTexture as only diffuse lighting from this light
  9645. * adds only specular lighting from this light
  9646. * adds dynamic shadows
  9647. */
  9648. static readonly LIGHTMAP_SPECULAR: number;
  9649. /**
  9650. * material.lightmapTexture as only lighting
  9651. * no light calculation from this light
  9652. * only adds dynamic shadows from this light
  9653. */
  9654. static readonly LIGHTMAP_SHADOWSONLY: number;
  9655. /**
  9656. * Each light type uses the default quantity according to its type:
  9657. * point/spot lights use luminous intensity
  9658. * directional lights use illuminance
  9659. */
  9660. static readonly INTENSITYMODE_AUTOMATIC: number;
  9661. /**
  9662. * lumen (lm)
  9663. */
  9664. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9665. /**
  9666. * candela (lm/sr)
  9667. */
  9668. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9669. /**
  9670. * lux (lm/m^2)
  9671. */
  9672. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9673. /**
  9674. * nit (cd/m^2)
  9675. */
  9676. static readonly INTENSITYMODE_LUMINANCE: number;
  9677. /**
  9678. * Light type const id of the point light.
  9679. */
  9680. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9681. /**
  9682. * Light type const id of the directional light.
  9683. */
  9684. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9685. /**
  9686. * Light type const id of the spot light.
  9687. */
  9688. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9689. /**
  9690. * Light type const id of the hemispheric light.
  9691. */
  9692. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9693. /**
  9694. * Diffuse gives the basic color to an object.
  9695. */
  9696. diffuse: Color3;
  9697. /**
  9698. * Specular produces a highlight color on an object.
  9699. * Note: This is note affecting PBR materials.
  9700. */
  9701. specular: Color3;
  9702. /**
  9703. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9704. * falling off base on range or angle.
  9705. * This can be set to any values in Light.FALLOFF_x.
  9706. *
  9707. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9708. * other types of materials.
  9709. */
  9710. falloffType: number;
  9711. /**
  9712. * Strength of the light.
  9713. * Note: By default it is define in the framework own unit.
  9714. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9715. */
  9716. intensity: number;
  9717. private _range;
  9718. protected _inverseSquaredRange: number;
  9719. /**
  9720. * Defines how far from the source the light is impacting in scene units.
  9721. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9722. */
  9723. /**
  9724. * Defines how far from the source the light is impacting in scene units.
  9725. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9726. */
  9727. range: number;
  9728. /**
  9729. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9730. * of light.
  9731. */
  9732. private _photometricScale;
  9733. private _intensityMode;
  9734. /**
  9735. * Gets the photometric scale used to interpret the intensity.
  9736. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9737. */
  9738. /**
  9739. * Sets the photometric scale used to interpret the intensity.
  9740. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9741. */
  9742. intensityMode: number;
  9743. private _radius;
  9744. /**
  9745. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9746. */
  9747. /**
  9748. * sets the light radius used by PBR Materials to simulate soft area lights.
  9749. */
  9750. radius: number;
  9751. private _renderPriority;
  9752. /**
  9753. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9754. * exceeding the number allowed of the materials.
  9755. */
  9756. renderPriority: number;
  9757. private _shadowEnabled;
  9758. /**
  9759. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9760. * the current shadow generator.
  9761. */
  9762. /**
  9763. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9764. * the current shadow generator.
  9765. */
  9766. shadowEnabled: boolean;
  9767. private _includedOnlyMeshes;
  9768. /**
  9769. * Gets the only meshes impacted by this light.
  9770. */
  9771. /**
  9772. * Sets the only meshes impacted by this light.
  9773. */
  9774. includedOnlyMeshes: AbstractMesh[];
  9775. private _excludedMeshes;
  9776. /**
  9777. * Gets the meshes not impacted by this light.
  9778. */
  9779. /**
  9780. * Sets the meshes not impacted by this light.
  9781. */
  9782. excludedMeshes: AbstractMesh[];
  9783. private _excludeWithLayerMask;
  9784. /**
  9785. * Gets the layer id use to find what meshes are not impacted by the light.
  9786. * Inactive if 0
  9787. */
  9788. /**
  9789. * Sets the layer id use to find what meshes are not impacted by the light.
  9790. * Inactive if 0
  9791. */
  9792. excludeWithLayerMask: number;
  9793. private _includeOnlyWithLayerMask;
  9794. /**
  9795. * Gets the layer id use to find what meshes are impacted by the light.
  9796. * Inactive if 0
  9797. */
  9798. /**
  9799. * Sets the layer id use to find what meshes are impacted by the light.
  9800. * Inactive if 0
  9801. */
  9802. includeOnlyWithLayerMask: number;
  9803. private _lightmapMode;
  9804. /**
  9805. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9806. */
  9807. /**
  9808. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9809. */
  9810. lightmapMode: number;
  9811. /**
  9812. * Shadow generator associted to the light.
  9813. * @hidden Internal use only.
  9814. */
  9815. _shadowGenerator: Nullable<IShadowGenerator>;
  9816. /**
  9817. * @hidden Internal use only.
  9818. */
  9819. _excludedMeshesIds: string[];
  9820. /**
  9821. * @hidden Internal use only.
  9822. */
  9823. _includedOnlyMeshesIds: string[];
  9824. /**
  9825. * The current light unifom buffer.
  9826. * @hidden Internal use only.
  9827. */
  9828. _uniformBuffer: UniformBuffer;
  9829. /**
  9830. * Creates a Light object in the scene.
  9831. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9832. * @param name The firendly name of the light
  9833. * @param scene The scene the light belongs too
  9834. */
  9835. constructor(name: string, scene: Scene);
  9836. protected abstract _buildUniformLayout(): void;
  9837. /**
  9838. * Sets the passed Effect "effect" with the Light information.
  9839. * @param effect The effect to update
  9840. * @param lightIndex The index of the light in the effect to update
  9841. * @returns The light
  9842. */
  9843. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9844. /**
  9845. * Sets the passed Effect "effect" with the Light information.
  9846. * @param effect The effect to update
  9847. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9848. * @returns The light
  9849. */
  9850. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9851. /**
  9852. * Returns the string "Light".
  9853. * @returns the class name
  9854. */
  9855. getClassName(): string;
  9856. /** @hidden */
  9857. readonly _isLight: boolean;
  9858. /**
  9859. * Converts the light information to a readable string for debug purpose.
  9860. * @param fullDetails Supports for multiple levels of logging within scene loading
  9861. * @returns the human readable light info
  9862. */
  9863. toString(fullDetails?: boolean): string;
  9864. /** @hidden */
  9865. protected _syncParentEnabledState(): void;
  9866. /**
  9867. * Set the enabled state of this node.
  9868. * @param value - the new enabled state
  9869. */
  9870. setEnabled(value: boolean): void;
  9871. /**
  9872. * Returns the Light associated shadow generator if any.
  9873. * @return the associated shadow generator.
  9874. */
  9875. getShadowGenerator(): Nullable<IShadowGenerator>;
  9876. /**
  9877. * Returns a Vector3, the absolute light position in the World.
  9878. * @returns the world space position of the light
  9879. */
  9880. getAbsolutePosition(): Vector3;
  9881. /**
  9882. * Specifies if the light will affect the passed mesh.
  9883. * @param mesh The mesh to test against the light
  9884. * @return true the mesh is affected otherwise, false.
  9885. */
  9886. canAffectMesh(mesh: AbstractMesh): boolean;
  9887. /**
  9888. * Sort function to order lights for rendering.
  9889. * @param a First Light object to compare to second.
  9890. * @param b Second Light object to compare first.
  9891. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9892. */
  9893. static CompareLightsPriority(a: Light, b: Light): number;
  9894. /**
  9895. * Releases resources associated with this node.
  9896. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9897. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9898. */
  9899. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9900. /**
  9901. * Returns the light type ID (integer).
  9902. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9903. */
  9904. getTypeID(): number;
  9905. /**
  9906. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9907. * @returns the scaled intensity in intensity mode unit
  9908. */
  9909. getScaledIntensity(): number;
  9910. /**
  9911. * Returns a new Light object, named "name", from the current one.
  9912. * @param name The name of the cloned light
  9913. * @returns the new created light
  9914. */
  9915. clone(name: string): Nullable<Light>;
  9916. /**
  9917. * Serializes the current light into a Serialization object.
  9918. * @returns the serialized object.
  9919. */
  9920. serialize(): any;
  9921. /**
  9922. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9923. * This new light is named "name" and added to the passed scene.
  9924. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9925. * @param name The friendly name of the light
  9926. * @param scene The scene the new light will belong to
  9927. * @returns the constructor function
  9928. */
  9929. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9930. /**
  9931. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9932. * @param parsedLight The JSON representation of the light
  9933. * @param scene The scene to create the parsed light in
  9934. * @returns the created light after parsing
  9935. */
  9936. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9937. private _hookArrayForExcluded;
  9938. private _hookArrayForIncludedOnly;
  9939. private _resyncMeshes;
  9940. /**
  9941. * Forces the meshes to update their light related information in their rendering used effects
  9942. * @hidden Internal Use Only
  9943. */
  9944. _markMeshesAsLightDirty(): void;
  9945. /**
  9946. * Recomputes the cached photometric scale if needed.
  9947. */
  9948. private _computePhotometricScale;
  9949. /**
  9950. * Returns the Photometric Scale according to the light type and intensity mode.
  9951. */
  9952. private _getPhotometricScale;
  9953. /**
  9954. * Reorder the light in the scene according to their defined priority.
  9955. * @hidden Internal Use Only
  9956. */
  9957. _reorderLightsInScene(): void;
  9958. /**
  9959. * Prepares the list of defines specific to the light type.
  9960. * @param defines the list of defines
  9961. * @param lightIndex defines the index of the light for the effect
  9962. */
  9963. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9964. }
  9965. }
  9966. declare module "babylonjs/Actions/action" {
  9967. import { Observable } from "babylonjs/Misc/observable";
  9968. import { Condition } from "babylonjs/Actions/condition";
  9969. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9970. import { ActionManager } from "babylonjs/Actions/actionManager";
  9971. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9972. /**
  9973. * Interface used to define Action
  9974. */
  9975. export interface IAction {
  9976. /**
  9977. * Trigger for the action
  9978. */
  9979. trigger: number;
  9980. /** Options of the trigger */
  9981. triggerOptions: any;
  9982. /**
  9983. * Gets the trigger parameters
  9984. * @returns the trigger parameters
  9985. */
  9986. getTriggerParameter(): any;
  9987. /**
  9988. * Internal only - executes current action event
  9989. * @hidden
  9990. */
  9991. _executeCurrent(evt?: ActionEvent): void;
  9992. /**
  9993. * Serialize placeholder for child classes
  9994. * @param parent of child
  9995. * @returns the serialized object
  9996. */
  9997. serialize(parent: any): any;
  9998. /**
  9999. * Internal only
  10000. * @hidden
  10001. */
  10002. _prepare(): void;
  10003. /**
  10004. * Internal only - manager for action
  10005. * @hidden
  10006. */
  10007. _actionManager: AbstractActionManager;
  10008. /**
  10009. * Adds action to chain of actions, may be a DoNothingAction
  10010. * @param action defines the next action to execute
  10011. * @returns The action passed in
  10012. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10013. */
  10014. then(action: IAction): IAction;
  10015. }
  10016. /**
  10017. * The action to be carried out following a trigger
  10018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10019. */
  10020. export class Action implements IAction {
  10021. /** the trigger, with or without parameters, for the action */
  10022. triggerOptions: any;
  10023. /**
  10024. * Trigger for the action
  10025. */
  10026. trigger: number;
  10027. /**
  10028. * Internal only - manager for action
  10029. * @hidden
  10030. */
  10031. _actionManager: ActionManager;
  10032. private _nextActiveAction;
  10033. private _child;
  10034. private _condition?;
  10035. private _triggerParameter;
  10036. /**
  10037. * An event triggered prior to action being executed.
  10038. */
  10039. onBeforeExecuteObservable: Observable<Action>;
  10040. /**
  10041. * Creates a new Action
  10042. * @param triggerOptions the trigger, with or without parameters, for the action
  10043. * @param condition an optional determinant of action
  10044. */
  10045. constructor(
  10046. /** the trigger, with or without parameters, for the action */
  10047. triggerOptions: any, condition?: Condition);
  10048. /**
  10049. * Internal only
  10050. * @hidden
  10051. */
  10052. _prepare(): void;
  10053. /**
  10054. * Gets the trigger parameters
  10055. * @returns the trigger parameters
  10056. */
  10057. getTriggerParameter(): any;
  10058. /**
  10059. * Internal only - executes current action event
  10060. * @hidden
  10061. */
  10062. _executeCurrent(evt?: ActionEvent): void;
  10063. /**
  10064. * Execute placeholder for child classes
  10065. * @param evt optional action event
  10066. */
  10067. execute(evt?: ActionEvent): void;
  10068. /**
  10069. * Skips to next active action
  10070. */
  10071. skipToNextActiveAction(): void;
  10072. /**
  10073. * Adds action to chain of actions, may be a DoNothingAction
  10074. * @param action defines the next action to execute
  10075. * @returns The action passed in
  10076. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10077. */
  10078. then(action: Action): Action;
  10079. /**
  10080. * Internal only
  10081. * @hidden
  10082. */
  10083. _getProperty(propertyPath: string): string;
  10084. /**
  10085. * Internal only
  10086. * @hidden
  10087. */
  10088. _getEffectiveTarget(target: any, propertyPath: string): any;
  10089. /**
  10090. * Serialize placeholder for child classes
  10091. * @param parent of child
  10092. * @returns the serialized object
  10093. */
  10094. serialize(parent: any): any;
  10095. /**
  10096. * Internal only called by serialize
  10097. * @hidden
  10098. */
  10099. protected _serialize(serializedAction: any, parent?: any): any;
  10100. /**
  10101. * Internal only
  10102. * @hidden
  10103. */
  10104. static _SerializeValueAsString: (value: any) => string;
  10105. /**
  10106. * Internal only
  10107. * @hidden
  10108. */
  10109. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10110. name: string;
  10111. targetType: string;
  10112. value: string;
  10113. };
  10114. }
  10115. }
  10116. declare module "babylonjs/Actions/condition" {
  10117. import { ActionManager } from "babylonjs/Actions/actionManager";
  10118. /**
  10119. * A Condition applied to an Action
  10120. */
  10121. export class Condition {
  10122. /**
  10123. * Internal only - manager for action
  10124. * @hidden
  10125. */
  10126. _actionManager: ActionManager;
  10127. /**
  10128. * Internal only
  10129. * @hidden
  10130. */
  10131. _evaluationId: number;
  10132. /**
  10133. * Internal only
  10134. * @hidden
  10135. */
  10136. _currentResult: boolean;
  10137. /**
  10138. * Creates a new Condition
  10139. * @param actionManager the manager of the action the condition is applied to
  10140. */
  10141. constructor(actionManager: ActionManager);
  10142. /**
  10143. * Check if the current condition is valid
  10144. * @returns a boolean
  10145. */
  10146. isValid(): boolean;
  10147. /**
  10148. * Internal only
  10149. * @hidden
  10150. */
  10151. _getProperty(propertyPath: string): string;
  10152. /**
  10153. * Internal only
  10154. * @hidden
  10155. */
  10156. _getEffectiveTarget(target: any, propertyPath: string): any;
  10157. /**
  10158. * Serialize placeholder for child classes
  10159. * @returns the serialized object
  10160. */
  10161. serialize(): any;
  10162. /**
  10163. * Internal only
  10164. * @hidden
  10165. */
  10166. protected _serialize(serializedCondition: any): any;
  10167. }
  10168. /**
  10169. * Defines specific conditional operators as extensions of Condition
  10170. */
  10171. export class ValueCondition extends Condition {
  10172. /** path to specify the property of the target the conditional operator uses */
  10173. propertyPath: string;
  10174. /** the value compared by the conditional operator against the current value of the property */
  10175. value: any;
  10176. /** the conditional operator, default ValueCondition.IsEqual */
  10177. operator: number;
  10178. /**
  10179. * Internal only
  10180. * @hidden
  10181. */
  10182. private static _IsEqual;
  10183. /**
  10184. * Internal only
  10185. * @hidden
  10186. */
  10187. private static _IsDifferent;
  10188. /**
  10189. * Internal only
  10190. * @hidden
  10191. */
  10192. private static _IsGreater;
  10193. /**
  10194. * Internal only
  10195. * @hidden
  10196. */
  10197. private static _IsLesser;
  10198. /**
  10199. * returns the number for IsEqual
  10200. */
  10201. static readonly IsEqual: number;
  10202. /**
  10203. * Returns the number for IsDifferent
  10204. */
  10205. static readonly IsDifferent: number;
  10206. /**
  10207. * Returns the number for IsGreater
  10208. */
  10209. static readonly IsGreater: number;
  10210. /**
  10211. * Returns the number for IsLesser
  10212. */
  10213. static readonly IsLesser: number;
  10214. /**
  10215. * Internal only The action manager for the condition
  10216. * @hidden
  10217. */
  10218. _actionManager: ActionManager;
  10219. /**
  10220. * Internal only
  10221. * @hidden
  10222. */
  10223. private _target;
  10224. /**
  10225. * Internal only
  10226. * @hidden
  10227. */
  10228. private _effectiveTarget;
  10229. /**
  10230. * Internal only
  10231. * @hidden
  10232. */
  10233. private _property;
  10234. /**
  10235. * Creates a new ValueCondition
  10236. * @param actionManager manager for the action the condition applies to
  10237. * @param target for the action
  10238. * @param propertyPath path to specify the property of the target the conditional operator uses
  10239. * @param value the value compared by the conditional operator against the current value of the property
  10240. * @param operator the conditional operator, default ValueCondition.IsEqual
  10241. */
  10242. constructor(actionManager: ActionManager, target: any,
  10243. /** path to specify the property of the target the conditional operator uses */
  10244. propertyPath: string,
  10245. /** the value compared by the conditional operator against the current value of the property */
  10246. value: any,
  10247. /** the conditional operator, default ValueCondition.IsEqual */
  10248. operator?: number);
  10249. /**
  10250. * Compares the given value with the property value for the specified conditional operator
  10251. * @returns the result of the comparison
  10252. */
  10253. isValid(): boolean;
  10254. /**
  10255. * Serialize the ValueCondition into a JSON compatible object
  10256. * @returns serialization object
  10257. */
  10258. serialize(): any;
  10259. /**
  10260. * Gets the name of the conditional operator for the ValueCondition
  10261. * @param operator the conditional operator
  10262. * @returns the name
  10263. */
  10264. static GetOperatorName(operator: number): string;
  10265. }
  10266. /**
  10267. * Defines a predicate condition as an extension of Condition
  10268. */
  10269. export class PredicateCondition extends Condition {
  10270. /** defines the predicate function used to validate the condition */
  10271. predicate: () => boolean;
  10272. /**
  10273. * Internal only - manager for action
  10274. * @hidden
  10275. */
  10276. _actionManager: ActionManager;
  10277. /**
  10278. * Creates a new PredicateCondition
  10279. * @param actionManager manager for the action the condition applies to
  10280. * @param predicate defines the predicate function used to validate the condition
  10281. */
  10282. constructor(actionManager: ActionManager,
  10283. /** defines the predicate function used to validate the condition */
  10284. predicate: () => boolean);
  10285. /**
  10286. * @returns the validity of the predicate condition
  10287. */
  10288. isValid(): boolean;
  10289. }
  10290. /**
  10291. * Defines a state condition as an extension of Condition
  10292. */
  10293. export class StateCondition extends Condition {
  10294. /** Value to compare with target state */
  10295. value: string;
  10296. /**
  10297. * Internal only - manager for action
  10298. * @hidden
  10299. */
  10300. _actionManager: ActionManager;
  10301. /**
  10302. * Internal only
  10303. * @hidden
  10304. */
  10305. private _target;
  10306. /**
  10307. * Creates a new StateCondition
  10308. * @param actionManager manager for the action the condition applies to
  10309. * @param target of the condition
  10310. * @param value to compare with target state
  10311. */
  10312. constructor(actionManager: ActionManager, target: any,
  10313. /** Value to compare with target state */
  10314. value: string);
  10315. /**
  10316. * Gets a boolean indicating if the current condition is met
  10317. * @returns the validity of the state
  10318. */
  10319. isValid(): boolean;
  10320. /**
  10321. * Serialize the StateCondition into a JSON compatible object
  10322. * @returns serialization object
  10323. */
  10324. serialize(): any;
  10325. }
  10326. }
  10327. declare module "babylonjs/Actions/directActions" {
  10328. import { Action } from "babylonjs/Actions/action";
  10329. import { Condition } from "babylonjs/Actions/condition";
  10330. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10331. /**
  10332. * This defines an action responsible to toggle a boolean once triggered.
  10333. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10334. */
  10335. export class SwitchBooleanAction extends Action {
  10336. /**
  10337. * The path to the boolean property in the target object
  10338. */
  10339. propertyPath: string;
  10340. private _target;
  10341. private _effectiveTarget;
  10342. private _property;
  10343. /**
  10344. * Instantiate the action
  10345. * @param triggerOptions defines the trigger options
  10346. * @param target defines the object containing the boolean
  10347. * @param propertyPath defines the path to the boolean property in the target object
  10348. * @param condition defines the trigger related conditions
  10349. */
  10350. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10351. /** @hidden */
  10352. _prepare(): void;
  10353. /**
  10354. * Execute the action toggle the boolean value.
  10355. */
  10356. execute(): void;
  10357. /**
  10358. * Serializes the actions and its related information.
  10359. * @param parent defines the object to serialize in
  10360. * @returns the serialized object
  10361. */
  10362. serialize(parent: any): any;
  10363. }
  10364. /**
  10365. * This defines an action responsible to set a the state field of the target
  10366. * to a desired value once triggered.
  10367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10368. */
  10369. export class SetStateAction extends Action {
  10370. /**
  10371. * The value to store in the state field.
  10372. */
  10373. value: string;
  10374. private _target;
  10375. /**
  10376. * Instantiate the action
  10377. * @param triggerOptions defines the trigger options
  10378. * @param target defines the object containing the state property
  10379. * @param value defines the value to store in the state field
  10380. * @param condition defines the trigger related conditions
  10381. */
  10382. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10383. /**
  10384. * Execute the action and store the value on the target state property.
  10385. */
  10386. execute(): void;
  10387. /**
  10388. * Serializes the actions and its related information.
  10389. * @param parent defines the object to serialize in
  10390. * @returns the serialized object
  10391. */
  10392. serialize(parent: any): any;
  10393. }
  10394. /**
  10395. * This defines an action responsible to set a property of the target
  10396. * to a desired value once triggered.
  10397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10398. */
  10399. export class SetValueAction extends Action {
  10400. /**
  10401. * The path of the property to set in the target.
  10402. */
  10403. propertyPath: string;
  10404. /**
  10405. * The value to set in the property
  10406. */
  10407. value: any;
  10408. private _target;
  10409. private _effectiveTarget;
  10410. private _property;
  10411. /**
  10412. * Instantiate the action
  10413. * @param triggerOptions defines the trigger options
  10414. * @param target defines the object containing the property
  10415. * @param propertyPath defines the path of the property to set in the target
  10416. * @param value defines the value to set in the property
  10417. * @param condition defines the trigger related conditions
  10418. */
  10419. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10420. /** @hidden */
  10421. _prepare(): void;
  10422. /**
  10423. * Execute the action and set the targetted property to the desired value.
  10424. */
  10425. execute(): void;
  10426. /**
  10427. * Serializes the actions and its related information.
  10428. * @param parent defines the object to serialize in
  10429. * @returns the serialized object
  10430. */
  10431. serialize(parent: any): any;
  10432. }
  10433. /**
  10434. * This defines an action responsible to increment the target value
  10435. * to a desired value once triggered.
  10436. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10437. */
  10438. export class IncrementValueAction extends Action {
  10439. /**
  10440. * The path of the property to increment in the target.
  10441. */
  10442. propertyPath: string;
  10443. /**
  10444. * The value we should increment the property by.
  10445. */
  10446. value: any;
  10447. private _target;
  10448. private _effectiveTarget;
  10449. private _property;
  10450. /**
  10451. * Instantiate the action
  10452. * @param triggerOptions defines the trigger options
  10453. * @param target defines the object containing the property
  10454. * @param propertyPath defines the path of the property to increment in the target
  10455. * @param value defines the value value we should increment the property by
  10456. * @param condition defines the trigger related conditions
  10457. */
  10458. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10459. /** @hidden */
  10460. _prepare(): void;
  10461. /**
  10462. * Execute the action and increment the target of the value amount.
  10463. */
  10464. execute(): void;
  10465. /**
  10466. * Serializes the actions and its related information.
  10467. * @param parent defines the object to serialize in
  10468. * @returns the serialized object
  10469. */
  10470. serialize(parent: any): any;
  10471. }
  10472. /**
  10473. * This defines an action responsible to start an animation once triggered.
  10474. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10475. */
  10476. export class PlayAnimationAction extends Action {
  10477. /**
  10478. * Where the animation should start (animation frame)
  10479. */
  10480. from: number;
  10481. /**
  10482. * Where the animation should stop (animation frame)
  10483. */
  10484. to: number;
  10485. /**
  10486. * Define if the animation should loop or stop after the first play.
  10487. */
  10488. loop?: boolean;
  10489. private _target;
  10490. /**
  10491. * Instantiate the action
  10492. * @param triggerOptions defines the trigger options
  10493. * @param target defines the target animation or animation name
  10494. * @param from defines from where the animation should start (animation frame)
  10495. * @param end defines where the animation should stop (animation frame)
  10496. * @param loop defines if the animation should loop or stop after the first play
  10497. * @param condition defines the trigger related conditions
  10498. */
  10499. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10500. /** @hidden */
  10501. _prepare(): void;
  10502. /**
  10503. * Execute the action and play the animation.
  10504. */
  10505. execute(): void;
  10506. /**
  10507. * Serializes the actions and its related information.
  10508. * @param parent defines the object to serialize in
  10509. * @returns the serialized object
  10510. */
  10511. serialize(parent: any): any;
  10512. }
  10513. /**
  10514. * This defines an action responsible to stop an animation once triggered.
  10515. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10516. */
  10517. export class StopAnimationAction extends Action {
  10518. private _target;
  10519. /**
  10520. * Instantiate the action
  10521. * @param triggerOptions defines the trigger options
  10522. * @param target defines the target animation or animation name
  10523. * @param condition defines the trigger related conditions
  10524. */
  10525. constructor(triggerOptions: any, target: any, condition?: Condition);
  10526. /** @hidden */
  10527. _prepare(): void;
  10528. /**
  10529. * Execute the action and stop the animation.
  10530. */
  10531. execute(): void;
  10532. /**
  10533. * Serializes the actions and its related information.
  10534. * @param parent defines the object to serialize in
  10535. * @returns the serialized object
  10536. */
  10537. serialize(parent: any): any;
  10538. }
  10539. /**
  10540. * This defines an action responsible that does nothing once triggered.
  10541. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10542. */
  10543. export class DoNothingAction extends Action {
  10544. /**
  10545. * Instantiate the action
  10546. * @param triggerOptions defines the trigger options
  10547. * @param condition defines the trigger related conditions
  10548. */
  10549. constructor(triggerOptions?: any, condition?: Condition);
  10550. /**
  10551. * Execute the action and do nothing.
  10552. */
  10553. execute(): void;
  10554. /**
  10555. * Serializes the actions and its related information.
  10556. * @param parent defines the object to serialize in
  10557. * @returns the serialized object
  10558. */
  10559. serialize(parent: any): any;
  10560. }
  10561. /**
  10562. * This defines an action responsible to trigger several actions once triggered.
  10563. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10564. */
  10565. export class CombineAction extends Action {
  10566. /**
  10567. * The list of aggregated animations to run.
  10568. */
  10569. children: Action[];
  10570. /**
  10571. * Instantiate the action
  10572. * @param triggerOptions defines the trigger options
  10573. * @param children defines the list of aggregated animations to run
  10574. * @param condition defines the trigger related conditions
  10575. */
  10576. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10577. /** @hidden */
  10578. _prepare(): void;
  10579. /**
  10580. * Execute the action and executes all the aggregated actions.
  10581. */
  10582. execute(evt: ActionEvent): void;
  10583. /**
  10584. * Serializes the actions and its related information.
  10585. * @param parent defines the object to serialize in
  10586. * @returns the serialized object
  10587. */
  10588. serialize(parent: any): any;
  10589. }
  10590. /**
  10591. * This defines an action responsible to run code (external event) once triggered.
  10592. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10593. */
  10594. export class ExecuteCodeAction extends Action {
  10595. /**
  10596. * The callback function to run.
  10597. */
  10598. func: (evt: ActionEvent) => void;
  10599. /**
  10600. * Instantiate the action
  10601. * @param triggerOptions defines the trigger options
  10602. * @param func defines the callback function to run
  10603. * @param condition defines the trigger related conditions
  10604. */
  10605. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10606. /**
  10607. * Execute the action and run the attached code.
  10608. */
  10609. execute(evt: ActionEvent): void;
  10610. }
  10611. /**
  10612. * This defines an action responsible to set the parent property of the target once triggered.
  10613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10614. */
  10615. export class SetParentAction extends Action {
  10616. private _parent;
  10617. private _target;
  10618. /**
  10619. * Instantiate the action
  10620. * @param triggerOptions defines the trigger options
  10621. * @param target defines the target containing the parent property
  10622. * @param parent defines from where the animation should start (animation frame)
  10623. * @param condition defines the trigger related conditions
  10624. */
  10625. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10626. /** @hidden */
  10627. _prepare(): void;
  10628. /**
  10629. * Execute the action and set the parent property.
  10630. */
  10631. execute(): void;
  10632. /**
  10633. * Serializes the actions and its related information.
  10634. * @param parent defines the object to serialize in
  10635. * @returns the serialized object
  10636. */
  10637. serialize(parent: any): any;
  10638. }
  10639. }
  10640. declare module "babylonjs/Actions/actionManager" {
  10641. import { Nullable } from "babylonjs/types";
  10642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10643. import { Scene } from "babylonjs/scene";
  10644. import { IAction } from "babylonjs/Actions/action";
  10645. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10646. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10647. /**
  10648. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10649. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10650. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10651. */
  10652. export class ActionManager extends AbstractActionManager {
  10653. /**
  10654. * Nothing
  10655. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10656. */
  10657. static readonly NothingTrigger: number;
  10658. /**
  10659. * On pick
  10660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10661. */
  10662. static readonly OnPickTrigger: number;
  10663. /**
  10664. * On left pick
  10665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10666. */
  10667. static readonly OnLeftPickTrigger: number;
  10668. /**
  10669. * On right pick
  10670. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10671. */
  10672. static readonly OnRightPickTrigger: number;
  10673. /**
  10674. * On center pick
  10675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10676. */
  10677. static readonly OnCenterPickTrigger: number;
  10678. /**
  10679. * On pick down
  10680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10681. */
  10682. static readonly OnPickDownTrigger: number;
  10683. /**
  10684. * On double pick
  10685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10686. */
  10687. static readonly OnDoublePickTrigger: number;
  10688. /**
  10689. * On pick up
  10690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10691. */
  10692. static readonly OnPickUpTrigger: number;
  10693. /**
  10694. * On pick out.
  10695. * This trigger will only be raised if you also declared a OnPickDown
  10696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10697. */
  10698. static readonly OnPickOutTrigger: number;
  10699. /**
  10700. * On long press
  10701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10702. */
  10703. static readonly OnLongPressTrigger: number;
  10704. /**
  10705. * On pointer over
  10706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10707. */
  10708. static readonly OnPointerOverTrigger: number;
  10709. /**
  10710. * On pointer out
  10711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10712. */
  10713. static readonly OnPointerOutTrigger: number;
  10714. /**
  10715. * On every frame
  10716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10717. */
  10718. static readonly OnEveryFrameTrigger: number;
  10719. /**
  10720. * On intersection enter
  10721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10722. */
  10723. static readonly OnIntersectionEnterTrigger: number;
  10724. /**
  10725. * On intersection exit
  10726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10727. */
  10728. static readonly OnIntersectionExitTrigger: number;
  10729. /**
  10730. * On key down
  10731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10732. */
  10733. static readonly OnKeyDownTrigger: number;
  10734. /**
  10735. * On key up
  10736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10737. */
  10738. static readonly OnKeyUpTrigger: number;
  10739. private _scene;
  10740. /**
  10741. * Creates a new action manager
  10742. * @param scene defines the hosting scene
  10743. */
  10744. constructor(scene: Scene);
  10745. /**
  10746. * Releases all associated resources
  10747. */
  10748. dispose(): void;
  10749. /**
  10750. * Gets hosting scene
  10751. * @returns the hosting scene
  10752. */
  10753. getScene(): Scene;
  10754. /**
  10755. * Does this action manager handles actions of any of the given triggers
  10756. * @param triggers defines the triggers to be tested
  10757. * @return a boolean indicating whether one (or more) of the triggers is handled
  10758. */
  10759. hasSpecificTriggers(triggers: number[]): boolean;
  10760. /**
  10761. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10762. * speed.
  10763. * @param triggerA defines the trigger to be tested
  10764. * @param triggerB defines the trigger to be tested
  10765. * @return a boolean indicating whether one (or more) of the triggers is handled
  10766. */
  10767. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10768. /**
  10769. * Does this action manager handles actions of a given trigger
  10770. * @param trigger defines the trigger to be tested
  10771. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10772. * @return whether the trigger is handled
  10773. */
  10774. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10775. /**
  10776. * Does this action manager has pointer triggers
  10777. */
  10778. readonly hasPointerTriggers: boolean;
  10779. /**
  10780. * Does this action manager has pick triggers
  10781. */
  10782. readonly hasPickTriggers: boolean;
  10783. /**
  10784. * Registers an action to this action manager
  10785. * @param action defines the action to be registered
  10786. * @return the action amended (prepared) after registration
  10787. */
  10788. registerAction(action: IAction): Nullable<IAction>;
  10789. /**
  10790. * Unregisters an action to this action manager
  10791. * @param action defines the action to be unregistered
  10792. * @return a boolean indicating whether the action has been unregistered
  10793. */
  10794. unregisterAction(action: IAction): Boolean;
  10795. /**
  10796. * Process a specific trigger
  10797. * @param trigger defines the trigger to process
  10798. * @param evt defines the event details to be processed
  10799. */
  10800. processTrigger(trigger: number, evt?: IActionEvent): void;
  10801. /** @hidden */
  10802. _getEffectiveTarget(target: any, propertyPath: string): any;
  10803. /** @hidden */
  10804. _getProperty(propertyPath: string): string;
  10805. /**
  10806. * Serialize this manager to a JSON object
  10807. * @param name defines the property name to store this manager
  10808. * @returns a JSON representation of this manager
  10809. */
  10810. serialize(name: string): any;
  10811. /**
  10812. * Creates a new ActionManager from a JSON data
  10813. * @param parsedActions defines the JSON data to read from
  10814. * @param object defines the hosting mesh
  10815. * @param scene defines the hosting scene
  10816. */
  10817. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10818. /**
  10819. * Get a trigger name by index
  10820. * @param trigger defines the trigger index
  10821. * @returns a trigger name
  10822. */
  10823. static GetTriggerName(trigger: number): string;
  10824. }
  10825. }
  10826. declare module "babylonjs/Culling/ray" {
  10827. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10828. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10830. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10831. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10832. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10833. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10834. import { Plane } from "babylonjs/Maths/math.plane";
  10835. /**
  10836. * Class representing a ray with position and direction
  10837. */
  10838. export class Ray {
  10839. /** origin point */
  10840. origin: Vector3;
  10841. /** direction */
  10842. direction: Vector3;
  10843. /** length of the ray */
  10844. length: number;
  10845. private static readonly TmpVector3;
  10846. private _tmpRay;
  10847. /**
  10848. * Creates a new ray
  10849. * @param origin origin point
  10850. * @param direction direction
  10851. * @param length length of the ray
  10852. */
  10853. constructor(
  10854. /** origin point */
  10855. origin: Vector3,
  10856. /** direction */
  10857. direction: Vector3,
  10858. /** length of the ray */
  10859. length?: number);
  10860. /**
  10861. * Checks if the ray intersects a box
  10862. * @param minimum bound of the box
  10863. * @param maximum bound of the box
  10864. * @param intersectionTreshold extra extend to be added to the box in all direction
  10865. * @returns if the box was hit
  10866. */
  10867. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10868. /**
  10869. * Checks if the ray intersects a box
  10870. * @param box the bounding box to check
  10871. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10872. * @returns if the box was hit
  10873. */
  10874. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10875. /**
  10876. * If the ray hits a sphere
  10877. * @param sphere the bounding sphere to check
  10878. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10879. * @returns true if it hits the sphere
  10880. */
  10881. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10882. /**
  10883. * If the ray hits a triange
  10884. * @param vertex0 triangle vertex
  10885. * @param vertex1 triangle vertex
  10886. * @param vertex2 triangle vertex
  10887. * @returns intersection information if hit
  10888. */
  10889. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10890. /**
  10891. * Checks if ray intersects a plane
  10892. * @param plane the plane to check
  10893. * @returns the distance away it was hit
  10894. */
  10895. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10896. /**
  10897. * Calculate the intercept of a ray on a given axis
  10898. * @param axis to check 'x' | 'y' | 'z'
  10899. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10900. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10901. */
  10902. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10903. /**
  10904. * Checks if ray intersects a mesh
  10905. * @param mesh the mesh to check
  10906. * @param fastCheck if only the bounding box should checked
  10907. * @returns picking info of the intersecton
  10908. */
  10909. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10910. /**
  10911. * Checks if ray intersects a mesh
  10912. * @param meshes the meshes to check
  10913. * @param fastCheck if only the bounding box should checked
  10914. * @param results array to store result in
  10915. * @returns Array of picking infos
  10916. */
  10917. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10918. private _comparePickingInfo;
  10919. private static smallnum;
  10920. private static rayl;
  10921. /**
  10922. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10923. * @param sega the first point of the segment to test the intersection against
  10924. * @param segb the second point of the segment to test the intersection against
  10925. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10926. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10927. */
  10928. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10929. /**
  10930. * Update the ray from viewport position
  10931. * @param x position
  10932. * @param y y position
  10933. * @param viewportWidth viewport width
  10934. * @param viewportHeight viewport height
  10935. * @param world world matrix
  10936. * @param view view matrix
  10937. * @param projection projection matrix
  10938. * @returns this ray updated
  10939. */
  10940. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10941. /**
  10942. * Creates a ray with origin and direction of 0,0,0
  10943. * @returns the new ray
  10944. */
  10945. static Zero(): Ray;
  10946. /**
  10947. * Creates a new ray from screen space and viewport
  10948. * @param x position
  10949. * @param y y position
  10950. * @param viewportWidth viewport width
  10951. * @param viewportHeight viewport height
  10952. * @param world world matrix
  10953. * @param view view matrix
  10954. * @param projection projection matrix
  10955. * @returns new ray
  10956. */
  10957. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10958. /**
  10959. * 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
  10960. * transformed to the given world matrix.
  10961. * @param origin The origin point
  10962. * @param end The end point
  10963. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10964. * @returns the new ray
  10965. */
  10966. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10967. /**
  10968. * Transforms a ray by a matrix
  10969. * @param ray ray to transform
  10970. * @param matrix matrix to apply
  10971. * @returns the resulting new ray
  10972. */
  10973. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10974. /**
  10975. * Transforms a ray by a matrix
  10976. * @param ray ray to transform
  10977. * @param matrix matrix to apply
  10978. * @param result ray to store result in
  10979. */
  10980. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10981. /**
  10982. * Unproject a ray from screen space to object space
  10983. * @param sourceX defines the screen space x coordinate to use
  10984. * @param sourceY defines the screen space y coordinate to use
  10985. * @param viewportWidth defines the current width of the viewport
  10986. * @param viewportHeight defines the current height of the viewport
  10987. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10988. * @param view defines the view matrix to use
  10989. * @param projection defines the projection matrix to use
  10990. */
  10991. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10992. }
  10993. /**
  10994. * Type used to define predicate used to select faces when a mesh intersection is detected
  10995. */
  10996. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10997. module "babylonjs/scene" {
  10998. interface Scene {
  10999. /** @hidden */
  11000. _tempPickingRay: Nullable<Ray>;
  11001. /** @hidden */
  11002. _cachedRayForTransform: Ray;
  11003. /** @hidden */
  11004. _pickWithRayInverseMatrix: Matrix;
  11005. /** @hidden */
  11006. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11007. /** @hidden */
  11008. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11009. }
  11010. }
  11011. }
  11012. declare module "babylonjs/sceneComponent" {
  11013. import { Scene } from "babylonjs/scene";
  11014. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11015. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11016. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11017. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11018. import { Nullable } from "babylonjs/types";
  11019. import { Camera } from "babylonjs/Cameras/camera";
  11020. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11021. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11022. import { AbstractScene } from "babylonjs/abstractScene";
  11023. /**
  11024. * Groups all the scene component constants in one place to ease maintenance.
  11025. * @hidden
  11026. */
  11027. export class SceneComponentConstants {
  11028. static readonly NAME_EFFECTLAYER: string;
  11029. static readonly NAME_LAYER: string;
  11030. static readonly NAME_LENSFLARESYSTEM: string;
  11031. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11032. static readonly NAME_PARTICLESYSTEM: string;
  11033. static readonly NAME_GAMEPAD: string;
  11034. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11035. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11036. static readonly NAME_DEPTHRENDERER: string;
  11037. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11038. static readonly NAME_SPRITE: string;
  11039. static readonly NAME_OUTLINERENDERER: string;
  11040. static readonly NAME_PROCEDURALTEXTURE: string;
  11041. static readonly NAME_SHADOWGENERATOR: string;
  11042. static readonly NAME_OCTREE: string;
  11043. static readonly NAME_PHYSICSENGINE: string;
  11044. static readonly NAME_AUDIO: string;
  11045. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11046. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11047. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11048. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11049. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11050. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11051. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11052. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11053. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11054. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11055. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11056. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11057. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11058. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11059. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11060. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11061. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11062. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11063. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11064. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11065. static readonly STEP_AFTERRENDER_AUDIO: number;
  11066. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11067. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11068. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11069. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11070. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11071. static readonly STEP_POINTERMOVE_SPRITE: number;
  11072. static readonly STEP_POINTERDOWN_SPRITE: number;
  11073. static readonly STEP_POINTERUP_SPRITE: number;
  11074. }
  11075. /**
  11076. * This represents a scene component.
  11077. *
  11078. * This is used to decouple the dependency the scene is having on the different workloads like
  11079. * layers, post processes...
  11080. */
  11081. export interface ISceneComponent {
  11082. /**
  11083. * The name of the component. Each component must have a unique name.
  11084. */
  11085. name: string;
  11086. /**
  11087. * The scene the component belongs to.
  11088. */
  11089. scene: Scene;
  11090. /**
  11091. * Register the component to one instance of a scene.
  11092. */
  11093. register(): void;
  11094. /**
  11095. * Rebuilds the elements related to this component in case of
  11096. * context lost for instance.
  11097. */
  11098. rebuild(): void;
  11099. /**
  11100. * Disposes the component and the associated ressources.
  11101. */
  11102. dispose(): void;
  11103. }
  11104. /**
  11105. * This represents a SERIALIZABLE scene component.
  11106. *
  11107. * This extends Scene Component to add Serialization methods on top.
  11108. */
  11109. export interface ISceneSerializableComponent extends ISceneComponent {
  11110. /**
  11111. * Adds all the elements from the container to the scene
  11112. * @param container the container holding the elements
  11113. */
  11114. addFromContainer(container: AbstractScene): void;
  11115. /**
  11116. * Removes all the elements in the container from the scene
  11117. * @param container contains the elements to remove
  11118. * @param dispose if the removed element should be disposed (default: false)
  11119. */
  11120. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11121. /**
  11122. * Serializes the component data to the specified json object
  11123. * @param serializationObject The object to serialize to
  11124. */
  11125. serialize(serializationObject: any): void;
  11126. }
  11127. /**
  11128. * Strong typing of a Mesh related stage step action
  11129. */
  11130. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11131. /**
  11132. * Strong typing of a Evaluate Sub Mesh related stage step action
  11133. */
  11134. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11135. /**
  11136. * Strong typing of a Active Mesh related stage step action
  11137. */
  11138. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11139. /**
  11140. * Strong typing of a Camera related stage step action
  11141. */
  11142. export type CameraStageAction = (camera: Camera) => void;
  11143. /**
  11144. * Strong typing of a Camera Frame buffer related stage step action
  11145. */
  11146. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11147. /**
  11148. * Strong typing of a Render Target related stage step action
  11149. */
  11150. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11151. /**
  11152. * Strong typing of a RenderingGroup related stage step action
  11153. */
  11154. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11155. /**
  11156. * Strong typing of a Mesh Render related stage step action
  11157. */
  11158. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11159. /**
  11160. * Strong typing of a simple stage step action
  11161. */
  11162. export type SimpleStageAction = () => void;
  11163. /**
  11164. * Strong typing of a render target action.
  11165. */
  11166. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11167. /**
  11168. * Strong typing of a pointer move action.
  11169. */
  11170. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11171. /**
  11172. * Strong typing of a pointer up/down action.
  11173. */
  11174. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11175. /**
  11176. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11177. * @hidden
  11178. */
  11179. export class Stage<T extends Function> extends Array<{
  11180. index: number;
  11181. component: ISceneComponent;
  11182. action: T;
  11183. }> {
  11184. /**
  11185. * Hide ctor from the rest of the world.
  11186. * @param items The items to add.
  11187. */
  11188. private constructor();
  11189. /**
  11190. * Creates a new Stage.
  11191. * @returns A new instance of a Stage
  11192. */
  11193. static Create<T extends Function>(): Stage<T>;
  11194. /**
  11195. * Registers a step in an ordered way in the targeted stage.
  11196. * @param index Defines the position to register the step in
  11197. * @param component Defines the component attached to the step
  11198. * @param action Defines the action to launch during the step
  11199. */
  11200. registerStep(index: number, component: ISceneComponent, action: T): void;
  11201. /**
  11202. * Clears all the steps from the stage.
  11203. */
  11204. clear(): void;
  11205. }
  11206. }
  11207. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11208. import { Nullable } from "babylonjs/types";
  11209. import { Observable } from "babylonjs/Misc/observable";
  11210. import { Scene } from "babylonjs/scene";
  11211. import { Sprite } from "babylonjs/Sprites/sprite";
  11212. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11213. import { Ray } from "babylonjs/Culling/ray";
  11214. import { Camera } from "babylonjs/Cameras/camera";
  11215. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11216. import { ISceneComponent } from "babylonjs/sceneComponent";
  11217. module "babylonjs/scene" {
  11218. interface Scene {
  11219. /** @hidden */
  11220. _pointerOverSprite: Nullable<Sprite>;
  11221. /** @hidden */
  11222. _pickedDownSprite: Nullable<Sprite>;
  11223. /** @hidden */
  11224. _tempSpritePickingRay: Nullable<Ray>;
  11225. /**
  11226. * All of the sprite managers added to this scene
  11227. * @see http://doc.babylonjs.com/babylon101/sprites
  11228. */
  11229. spriteManagers: Array<ISpriteManager>;
  11230. /**
  11231. * An event triggered when sprites rendering is about to start
  11232. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11233. */
  11234. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11235. /**
  11236. * An event triggered when sprites rendering is done
  11237. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11238. */
  11239. onAfterSpritesRenderingObservable: Observable<Scene>;
  11240. /** @hidden */
  11241. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11242. /** Launch a ray to try to pick a sprite in the scene
  11243. * @param x position on screen
  11244. * @param y position on screen
  11245. * @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
  11246. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11247. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11248. * @returns a PickingInfo
  11249. */
  11250. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11251. /** Use the given ray to pick a sprite in the scene
  11252. * @param ray The ray (in world space) to use to pick meshes
  11253. * @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
  11254. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11255. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11256. * @returns a PickingInfo
  11257. */
  11258. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11259. /** @hidden */
  11260. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11261. /** Launch a ray to try to pick sprites in the scene
  11262. * @param x position on screen
  11263. * @param y position on screen
  11264. * @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
  11265. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11266. * @returns a PickingInfo array
  11267. */
  11268. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11269. /** Use the given ray to pick sprites in the scene
  11270. * @param ray The ray (in world space) to use to pick meshes
  11271. * @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
  11272. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11273. * @returns a PickingInfo array
  11274. */
  11275. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11276. /**
  11277. * Force the sprite under the pointer
  11278. * @param sprite defines the sprite to use
  11279. */
  11280. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11281. /**
  11282. * Gets the sprite under the pointer
  11283. * @returns a Sprite or null if no sprite is under the pointer
  11284. */
  11285. getPointerOverSprite(): Nullable<Sprite>;
  11286. }
  11287. }
  11288. /**
  11289. * Defines the sprite scene component responsible to manage sprites
  11290. * in a given scene.
  11291. */
  11292. export class SpriteSceneComponent implements ISceneComponent {
  11293. /**
  11294. * The component name helpfull to identify the component in the list of scene components.
  11295. */
  11296. readonly name: string;
  11297. /**
  11298. * The scene the component belongs to.
  11299. */
  11300. scene: Scene;
  11301. /** @hidden */
  11302. private _spritePredicate;
  11303. /**
  11304. * Creates a new instance of the component for the given scene
  11305. * @param scene Defines the scene to register the component in
  11306. */
  11307. constructor(scene: Scene);
  11308. /**
  11309. * Registers the component in a given scene
  11310. */
  11311. register(): void;
  11312. /**
  11313. * Rebuilds the elements related to this component in case of
  11314. * context lost for instance.
  11315. */
  11316. rebuild(): void;
  11317. /**
  11318. * Disposes the component and the associated ressources.
  11319. */
  11320. dispose(): void;
  11321. private _pickSpriteButKeepRay;
  11322. private _pointerMove;
  11323. private _pointerDown;
  11324. private _pointerUp;
  11325. }
  11326. }
  11327. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11328. /** @hidden */
  11329. export var fogFragmentDeclaration: {
  11330. name: string;
  11331. shader: string;
  11332. };
  11333. }
  11334. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11335. /** @hidden */
  11336. export var fogFragment: {
  11337. name: string;
  11338. shader: string;
  11339. };
  11340. }
  11341. declare module "babylonjs/Shaders/sprites.fragment" {
  11342. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11343. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11344. /** @hidden */
  11345. export var spritesPixelShader: {
  11346. name: string;
  11347. shader: string;
  11348. };
  11349. }
  11350. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11351. /** @hidden */
  11352. export var fogVertexDeclaration: {
  11353. name: string;
  11354. shader: string;
  11355. };
  11356. }
  11357. declare module "babylonjs/Shaders/sprites.vertex" {
  11358. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11359. /** @hidden */
  11360. export var spritesVertexShader: {
  11361. name: string;
  11362. shader: string;
  11363. };
  11364. }
  11365. declare module "babylonjs/Sprites/spriteManager" {
  11366. import { IDisposable, Scene } from "babylonjs/scene";
  11367. import { Nullable } from "babylonjs/types";
  11368. import { Observable } from "babylonjs/Misc/observable";
  11369. import { Sprite } from "babylonjs/Sprites/sprite";
  11370. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11371. import { Camera } from "babylonjs/Cameras/camera";
  11372. import { Texture } from "babylonjs/Materials/Textures/texture";
  11373. import "babylonjs/Shaders/sprites.fragment";
  11374. import "babylonjs/Shaders/sprites.vertex";
  11375. import { Ray } from "babylonjs/Culling/ray";
  11376. /**
  11377. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11378. */
  11379. export interface ISpriteManager extends IDisposable {
  11380. /**
  11381. * Restricts the camera to viewing objects with the same layerMask.
  11382. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11383. */
  11384. layerMask: number;
  11385. /**
  11386. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11387. */
  11388. isPickable: boolean;
  11389. /**
  11390. * Specifies the rendering group id for this mesh (0 by default)
  11391. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11392. */
  11393. renderingGroupId: number;
  11394. /**
  11395. * Defines the list of sprites managed by the manager.
  11396. */
  11397. sprites: Array<Sprite>;
  11398. /**
  11399. * Tests the intersection of a sprite with a specific ray.
  11400. * @param ray The ray we are sending to test the collision
  11401. * @param camera The camera space we are sending rays in
  11402. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11403. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11404. * @returns picking info or null.
  11405. */
  11406. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11407. /**
  11408. * Intersects the sprites with a ray
  11409. * @param ray defines the ray to intersect with
  11410. * @param camera defines the current active camera
  11411. * @param predicate defines a predicate used to select candidate sprites
  11412. * @returns null if no hit or a PickingInfo array
  11413. */
  11414. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11415. /**
  11416. * Renders the list of sprites on screen.
  11417. */
  11418. render(): void;
  11419. }
  11420. /**
  11421. * Class used to manage multiple sprites on the same spritesheet
  11422. * @see http://doc.babylonjs.com/babylon101/sprites
  11423. */
  11424. export class SpriteManager implements ISpriteManager {
  11425. /** defines the manager's name */
  11426. name: string;
  11427. /** Gets the list of sprites */
  11428. sprites: Sprite[];
  11429. /** Gets or sets the rendering group id (0 by default) */
  11430. renderingGroupId: number;
  11431. /** Gets or sets camera layer mask */
  11432. layerMask: number;
  11433. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11434. fogEnabled: boolean;
  11435. /** Gets or sets a boolean indicating if the sprites are pickable */
  11436. isPickable: boolean;
  11437. /** Defines the default width of a cell in the spritesheet */
  11438. cellWidth: number;
  11439. /** Defines the default height of a cell in the spritesheet */
  11440. cellHeight: number;
  11441. /** Associative array from JSON sprite data file */
  11442. private _cellData;
  11443. /** Array of sprite names from JSON sprite data file */
  11444. private _spriteMap;
  11445. /** True when packed cell data from JSON file is ready*/
  11446. private _packedAndReady;
  11447. /**
  11448. * An event triggered when the manager is disposed.
  11449. */
  11450. onDisposeObservable: Observable<SpriteManager>;
  11451. private _onDisposeObserver;
  11452. /**
  11453. * Callback called when the manager is disposed
  11454. */
  11455. onDispose: () => void;
  11456. private _capacity;
  11457. private _fromPacked;
  11458. private _spriteTexture;
  11459. private _epsilon;
  11460. private _scene;
  11461. private _vertexData;
  11462. private _buffer;
  11463. private _vertexBuffers;
  11464. private _indexBuffer;
  11465. private _effectBase;
  11466. private _effectFog;
  11467. /**
  11468. * Gets or sets the spritesheet texture
  11469. */
  11470. texture: Texture;
  11471. /**
  11472. * Creates a new sprite manager
  11473. * @param name defines the manager's name
  11474. * @param imgUrl defines the sprite sheet url
  11475. * @param capacity defines the maximum allowed number of sprites
  11476. * @param cellSize defines the size of a sprite cell
  11477. * @param scene defines the hosting scene
  11478. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11479. * @param samplingMode defines the smapling mode to use with spritesheet
  11480. * @param fromPacked set to false; do not alter
  11481. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11482. */
  11483. constructor(
  11484. /** defines the manager's name */
  11485. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11486. private _makePacked;
  11487. private _appendSpriteVertex;
  11488. /**
  11489. * Intersects the sprites with a ray
  11490. * @param ray defines the ray to intersect with
  11491. * @param camera defines the current active camera
  11492. * @param predicate defines a predicate used to select candidate sprites
  11493. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11494. * @returns null if no hit or a PickingInfo
  11495. */
  11496. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11497. /**
  11498. * Intersects the sprites with a ray
  11499. * @param ray defines the ray to intersect with
  11500. * @param camera defines the current active camera
  11501. * @param predicate defines a predicate used to select candidate sprites
  11502. * @returns null if no hit or a PickingInfo array
  11503. */
  11504. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11505. /**
  11506. * Render all child sprites
  11507. */
  11508. render(): void;
  11509. /**
  11510. * Release associated resources
  11511. */
  11512. dispose(): void;
  11513. }
  11514. }
  11515. declare module "babylonjs/Sprites/sprite" {
  11516. import { Vector3 } from "babylonjs/Maths/math.vector";
  11517. import { Nullable } from "babylonjs/types";
  11518. import { ActionManager } from "babylonjs/Actions/actionManager";
  11519. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11520. import { Color4 } from "babylonjs/Maths/math.color";
  11521. /**
  11522. * Class used to represent a sprite
  11523. * @see http://doc.babylonjs.com/babylon101/sprites
  11524. */
  11525. export class Sprite {
  11526. /** defines the name */
  11527. name: string;
  11528. /** Gets or sets the current world position */
  11529. position: Vector3;
  11530. /** Gets or sets the main color */
  11531. color: Color4;
  11532. /** Gets or sets the width */
  11533. width: number;
  11534. /** Gets or sets the height */
  11535. height: number;
  11536. /** Gets or sets rotation angle */
  11537. angle: number;
  11538. /** Gets or sets the cell index in the sprite sheet */
  11539. cellIndex: number;
  11540. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11541. cellRef: string;
  11542. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11543. invertU: number;
  11544. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11545. invertV: number;
  11546. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11547. disposeWhenFinishedAnimating: boolean;
  11548. /** Gets the list of attached animations */
  11549. animations: Animation[];
  11550. /** Gets or sets a boolean indicating if the sprite can be picked */
  11551. isPickable: boolean;
  11552. /**
  11553. * Gets or sets the associated action manager
  11554. */
  11555. actionManager: Nullable<ActionManager>;
  11556. private _animationStarted;
  11557. private _loopAnimation;
  11558. private _fromIndex;
  11559. private _toIndex;
  11560. private _delay;
  11561. private _direction;
  11562. private _manager;
  11563. private _time;
  11564. private _onAnimationEnd;
  11565. /**
  11566. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11567. */
  11568. isVisible: boolean;
  11569. /**
  11570. * Gets or sets the sprite size
  11571. */
  11572. size: number;
  11573. /**
  11574. * Creates a new Sprite
  11575. * @param name defines the name
  11576. * @param manager defines the manager
  11577. */
  11578. constructor(
  11579. /** defines the name */
  11580. name: string, manager: ISpriteManager);
  11581. /**
  11582. * Starts an animation
  11583. * @param from defines the initial key
  11584. * @param to defines the end key
  11585. * @param loop defines if the animation must loop
  11586. * @param delay defines the start delay (in ms)
  11587. * @param onAnimationEnd defines a callback to call when animation ends
  11588. */
  11589. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11590. /** Stops current animation (if any) */
  11591. stopAnimation(): void;
  11592. /** @hidden */
  11593. _animate(deltaTime: number): void;
  11594. /** Release associated resources */
  11595. dispose(): void;
  11596. }
  11597. }
  11598. declare module "babylonjs/Collisions/pickingInfo" {
  11599. import { Nullable } from "babylonjs/types";
  11600. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11602. import { Sprite } from "babylonjs/Sprites/sprite";
  11603. import { Ray } from "babylonjs/Culling/ray";
  11604. /**
  11605. * Information about the result of picking within a scene
  11606. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11607. */
  11608. export class PickingInfo {
  11609. /** @hidden */
  11610. _pickingUnavailable: boolean;
  11611. /**
  11612. * If the pick collided with an object
  11613. */
  11614. hit: boolean;
  11615. /**
  11616. * Distance away where the pick collided
  11617. */
  11618. distance: number;
  11619. /**
  11620. * The location of pick collision
  11621. */
  11622. pickedPoint: Nullable<Vector3>;
  11623. /**
  11624. * The mesh corresponding the the pick collision
  11625. */
  11626. pickedMesh: Nullable<AbstractMesh>;
  11627. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11628. bu: number;
  11629. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11630. bv: number;
  11631. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11632. faceId: number;
  11633. /** Id of the the submesh that was picked */
  11634. subMeshId: number;
  11635. /** If a sprite was picked, this will be the sprite the pick collided with */
  11636. pickedSprite: Nullable<Sprite>;
  11637. /**
  11638. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11639. */
  11640. originMesh: Nullable<AbstractMesh>;
  11641. /**
  11642. * The ray that was used to perform the picking.
  11643. */
  11644. ray: Nullable<Ray>;
  11645. /**
  11646. * Gets the normal correspodning to the face the pick collided with
  11647. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11648. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11649. * @returns The normal correspodning to the face the pick collided with
  11650. */
  11651. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11652. /**
  11653. * Gets the texture coordinates of where the pick occured
  11654. * @returns the vector containing the coordnates of the texture
  11655. */
  11656. getTextureCoordinates(): Nullable<Vector2>;
  11657. }
  11658. }
  11659. declare module "babylonjs/Events/pointerEvents" {
  11660. import { Nullable } from "babylonjs/types";
  11661. import { Vector2 } from "babylonjs/Maths/math.vector";
  11662. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11663. import { Ray } from "babylonjs/Culling/ray";
  11664. /**
  11665. * Gather the list of pointer event types as constants.
  11666. */
  11667. export class PointerEventTypes {
  11668. /**
  11669. * 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.
  11670. */
  11671. static readonly POINTERDOWN: number;
  11672. /**
  11673. * The pointerup event is fired when a pointer is no longer active.
  11674. */
  11675. static readonly POINTERUP: number;
  11676. /**
  11677. * The pointermove event is fired when a pointer changes coordinates.
  11678. */
  11679. static readonly POINTERMOVE: number;
  11680. /**
  11681. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11682. */
  11683. static readonly POINTERWHEEL: number;
  11684. /**
  11685. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11686. */
  11687. static readonly POINTERPICK: number;
  11688. /**
  11689. * The pointertap event is fired when a the object has been touched and released without drag.
  11690. */
  11691. static readonly POINTERTAP: number;
  11692. /**
  11693. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11694. */
  11695. static readonly POINTERDOUBLETAP: number;
  11696. }
  11697. /**
  11698. * Base class of pointer info types.
  11699. */
  11700. export class PointerInfoBase {
  11701. /**
  11702. * Defines the type of event (PointerEventTypes)
  11703. */
  11704. type: number;
  11705. /**
  11706. * Defines the related dom event
  11707. */
  11708. event: PointerEvent | MouseWheelEvent;
  11709. /**
  11710. * Instantiates the base class of pointers info.
  11711. * @param type Defines the type of event (PointerEventTypes)
  11712. * @param event Defines the related dom event
  11713. */
  11714. constructor(
  11715. /**
  11716. * Defines the type of event (PointerEventTypes)
  11717. */
  11718. type: number,
  11719. /**
  11720. * Defines the related dom event
  11721. */
  11722. event: PointerEvent | MouseWheelEvent);
  11723. }
  11724. /**
  11725. * This class is used to store pointer related info for the onPrePointerObservable event.
  11726. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11727. */
  11728. export class PointerInfoPre extends PointerInfoBase {
  11729. /**
  11730. * Ray from a pointer if availible (eg. 6dof controller)
  11731. */
  11732. ray: Nullable<Ray>;
  11733. /**
  11734. * Defines the local position of the pointer on the canvas.
  11735. */
  11736. localPosition: Vector2;
  11737. /**
  11738. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11739. */
  11740. skipOnPointerObservable: boolean;
  11741. /**
  11742. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11743. * @param type Defines the type of event (PointerEventTypes)
  11744. * @param event Defines the related dom event
  11745. * @param localX Defines the local x coordinates of the pointer when the event occured
  11746. * @param localY Defines the local y coordinates of the pointer when the event occured
  11747. */
  11748. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11749. }
  11750. /**
  11751. * This type contains all the data related to a pointer event in Babylon.js.
  11752. * 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.
  11753. */
  11754. export class PointerInfo extends PointerInfoBase {
  11755. /**
  11756. * Defines the picking info associated to the info (if any)\
  11757. */
  11758. pickInfo: Nullable<PickingInfo>;
  11759. /**
  11760. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11761. * @param type Defines the type of event (PointerEventTypes)
  11762. * @param event Defines the related dom event
  11763. * @param pickInfo Defines the picking info associated to the info (if any)\
  11764. */
  11765. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11766. /**
  11767. * Defines the picking info associated to the info (if any)\
  11768. */
  11769. pickInfo: Nullable<PickingInfo>);
  11770. }
  11771. /**
  11772. * Data relating to a touch event on the screen.
  11773. */
  11774. export interface PointerTouch {
  11775. /**
  11776. * X coordinate of touch.
  11777. */
  11778. x: number;
  11779. /**
  11780. * Y coordinate of touch.
  11781. */
  11782. y: number;
  11783. /**
  11784. * Id of touch. Unique for each finger.
  11785. */
  11786. pointerId: number;
  11787. /**
  11788. * Event type passed from DOM.
  11789. */
  11790. type: any;
  11791. }
  11792. }
  11793. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11794. import { Observable } from "babylonjs/Misc/observable";
  11795. import { Nullable } from "babylonjs/types";
  11796. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11797. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11798. /**
  11799. * Manage the mouse inputs to control the movement of a free camera.
  11800. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11801. */
  11802. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11803. /**
  11804. * Define if touch is enabled in the mouse input
  11805. */
  11806. touchEnabled: boolean;
  11807. /**
  11808. * Defines the camera the input is attached to.
  11809. */
  11810. camera: FreeCamera;
  11811. /**
  11812. * Defines the buttons associated with the input to handle camera move.
  11813. */
  11814. buttons: number[];
  11815. /**
  11816. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11817. */
  11818. angularSensibility: number;
  11819. private _pointerInput;
  11820. private _onMouseMove;
  11821. private _observer;
  11822. private previousPosition;
  11823. /**
  11824. * Observable for when a pointer move event occurs containing the move offset
  11825. */
  11826. onPointerMovedObservable: Observable<{
  11827. offsetX: number;
  11828. offsetY: number;
  11829. }>;
  11830. /**
  11831. * @hidden
  11832. * If the camera should be rotated automatically based on pointer movement
  11833. */
  11834. _allowCameraRotation: boolean;
  11835. /**
  11836. * Manage the mouse inputs to control the movement of a free camera.
  11837. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11838. * @param touchEnabled Defines if touch is enabled or not
  11839. */
  11840. constructor(
  11841. /**
  11842. * Define if touch is enabled in the mouse input
  11843. */
  11844. touchEnabled?: boolean);
  11845. /**
  11846. * Attach the input controls to a specific dom element to get the input from.
  11847. * @param element Defines the element the controls should be listened from
  11848. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11849. */
  11850. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11851. /**
  11852. * Called on JS contextmenu event.
  11853. * Override this method to provide functionality.
  11854. */
  11855. protected onContextMenu(evt: PointerEvent): void;
  11856. /**
  11857. * Detach the current controls from the specified dom element.
  11858. * @param element Defines the element to stop listening the inputs from
  11859. */
  11860. detachControl(element: Nullable<HTMLElement>): void;
  11861. /**
  11862. * Gets the class name of the current intput.
  11863. * @returns the class name
  11864. */
  11865. getClassName(): string;
  11866. /**
  11867. * Get the friendly name associated with the input class.
  11868. * @returns the input friendly name
  11869. */
  11870. getSimpleName(): string;
  11871. }
  11872. }
  11873. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  11874. import { Nullable } from "babylonjs/types";
  11875. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11876. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11877. /**
  11878. * Manage the touch inputs to control the movement of a free camera.
  11879. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11880. */
  11881. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11882. /**
  11883. * Defines the camera the input is attached to.
  11884. */
  11885. camera: FreeCamera;
  11886. /**
  11887. * Defines the touch sensibility for rotation.
  11888. * The higher the faster.
  11889. */
  11890. touchAngularSensibility: number;
  11891. /**
  11892. * Defines the touch sensibility for move.
  11893. * The higher the faster.
  11894. */
  11895. touchMoveSensibility: number;
  11896. private _offsetX;
  11897. private _offsetY;
  11898. private _pointerPressed;
  11899. private _pointerInput;
  11900. private _observer;
  11901. private _onLostFocus;
  11902. /**
  11903. * Attach the input controls to a specific dom element to get the input from.
  11904. * @param element Defines the element the controls should be listened from
  11905. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11906. */
  11907. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11908. /**
  11909. * Detach the current controls from the specified dom element.
  11910. * @param element Defines the element to stop listening the inputs from
  11911. */
  11912. detachControl(element: Nullable<HTMLElement>): void;
  11913. /**
  11914. * Update the current camera state depending on the inputs that have been used this frame.
  11915. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11916. */
  11917. checkInputs(): void;
  11918. /**
  11919. * Gets the class name of the current intput.
  11920. * @returns the class name
  11921. */
  11922. getClassName(): string;
  11923. /**
  11924. * Get the friendly name associated with the input class.
  11925. * @returns the input friendly name
  11926. */
  11927. getSimpleName(): string;
  11928. }
  11929. }
  11930. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  11931. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11932. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  11933. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  11934. import { Nullable } from "babylonjs/types";
  11935. /**
  11936. * Default Inputs manager for the FreeCamera.
  11937. * It groups all the default supported inputs for ease of use.
  11938. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11939. */
  11940. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11941. /**
  11942. * @hidden
  11943. */
  11944. _mouseInput: Nullable<FreeCameraMouseInput>;
  11945. /**
  11946. * Instantiates a new FreeCameraInputsManager.
  11947. * @param camera Defines the camera the inputs belong to
  11948. */
  11949. constructor(camera: FreeCamera);
  11950. /**
  11951. * Add keyboard input support to the input manager.
  11952. * @returns the current input manager
  11953. */
  11954. addKeyboard(): FreeCameraInputsManager;
  11955. /**
  11956. * Add mouse input support to the input manager.
  11957. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11958. * @returns the current input manager
  11959. */
  11960. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11961. /**
  11962. * Removes the mouse input support from the manager
  11963. * @returns the current input manager
  11964. */
  11965. removeMouse(): FreeCameraInputsManager;
  11966. /**
  11967. * Add touch input support to the input manager.
  11968. * @returns the current input manager
  11969. */
  11970. addTouch(): FreeCameraInputsManager;
  11971. /**
  11972. * Remove all attached input methods from a camera
  11973. */
  11974. clear(): void;
  11975. }
  11976. }
  11977. declare module "babylonjs/Cameras/freeCamera" {
  11978. import { Vector3 } from "babylonjs/Maths/math.vector";
  11979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11980. import { Scene } from "babylonjs/scene";
  11981. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  11982. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  11983. /**
  11984. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11985. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11986. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11987. */
  11988. export class FreeCamera extends TargetCamera {
  11989. /**
  11990. * Define the collision ellipsoid of the camera.
  11991. * This is helpful to simulate a camera body like the player body around the camera
  11992. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11993. */
  11994. ellipsoid: Vector3;
  11995. /**
  11996. * Define an offset for the position of the ellipsoid around the camera.
  11997. * This can be helpful to determine the center of the body near the gravity center of the body
  11998. * instead of its head.
  11999. */
  12000. ellipsoidOffset: Vector3;
  12001. /**
  12002. * Enable or disable collisions of the camera with the rest of the scene objects.
  12003. */
  12004. checkCollisions: boolean;
  12005. /**
  12006. * Enable or disable gravity on the camera.
  12007. */
  12008. applyGravity: boolean;
  12009. /**
  12010. * Define the input manager associated to the camera.
  12011. */
  12012. inputs: FreeCameraInputsManager;
  12013. /**
  12014. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12015. * Higher values reduce sensitivity.
  12016. */
  12017. /**
  12018. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12019. * Higher values reduce sensitivity.
  12020. */
  12021. angularSensibility: number;
  12022. /**
  12023. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12024. */
  12025. keysUp: number[];
  12026. /**
  12027. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12028. */
  12029. keysDown: number[];
  12030. /**
  12031. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12032. */
  12033. keysLeft: number[];
  12034. /**
  12035. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12036. */
  12037. keysRight: number[];
  12038. /**
  12039. * Event raised when the camera collide with a mesh in the scene.
  12040. */
  12041. onCollide: (collidedMesh: AbstractMesh) => void;
  12042. private _collider;
  12043. private _needMoveForGravity;
  12044. private _oldPosition;
  12045. private _diffPosition;
  12046. private _newPosition;
  12047. /** @hidden */
  12048. _localDirection: Vector3;
  12049. /** @hidden */
  12050. _transformedDirection: Vector3;
  12051. /**
  12052. * Instantiates a Free Camera.
  12053. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12054. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12055. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12056. * @param name Define the name of the camera in the scene
  12057. * @param position Define the start position of the camera in the scene
  12058. * @param scene Define the scene the camera belongs to
  12059. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12060. */
  12061. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12062. /**
  12063. * Attached controls to the current camera.
  12064. * @param element Defines the element the controls should be listened from
  12065. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12066. */
  12067. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12068. /**
  12069. * Detach the current controls from the camera.
  12070. * The camera will stop reacting to inputs.
  12071. * @param element Defines the element to stop listening the inputs from
  12072. */
  12073. detachControl(element: HTMLElement): void;
  12074. private _collisionMask;
  12075. /**
  12076. * Define a collision mask to limit the list of object the camera can collide with
  12077. */
  12078. collisionMask: number;
  12079. /** @hidden */
  12080. _collideWithWorld(displacement: Vector3): void;
  12081. private _onCollisionPositionChange;
  12082. /** @hidden */
  12083. _checkInputs(): void;
  12084. /** @hidden */
  12085. _decideIfNeedsToMove(): boolean;
  12086. /** @hidden */
  12087. _updatePosition(): void;
  12088. /**
  12089. * Destroy the camera and release the current resources hold by it.
  12090. */
  12091. dispose(): void;
  12092. /**
  12093. * Gets the current object class name.
  12094. * @return the class name
  12095. */
  12096. getClassName(): string;
  12097. }
  12098. }
  12099. declare module "babylonjs/Gamepads/gamepad" {
  12100. import { Observable } from "babylonjs/Misc/observable";
  12101. /**
  12102. * Represents a gamepad control stick position
  12103. */
  12104. export class StickValues {
  12105. /**
  12106. * The x component of the control stick
  12107. */
  12108. x: number;
  12109. /**
  12110. * The y component of the control stick
  12111. */
  12112. y: number;
  12113. /**
  12114. * Initializes the gamepad x and y control stick values
  12115. * @param x The x component of the gamepad control stick value
  12116. * @param y The y component of the gamepad control stick value
  12117. */
  12118. constructor(
  12119. /**
  12120. * The x component of the control stick
  12121. */
  12122. x: number,
  12123. /**
  12124. * The y component of the control stick
  12125. */
  12126. y: number);
  12127. }
  12128. /**
  12129. * An interface which manages callbacks for gamepad button changes
  12130. */
  12131. export interface GamepadButtonChanges {
  12132. /**
  12133. * Called when a gamepad has been changed
  12134. */
  12135. changed: boolean;
  12136. /**
  12137. * Called when a gamepad press event has been triggered
  12138. */
  12139. pressChanged: boolean;
  12140. /**
  12141. * Called when a touch event has been triggered
  12142. */
  12143. touchChanged: boolean;
  12144. /**
  12145. * Called when a value has changed
  12146. */
  12147. valueChanged: boolean;
  12148. }
  12149. /**
  12150. * Represents a gamepad
  12151. */
  12152. export class Gamepad {
  12153. /**
  12154. * The id of the gamepad
  12155. */
  12156. id: string;
  12157. /**
  12158. * The index of the gamepad
  12159. */
  12160. index: number;
  12161. /**
  12162. * The browser gamepad
  12163. */
  12164. browserGamepad: any;
  12165. /**
  12166. * Specifies what type of gamepad this represents
  12167. */
  12168. type: number;
  12169. private _leftStick;
  12170. private _rightStick;
  12171. /** @hidden */
  12172. _isConnected: boolean;
  12173. private _leftStickAxisX;
  12174. private _leftStickAxisY;
  12175. private _rightStickAxisX;
  12176. private _rightStickAxisY;
  12177. /**
  12178. * Triggered when the left control stick has been changed
  12179. */
  12180. private _onleftstickchanged;
  12181. /**
  12182. * Triggered when the right control stick has been changed
  12183. */
  12184. private _onrightstickchanged;
  12185. /**
  12186. * Represents a gamepad controller
  12187. */
  12188. static GAMEPAD: number;
  12189. /**
  12190. * Represents a generic controller
  12191. */
  12192. static GENERIC: number;
  12193. /**
  12194. * Represents an XBox controller
  12195. */
  12196. static XBOX: number;
  12197. /**
  12198. * Represents a pose-enabled controller
  12199. */
  12200. static POSE_ENABLED: number;
  12201. /**
  12202. * Represents an Dual Shock controller
  12203. */
  12204. static DUALSHOCK: number;
  12205. /**
  12206. * Specifies whether the left control stick should be Y-inverted
  12207. */
  12208. protected _invertLeftStickY: boolean;
  12209. /**
  12210. * Specifies if the gamepad has been connected
  12211. */
  12212. readonly isConnected: boolean;
  12213. /**
  12214. * Initializes the gamepad
  12215. * @param id The id of the gamepad
  12216. * @param index The index of the gamepad
  12217. * @param browserGamepad The browser gamepad
  12218. * @param leftStickX The x component of the left joystick
  12219. * @param leftStickY The y component of the left joystick
  12220. * @param rightStickX The x component of the right joystick
  12221. * @param rightStickY The y component of the right joystick
  12222. */
  12223. constructor(
  12224. /**
  12225. * The id of the gamepad
  12226. */
  12227. id: string,
  12228. /**
  12229. * The index of the gamepad
  12230. */
  12231. index: number,
  12232. /**
  12233. * The browser gamepad
  12234. */
  12235. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12236. /**
  12237. * Callback triggered when the left joystick has changed
  12238. * @param callback
  12239. */
  12240. onleftstickchanged(callback: (values: StickValues) => void): void;
  12241. /**
  12242. * Callback triggered when the right joystick has changed
  12243. * @param callback
  12244. */
  12245. onrightstickchanged(callback: (values: StickValues) => void): void;
  12246. /**
  12247. * Gets the left joystick
  12248. */
  12249. /**
  12250. * Sets the left joystick values
  12251. */
  12252. leftStick: StickValues;
  12253. /**
  12254. * Gets the right joystick
  12255. */
  12256. /**
  12257. * Sets the right joystick value
  12258. */
  12259. rightStick: StickValues;
  12260. /**
  12261. * Updates the gamepad joystick positions
  12262. */
  12263. update(): void;
  12264. /**
  12265. * Disposes the gamepad
  12266. */
  12267. dispose(): void;
  12268. }
  12269. /**
  12270. * Represents a generic gamepad
  12271. */
  12272. export class GenericPad extends Gamepad {
  12273. private _buttons;
  12274. private _onbuttondown;
  12275. private _onbuttonup;
  12276. /**
  12277. * Observable triggered when a button has been pressed
  12278. */
  12279. onButtonDownObservable: Observable<number>;
  12280. /**
  12281. * Observable triggered when a button has been released
  12282. */
  12283. onButtonUpObservable: Observable<number>;
  12284. /**
  12285. * Callback triggered when a button has been pressed
  12286. * @param callback Called when a button has been pressed
  12287. */
  12288. onbuttondown(callback: (buttonPressed: number) => void): void;
  12289. /**
  12290. * Callback triggered when a button has been released
  12291. * @param callback Called when a button has been released
  12292. */
  12293. onbuttonup(callback: (buttonReleased: number) => void): void;
  12294. /**
  12295. * Initializes the generic gamepad
  12296. * @param id The id of the generic gamepad
  12297. * @param index The index of the generic gamepad
  12298. * @param browserGamepad The browser gamepad
  12299. */
  12300. constructor(id: string, index: number, browserGamepad: any);
  12301. private _setButtonValue;
  12302. /**
  12303. * Updates the generic gamepad
  12304. */
  12305. update(): void;
  12306. /**
  12307. * Disposes the generic gamepad
  12308. */
  12309. dispose(): void;
  12310. }
  12311. }
  12312. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12313. import { Nullable } from "babylonjs/types";
  12314. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12315. import { Scene } from "babylonjs/scene";
  12316. module "babylonjs/Engines/engine" {
  12317. interface Engine {
  12318. /**
  12319. * Creates a raw texture
  12320. * @param data defines the data to store in the texture
  12321. * @param width defines the width of the texture
  12322. * @param height defines the height of the texture
  12323. * @param format defines the format of the data
  12324. * @param generateMipMaps defines if the engine should generate the mip levels
  12325. * @param invertY defines if data must be stored with Y axis inverted
  12326. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12327. * @param compression defines the compression used (null by default)
  12328. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12329. * @returns the raw texture inside an InternalTexture
  12330. */
  12331. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12332. /**
  12333. * Update a raw texture
  12334. * @param texture defines the texture to update
  12335. * @param data defines the data to store in the texture
  12336. * @param format defines the format of the data
  12337. * @param invertY defines if data must be stored with Y axis inverted
  12338. */
  12339. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12340. /**
  12341. * Update a raw texture
  12342. * @param texture defines the texture to update
  12343. * @param data defines the data to store in the texture
  12344. * @param format defines the format of the data
  12345. * @param invertY defines if data must be stored with Y axis inverted
  12346. * @param compression defines the compression used (null by default)
  12347. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12348. */
  12349. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12350. /**
  12351. * Creates a new raw cube texture
  12352. * @param data defines the array of data to use to create each face
  12353. * @param size defines the size of the textures
  12354. * @param format defines the format of the data
  12355. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12356. * @param generateMipMaps defines if the engine should generate the mip levels
  12357. * @param invertY defines if data must be stored with Y axis inverted
  12358. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12359. * @param compression defines the compression used (null by default)
  12360. * @returns the cube texture as an InternalTexture
  12361. */
  12362. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12363. /**
  12364. * Update a raw cube texture
  12365. * @param texture defines the texture to udpdate
  12366. * @param data defines the data to store
  12367. * @param format defines the data format
  12368. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12369. * @param invertY defines if data must be stored with Y axis inverted
  12370. */
  12371. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12372. /**
  12373. * Update a raw cube texture
  12374. * @param texture defines the texture to udpdate
  12375. * @param data defines the data to store
  12376. * @param format defines the data format
  12377. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12378. * @param invertY defines if data must be stored with Y axis inverted
  12379. * @param compression defines the compression used (null by default)
  12380. */
  12381. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12382. /**
  12383. * Update a raw cube texture
  12384. * @param texture defines the texture to udpdate
  12385. * @param data defines the data to store
  12386. * @param format defines the data format
  12387. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12388. * @param invertY defines if data must be stored with Y axis inverted
  12389. * @param compression defines the compression used (null by default)
  12390. * @param level defines which level of the texture to update
  12391. */
  12392. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12393. /**
  12394. * Creates a new raw cube texture from a specified url
  12395. * @param url defines the url where the data is located
  12396. * @param scene defines the current scene
  12397. * @param size defines the size of the textures
  12398. * @param format defines the format of the data
  12399. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12400. * @param noMipmap defines if the engine should avoid generating the mip levels
  12401. * @param callback defines a callback used to extract texture data from loaded data
  12402. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12403. * @param onLoad defines a callback called when texture is loaded
  12404. * @param onError defines a callback called if there is an error
  12405. * @returns the cube texture as an InternalTexture
  12406. */
  12407. 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;
  12408. /**
  12409. * Creates a new raw cube texture from a specified url
  12410. * @param url defines the url where the data is located
  12411. * @param scene defines the current scene
  12412. * @param size defines the size of the textures
  12413. * @param format defines the format of the data
  12414. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12415. * @param noMipmap defines if the engine should avoid generating the mip levels
  12416. * @param callback defines a callback used to extract texture data from loaded data
  12417. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12418. * @param onLoad defines a callback called when texture is loaded
  12419. * @param onError defines a callback called if there is an error
  12420. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12421. * @param invertY defines if data must be stored with Y axis inverted
  12422. * @returns the cube texture as an InternalTexture
  12423. */
  12424. 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;
  12425. /**
  12426. * Creates a new raw 3D texture
  12427. * @param data defines the data used to create the texture
  12428. * @param width defines the width of the texture
  12429. * @param height defines the height of the texture
  12430. * @param depth defines the depth of the texture
  12431. * @param format defines the format of the texture
  12432. * @param generateMipMaps defines if the engine must generate mip levels
  12433. * @param invertY defines if data must be stored with Y axis inverted
  12434. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12435. * @param compression defines the compressed used (can be null)
  12436. * @param textureType defines the compressed used (can be null)
  12437. * @returns a new raw 3D texture (stored in an InternalTexture)
  12438. */
  12439. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12440. /**
  12441. * Update a raw 3D texture
  12442. * @param texture defines the texture to update
  12443. * @param data defines the data to store
  12444. * @param format defines the data format
  12445. * @param invertY defines if data must be stored with Y axis inverted
  12446. */
  12447. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12448. /**
  12449. * Update a raw 3D texture
  12450. * @param texture defines the texture to update
  12451. * @param data defines the data to store
  12452. * @param format defines the data format
  12453. * @param invertY defines if data must be stored with Y axis inverted
  12454. * @param compression defines the used compression (can be null)
  12455. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12456. */
  12457. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12458. }
  12459. }
  12460. }
  12461. declare module "babylonjs/Materials/Textures/rawTexture" {
  12462. import { Scene } from "babylonjs/scene";
  12463. import { Texture } from "babylonjs/Materials/Textures/texture";
  12464. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12465. /**
  12466. * Raw texture can help creating a texture directly from an array of data.
  12467. * This can be super useful if you either get the data from an uncompressed source or
  12468. * if you wish to create your texture pixel by pixel.
  12469. */
  12470. export class RawTexture extends Texture {
  12471. /**
  12472. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12473. */
  12474. format: number;
  12475. private _engine;
  12476. /**
  12477. * Instantiates a new RawTexture.
  12478. * Raw texture can help creating a texture directly from an array of data.
  12479. * This can be super useful if you either get the data from an uncompressed source or
  12480. * if you wish to create your texture pixel by pixel.
  12481. * @param data define the array of data to use to create the texture
  12482. * @param width define the width of the texture
  12483. * @param height define the height of the texture
  12484. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12485. * @param scene define the scene the texture belongs to
  12486. * @param generateMipMaps define whether mip maps should be generated or not
  12487. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12488. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12489. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12490. */
  12491. constructor(data: ArrayBufferView, width: number, height: number,
  12492. /**
  12493. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12494. */
  12495. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12496. /**
  12497. * Updates the texture underlying data.
  12498. * @param data Define the new data of the texture
  12499. */
  12500. update(data: ArrayBufferView): void;
  12501. /**
  12502. * Creates a luminance texture from some data.
  12503. * @param data Define the texture data
  12504. * @param width Define the width of the texture
  12505. * @param height Define the height of the texture
  12506. * @param scene Define the scene the texture belongs to
  12507. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12508. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12509. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12510. * @returns the luminance texture
  12511. */
  12512. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12513. /**
  12514. * Creates a luminance alpha texture from some data.
  12515. * @param data Define the texture data
  12516. * @param width Define the width of the texture
  12517. * @param height Define the height of the texture
  12518. * @param scene Define the scene the texture belongs to
  12519. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12520. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12521. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12522. * @returns the luminance alpha texture
  12523. */
  12524. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12525. /**
  12526. * Creates an alpha texture from some data.
  12527. * @param data Define the texture data
  12528. * @param width Define the width of the texture
  12529. * @param height Define the height of the texture
  12530. * @param scene Define the scene the texture belongs to
  12531. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12532. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12533. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12534. * @returns the alpha texture
  12535. */
  12536. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12537. /**
  12538. * Creates a RGB texture from some data.
  12539. * @param data Define the texture data
  12540. * @param width Define the width of the texture
  12541. * @param height Define the height of the texture
  12542. * @param scene Define the scene the texture belongs to
  12543. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12544. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12545. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12546. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12547. * @returns the RGB alpha texture
  12548. */
  12549. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12550. /**
  12551. * Creates a RGBA texture from some data.
  12552. * @param data Define the texture data
  12553. * @param width Define the width of the texture
  12554. * @param height Define the height of the texture
  12555. * @param scene Define the scene the texture belongs to
  12556. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12557. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12558. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12559. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12560. * @returns the RGBA texture
  12561. */
  12562. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12563. /**
  12564. * Creates a R texture from some data.
  12565. * @param data Define the texture data
  12566. * @param width Define the width of the texture
  12567. * @param height Define the height of the texture
  12568. * @param scene Define the scene the texture belongs to
  12569. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12570. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12571. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12572. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12573. * @returns the R texture
  12574. */
  12575. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12576. }
  12577. }
  12578. declare module "babylonjs/Maths/math.size" {
  12579. /**
  12580. * Interface for the size containing width and height
  12581. */
  12582. export interface ISize {
  12583. /**
  12584. * Width
  12585. */
  12586. width: number;
  12587. /**
  12588. * Heighht
  12589. */
  12590. height: number;
  12591. }
  12592. /**
  12593. * Size containing widht and height
  12594. */
  12595. export class Size implements ISize {
  12596. /**
  12597. * Width
  12598. */
  12599. width: number;
  12600. /**
  12601. * Height
  12602. */
  12603. height: number;
  12604. /**
  12605. * Creates a Size object from the given width and height (floats).
  12606. * @param width width of the new size
  12607. * @param height height of the new size
  12608. */
  12609. constructor(width: number, height: number);
  12610. /**
  12611. * Returns a string with the Size width and height
  12612. * @returns a string with the Size width and height
  12613. */
  12614. toString(): string;
  12615. /**
  12616. * "Size"
  12617. * @returns the string "Size"
  12618. */
  12619. getClassName(): string;
  12620. /**
  12621. * Returns the Size hash code.
  12622. * @returns a hash code for a unique width and height
  12623. */
  12624. getHashCode(): number;
  12625. /**
  12626. * Updates the current size from the given one.
  12627. * @param src the given size
  12628. */
  12629. copyFrom(src: Size): void;
  12630. /**
  12631. * Updates in place the current Size from the given floats.
  12632. * @param width width of the new size
  12633. * @param height height of the new size
  12634. * @returns the updated Size.
  12635. */
  12636. copyFromFloats(width: number, height: number): Size;
  12637. /**
  12638. * Updates in place the current Size from the given floats.
  12639. * @param width width to set
  12640. * @param height height to set
  12641. * @returns the updated Size.
  12642. */
  12643. set(width: number, height: number): Size;
  12644. /**
  12645. * Multiplies the width and height by numbers
  12646. * @param w factor to multiple the width by
  12647. * @param h factor to multiple the height by
  12648. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12649. */
  12650. multiplyByFloats(w: number, h: number): Size;
  12651. /**
  12652. * Clones the size
  12653. * @returns a new Size copied from the given one.
  12654. */
  12655. clone(): Size;
  12656. /**
  12657. * True if the current Size and the given one width and height are strictly equal.
  12658. * @param other the other size to compare against
  12659. * @returns True if the current Size and the given one width and height are strictly equal.
  12660. */
  12661. equals(other: Size): boolean;
  12662. /**
  12663. * The surface of the Size : width * height (float).
  12664. */
  12665. readonly surface: number;
  12666. /**
  12667. * Create a new size of zero
  12668. * @returns a new Size set to (0.0, 0.0)
  12669. */
  12670. static Zero(): Size;
  12671. /**
  12672. * Sums the width and height of two sizes
  12673. * @param otherSize size to add to this size
  12674. * @returns a new Size set as the addition result of the current Size and the given one.
  12675. */
  12676. add(otherSize: Size): Size;
  12677. /**
  12678. * Subtracts the width and height of two
  12679. * @param otherSize size to subtract to this size
  12680. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12681. */
  12682. subtract(otherSize: Size): Size;
  12683. /**
  12684. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12685. * @param start starting size to lerp between
  12686. * @param end end size to lerp between
  12687. * @param amount amount to lerp between the start and end values
  12688. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12689. */
  12690. static Lerp(start: Size, end: Size, amount: number): Size;
  12691. }
  12692. }
  12693. declare module "babylonjs/Animations/runtimeAnimation" {
  12694. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12695. import { Animatable } from "babylonjs/Animations/animatable";
  12696. import { Scene } from "babylonjs/scene";
  12697. /**
  12698. * Defines a runtime animation
  12699. */
  12700. export class RuntimeAnimation {
  12701. private _events;
  12702. /**
  12703. * The current frame of the runtime animation
  12704. */
  12705. private _currentFrame;
  12706. /**
  12707. * The animation used by the runtime animation
  12708. */
  12709. private _animation;
  12710. /**
  12711. * The target of the runtime animation
  12712. */
  12713. private _target;
  12714. /**
  12715. * The initiating animatable
  12716. */
  12717. private _host;
  12718. /**
  12719. * The original value of the runtime animation
  12720. */
  12721. private _originalValue;
  12722. /**
  12723. * The original blend value of the runtime animation
  12724. */
  12725. private _originalBlendValue;
  12726. /**
  12727. * The offsets cache of the runtime animation
  12728. */
  12729. private _offsetsCache;
  12730. /**
  12731. * The high limits cache of the runtime animation
  12732. */
  12733. private _highLimitsCache;
  12734. /**
  12735. * Specifies if the runtime animation has been stopped
  12736. */
  12737. private _stopped;
  12738. /**
  12739. * The blending factor of the runtime animation
  12740. */
  12741. private _blendingFactor;
  12742. /**
  12743. * The BabylonJS scene
  12744. */
  12745. private _scene;
  12746. /**
  12747. * The current value of the runtime animation
  12748. */
  12749. private _currentValue;
  12750. /** @hidden */
  12751. _animationState: _IAnimationState;
  12752. /**
  12753. * The active target of the runtime animation
  12754. */
  12755. private _activeTargets;
  12756. private _currentActiveTarget;
  12757. private _directTarget;
  12758. /**
  12759. * The target path of the runtime animation
  12760. */
  12761. private _targetPath;
  12762. /**
  12763. * The weight of the runtime animation
  12764. */
  12765. private _weight;
  12766. /**
  12767. * The ratio offset of the runtime animation
  12768. */
  12769. private _ratioOffset;
  12770. /**
  12771. * The previous delay of the runtime animation
  12772. */
  12773. private _previousDelay;
  12774. /**
  12775. * The previous ratio of the runtime animation
  12776. */
  12777. private _previousRatio;
  12778. private _enableBlending;
  12779. private _keys;
  12780. private _minFrame;
  12781. private _maxFrame;
  12782. private _minValue;
  12783. private _maxValue;
  12784. private _targetIsArray;
  12785. /**
  12786. * Gets the current frame of the runtime animation
  12787. */
  12788. readonly currentFrame: number;
  12789. /**
  12790. * Gets the weight of the runtime animation
  12791. */
  12792. readonly weight: number;
  12793. /**
  12794. * Gets the current value of the runtime animation
  12795. */
  12796. readonly currentValue: any;
  12797. /**
  12798. * Gets the target path of the runtime animation
  12799. */
  12800. readonly targetPath: string;
  12801. /**
  12802. * Gets the actual target of the runtime animation
  12803. */
  12804. readonly target: any;
  12805. /** @hidden */
  12806. _onLoop: () => void;
  12807. /**
  12808. * Create a new RuntimeAnimation object
  12809. * @param target defines the target of the animation
  12810. * @param animation defines the source animation object
  12811. * @param scene defines the hosting scene
  12812. * @param host defines the initiating Animatable
  12813. */
  12814. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12815. private _preparePath;
  12816. /**
  12817. * Gets the animation from the runtime animation
  12818. */
  12819. readonly animation: Animation;
  12820. /**
  12821. * Resets the runtime animation to the beginning
  12822. * @param restoreOriginal defines whether to restore the target property to the original value
  12823. */
  12824. reset(restoreOriginal?: boolean): void;
  12825. /**
  12826. * Specifies if the runtime animation is stopped
  12827. * @returns Boolean specifying if the runtime animation is stopped
  12828. */
  12829. isStopped(): boolean;
  12830. /**
  12831. * Disposes of the runtime animation
  12832. */
  12833. dispose(): void;
  12834. /**
  12835. * Apply the interpolated value to the target
  12836. * @param currentValue defines the value computed by the animation
  12837. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12838. */
  12839. setValue(currentValue: any, weight: number): void;
  12840. private _getOriginalValues;
  12841. private _setValue;
  12842. /**
  12843. * Gets the loop pmode of the runtime animation
  12844. * @returns Loop Mode
  12845. */
  12846. private _getCorrectLoopMode;
  12847. /**
  12848. * Move the current animation to a given frame
  12849. * @param frame defines the frame to move to
  12850. */
  12851. goToFrame(frame: number): void;
  12852. /**
  12853. * @hidden Internal use only
  12854. */
  12855. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12856. /**
  12857. * Execute the current animation
  12858. * @param delay defines the delay to add to the current frame
  12859. * @param from defines the lower bound of the animation range
  12860. * @param to defines the upper bound of the animation range
  12861. * @param loop defines if the current animation must loop
  12862. * @param speedRatio defines the current speed ratio
  12863. * @param weight defines the weight of the animation (default is -1 so no weight)
  12864. * @param onLoop optional callback called when animation loops
  12865. * @returns a boolean indicating if the animation is running
  12866. */
  12867. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12868. }
  12869. }
  12870. declare module "babylonjs/Animations/animatable" {
  12871. import { Animation } from "babylonjs/Animations/animation";
  12872. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  12873. import { Nullable } from "babylonjs/types";
  12874. import { Observable } from "babylonjs/Misc/observable";
  12875. import { Scene } from "babylonjs/scene";
  12876. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  12877. import { Node } from "babylonjs/node";
  12878. /**
  12879. * Class used to store an actual running animation
  12880. */
  12881. export class Animatable {
  12882. /** defines the target object */
  12883. target: any;
  12884. /** defines the starting frame number (default is 0) */
  12885. fromFrame: number;
  12886. /** defines the ending frame number (default is 100) */
  12887. toFrame: number;
  12888. /** defines if the animation must loop (default is false) */
  12889. loopAnimation: boolean;
  12890. /** defines a callback to call when animation ends if it is not looping */
  12891. onAnimationEnd?: (() => void) | null | undefined;
  12892. /** defines a callback to call when animation loops */
  12893. onAnimationLoop?: (() => void) | null | undefined;
  12894. private _localDelayOffset;
  12895. private _pausedDelay;
  12896. private _runtimeAnimations;
  12897. private _paused;
  12898. private _scene;
  12899. private _speedRatio;
  12900. private _weight;
  12901. private _syncRoot;
  12902. /**
  12903. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12904. * This will only apply for non looping animation (default is true)
  12905. */
  12906. disposeOnEnd: boolean;
  12907. /**
  12908. * Gets a boolean indicating if the animation has started
  12909. */
  12910. animationStarted: boolean;
  12911. /**
  12912. * Observer raised when the animation ends
  12913. */
  12914. onAnimationEndObservable: Observable<Animatable>;
  12915. /**
  12916. * Observer raised when the animation loops
  12917. */
  12918. onAnimationLoopObservable: Observable<Animatable>;
  12919. /**
  12920. * Gets the root Animatable used to synchronize and normalize animations
  12921. */
  12922. readonly syncRoot: Nullable<Animatable>;
  12923. /**
  12924. * Gets the current frame of the first RuntimeAnimation
  12925. * Used to synchronize Animatables
  12926. */
  12927. readonly masterFrame: number;
  12928. /**
  12929. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12930. */
  12931. weight: number;
  12932. /**
  12933. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12934. */
  12935. speedRatio: number;
  12936. /**
  12937. * Creates a new Animatable
  12938. * @param scene defines the hosting scene
  12939. * @param target defines the target object
  12940. * @param fromFrame defines the starting frame number (default is 0)
  12941. * @param toFrame defines the ending frame number (default is 100)
  12942. * @param loopAnimation defines if the animation must loop (default is false)
  12943. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12944. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12945. * @param animations defines a group of animation to add to the new Animatable
  12946. * @param onAnimationLoop defines a callback to call when animation loops
  12947. */
  12948. constructor(scene: Scene,
  12949. /** defines the target object */
  12950. target: any,
  12951. /** defines the starting frame number (default is 0) */
  12952. fromFrame?: number,
  12953. /** defines the ending frame number (default is 100) */
  12954. toFrame?: number,
  12955. /** defines if the animation must loop (default is false) */
  12956. loopAnimation?: boolean, speedRatio?: number,
  12957. /** defines a callback to call when animation ends if it is not looping */
  12958. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12959. /** defines a callback to call when animation loops */
  12960. onAnimationLoop?: (() => void) | null | undefined);
  12961. /**
  12962. * Synchronize and normalize current Animatable with a source Animatable
  12963. * This is useful when using animation weights and when animations are not of the same length
  12964. * @param root defines the root Animatable to synchronize with
  12965. * @returns the current Animatable
  12966. */
  12967. syncWith(root: Animatable): Animatable;
  12968. /**
  12969. * Gets the list of runtime animations
  12970. * @returns an array of RuntimeAnimation
  12971. */
  12972. getAnimations(): RuntimeAnimation[];
  12973. /**
  12974. * Adds more animations to the current animatable
  12975. * @param target defines the target of the animations
  12976. * @param animations defines the new animations to add
  12977. */
  12978. appendAnimations(target: any, animations: Animation[]): void;
  12979. /**
  12980. * Gets the source animation for a specific property
  12981. * @param property defines the propertyu to look for
  12982. * @returns null or the source animation for the given property
  12983. */
  12984. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12985. /**
  12986. * Gets the runtime animation for a specific property
  12987. * @param property defines the propertyu to look for
  12988. * @returns null or the runtime animation for the given property
  12989. */
  12990. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12991. /**
  12992. * Resets the animatable to its original state
  12993. */
  12994. reset(): void;
  12995. /**
  12996. * Allows the animatable to blend with current running animations
  12997. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12998. * @param blendingSpeed defines the blending speed to use
  12999. */
  13000. enableBlending(blendingSpeed: number): void;
  13001. /**
  13002. * Disable animation blending
  13003. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13004. */
  13005. disableBlending(): void;
  13006. /**
  13007. * Jump directly to a given frame
  13008. * @param frame defines the frame to jump to
  13009. */
  13010. goToFrame(frame: number): void;
  13011. /**
  13012. * Pause the animation
  13013. */
  13014. pause(): void;
  13015. /**
  13016. * Restart the animation
  13017. */
  13018. restart(): void;
  13019. private _raiseOnAnimationEnd;
  13020. /**
  13021. * Stop and delete the current animation
  13022. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13023. * @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)
  13024. */
  13025. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13026. /**
  13027. * Wait asynchronously for the animation to end
  13028. * @returns a promise which will be fullfilled when the animation ends
  13029. */
  13030. waitAsync(): Promise<Animatable>;
  13031. /** @hidden */
  13032. _animate(delay: number): boolean;
  13033. }
  13034. module "babylonjs/scene" {
  13035. interface Scene {
  13036. /** @hidden */
  13037. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13038. /** @hidden */
  13039. _processLateAnimationBindingsForMatrices(holder: {
  13040. totalWeight: number;
  13041. animations: RuntimeAnimation[];
  13042. originalValue: Matrix;
  13043. }): any;
  13044. /** @hidden */
  13045. _processLateAnimationBindingsForQuaternions(holder: {
  13046. totalWeight: number;
  13047. animations: RuntimeAnimation[];
  13048. originalValue: Quaternion;
  13049. }, refQuaternion: Quaternion): Quaternion;
  13050. /** @hidden */
  13051. _processLateAnimationBindings(): void;
  13052. /**
  13053. * Will start the animation sequence of a given target
  13054. * @param target defines the target
  13055. * @param from defines from which frame should animation start
  13056. * @param to defines until which frame should animation run.
  13057. * @param weight defines the weight to apply to the animation (1.0 by default)
  13058. * @param loop defines if the animation loops
  13059. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13060. * @param onAnimationEnd defines the function to be executed when the animation ends
  13061. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13062. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13063. * @param onAnimationLoop defines the callback to call when an animation loops
  13064. * @returns the animatable object created for this animation
  13065. */
  13066. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13067. /**
  13068. * Will start the animation sequence of a given target
  13069. * @param target defines the target
  13070. * @param from defines from which frame should animation start
  13071. * @param to defines until which frame should animation run.
  13072. * @param loop defines if the animation loops
  13073. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13074. * @param onAnimationEnd defines the function to be executed when the animation ends
  13075. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13076. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13077. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13078. * @param onAnimationLoop defines the callback to call when an animation loops
  13079. * @returns the animatable object created for this animation
  13080. */
  13081. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13082. /**
  13083. * Will start the animation sequence of a given target and its hierarchy
  13084. * @param target defines the target
  13085. * @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.
  13086. * @param from defines from which frame should animation start
  13087. * @param to defines until which frame should animation run.
  13088. * @param loop defines if the animation loops
  13089. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13090. * @param onAnimationEnd defines the function to be executed when the animation ends
  13091. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13092. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13093. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13094. * @param onAnimationLoop defines the callback to call when an animation loops
  13095. * @returns the list of created animatables
  13096. */
  13097. 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[];
  13098. /**
  13099. * Begin a new animation on a given node
  13100. * @param target defines the target where the animation will take place
  13101. * @param animations defines the list of animations to start
  13102. * @param from defines the initial value
  13103. * @param to defines the final value
  13104. * @param loop defines if you want animation to loop (off by default)
  13105. * @param speedRatio defines the speed ratio to apply to all animations
  13106. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13107. * @param onAnimationLoop defines the callback to call when an animation loops
  13108. * @returns the list of created animatables
  13109. */
  13110. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13111. /**
  13112. * Begin a new animation on a given node and its hierarchy
  13113. * @param target defines the root node where the animation will take place
  13114. * @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.
  13115. * @param animations defines the list of animations to start
  13116. * @param from defines the initial value
  13117. * @param to defines the final value
  13118. * @param loop defines if you want animation to loop (off by default)
  13119. * @param speedRatio defines the speed ratio to apply to all animations
  13120. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13121. * @param onAnimationLoop defines the callback to call when an animation loops
  13122. * @returns the list of animatables created for all nodes
  13123. */
  13124. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13125. /**
  13126. * Gets the animatable associated with a specific target
  13127. * @param target defines the target of the animatable
  13128. * @returns the required animatable if found
  13129. */
  13130. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13131. /**
  13132. * Gets all animatables associated with a given target
  13133. * @param target defines the target to look animatables for
  13134. * @returns an array of Animatables
  13135. */
  13136. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13137. /**
  13138. * Stops and removes all animations that have been applied to the scene
  13139. */
  13140. stopAllAnimations(): void;
  13141. }
  13142. }
  13143. module "babylonjs/Bones/bone" {
  13144. interface Bone {
  13145. /**
  13146. * Copy an animation range from another bone
  13147. * @param source defines the source bone
  13148. * @param rangeName defines the range name to copy
  13149. * @param frameOffset defines the frame offset
  13150. * @param rescaleAsRequired defines if rescaling must be applied if required
  13151. * @param skelDimensionsRatio defines the scaling ratio
  13152. * @returns true if operation was successful
  13153. */
  13154. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13155. }
  13156. }
  13157. }
  13158. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13159. /**
  13160. * Class used to override all child animations of a given target
  13161. */
  13162. export class AnimationPropertiesOverride {
  13163. /**
  13164. * Gets or sets a value indicating if animation blending must be used
  13165. */
  13166. enableBlending: boolean;
  13167. /**
  13168. * Gets or sets the blending speed to use when enableBlending is true
  13169. */
  13170. blendingSpeed: number;
  13171. /**
  13172. * Gets or sets the default loop mode to use
  13173. */
  13174. loopMode: number;
  13175. }
  13176. }
  13177. declare module "babylonjs/Bones/skeleton" {
  13178. import { Bone } from "babylonjs/Bones/bone";
  13179. import { Observable } from "babylonjs/Misc/observable";
  13180. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13181. import { Scene } from "babylonjs/scene";
  13182. import { Nullable } from "babylonjs/types";
  13183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13184. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13185. import { Animatable } from "babylonjs/Animations/animatable";
  13186. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13187. import { Animation } from "babylonjs/Animations/animation";
  13188. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13189. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13190. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13191. /**
  13192. * Class used to handle skinning animations
  13193. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13194. */
  13195. export class Skeleton implements IAnimatable {
  13196. /** defines the skeleton name */
  13197. name: string;
  13198. /** defines the skeleton Id */
  13199. id: string;
  13200. /**
  13201. * Defines the list of child bones
  13202. */
  13203. bones: Bone[];
  13204. /**
  13205. * Defines an estimate of the dimension of the skeleton at rest
  13206. */
  13207. dimensionsAtRest: Vector3;
  13208. /**
  13209. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13210. */
  13211. needInitialSkinMatrix: boolean;
  13212. /**
  13213. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13214. */
  13215. overrideMesh: Nullable<AbstractMesh>;
  13216. /**
  13217. * Gets the list of animations attached to this skeleton
  13218. */
  13219. animations: Array<Animation>;
  13220. private _scene;
  13221. private _isDirty;
  13222. private _transformMatrices;
  13223. private _transformMatrixTexture;
  13224. private _meshesWithPoseMatrix;
  13225. private _animatables;
  13226. private _identity;
  13227. private _synchronizedWithMesh;
  13228. private _ranges;
  13229. private _lastAbsoluteTransformsUpdateId;
  13230. private _canUseTextureForBones;
  13231. private _uniqueId;
  13232. /** @hidden */
  13233. _numBonesWithLinkedTransformNode: number;
  13234. /** @hidden */
  13235. _hasWaitingData: Nullable<boolean>;
  13236. /**
  13237. * Specifies if the skeleton should be serialized
  13238. */
  13239. doNotSerialize: boolean;
  13240. private _useTextureToStoreBoneMatrices;
  13241. /**
  13242. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13243. * Please note that this option is not available if the hardware does not support it
  13244. */
  13245. useTextureToStoreBoneMatrices: boolean;
  13246. private _animationPropertiesOverride;
  13247. /**
  13248. * Gets or sets the animation properties override
  13249. */
  13250. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13251. /**
  13252. * List of inspectable custom properties (used by the Inspector)
  13253. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13254. */
  13255. inspectableCustomProperties: IInspectable[];
  13256. /**
  13257. * An observable triggered before computing the skeleton's matrices
  13258. */
  13259. onBeforeComputeObservable: Observable<Skeleton>;
  13260. /**
  13261. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13262. */
  13263. readonly isUsingTextureForMatrices: boolean;
  13264. /**
  13265. * Gets the unique ID of this skeleton
  13266. */
  13267. readonly uniqueId: number;
  13268. /**
  13269. * Creates a new skeleton
  13270. * @param name defines the skeleton name
  13271. * @param id defines the skeleton Id
  13272. * @param scene defines the hosting scene
  13273. */
  13274. constructor(
  13275. /** defines the skeleton name */
  13276. name: string,
  13277. /** defines the skeleton Id */
  13278. id: string, scene: Scene);
  13279. /**
  13280. * Gets the current object class name.
  13281. * @return the class name
  13282. */
  13283. getClassName(): string;
  13284. /**
  13285. * Returns an array containing the root bones
  13286. * @returns an array containing the root bones
  13287. */
  13288. getChildren(): Array<Bone>;
  13289. /**
  13290. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13291. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13292. * @returns a Float32Array containing matrices data
  13293. */
  13294. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13295. /**
  13296. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13297. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13298. * @returns a raw texture containing the data
  13299. */
  13300. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13301. /**
  13302. * Gets the current hosting scene
  13303. * @returns a scene object
  13304. */
  13305. getScene(): Scene;
  13306. /**
  13307. * Gets a string representing the current skeleton data
  13308. * @param fullDetails defines a boolean indicating if we want a verbose version
  13309. * @returns a string representing the current skeleton data
  13310. */
  13311. toString(fullDetails?: boolean): string;
  13312. /**
  13313. * Get bone's index searching by name
  13314. * @param name defines bone's name to search for
  13315. * @return the indice of the bone. Returns -1 if not found
  13316. */
  13317. getBoneIndexByName(name: string): number;
  13318. /**
  13319. * Creater a new animation range
  13320. * @param name defines the name of the range
  13321. * @param from defines the start key
  13322. * @param to defines the end key
  13323. */
  13324. createAnimationRange(name: string, from: number, to: number): void;
  13325. /**
  13326. * Delete a specific animation range
  13327. * @param name defines the name of the range
  13328. * @param deleteFrames defines if frames must be removed as well
  13329. */
  13330. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13331. /**
  13332. * Gets a specific animation range
  13333. * @param name defines the name of the range to look for
  13334. * @returns the requested animation range or null if not found
  13335. */
  13336. getAnimationRange(name: string): Nullable<AnimationRange>;
  13337. /**
  13338. * Gets the list of all animation ranges defined on this skeleton
  13339. * @returns an array
  13340. */
  13341. getAnimationRanges(): Nullable<AnimationRange>[];
  13342. /**
  13343. * Copy animation range from a source skeleton.
  13344. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13345. * @param source defines the source skeleton
  13346. * @param name defines the name of the range to copy
  13347. * @param rescaleAsRequired defines if rescaling must be applied if required
  13348. * @returns true if operation was successful
  13349. */
  13350. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13351. /**
  13352. * Forces the skeleton to go to rest pose
  13353. */
  13354. returnToRest(): void;
  13355. private _getHighestAnimationFrame;
  13356. /**
  13357. * Begin a specific animation range
  13358. * @param name defines the name of the range to start
  13359. * @param loop defines if looping must be turned on (false by default)
  13360. * @param speedRatio defines the speed ratio to apply (1 by default)
  13361. * @param onAnimationEnd defines a callback which will be called when animation will end
  13362. * @returns a new animatable
  13363. */
  13364. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13365. /** @hidden */
  13366. _markAsDirty(): void;
  13367. /** @hidden */
  13368. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13369. /** @hidden */
  13370. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13371. private _computeTransformMatrices;
  13372. /**
  13373. * Build all resources required to render a skeleton
  13374. */
  13375. prepare(): void;
  13376. /**
  13377. * Gets the list of animatables currently running for this skeleton
  13378. * @returns an array of animatables
  13379. */
  13380. getAnimatables(): IAnimatable[];
  13381. /**
  13382. * Clone the current skeleton
  13383. * @param name defines the name of the new skeleton
  13384. * @param id defines the id of the new skeleton
  13385. * @returns the new skeleton
  13386. */
  13387. clone(name: string, id: string): Skeleton;
  13388. /**
  13389. * Enable animation blending for this skeleton
  13390. * @param blendingSpeed defines the blending speed to apply
  13391. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13392. */
  13393. enableBlending(blendingSpeed?: number): void;
  13394. /**
  13395. * Releases all resources associated with the current skeleton
  13396. */
  13397. dispose(): void;
  13398. /**
  13399. * Serialize the skeleton in a JSON object
  13400. * @returns a JSON object
  13401. */
  13402. serialize(): any;
  13403. /**
  13404. * Creates a new skeleton from serialized data
  13405. * @param parsedSkeleton defines the serialized data
  13406. * @param scene defines the hosting scene
  13407. * @returns a new skeleton
  13408. */
  13409. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13410. /**
  13411. * Compute all node absolute transforms
  13412. * @param forceUpdate defines if computation must be done even if cache is up to date
  13413. */
  13414. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13415. /**
  13416. * Gets the root pose matrix
  13417. * @returns a matrix
  13418. */
  13419. getPoseMatrix(): Nullable<Matrix>;
  13420. /**
  13421. * Sorts bones per internal index
  13422. */
  13423. sortBones(): void;
  13424. private _sortBones;
  13425. }
  13426. }
  13427. declare module "babylonjs/Bones/bone" {
  13428. import { Skeleton } from "babylonjs/Bones/skeleton";
  13429. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13430. import { Nullable } from "babylonjs/types";
  13431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13432. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13433. import { Node } from "babylonjs/node";
  13434. import { Space } from "babylonjs/Maths/math.axis";
  13435. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13436. /**
  13437. * Class used to store bone information
  13438. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13439. */
  13440. export class Bone extends Node {
  13441. /**
  13442. * defines the bone name
  13443. */
  13444. name: string;
  13445. private static _tmpVecs;
  13446. private static _tmpQuat;
  13447. private static _tmpMats;
  13448. /**
  13449. * Gets the list of child bones
  13450. */
  13451. children: Bone[];
  13452. /** Gets the animations associated with this bone */
  13453. animations: import("babylonjs/Animations/animation").Animation[];
  13454. /**
  13455. * Gets or sets bone length
  13456. */
  13457. length: number;
  13458. /**
  13459. * @hidden Internal only
  13460. * Set this value to map this bone to a different index in the transform matrices
  13461. * Set this value to -1 to exclude the bone from the transform matrices
  13462. */
  13463. _index: Nullable<number>;
  13464. private _skeleton;
  13465. private _localMatrix;
  13466. private _restPose;
  13467. private _baseMatrix;
  13468. private _absoluteTransform;
  13469. private _invertedAbsoluteTransform;
  13470. private _parent;
  13471. private _scalingDeterminant;
  13472. private _worldTransform;
  13473. private _localScaling;
  13474. private _localRotation;
  13475. private _localPosition;
  13476. private _needToDecompose;
  13477. private _needToCompose;
  13478. /** @hidden */
  13479. _linkedTransformNode: Nullable<TransformNode>;
  13480. /** @hidden */
  13481. _waitingTransformNodeId: Nullable<string>;
  13482. /** @hidden */
  13483. /** @hidden */
  13484. _matrix: Matrix;
  13485. /**
  13486. * Create a new bone
  13487. * @param name defines the bone name
  13488. * @param skeleton defines the parent skeleton
  13489. * @param parentBone defines the parent (can be null if the bone is the root)
  13490. * @param localMatrix defines the local matrix
  13491. * @param restPose defines the rest pose matrix
  13492. * @param baseMatrix defines the base matrix
  13493. * @param index defines index of the bone in the hiearchy
  13494. */
  13495. constructor(
  13496. /**
  13497. * defines the bone name
  13498. */
  13499. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13500. /**
  13501. * Gets the current object class name.
  13502. * @return the class name
  13503. */
  13504. getClassName(): string;
  13505. /**
  13506. * Gets the parent skeleton
  13507. * @returns a skeleton
  13508. */
  13509. getSkeleton(): Skeleton;
  13510. /**
  13511. * Gets parent bone
  13512. * @returns a bone or null if the bone is the root of the bone hierarchy
  13513. */
  13514. getParent(): Nullable<Bone>;
  13515. /**
  13516. * Returns an array containing the root bones
  13517. * @returns an array containing the root bones
  13518. */
  13519. getChildren(): Array<Bone>;
  13520. /**
  13521. * Sets the parent bone
  13522. * @param parent defines the parent (can be null if the bone is the root)
  13523. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13524. */
  13525. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13526. /**
  13527. * Gets the local matrix
  13528. * @returns a matrix
  13529. */
  13530. getLocalMatrix(): Matrix;
  13531. /**
  13532. * Gets the base matrix (initial matrix which remains unchanged)
  13533. * @returns a matrix
  13534. */
  13535. getBaseMatrix(): Matrix;
  13536. /**
  13537. * Gets the rest pose matrix
  13538. * @returns a matrix
  13539. */
  13540. getRestPose(): Matrix;
  13541. /**
  13542. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13543. */
  13544. getWorldMatrix(): Matrix;
  13545. /**
  13546. * Sets the local matrix to rest pose matrix
  13547. */
  13548. returnToRest(): void;
  13549. /**
  13550. * Gets the inverse of the absolute transform matrix.
  13551. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13552. * @returns a matrix
  13553. */
  13554. getInvertedAbsoluteTransform(): Matrix;
  13555. /**
  13556. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13557. * @returns a matrix
  13558. */
  13559. getAbsoluteTransform(): Matrix;
  13560. /**
  13561. * Links with the given transform node.
  13562. * The local matrix of this bone is copied from the transform node every frame.
  13563. * @param transformNode defines the transform node to link to
  13564. */
  13565. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13566. /**
  13567. * Gets the node used to drive the bone's transformation
  13568. * @returns a transform node or null
  13569. */
  13570. getTransformNode(): Nullable<TransformNode>;
  13571. /** Gets or sets current position (in local space) */
  13572. position: Vector3;
  13573. /** Gets or sets current rotation (in local space) */
  13574. rotation: Vector3;
  13575. /** Gets or sets current rotation quaternion (in local space) */
  13576. rotationQuaternion: Quaternion;
  13577. /** Gets or sets current scaling (in local space) */
  13578. scaling: Vector3;
  13579. /**
  13580. * Gets the animation properties override
  13581. */
  13582. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13583. private _decompose;
  13584. private _compose;
  13585. /**
  13586. * Update the base and local matrices
  13587. * @param matrix defines the new base or local matrix
  13588. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13589. * @param updateLocalMatrix defines if the local matrix should be updated
  13590. */
  13591. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13592. /** @hidden */
  13593. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13594. /**
  13595. * Flag the bone as dirty (Forcing it to update everything)
  13596. */
  13597. markAsDirty(): void;
  13598. /** @hidden */
  13599. _markAsDirtyAndCompose(): void;
  13600. private _markAsDirtyAndDecompose;
  13601. /**
  13602. * Translate the bone in local or world space
  13603. * @param vec The amount to translate the bone
  13604. * @param space The space that the translation is in
  13605. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13606. */
  13607. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13608. /**
  13609. * Set the postion of the bone in local or world space
  13610. * @param position The position to set the bone
  13611. * @param space The space that the position is in
  13612. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13613. */
  13614. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13615. /**
  13616. * Set the absolute position of the bone (world space)
  13617. * @param position The position to set the bone
  13618. * @param mesh The mesh that this bone is attached to
  13619. */
  13620. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13621. /**
  13622. * Scale the bone on the x, y and z axes (in local space)
  13623. * @param x The amount to scale the bone on the x axis
  13624. * @param y The amount to scale the bone on the y axis
  13625. * @param z The amount to scale the bone on the z axis
  13626. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13627. */
  13628. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13629. /**
  13630. * Set the bone scaling in local space
  13631. * @param scale defines the scaling vector
  13632. */
  13633. setScale(scale: Vector3): void;
  13634. /**
  13635. * Gets the current scaling in local space
  13636. * @returns the current scaling vector
  13637. */
  13638. getScale(): Vector3;
  13639. /**
  13640. * Gets the current scaling in local space and stores it in a target vector
  13641. * @param result defines the target vector
  13642. */
  13643. getScaleToRef(result: Vector3): void;
  13644. /**
  13645. * Set the yaw, pitch, and roll of the bone in local or world space
  13646. * @param yaw The rotation of the bone on the y axis
  13647. * @param pitch The rotation of the bone on the x axis
  13648. * @param roll The rotation of the bone on the z axis
  13649. * @param space The space that the axes of rotation are in
  13650. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13651. */
  13652. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13653. /**
  13654. * Add a rotation to the bone on an axis in local or world space
  13655. * @param axis The axis to rotate the bone on
  13656. * @param amount The amount to rotate the bone
  13657. * @param space The space that the axis is in
  13658. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13659. */
  13660. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13661. /**
  13662. * Set the rotation of the bone to a particular axis angle in local or world space
  13663. * @param axis The axis to rotate the bone on
  13664. * @param angle The angle that the bone should be rotated to
  13665. * @param space The space that the axis is in
  13666. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13667. */
  13668. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13669. /**
  13670. * Set the euler rotation of the bone in local of world space
  13671. * @param rotation The euler rotation that the bone should be set to
  13672. * @param space The space that the rotation is in
  13673. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13674. */
  13675. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13676. /**
  13677. * Set the quaternion rotation of the bone in local of world space
  13678. * @param quat The quaternion rotation that the bone should be set to
  13679. * @param space The space that the rotation is in
  13680. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13681. */
  13682. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13683. /**
  13684. * Set the rotation matrix of the bone in local of world space
  13685. * @param rotMat The rotation matrix that the bone should be set to
  13686. * @param space The space that the rotation is in
  13687. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13688. */
  13689. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13690. private _rotateWithMatrix;
  13691. private _getNegativeRotationToRef;
  13692. /**
  13693. * Get the position of the bone in local or world space
  13694. * @param space The space that the returned position is in
  13695. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13696. * @returns The position of the bone
  13697. */
  13698. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13699. /**
  13700. * Copy the position of the bone to a vector3 in local or world space
  13701. * @param space The space that the returned position is in
  13702. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13703. * @param result The vector3 to copy the position to
  13704. */
  13705. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13706. /**
  13707. * Get the absolute position of the bone (world space)
  13708. * @param mesh The mesh that this bone is attached to
  13709. * @returns The absolute position of the bone
  13710. */
  13711. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13712. /**
  13713. * Copy the absolute position of the bone (world space) to the result param
  13714. * @param mesh The mesh that this bone is attached to
  13715. * @param result The vector3 to copy the absolute position to
  13716. */
  13717. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13718. /**
  13719. * Compute the absolute transforms of this bone and its children
  13720. */
  13721. computeAbsoluteTransforms(): void;
  13722. /**
  13723. * Get the world direction from an axis that is in the local space of the bone
  13724. * @param localAxis The local direction that is used to compute the world direction
  13725. * @param mesh The mesh that this bone is attached to
  13726. * @returns The world direction
  13727. */
  13728. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13729. /**
  13730. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13731. * @param localAxis The local direction that is used to compute the world direction
  13732. * @param mesh The mesh that this bone is attached to
  13733. * @param result The vector3 that the world direction will be copied to
  13734. */
  13735. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13736. /**
  13737. * Get the euler rotation of the bone in local or world space
  13738. * @param space The space that the rotation should be in
  13739. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13740. * @returns The euler rotation
  13741. */
  13742. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13743. /**
  13744. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13745. * @param space The space that the rotation should be in
  13746. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13747. * @param result The vector3 that the rotation should be copied to
  13748. */
  13749. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13750. /**
  13751. * Get the quaternion rotation of the bone in either local or world space
  13752. * @param space The space that the rotation should be in
  13753. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13754. * @returns The quaternion rotation
  13755. */
  13756. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13757. /**
  13758. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13759. * @param space The space that the rotation should be in
  13760. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13761. * @param result The quaternion that the rotation should be copied to
  13762. */
  13763. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13764. /**
  13765. * Get the rotation matrix of the bone in local or world space
  13766. * @param space The space that the rotation should be in
  13767. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13768. * @returns The rotation matrix
  13769. */
  13770. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13771. /**
  13772. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13773. * @param space The space that the rotation should be in
  13774. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13775. * @param result The quaternion that the rotation should be copied to
  13776. */
  13777. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13778. /**
  13779. * Get the world position of a point that is in the local space of the bone
  13780. * @param position The local position
  13781. * @param mesh The mesh that this bone is attached to
  13782. * @returns The world position
  13783. */
  13784. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13785. /**
  13786. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13787. * @param position The local position
  13788. * @param mesh The mesh that this bone is attached to
  13789. * @param result The vector3 that the world position should be copied to
  13790. */
  13791. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13792. /**
  13793. * Get the local position of a point that is in world space
  13794. * @param position The world position
  13795. * @param mesh The mesh that this bone is attached to
  13796. * @returns The local position
  13797. */
  13798. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13799. /**
  13800. * Get the local position of a point that is in world space and copy it to the result param
  13801. * @param position The world position
  13802. * @param mesh The mesh that this bone is attached to
  13803. * @param result The vector3 that the local position should be copied to
  13804. */
  13805. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13806. }
  13807. }
  13808. declare module "babylonjs/Meshes/transformNode" {
  13809. import { DeepImmutable } from "babylonjs/types";
  13810. import { Observable } from "babylonjs/Misc/observable";
  13811. import { Nullable } from "babylonjs/types";
  13812. import { Camera } from "babylonjs/Cameras/camera";
  13813. import { Scene } from "babylonjs/scene";
  13814. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13815. import { Node } from "babylonjs/node";
  13816. import { Bone } from "babylonjs/Bones/bone";
  13817. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13818. import { Space } from "babylonjs/Maths/math.axis";
  13819. /**
  13820. * 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.
  13821. * @see https://doc.babylonjs.com/how_to/transformnode
  13822. */
  13823. export class TransformNode extends Node {
  13824. /**
  13825. * Object will not rotate to face the camera
  13826. */
  13827. static BILLBOARDMODE_NONE: number;
  13828. /**
  13829. * Object will rotate to face the camera but only on the x axis
  13830. */
  13831. static BILLBOARDMODE_X: number;
  13832. /**
  13833. * Object will rotate to face the camera but only on the y axis
  13834. */
  13835. static BILLBOARDMODE_Y: number;
  13836. /**
  13837. * Object will rotate to face the camera but only on the z axis
  13838. */
  13839. static BILLBOARDMODE_Z: number;
  13840. /**
  13841. * Object will rotate to face the camera
  13842. */
  13843. static BILLBOARDMODE_ALL: number;
  13844. /**
  13845. * Object will rotate to face the camera's position instead of orientation
  13846. */
  13847. static BILLBOARDMODE_USE_POSITION: number;
  13848. private _forward;
  13849. private _forwardInverted;
  13850. private _up;
  13851. private _right;
  13852. private _rightInverted;
  13853. private _position;
  13854. private _rotation;
  13855. private _rotationQuaternion;
  13856. protected _scaling: Vector3;
  13857. protected _isDirty: boolean;
  13858. private _transformToBoneReferal;
  13859. private _isAbsoluteSynced;
  13860. private _billboardMode;
  13861. /**
  13862. * Gets or sets the billboard mode. Default is 0.
  13863. *
  13864. * | Value | Type | Description |
  13865. * | --- | --- | --- |
  13866. * | 0 | BILLBOARDMODE_NONE | |
  13867. * | 1 | BILLBOARDMODE_X | |
  13868. * | 2 | BILLBOARDMODE_Y | |
  13869. * | 4 | BILLBOARDMODE_Z | |
  13870. * | 7 | BILLBOARDMODE_ALL | |
  13871. *
  13872. */
  13873. billboardMode: number;
  13874. private _preserveParentRotationForBillboard;
  13875. /**
  13876. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13877. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13878. */
  13879. preserveParentRotationForBillboard: boolean;
  13880. /**
  13881. * 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
  13882. */
  13883. scalingDeterminant: number;
  13884. private _infiniteDistance;
  13885. /**
  13886. * Gets or sets the distance of the object to max, often used by skybox
  13887. */
  13888. infiniteDistance: boolean;
  13889. /**
  13890. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13891. * By default the system will update normals to compensate
  13892. */
  13893. ignoreNonUniformScaling: boolean;
  13894. /**
  13895. * 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
  13896. */
  13897. reIntegrateRotationIntoRotationQuaternion: boolean;
  13898. /** @hidden */
  13899. _poseMatrix: Nullable<Matrix>;
  13900. /** @hidden */
  13901. _localMatrix: Matrix;
  13902. private _usePivotMatrix;
  13903. private _absolutePosition;
  13904. private _absoluteScaling;
  13905. private _absoluteRotationQuaternion;
  13906. private _pivotMatrix;
  13907. private _pivotMatrixInverse;
  13908. protected _postMultiplyPivotMatrix: boolean;
  13909. protected _isWorldMatrixFrozen: boolean;
  13910. /** @hidden */
  13911. _indexInSceneTransformNodesArray: number;
  13912. /**
  13913. * An event triggered after the world matrix is updated
  13914. */
  13915. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13916. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13917. /**
  13918. * Gets a string identifying the name of the class
  13919. * @returns "TransformNode" string
  13920. */
  13921. getClassName(): string;
  13922. /**
  13923. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13924. */
  13925. position: Vector3;
  13926. /**
  13927. * 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)).
  13928. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13929. */
  13930. rotation: Vector3;
  13931. /**
  13932. * 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)).
  13933. */
  13934. scaling: Vector3;
  13935. /**
  13936. * 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).
  13937. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13938. */
  13939. rotationQuaternion: Nullable<Quaternion>;
  13940. /**
  13941. * The forward direction of that transform in world space.
  13942. */
  13943. readonly forward: Vector3;
  13944. /**
  13945. * The up direction of that transform in world space.
  13946. */
  13947. readonly up: Vector3;
  13948. /**
  13949. * The right direction of that transform in world space.
  13950. */
  13951. readonly right: Vector3;
  13952. /**
  13953. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13954. * @param matrix the matrix to copy the pose from
  13955. * @returns this TransformNode.
  13956. */
  13957. updatePoseMatrix(matrix: Matrix): TransformNode;
  13958. /**
  13959. * Returns the mesh Pose matrix.
  13960. * @returns the pose matrix
  13961. */
  13962. getPoseMatrix(): Matrix;
  13963. /** @hidden */
  13964. _isSynchronized(): boolean;
  13965. /** @hidden */
  13966. _initCache(): void;
  13967. /**
  13968. * Flag the transform node as dirty (Forcing it to update everything)
  13969. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13970. * @returns this transform node
  13971. */
  13972. markAsDirty(property: string): TransformNode;
  13973. /**
  13974. * Returns the current mesh absolute position.
  13975. * Returns a Vector3.
  13976. */
  13977. readonly absolutePosition: Vector3;
  13978. /**
  13979. * Returns the current mesh absolute scaling.
  13980. * Returns a Vector3.
  13981. */
  13982. readonly absoluteScaling: Vector3;
  13983. /**
  13984. * Returns the current mesh absolute rotation.
  13985. * Returns a Quaternion.
  13986. */
  13987. readonly absoluteRotationQuaternion: Quaternion;
  13988. /**
  13989. * Sets a new matrix to apply before all other transformation
  13990. * @param matrix defines the transform matrix
  13991. * @returns the current TransformNode
  13992. */
  13993. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13994. /**
  13995. * Sets a new pivot matrix to the current node
  13996. * @param matrix defines the new pivot matrix to use
  13997. * @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
  13998. * @returns the current TransformNode
  13999. */
  14000. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14001. /**
  14002. * Returns the mesh pivot matrix.
  14003. * Default : Identity.
  14004. * @returns the matrix
  14005. */
  14006. getPivotMatrix(): Matrix;
  14007. /**
  14008. * Instantiate (when possible) or clone that node with its hierarchy
  14009. * @param newParent defines the new parent to use for the instance (or clone)
  14010. * @returns an instance (or a clone) of the current node with its hiearchy
  14011. */
  14012. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14013. /**
  14014. * Prevents the World matrix to be computed any longer
  14015. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14016. * @returns the TransformNode.
  14017. */
  14018. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14019. /**
  14020. * Allows back the World matrix computation.
  14021. * @returns the TransformNode.
  14022. */
  14023. unfreezeWorldMatrix(): this;
  14024. /**
  14025. * True if the World matrix has been frozen.
  14026. */
  14027. readonly isWorldMatrixFrozen: boolean;
  14028. /**
  14029. * Retuns the mesh absolute position in the World.
  14030. * @returns a Vector3.
  14031. */
  14032. getAbsolutePosition(): Vector3;
  14033. /**
  14034. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14035. * @param absolutePosition the absolute position to set
  14036. * @returns the TransformNode.
  14037. */
  14038. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14039. /**
  14040. * Sets the mesh position in its local space.
  14041. * @param vector3 the position to set in localspace
  14042. * @returns the TransformNode.
  14043. */
  14044. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14045. /**
  14046. * Returns the mesh position in the local space from the current World matrix values.
  14047. * @returns a new Vector3.
  14048. */
  14049. getPositionExpressedInLocalSpace(): Vector3;
  14050. /**
  14051. * Translates the mesh along the passed Vector3 in its local space.
  14052. * @param vector3 the distance to translate in localspace
  14053. * @returns the TransformNode.
  14054. */
  14055. locallyTranslate(vector3: Vector3): TransformNode;
  14056. private static _lookAtVectorCache;
  14057. /**
  14058. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14059. * @param targetPoint the position (must be in same space as current mesh) to look at
  14060. * @param yawCor optional yaw (y-axis) correction in radians
  14061. * @param pitchCor optional pitch (x-axis) correction in radians
  14062. * @param rollCor optional roll (z-axis) correction in radians
  14063. * @param space the choosen space of the target
  14064. * @returns the TransformNode.
  14065. */
  14066. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14067. /**
  14068. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14069. * This Vector3 is expressed in the World space.
  14070. * @param localAxis axis to rotate
  14071. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14072. */
  14073. getDirection(localAxis: Vector3): Vector3;
  14074. /**
  14075. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14076. * localAxis is expressed in the mesh local space.
  14077. * result is computed in the Wordl space from the mesh World matrix.
  14078. * @param localAxis axis to rotate
  14079. * @param result the resulting transformnode
  14080. * @returns this TransformNode.
  14081. */
  14082. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14083. /**
  14084. * Sets this transform node rotation to the given local axis.
  14085. * @param localAxis the axis in local space
  14086. * @param yawCor optional yaw (y-axis) correction in radians
  14087. * @param pitchCor optional pitch (x-axis) correction in radians
  14088. * @param rollCor optional roll (z-axis) correction in radians
  14089. * @returns this TransformNode
  14090. */
  14091. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14092. /**
  14093. * Sets a new pivot point to the current node
  14094. * @param point defines the new pivot point to use
  14095. * @param space defines if the point is in world or local space (local by default)
  14096. * @returns the current TransformNode
  14097. */
  14098. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14099. /**
  14100. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14101. * @returns the pivot point
  14102. */
  14103. getPivotPoint(): Vector3;
  14104. /**
  14105. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14106. * @param result the vector3 to store the result
  14107. * @returns this TransformNode.
  14108. */
  14109. getPivotPointToRef(result: Vector3): TransformNode;
  14110. /**
  14111. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14112. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14113. */
  14114. getAbsolutePivotPoint(): Vector3;
  14115. /**
  14116. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14117. * @param result vector3 to store the result
  14118. * @returns this TransformNode.
  14119. */
  14120. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14121. /**
  14122. * Defines the passed node as the parent of the current node.
  14123. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14124. * @see https://doc.babylonjs.com/how_to/parenting
  14125. * @param node the node ot set as the parent
  14126. * @returns this TransformNode.
  14127. */
  14128. setParent(node: Nullable<Node>): TransformNode;
  14129. private _nonUniformScaling;
  14130. /**
  14131. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14132. */
  14133. readonly nonUniformScaling: boolean;
  14134. /** @hidden */
  14135. _updateNonUniformScalingState(value: boolean): boolean;
  14136. /**
  14137. * Attach the current TransformNode to another TransformNode associated with a bone
  14138. * @param bone Bone affecting the TransformNode
  14139. * @param affectedTransformNode TransformNode associated with the bone
  14140. * @returns this object
  14141. */
  14142. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14143. /**
  14144. * Detach the transform node if its associated with a bone
  14145. * @returns this object
  14146. */
  14147. detachFromBone(): TransformNode;
  14148. private static _rotationAxisCache;
  14149. /**
  14150. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14151. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14152. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14153. * The passed axis is also normalized.
  14154. * @param axis the axis to rotate around
  14155. * @param amount the amount to rotate in radians
  14156. * @param space Space to rotate in (Default: local)
  14157. * @returns the TransformNode.
  14158. */
  14159. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14160. /**
  14161. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14162. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14163. * The passed axis is also normalized. .
  14164. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14165. * @param point the point to rotate around
  14166. * @param axis the axis to rotate around
  14167. * @param amount the amount to rotate in radians
  14168. * @returns the TransformNode
  14169. */
  14170. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14171. /**
  14172. * Translates the mesh along the axis vector for the passed distance in the given space.
  14173. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14174. * @param axis the axis to translate in
  14175. * @param distance the distance to translate
  14176. * @param space Space to rotate in (Default: local)
  14177. * @returns the TransformNode.
  14178. */
  14179. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14180. /**
  14181. * Adds a rotation step to the mesh current rotation.
  14182. * x, y, z are Euler angles expressed in radians.
  14183. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14184. * This means this rotation is made in the mesh local space only.
  14185. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14186. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14187. * ```javascript
  14188. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14189. * ```
  14190. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14191. * 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.
  14192. * @param x Rotation to add
  14193. * @param y Rotation to add
  14194. * @param z Rotation to add
  14195. * @returns the TransformNode.
  14196. */
  14197. addRotation(x: number, y: number, z: number): TransformNode;
  14198. /**
  14199. * @hidden
  14200. */
  14201. protected _getEffectiveParent(): Nullable<Node>;
  14202. /**
  14203. * Computes the world matrix of the node
  14204. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14205. * @returns the world matrix
  14206. */
  14207. computeWorldMatrix(force?: boolean): Matrix;
  14208. protected _afterComputeWorldMatrix(): void;
  14209. /**
  14210. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14211. * @param func callback function to add
  14212. *
  14213. * @returns the TransformNode.
  14214. */
  14215. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14216. /**
  14217. * Removes a registered callback function.
  14218. * @param func callback function to remove
  14219. * @returns the TransformNode.
  14220. */
  14221. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14222. /**
  14223. * Gets the position of the current mesh in camera space
  14224. * @param camera defines the camera to use
  14225. * @returns a position
  14226. */
  14227. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14228. /**
  14229. * Returns the distance from the mesh to the active camera
  14230. * @param camera defines the camera to use
  14231. * @returns the distance
  14232. */
  14233. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14234. /**
  14235. * Clone the current transform node
  14236. * @param name Name of the new clone
  14237. * @param newParent New parent for the clone
  14238. * @param doNotCloneChildren Do not clone children hierarchy
  14239. * @returns the new transform node
  14240. */
  14241. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14242. /**
  14243. * Serializes the objects information.
  14244. * @param currentSerializationObject defines the object to serialize in
  14245. * @returns the serialized object
  14246. */
  14247. serialize(currentSerializationObject?: any): any;
  14248. /**
  14249. * Returns a new TransformNode object parsed from the source provided.
  14250. * @param parsedTransformNode is the source.
  14251. * @param scene the scne the object belongs to
  14252. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14253. * @returns a new TransformNode object parsed from the source provided.
  14254. */
  14255. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14256. /**
  14257. * Get all child-transformNodes of this node
  14258. * @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
  14259. * @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
  14260. * @returns an array of TransformNode
  14261. */
  14262. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14263. /**
  14264. * Releases resources associated with this transform node.
  14265. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14266. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14267. */
  14268. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14269. /**
  14270. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14271. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14272. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14273. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14274. * @returns the current mesh
  14275. */
  14276. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14277. private _syncAbsoluteScalingAndRotation;
  14278. }
  14279. }
  14280. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14281. import { Observable } from "babylonjs/Misc/observable";
  14282. import { Nullable } from "babylonjs/types";
  14283. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14284. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14285. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14286. import { Ray } from "babylonjs/Culling/ray";
  14287. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14288. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14289. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14290. /**
  14291. * Defines the types of pose enabled controllers that are supported
  14292. */
  14293. export enum PoseEnabledControllerType {
  14294. /**
  14295. * HTC Vive
  14296. */
  14297. VIVE = 0,
  14298. /**
  14299. * Oculus Rift
  14300. */
  14301. OCULUS = 1,
  14302. /**
  14303. * Windows mixed reality
  14304. */
  14305. WINDOWS = 2,
  14306. /**
  14307. * Samsung gear VR
  14308. */
  14309. GEAR_VR = 3,
  14310. /**
  14311. * Google Daydream
  14312. */
  14313. DAYDREAM = 4,
  14314. /**
  14315. * Generic
  14316. */
  14317. GENERIC = 5
  14318. }
  14319. /**
  14320. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14321. */
  14322. export interface MutableGamepadButton {
  14323. /**
  14324. * Value of the button/trigger
  14325. */
  14326. value: number;
  14327. /**
  14328. * If the button/trigger is currently touched
  14329. */
  14330. touched: boolean;
  14331. /**
  14332. * If the button/trigger is currently pressed
  14333. */
  14334. pressed: boolean;
  14335. }
  14336. /**
  14337. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14338. * @hidden
  14339. */
  14340. export interface ExtendedGamepadButton extends GamepadButton {
  14341. /**
  14342. * If the button/trigger is currently pressed
  14343. */
  14344. readonly pressed: boolean;
  14345. /**
  14346. * If the button/trigger is currently touched
  14347. */
  14348. readonly touched: boolean;
  14349. /**
  14350. * Value of the button/trigger
  14351. */
  14352. readonly value: number;
  14353. }
  14354. /** @hidden */
  14355. export interface _GamePadFactory {
  14356. /**
  14357. * Returns wether or not the current gamepad can be created for this type of controller.
  14358. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14359. * @returns true if it can be created, otherwise false
  14360. */
  14361. canCreate(gamepadInfo: any): boolean;
  14362. /**
  14363. * Creates a new instance of the Gamepad.
  14364. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14365. * @returns the new gamepad instance
  14366. */
  14367. create(gamepadInfo: any): Gamepad;
  14368. }
  14369. /**
  14370. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14371. */
  14372. export class PoseEnabledControllerHelper {
  14373. /** @hidden */
  14374. static _ControllerFactories: _GamePadFactory[];
  14375. /** @hidden */
  14376. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14377. /**
  14378. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14379. * @param vrGamepad the gamepad to initialized
  14380. * @returns a vr controller of the type the gamepad identified as
  14381. */
  14382. static InitiateController(vrGamepad: any): Gamepad;
  14383. }
  14384. /**
  14385. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14386. */
  14387. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14388. /**
  14389. * If the controller is used in a webXR session
  14390. */
  14391. isXR: boolean;
  14392. private _deviceRoomPosition;
  14393. private _deviceRoomRotationQuaternion;
  14394. /**
  14395. * The device position in babylon space
  14396. */
  14397. devicePosition: Vector3;
  14398. /**
  14399. * The device rotation in babylon space
  14400. */
  14401. deviceRotationQuaternion: Quaternion;
  14402. /**
  14403. * The scale factor of the device in babylon space
  14404. */
  14405. deviceScaleFactor: number;
  14406. /**
  14407. * (Likely devicePosition should be used instead) The device position in its room space
  14408. */
  14409. position: Vector3;
  14410. /**
  14411. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14412. */
  14413. rotationQuaternion: Quaternion;
  14414. /**
  14415. * The type of controller (Eg. Windows mixed reality)
  14416. */
  14417. controllerType: PoseEnabledControllerType;
  14418. protected _calculatedPosition: Vector3;
  14419. private _calculatedRotation;
  14420. /**
  14421. * The raw pose from the device
  14422. */
  14423. rawPose: DevicePose;
  14424. private _trackPosition;
  14425. private _maxRotationDistFromHeadset;
  14426. private _draggedRoomRotation;
  14427. /**
  14428. * @hidden
  14429. */
  14430. _disableTrackPosition(fixedPosition: Vector3): void;
  14431. /**
  14432. * Internal, the mesh attached to the controller
  14433. * @hidden
  14434. */
  14435. _mesh: Nullable<AbstractMesh>;
  14436. private _poseControlledCamera;
  14437. private _leftHandSystemQuaternion;
  14438. /**
  14439. * Internal, matrix used to convert room space to babylon space
  14440. * @hidden
  14441. */
  14442. _deviceToWorld: Matrix;
  14443. /**
  14444. * Node to be used when casting a ray from the controller
  14445. * @hidden
  14446. */
  14447. _pointingPoseNode: Nullable<TransformNode>;
  14448. /**
  14449. * Name of the child mesh that can be used to cast a ray from the controller
  14450. */
  14451. static readonly POINTING_POSE: string;
  14452. /**
  14453. * Creates a new PoseEnabledController from a gamepad
  14454. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14455. */
  14456. constructor(browserGamepad: any);
  14457. private _workingMatrix;
  14458. /**
  14459. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14460. */
  14461. update(): void;
  14462. /**
  14463. * Updates only the pose device and mesh without doing any button event checking
  14464. */
  14465. protected _updatePoseAndMesh(): void;
  14466. /**
  14467. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14468. * @param poseData raw pose fromthe device
  14469. */
  14470. updateFromDevice(poseData: DevicePose): void;
  14471. /**
  14472. * @hidden
  14473. */
  14474. _meshAttachedObservable: Observable<AbstractMesh>;
  14475. /**
  14476. * Attaches a mesh to the controller
  14477. * @param mesh the mesh to be attached
  14478. */
  14479. attachToMesh(mesh: AbstractMesh): void;
  14480. /**
  14481. * Attaches the controllers mesh to a camera
  14482. * @param camera the camera the mesh should be attached to
  14483. */
  14484. attachToPoseControlledCamera(camera: TargetCamera): void;
  14485. /**
  14486. * Disposes of the controller
  14487. */
  14488. dispose(): void;
  14489. /**
  14490. * The mesh that is attached to the controller
  14491. */
  14492. readonly mesh: Nullable<AbstractMesh>;
  14493. /**
  14494. * Gets the ray of the controller in the direction the controller is pointing
  14495. * @param length the length the resulting ray should be
  14496. * @returns a ray in the direction the controller is pointing
  14497. */
  14498. getForwardRay(length?: number): Ray;
  14499. }
  14500. }
  14501. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14502. import { Observable } from "babylonjs/Misc/observable";
  14503. import { Scene } from "babylonjs/scene";
  14504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14505. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14506. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14507. import { Nullable } from "babylonjs/types";
  14508. /**
  14509. * Defines the WebVRController object that represents controllers tracked in 3D space
  14510. */
  14511. export abstract class WebVRController extends PoseEnabledController {
  14512. /**
  14513. * Internal, the default controller model for the controller
  14514. */
  14515. protected _defaultModel: Nullable<AbstractMesh>;
  14516. /**
  14517. * Fired when the trigger state has changed
  14518. */
  14519. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14520. /**
  14521. * Fired when the main button state has changed
  14522. */
  14523. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14524. /**
  14525. * Fired when the secondary button state has changed
  14526. */
  14527. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14528. /**
  14529. * Fired when the pad state has changed
  14530. */
  14531. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14532. /**
  14533. * Fired when controllers stick values have changed
  14534. */
  14535. onPadValuesChangedObservable: Observable<StickValues>;
  14536. /**
  14537. * Array of button availible on the controller
  14538. */
  14539. protected _buttons: Array<MutableGamepadButton>;
  14540. private _onButtonStateChange;
  14541. /**
  14542. * Fired when a controller button's state has changed
  14543. * @param callback the callback containing the button that was modified
  14544. */
  14545. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14546. /**
  14547. * X and Y axis corresponding to the controllers joystick
  14548. */
  14549. pad: StickValues;
  14550. /**
  14551. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14552. */
  14553. hand: string;
  14554. /**
  14555. * The default controller model for the controller
  14556. */
  14557. readonly defaultModel: Nullable<AbstractMesh>;
  14558. /**
  14559. * Creates a new WebVRController from a gamepad
  14560. * @param vrGamepad the gamepad that the WebVRController should be created from
  14561. */
  14562. constructor(vrGamepad: any);
  14563. /**
  14564. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14565. */
  14566. update(): void;
  14567. /**
  14568. * Function to be called when a button is modified
  14569. */
  14570. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14571. /**
  14572. * Loads a mesh and attaches it to the controller
  14573. * @param scene the scene the mesh should be added to
  14574. * @param meshLoaded callback for when the mesh has been loaded
  14575. */
  14576. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14577. private _setButtonValue;
  14578. private _changes;
  14579. private _checkChanges;
  14580. /**
  14581. * Disposes of th webVRCOntroller
  14582. */
  14583. dispose(): void;
  14584. }
  14585. }
  14586. declare module "babylonjs/Lights/hemisphericLight" {
  14587. import { Nullable } from "babylonjs/types";
  14588. import { Scene } from "babylonjs/scene";
  14589. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14590. import { Color3 } from "babylonjs/Maths/math.color";
  14591. import { Effect } from "babylonjs/Materials/effect";
  14592. import { Light } from "babylonjs/Lights/light";
  14593. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14594. /**
  14595. * The HemisphericLight simulates the ambient environment light,
  14596. * so the passed direction is the light reflection direction, not the incoming direction.
  14597. */
  14598. export class HemisphericLight extends Light {
  14599. /**
  14600. * The groundColor is the light in the opposite direction to the one specified during creation.
  14601. * 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.
  14602. */
  14603. groundColor: Color3;
  14604. /**
  14605. * The light reflection direction, not the incoming direction.
  14606. */
  14607. direction: Vector3;
  14608. /**
  14609. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14610. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14611. * The HemisphericLight can't cast shadows.
  14612. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14613. * @param name The friendly name of the light
  14614. * @param direction The direction of the light reflection
  14615. * @param scene The scene the light belongs to
  14616. */
  14617. constructor(name: string, direction: Vector3, scene: Scene);
  14618. protected _buildUniformLayout(): void;
  14619. /**
  14620. * Returns the string "HemisphericLight".
  14621. * @return The class name
  14622. */
  14623. getClassName(): string;
  14624. /**
  14625. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14626. * Returns the updated direction.
  14627. * @param target The target the direction should point to
  14628. * @return The computed direction
  14629. */
  14630. setDirectionToTarget(target: Vector3): Vector3;
  14631. /**
  14632. * Returns the shadow generator associated to the light.
  14633. * @returns Always null for hemispheric lights because it does not support shadows.
  14634. */
  14635. getShadowGenerator(): Nullable<IShadowGenerator>;
  14636. /**
  14637. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14638. * @param effect The effect to update
  14639. * @param lightIndex The index of the light in the effect to update
  14640. * @returns The hemispheric light
  14641. */
  14642. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14643. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14644. /**
  14645. * Computes the world matrix of the node
  14646. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14647. * @param useWasUpdatedFlag defines a reserved property
  14648. * @returns the world matrix
  14649. */
  14650. computeWorldMatrix(): Matrix;
  14651. /**
  14652. * Returns the integer 3.
  14653. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14654. */
  14655. getTypeID(): number;
  14656. /**
  14657. * Prepares the list of defines specific to the light type.
  14658. * @param defines the list of defines
  14659. * @param lightIndex defines the index of the light for the effect
  14660. */
  14661. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14662. }
  14663. }
  14664. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14665. /** @hidden */
  14666. export var vrMultiviewToSingleviewPixelShader: {
  14667. name: string;
  14668. shader: string;
  14669. };
  14670. }
  14671. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14672. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14673. import { Scene } from "babylonjs/scene";
  14674. /**
  14675. * Renders to multiple views with a single draw call
  14676. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14677. */
  14678. export class MultiviewRenderTarget extends RenderTargetTexture {
  14679. /**
  14680. * Creates a multiview render target
  14681. * @param scene scene used with the render target
  14682. * @param size the size of the render target (used for each view)
  14683. */
  14684. constructor(scene: Scene, size?: number | {
  14685. width: number;
  14686. height: number;
  14687. } | {
  14688. ratio: number;
  14689. });
  14690. /**
  14691. * @hidden
  14692. * @param faceIndex the face index, if its a cube texture
  14693. */
  14694. _bindFrameBuffer(faceIndex?: number): void;
  14695. /**
  14696. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14697. * @returns the view count
  14698. */
  14699. getViewCount(): number;
  14700. }
  14701. }
  14702. declare module "babylonjs/Maths/math.frustum" {
  14703. import { Matrix } from "babylonjs/Maths/math.vector";
  14704. import { DeepImmutable } from "babylonjs/types";
  14705. import { Plane } from "babylonjs/Maths/math.plane";
  14706. /**
  14707. * Represents a camera frustum
  14708. */
  14709. export class Frustum {
  14710. /**
  14711. * Gets the planes representing the frustum
  14712. * @param transform matrix to be applied to the returned planes
  14713. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14714. */
  14715. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14716. /**
  14717. * Gets the near frustum plane transformed by the transform matrix
  14718. * @param transform transformation matrix to be applied to the resulting frustum plane
  14719. * @param frustumPlane the resuling frustum plane
  14720. */
  14721. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14722. /**
  14723. * Gets the far frustum plane transformed by the transform matrix
  14724. * @param transform transformation matrix to be applied to the resulting frustum plane
  14725. * @param frustumPlane the resuling frustum plane
  14726. */
  14727. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14728. /**
  14729. * Gets the left frustum plane transformed by the transform matrix
  14730. * @param transform transformation matrix to be applied to the resulting frustum plane
  14731. * @param frustumPlane the resuling frustum plane
  14732. */
  14733. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14734. /**
  14735. * Gets the right frustum plane transformed by the transform matrix
  14736. * @param transform transformation matrix to be applied to the resulting frustum plane
  14737. * @param frustumPlane the resuling frustum plane
  14738. */
  14739. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14740. /**
  14741. * Gets the top frustum plane transformed by the transform matrix
  14742. * @param transform transformation matrix to be applied to the resulting frustum plane
  14743. * @param frustumPlane the resuling frustum plane
  14744. */
  14745. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14746. /**
  14747. * Gets the bottom frustum plane transformed by the transform matrix
  14748. * @param transform transformation matrix to be applied to the resulting frustum plane
  14749. * @param frustumPlane the resuling frustum plane
  14750. */
  14751. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14752. /**
  14753. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14754. * @param transform transformation matrix to be applied to the resulting frustum planes
  14755. * @param frustumPlanes the resuling frustum planes
  14756. */
  14757. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14758. }
  14759. }
  14760. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14761. import { Camera } from "babylonjs/Cameras/camera";
  14762. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14763. import { Nullable } from "babylonjs/types";
  14764. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14765. import { Matrix } from "babylonjs/Maths/math.vector";
  14766. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14767. module "babylonjs/Engines/engine" {
  14768. interface Engine {
  14769. /**
  14770. * Creates a new multiview render target
  14771. * @param width defines the width of the texture
  14772. * @param height defines the height of the texture
  14773. * @returns the created multiview texture
  14774. */
  14775. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14776. /**
  14777. * Binds a multiview framebuffer to be drawn to
  14778. * @param multiviewTexture texture to bind
  14779. */
  14780. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14781. }
  14782. }
  14783. module "babylonjs/Cameras/camera" {
  14784. interface Camera {
  14785. /**
  14786. * @hidden
  14787. * 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)
  14788. */
  14789. _useMultiviewToSingleView: boolean;
  14790. /**
  14791. * @hidden
  14792. * 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)
  14793. */
  14794. _multiviewTexture: Nullable<RenderTargetTexture>;
  14795. /**
  14796. * @hidden
  14797. * ensures the multiview texture of the camera exists and has the specified width/height
  14798. * @param width height to set on the multiview texture
  14799. * @param height width to set on the multiview texture
  14800. */
  14801. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14802. }
  14803. }
  14804. module "babylonjs/scene" {
  14805. interface Scene {
  14806. /** @hidden */
  14807. _transformMatrixR: Matrix;
  14808. /** @hidden */
  14809. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14810. /** @hidden */
  14811. _createMultiviewUbo(): void;
  14812. /** @hidden */
  14813. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14814. /** @hidden */
  14815. _renderMultiviewToSingleView(camera: Camera): void;
  14816. }
  14817. }
  14818. }
  14819. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14820. import { Camera } from "babylonjs/Cameras/camera";
  14821. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14822. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14823. import "babylonjs/Engines/Extensions/engine.multiview";
  14824. /**
  14825. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14826. * This will not be used for webXR as it supports displaying texture arrays directly
  14827. */
  14828. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14829. /**
  14830. * Initializes a VRMultiviewToSingleview
  14831. * @param name name of the post process
  14832. * @param camera camera to be applied to
  14833. * @param scaleFactor scaling factor to the size of the output texture
  14834. */
  14835. constructor(name: string, camera: Camera, scaleFactor: number);
  14836. }
  14837. }
  14838. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  14839. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  14840. import { Nullable } from "babylonjs/types";
  14841. import { Size } from "babylonjs/Maths/math.size";
  14842. import { Observable } from "babylonjs/Misc/observable";
  14843. module "babylonjs/Engines/engine" {
  14844. interface Engine {
  14845. /** @hidden */
  14846. _vrDisplay: any;
  14847. /** @hidden */
  14848. _vrSupported: boolean;
  14849. /** @hidden */
  14850. _oldSize: Size;
  14851. /** @hidden */
  14852. _oldHardwareScaleFactor: number;
  14853. /** @hidden */
  14854. _vrExclusivePointerMode: boolean;
  14855. /** @hidden */
  14856. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14857. /** @hidden */
  14858. _onVRDisplayPointerRestricted: () => void;
  14859. /** @hidden */
  14860. _onVRDisplayPointerUnrestricted: () => void;
  14861. /** @hidden */
  14862. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14863. /** @hidden */
  14864. _onVrDisplayDisconnect: Nullable<() => void>;
  14865. /** @hidden */
  14866. _onVrDisplayPresentChange: Nullable<() => void>;
  14867. /**
  14868. * Observable signaled when VR display mode changes
  14869. */
  14870. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14871. /**
  14872. * Observable signaled when VR request present is complete
  14873. */
  14874. onVRRequestPresentComplete: Observable<boolean>;
  14875. /**
  14876. * Observable signaled when VR request present starts
  14877. */
  14878. onVRRequestPresentStart: Observable<Engine>;
  14879. /**
  14880. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14881. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14882. */
  14883. isInVRExclusivePointerMode: boolean;
  14884. /**
  14885. * Gets a boolean indicating if a webVR device was detected
  14886. * @returns true if a webVR device was detected
  14887. */
  14888. isVRDevicePresent(): boolean;
  14889. /**
  14890. * Gets the current webVR device
  14891. * @returns the current webVR device (or null)
  14892. */
  14893. getVRDevice(): any;
  14894. /**
  14895. * Initializes a webVR display and starts listening to display change events
  14896. * The onVRDisplayChangedObservable will be notified upon these changes
  14897. * @returns A promise containing a VRDisplay and if vr is supported
  14898. */
  14899. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14900. /** @hidden */
  14901. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14902. /**
  14903. * Call this function to switch to webVR mode
  14904. * Will do nothing if webVR is not supported or if there is no webVR device
  14905. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14906. */
  14907. enableVR(): void;
  14908. /** @hidden */
  14909. _onVRFullScreenTriggered(): void;
  14910. }
  14911. }
  14912. }
  14913. declare module "babylonjs/Cameras/VR/webVRCamera" {
  14914. import { Nullable } from "babylonjs/types";
  14915. import { Observable } from "babylonjs/Misc/observable";
  14916. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  14917. import { Scene } from "babylonjs/scene";
  14918. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14919. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  14920. import { Node } from "babylonjs/node";
  14921. import { Ray } from "babylonjs/Culling/ray";
  14922. import "babylonjs/Cameras/RigModes/webVRRigMode";
  14923. import "babylonjs/Engines/Extensions/engine.webVR";
  14924. /**
  14925. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14926. * IMPORTANT!! The data is right-hand data.
  14927. * @export
  14928. * @interface DevicePose
  14929. */
  14930. export interface DevicePose {
  14931. /**
  14932. * The position of the device, values in array are [x,y,z].
  14933. */
  14934. readonly position: Nullable<Float32Array>;
  14935. /**
  14936. * The linearVelocity of the device, values in array are [x,y,z].
  14937. */
  14938. readonly linearVelocity: Nullable<Float32Array>;
  14939. /**
  14940. * The linearAcceleration of the device, values in array are [x,y,z].
  14941. */
  14942. readonly linearAcceleration: Nullable<Float32Array>;
  14943. /**
  14944. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14945. */
  14946. readonly orientation: Nullable<Float32Array>;
  14947. /**
  14948. * The angularVelocity of the device, values in array are [x,y,z].
  14949. */
  14950. readonly angularVelocity: Nullable<Float32Array>;
  14951. /**
  14952. * The angularAcceleration of the device, values in array are [x,y,z].
  14953. */
  14954. readonly angularAcceleration: Nullable<Float32Array>;
  14955. }
  14956. /**
  14957. * Interface representing a pose controlled object in Babylon.
  14958. * A pose controlled object has both regular pose values as well as pose values
  14959. * from an external device such as a VR head mounted display
  14960. */
  14961. export interface PoseControlled {
  14962. /**
  14963. * The position of the object in babylon space.
  14964. */
  14965. position: Vector3;
  14966. /**
  14967. * The rotation quaternion of the object in babylon space.
  14968. */
  14969. rotationQuaternion: Quaternion;
  14970. /**
  14971. * The position of the device in babylon space.
  14972. */
  14973. devicePosition?: Vector3;
  14974. /**
  14975. * The rotation quaternion of the device in babylon space.
  14976. */
  14977. deviceRotationQuaternion: Quaternion;
  14978. /**
  14979. * The raw pose coming from the device.
  14980. */
  14981. rawPose: Nullable<DevicePose>;
  14982. /**
  14983. * The scale of the device to be used when translating from device space to babylon space.
  14984. */
  14985. deviceScaleFactor: number;
  14986. /**
  14987. * Updates the poseControlled values based on the input device pose.
  14988. * @param poseData the pose data to update the object with
  14989. */
  14990. updateFromDevice(poseData: DevicePose): void;
  14991. }
  14992. /**
  14993. * Set of options to customize the webVRCamera
  14994. */
  14995. export interface WebVROptions {
  14996. /**
  14997. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14998. */
  14999. trackPosition?: boolean;
  15000. /**
  15001. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15002. */
  15003. positionScale?: number;
  15004. /**
  15005. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15006. */
  15007. displayName?: string;
  15008. /**
  15009. * Should the native controller meshes be initialized. (default: true)
  15010. */
  15011. controllerMeshes?: boolean;
  15012. /**
  15013. * Creating a default HemiLight only on controllers. (default: true)
  15014. */
  15015. defaultLightingOnControllers?: boolean;
  15016. /**
  15017. * If you don't want to use the default VR button of the helper. (default: false)
  15018. */
  15019. useCustomVRButton?: boolean;
  15020. /**
  15021. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15022. */
  15023. customVRButton?: HTMLButtonElement;
  15024. /**
  15025. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15026. */
  15027. rayLength?: number;
  15028. /**
  15029. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15030. */
  15031. defaultHeight?: number;
  15032. /**
  15033. * If multiview should be used if availible (default: false)
  15034. */
  15035. useMultiview?: boolean;
  15036. }
  15037. /**
  15038. * This represents a WebVR camera.
  15039. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15040. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15041. */
  15042. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15043. private webVROptions;
  15044. /**
  15045. * @hidden
  15046. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15047. */
  15048. _vrDevice: any;
  15049. /**
  15050. * The rawPose of the vrDevice.
  15051. */
  15052. rawPose: Nullable<DevicePose>;
  15053. private _onVREnabled;
  15054. private _specsVersion;
  15055. private _attached;
  15056. private _frameData;
  15057. protected _descendants: Array<Node>;
  15058. private _deviceRoomPosition;
  15059. /** @hidden */
  15060. _deviceRoomRotationQuaternion: Quaternion;
  15061. private _standingMatrix;
  15062. /**
  15063. * Represents device position in babylon space.
  15064. */
  15065. devicePosition: Vector3;
  15066. /**
  15067. * Represents device rotation in babylon space.
  15068. */
  15069. deviceRotationQuaternion: Quaternion;
  15070. /**
  15071. * The scale of the device to be used when translating from device space to babylon space.
  15072. */
  15073. deviceScaleFactor: number;
  15074. private _deviceToWorld;
  15075. private _worldToDevice;
  15076. /**
  15077. * References to the webVR controllers for the vrDevice.
  15078. */
  15079. controllers: Array<WebVRController>;
  15080. /**
  15081. * Emits an event when a controller is attached.
  15082. */
  15083. onControllersAttachedObservable: Observable<WebVRController[]>;
  15084. /**
  15085. * Emits an event when a controller's mesh has been loaded;
  15086. */
  15087. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15088. /**
  15089. * Emits an event when the HMD's pose has been updated.
  15090. */
  15091. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15092. private _poseSet;
  15093. /**
  15094. * If the rig cameras be used as parent instead of this camera.
  15095. */
  15096. rigParenting: boolean;
  15097. private _lightOnControllers;
  15098. private _defaultHeight?;
  15099. /**
  15100. * Instantiates a WebVRFreeCamera.
  15101. * @param name The name of the WebVRFreeCamera
  15102. * @param position The starting anchor position for the camera
  15103. * @param scene The scene the camera belongs to
  15104. * @param webVROptions a set of customizable options for the webVRCamera
  15105. */
  15106. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15107. /**
  15108. * Gets the device distance from the ground in meters.
  15109. * @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.
  15110. */
  15111. deviceDistanceToRoomGround(): number;
  15112. /**
  15113. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15114. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15115. */
  15116. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15117. /**
  15118. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15119. * @returns A promise with a boolean set to if the standing matrix is supported.
  15120. */
  15121. useStandingMatrixAsync(): Promise<boolean>;
  15122. /**
  15123. * Disposes the camera
  15124. */
  15125. dispose(): void;
  15126. /**
  15127. * Gets a vrController by name.
  15128. * @param name The name of the controller to retreive
  15129. * @returns the controller matching the name specified or null if not found
  15130. */
  15131. getControllerByName(name: string): Nullable<WebVRController>;
  15132. private _leftController;
  15133. /**
  15134. * The controller corresponding to the users left hand.
  15135. */
  15136. readonly leftController: Nullable<WebVRController>;
  15137. private _rightController;
  15138. /**
  15139. * The controller corresponding to the users right hand.
  15140. */
  15141. readonly rightController: Nullable<WebVRController>;
  15142. /**
  15143. * Casts a ray forward from the vrCamera's gaze.
  15144. * @param length Length of the ray (default: 100)
  15145. * @returns the ray corresponding to the gaze
  15146. */
  15147. getForwardRay(length?: number): Ray;
  15148. /**
  15149. * @hidden
  15150. * Updates the camera based on device's frame data
  15151. */
  15152. _checkInputs(): void;
  15153. /**
  15154. * Updates the poseControlled values based on the input device pose.
  15155. * @param poseData Pose coming from the device
  15156. */
  15157. updateFromDevice(poseData: DevicePose): void;
  15158. private _htmlElementAttached;
  15159. private _detachIfAttached;
  15160. /**
  15161. * WebVR's attach control will start broadcasting frames to the device.
  15162. * Note that in certain browsers (chrome for example) this function must be called
  15163. * within a user-interaction callback. Example:
  15164. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15165. *
  15166. * @param element html element to attach the vrDevice to
  15167. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15168. */
  15169. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15170. /**
  15171. * Detaches the camera from the html element and disables VR
  15172. *
  15173. * @param element html element to detach from
  15174. */
  15175. detachControl(element: HTMLElement): void;
  15176. /**
  15177. * @returns the name of this class
  15178. */
  15179. getClassName(): string;
  15180. /**
  15181. * Calls resetPose on the vrDisplay
  15182. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15183. */
  15184. resetToCurrentRotation(): void;
  15185. /**
  15186. * @hidden
  15187. * Updates the rig cameras (left and right eye)
  15188. */
  15189. _updateRigCameras(): void;
  15190. private _workingVector;
  15191. private _oneVector;
  15192. private _workingMatrix;
  15193. private updateCacheCalled;
  15194. private _correctPositionIfNotTrackPosition;
  15195. /**
  15196. * @hidden
  15197. * Updates the cached values of the camera
  15198. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15199. */
  15200. _updateCache(ignoreParentClass?: boolean): void;
  15201. /**
  15202. * @hidden
  15203. * Get current device position in babylon world
  15204. */
  15205. _computeDevicePosition(): void;
  15206. /**
  15207. * Updates the current device position and rotation in the babylon world
  15208. */
  15209. update(): void;
  15210. /**
  15211. * @hidden
  15212. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15213. * @returns an identity matrix
  15214. */
  15215. _getViewMatrix(): Matrix;
  15216. private _tmpMatrix;
  15217. /**
  15218. * This function is called by the two RIG cameras.
  15219. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15220. * @hidden
  15221. */
  15222. _getWebVRViewMatrix(): Matrix;
  15223. /** @hidden */
  15224. _getWebVRProjectionMatrix(): Matrix;
  15225. private _onGamepadConnectedObserver;
  15226. private _onGamepadDisconnectedObserver;
  15227. private _updateCacheWhenTrackingDisabledObserver;
  15228. /**
  15229. * Initializes the controllers and their meshes
  15230. */
  15231. initControllers(): void;
  15232. }
  15233. }
  15234. declare module "babylonjs/PostProcesses/postProcess" {
  15235. import { Nullable } from "babylonjs/types";
  15236. import { SmartArray } from "babylonjs/Misc/smartArray";
  15237. import { Observable } from "babylonjs/Misc/observable";
  15238. import { Vector2 } from "babylonjs/Maths/math.vector";
  15239. import { Camera } from "babylonjs/Cameras/camera";
  15240. import { Effect } from "babylonjs/Materials/effect";
  15241. import "babylonjs/Shaders/postprocess.vertex";
  15242. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15243. import { Engine } from "babylonjs/Engines/engine";
  15244. import { Color4 } from "babylonjs/Maths/math.color";
  15245. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15246. /**
  15247. * Size options for a post process
  15248. */
  15249. export type PostProcessOptions = {
  15250. width: number;
  15251. height: number;
  15252. };
  15253. /**
  15254. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15255. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15256. */
  15257. export class PostProcess {
  15258. /** Name of the PostProcess. */
  15259. name: string;
  15260. /**
  15261. * Gets or sets the unique id of the post process
  15262. */
  15263. uniqueId: number;
  15264. /**
  15265. * Width of the texture to apply the post process on
  15266. */
  15267. width: number;
  15268. /**
  15269. * Height of the texture to apply the post process on
  15270. */
  15271. height: number;
  15272. /**
  15273. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15274. * @hidden
  15275. */
  15276. _outputTexture: Nullable<InternalTexture>;
  15277. /**
  15278. * Sampling mode used by the shader
  15279. * See https://doc.babylonjs.com/classes/3.1/texture
  15280. */
  15281. renderTargetSamplingMode: number;
  15282. /**
  15283. * Clear color to use when screen clearing
  15284. */
  15285. clearColor: Color4;
  15286. /**
  15287. * If the buffer needs to be cleared before applying the post process. (default: true)
  15288. * Should be set to false if shader will overwrite all previous pixels.
  15289. */
  15290. autoClear: boolean;
  15291. /**
  15292. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15293. */
  15294. alphaMode: number;
  15295. /**
  15296. * Sets the setAlphaBlendConstants of the babylon engine
  15297. */
  15298. alphaConstants: Color4;
  15299. /**
  15300. * Animations to be used for the post processing
  15301. */
  15302. animations: import("babylonjs/Animations/animation").Animation[];
  15303. /**
  15304. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15305. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15306. */
  15307. enablePixelPerfectMode: boolean;
  15308. /**
  15309. * Force the postprocess to be applied without taking in account viewport
  15310. */
  15311. forceFullscreenViewport: boolean;
  15312. /**
  15313. * List of inspectable custom properties (used by the Inspector)
  15314. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15315. */
  15316. inspectableCustomProperties: IInspectable[];
  15317. /**
  15318. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15319. *
  15320. * | Value | Type | Description |
  15321. * | ----- | ----------------------------------- | ----------- |
  15322. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15323. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15324. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15325. *
  15326. */
  15327. scaleMode: number;
  15328. /**
  15329. * Force textures to be a power of two (default: false)
  15330. */
  15331. alwaysForcePOT: boolean;
  15332. private _samples;
  15333. /**
  15334. * Number of sample textures (default: 1)
  15335. */
  15336. samples: number;
  15337. /**
  15338. * Modify the scale of the post process to be the same as the viewport (default: false)
  15339. */
  15340. adaptScaleToCurrentViewport: boolean;
  15341. private _camera;
  15342. private _scene;
  15343. private _engine;
  15344. private _options;
  15345. private _reusable;
  15346. private _textureType;
  15347. /**
  15348. * Smart array of input and output textures for the post process.
  15349. * @hidden
  15350. */
  15351. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15352. /**
  15353. * The index in _textures that corresponds to the output texture.
  15354. * @hidden
  15355. */
  15356. _currentRenderTextureInd: number;
  15357. private _effect;
  15358. private _samplers;
  15359. private _fragmentUrl;
  15360. private _vertexUrl;
  15361. private _parameters;
  15362. private _scaleRatio;
  15363. protected _indexParameters: any;
  15364. private _shareOutputWithPostProcess;
  15365. private _texelSize;
  15366. private _forcedOutputTexture;
  15367. /**
  15368. * Returns the fragment url or shader name used in the post process.
  15369. * @returns the fragment url or name in the shader store.
  15370. */
  15371. getEffectName(): string;
  15372. /**
  15373. * An event triggered when the postprocess is activated.
  15374. */
  15375. onActivateObservable: Observable<Camera>;
  15376. private _onActivateObserver;
  15377. /**
  15378. * A function that is added to the onActivateObservable
  15379. */
  15380. onActivate: Nullable<(camera: Camera) => void>;
  15381. /**
  15382. * An event triggered when the postprocess changes its size.
  15383. */
  15384. onSizeChangedObservable: Observable<PostProcess>;
  15385. private _onSizeChangedObserver;
  15386. /**
  15387. * A function that is added to the onSizeChangedObservable
  15388. */
  15389. onSizeChanged: (postProcess: PostProcess) => void;
  15390. /**
  15391. * An event triggered when the postprocess applies its effect.
  15392. */
  15393. onApplyObservable: Observable<Effect>;
  15394. private _onApplyObserver;
  15395. /**
  15396. * A function that is added to the onApplyObservable
  15397. */
  15398. onApply: (effect: Effect) => void;
  15399. /**
  15400. * An event triggered before rendering the postprocess
  15401. */
  15402. onBeforeRenderObservable: Observable<Effect>;
  15403. private _onBeforeRenderObserver;
  15404. /**
  15405. * A function that is added to the onBeforeRenderObservable
  15406. */
  15407. onBeforeRender: (effect: Effect) => void;
  15408. /**
  15409. * An event triggered after rendering the postprocess
  15410. */
  15411. onAfterRenderObservable: Observable<Effect>;
  15412. private _onAfterRenderObserver;
  15413. /**
  15414. * A function that is added to the onAfterRenderObservable
  15415. */
  15416. onAfterRender: (efect: Effect) => void;
  15417. /**
  15418. * 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
  15419. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15420. */
  15421. inputTexture: InternalTexture;
  15422. /**
  15423. * Gets the camera which post process is applied to.
  15424. * @returns The camera the post process is applied to.
  15425. */
  15426. getCamera(): Camera;
  15427. /**
  15428. * Gets the texel size of the postprocess.
  15429. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15430. */
  15431. readonly texelSize: Vector2;
  15432. /**
  15433. * Creates a new instance PostProcess
  15434. * @param name The name of the PostProcess.
  15435. * @param fragmentUrl The url of the fragment shader to be used.
  15436. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15437. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15438. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15439. * @param camera The camera to apply the render pass to.
  15440. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15441. * @param engine The engine which the post process will be applied. (default: current engine)
  15442. * @param reusable If the post process can be reused on the same frame. (default: false)
  15443. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15444. * @param textureType Type of textures used when performing the post process. (default: 0)
  15445. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15446. * @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
  15447. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15448. */
  15449. constructor(
  15450. /** Name of the PostProcess. */
  15451. 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);
  15452. /**
  15453. * Gets a string idenfifying the name of the class
  15454. * @returns "PostProcess" string
  15455. */
  15456. getClassName(): string;
  15457. /**
  15458. * Gets the engine which this post process belongs to.
  15459. * @returns The engine the post process was enabled with.
  15460. */
  15461. getEngine(): Engine;
  15462. /**
  15463. * The effect that is created when initializing the post process.
  15464. * @returns The created effect corresponding the the postprocess.
  15465. */
  15466. getEffect(): Effect;
  15467. /**
  15468. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15469. * @param postProcess The post process to share the output with.
  15470. * @returns This post process.
  15471. */
  15472. shareOutputWith(postProcess: PostProcess): PostProcess;
  15473. /**
  15474. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15475. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15476. */
  15477. useOwnOutput(): void;
  15478. /**
  15479. * Updates the effect with the current post process compile time values and recompiles the shader.
  15480. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15481. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15482. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15483. * @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
  15484. * @param onCompiled Called when the shader has been compiled.
  15485. * @param onError Called if there is an error when compiling a shader.
  15486. */
  15487. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15488. /**
  15489. * The post process is reusable if it can be used multiple times within one frame.
  15490. * @returns If the post process is reusable
  15491. */
  15492. isReusable(): boolean;
  15493. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15494. markTextureDirty(): void;
  15495. /**
  15496. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15497. * 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.
  15498. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15499. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15500. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15501. * @returns The target texture that was bound to be written to.
  15502. */
  15503. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15504. /**
  15505. * If the post process is supported.
  15506. */
  15507. readonly isSupported: boolean;
  15508. /**
  15509. * The aspect ratio of the output texture.
  15510. */
  15511. readonly aspectRatio: number;
  15512. /**
  15513. * Get a value indicating if the post-process is ready to be used
  15514. * @returns true if the post-process is ready (shader is compiled)
  15515. */
  15516. isReady(): boolean;
  15517. /**
  15518. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15519. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15520. */
  15521. apply(): Nullable<Effect>;
  15522. private _disposeTextures;
  15523. /**
  15524. * Disposes the post process.
  15525. * @param camera The camera to dispose the post process on.
  15526. */
  15527. dispose(camera?: Camera): void;
  15528. }
  15529. }
  15530. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15531. /** @hidden */
  15532. export var kernelBlurVaryingDeclaration: {
  15533. name: string;
  15534. shader: string;
  15535. };
  15536. }
  15537. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15538. /** @hidden */
  15539. export var kernelBlurFragment: {
  15540. name: string;
  15541. shader: string;
  15542. };
  15543. }
  15544. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15545. /** @hidden */
  15546. export var kernelBlurFragment2: {
  15547. name: string;
  15548. shader: string;
  15549. };
  15550. }
  15551. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15552. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15553. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15554. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15555. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15556. /** @hidden */
  15557. export var kernelBlurPixelShader: {
  15558. name: string;
  15559. shader: string;
  15560. };
  15561. }
  15562. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15563. /** @hidden */
  15564. export var kernelBlurVertex: {
  15565. name: string;
  15566. shader: string;
  15567. };
  15568. }
  15569. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15570. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15571. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15572. /** @hidden */
  15573. export var kernelBlurVertexShader: {
  15574. name: string;
  15575. shader: string;
  15576. };
  15577. }
  15578. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15579. import { Vector2 } from "babylonjs/Maths/math.vector";
  15580. import { Nullable } from "babylonjs/types";
  15581. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15582. import { Camera } from "babylonjs/Cameras/camera";
  15583. import { Effect } from "babylonjs/Materials/effect";
  15584. import { Engine } from "babylonjs/Engines/engine";
  15585. import "babylonjs/Shaders/kernelBlur.fragment";
  15586. import "babylonjs/Shaders/kernelBlur.vertex";
  15587. /**
  15588. * The Blur Post Process which blurs an image based on a kernel and direction.
  15589. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15590. */
  15591. export class BlurPostProcess extends PostProcess {
  15592. /** The direction in which to blur the image. */
  15593. direction: Vector2;
  15594. private blockCompilation;
  15595. protected _kernel: number;
  15596. protected _idealKernel: number;
  15597. protected _packedFloat: boolean;
  15598. private _staticDefines;
  15599. /**
  15600. * Sets the length in pixels of the blur sample region
  15601. */
  15602. /**
  15603. * Gets the length in pixels of the blur sample region
  15604. */
  15605. kernel: number;
  15606. /**
  15607. * Sets wether or not the blur needs to unpack/repack floats
  15608. */
  15609. /**
  15610. * Gets wether or not the blur is unpacking/repacking floats
  15611. */
  15612. packedFloat: boolean;
  15613. /**
  15614. * Creates a new instance BlurPostProcess
  15615. * @param name The name of the effect.
  15616. * @param direction The direction in which to blur the image.
  15617. * @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.
  15618. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15619. * @param camera The camera to apply the render pass to.
  15620. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15621. * @param engine The engine which the post process will be applied. (default: current engine)
  15622. * @param reusable If the post process can be reused on the same frame. (default: false)
  15623. * @param textureType Type of textures used when performing the post process. (default: 0)
  15624. * @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)
  15625. */
  15626. constructor(name: string,
  15627. /** The direction in which to blur the image. */
  15628. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15629. /**
  15630. * Updates the effect with the current post process compile time values and recompiles the shader.
  15631. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15632. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15633. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15634. * @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
  15635. * @param onCompiled Called when the shader has been compiled.
  15636. * @param onError Called if there is an error when compiling a shader.
  15637. */
  15638. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15639. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15640. /**
  15641. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15642. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15643. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15644. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15645. * The gaps between physical kernels are compensated for in the weighting of the samples
  15646. * @param idealKernel Ideal blur kernel.
  15647. * @return Nearest best kernel.
  15648. */
  15649. protected _nearestBestKernel(idealKernel: number): number;
  15650. /**
  15651. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15652. * @param x The point on the Gaussian distribution to sample.
  15653. * @return the value of the Gaussian function at x.
  15654. */
  15655. protected _gaussianWeight(x: number): number;
  15656. /**
  15657. * Generates a string that can be used as a floating point number in GLSL.
  15658. * @param x Value to print.
  15659. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15660. * @return GLSL float string.
  15661. */
  15662. protected _glslFloat(x: number, decimalFigures?: number): string;
  15663. }
  15664. }
  15665. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15666. import { Scene } from "babylonjs/scene";
  15667. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15668. import { Plane } from "babylonjs/Maths/math.plane";
  15669. /**
  15670. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15671. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15672. * You can then easily use it as a reflectionTexture on a flat surface.
  15673. * In case the surface is not a plane, please consider relying on reflection probes.
  15674. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15675. */
  15676. export class MirrorTexture extends RenderTargetTexture {
  15677. private scene;
  15678. /**
  15679. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15680. * 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.
  15681. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15682. */
  15683. mirrorPlane: Plane;
  15684. /**
  15685. * Define the blur ratio used to blur the reflection if needed.
  15686. */
  15687. blurRatio: number;
  15688. /**
  15689. * Define the adaptive blur kernel used to blur the reflection if needed.
  15690. * This will autocompute the closest best match for the `blurKernel`
  15691. */
  15692. adaptiveBlurKernel: number;
  15693. /**
  15694. * Define the blur kernel used to blur the reflection if needed.
  15695. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15696. */
  15697. blurKernel: number;
  15698. /**
  15699. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15700. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15701. */
  15702. blurKernelX: number;
  15703. /**
  15704. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15705. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15706. */
  15707. blurKernelY: number;
  15708. private _autoComputeBlurKernel;
  15709. protected _onRatioRescale(): void;
  15710. private _updateGammaSpace;
  15711. private _imageProcessingConfigChangeObserver;
  15712. private _transformMatrix;
  15713. private _mirrorMatrix;
  15714. private _savedViewMatrix;
  15715. private _blurX;
  15716. private _blurY;
  15717. private _adaptiveBlurKernel;
  15718. private _blurKernelX;
  15719. private _blurKernelY;
  15720. private _blurRatio;
  15721. /**
  15722. * Instantiates a Mirror Texture.
  15723. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15724. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15725. * You can then easily use it as a reflectionTexture on a flat surface.
  15726. * In case the surface is not a plane, please consider relying on reflection probes.
  15727. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15728. * @param name
  15729. * @param size
  15730. * @param scene
  15731. * @param generateMipMaps
  15732. * @param type
  15733. * @param samplingMode
  15734. * @param generateDepthBuffer
  15735. */
  15736. constructor(name: string, size: number | {
  15737. width: number;
  15738. height: number;
  15739. } | {
  15740. ratio: number;
  15741. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15742. private _preparePostProcesses;
  15743. /**
  15744. * Clone the mirror texture.
  15745. * @returns the cloned texture
  15746. */
  15747. clone(): MirrorTexture;
  15748. /**
  15749. * Serialize the texture to a JSON representation you could use in Parse later on
  15750. * @returns the serialized JSON representation
  15751. */
  15752. serialize(): any;
  15753. /**
  15754. * Dispose the texture and release its associated resources.
  15755. */
  15756. dispose(): void;
  15757. }
  15758. }
  15759. declare module "babylonjs/Materials/Textures/texture" {
  15760. import { Observable } from "babylonjs/Misc/observable";
  15761. import { Nullable } from "babylonjs/types";
  15762. import { Scene } from "babylonjs/scene";
  15763. import { Matrix } from "babylonjs/Maths/math.vector";
  15764. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15765. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15766. import { Engine } from "babylonjs/Engines/engine";
  15767. /**
  15768. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15769. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15770. */
  15771. export class Texture extends BaseTexture {
  15772. /**
  15773. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15774. */
  15775. static SerializeBuffers: boolean;
  15776. /** @hidden */
  15777. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15778. /** @hidden */
  15779. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15780. /** @hidden */
  15781. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15782. /** nearest is mag = nearest and min = nearest and mip = linear */
  15783. static readonly NEAREST_SAMPLINGMODE: number;
  15784. /** nearest is mag = nearest and min = nearest and mip = linear */
  15785. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15786. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15787. static readonly BILINEAR_SAMPLINGMODE: number;
  15788. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15789. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15790. /** Trilinear is mag = linear and min = linear and mip = linear */
  15791. static readonly TRILINEAR_SAMPLINGMODE: number;
  15792. /** Trilinear is mag = linear and min = linear and mip = linear */
  15793. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15794. /** mag = nearest and min = nearest and mip = nearest */
  15795. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15796. /** mag = nearest and min = linear and mip = nearest */
  15797. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15798. /** mag = nearest and min = linear and mip = linear */
  15799. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15800. /** mag = nearest and min = linear and mip = none */
  15801. static readonly NEAREST_LINEAR: number;
  15802. /** mag = nearest and min = nearest and mip = none */
  15803. static readonly NEAREST_NEAREST: number;
  15804. /** mag = linear and min = nearest and mip = nearest */
  15805. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15806. /** mag = linear and min = nearest and mip = linear */
  15807. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15808. /** mag = linear and min = linear and mip = none */
  15809. static readonly LINEAR_LINEAR: number;
  15810. /** mag = linear and min = nearest and mip = none */
  15811. static readonly LINEAR_NEAREST: number;
  15812. /** Explicit coordinates mode */
  15813. static readonly EXPLICIT_MODE: number;
  15814. /** Spherical coordinates mode */
  15815. static readonly SPHERICAL_MODE: number;
  15816. /** Planar coordinates mode */
  15817. static readonly PLANAR_MODE: number;
  15818. /** Cubic coordinates mode */
  15819. static readonly CUBIC_MODE: number;
  15820. /** Projection coordinates mode */
  15821. static readonly PROJECTION_MODE: number;
  15822. /** Inverse Cubic coordinates mode */
  15823. static readonly SKYBOX_MODE: number;
  15824. /** Inverse Cubic coordinates mode */
  15825. static readonly INVCUBIC_MODE: number;
  15826. /** Equirectangular coordinates mode */
  15827. static readonly EQUIRECTANGULAR_MODE: number;
  15828. /** Equirectangular Fixed coordinates mode */
  15829. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15830. /** Equirectangular Fixed Mirrored coordinates mode */
  15831. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15832. /** Texture is not repeating outside of 0..1 UVs */
  15833. static readonly CLAMP_ADDRESSMODE: number;
  15834. /** Texture is repeating outside of 0..1 UVs */
  15835. static readonly WRAP_ADDRESSMODE: number;
  15836. /** Texture is repeating and mirrored */
  15837. static readonly MIRROR_ADDRESSMODE: number;
  15838. /**
  15839. * 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
  15840. */
  15841. static UseSerializedUrlIfAny: boolean;
  15842. /**
  15843. * Define the url of the texture.
  15844. */
  15845. url: Nullable<string>;
  15846. /**
  15847. * Define an offset on the texture to offset the u coordinates of the UVs
  15848. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15849. */
  15850. uOffset: number;
  15851. /**
  15852. * Define an offset on the texture to offset the v coordinates of the UVs
  15853. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15854. */
  15855. vOffset: number;
  15856. /**
  15857. * Define an offset on the texture to scale the u coordinates of the UVs
  15858. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15859. */
  15860. uScale: number;
  15861. /**
  15862. * Define an offset on the texture to scale the v coordinates of the UVs
  15863. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15864. */
  15865. vScale: number;
  15866. /**
  15867. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15868. * @see http://doc.babylonjs.com/how_to/more_materials
  15869. */
  15870. uAng: number;
  15871. /**
  15872. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15873. * @see http://doc.babylonjs.com/how_to/more_materials
  15874. */
  15875. vAng: number;
  15876. /**
  15877. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15878. * @see http://doc.babylonjs.com/how_to/more_materials
  15879. */
  15880. wAng: number;
  15881. /**
  15882. * Defines the center of rotation (U)
  15883. */
  15884. uRotationCenter: number;
  15885. /**
  15886. * Defines the center of rotation (V)
  15887. */
  15888. vRotationCenter: number;
  15889. /**
  15890. * Defines the center of rotation (W)
  15891. */
  15892. wRotationCenter: number;
  15893. /**
  15894. * Are mip maps generated for this texture or not.
  15895. */
  15896. readonly noMipmap: boolean;
  15897. /**
  15898. * List of inspectable custom properties (used by the Inspector)
  15899. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15900. */
  15901. inspectableCustomProperties: Nullable<IInspectable[]>;
  15902. private _noMipmap;
  15903. /** @hidden */
  15904. _invertY: boolean;
  15905. private _rowGenerationMatrix;
  15906. private _cachedTextureMatrix;
  15907. private _projectionModeMatrix;
  15908. private _t0;
  15909. private _t1;
  15910. private _t2;
  15911. private _cachedUOffset;
  15912. private _cachedVOffset;
  15913. private _cachedUScale;
  15914. private _cachedVScale;
  15915. private _cachedUAng;
  15916. private _cachedVAng;
  15917. private _cachedWAng;
  15918. private _cachedProjectionMatrixId;
  15919. private _cachedCoordinatesMode;
  15920. /** @hidden */
  15921. protected _initialSamplingMode: number;
  15922. /** @hidden */
  15923. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15924. private _deleteBuffer;
  15925. protected _format: Nullable<number>;
  15926. private _delayedOnLoad;
  15927. private _delayedOnError;
  15928. /**
  15929. * Observable triggered once the texture has been loaded.
  15930. */
  15931. onLoadObservable: Observable<Texture>;
  15932. protected _isBlocking: boolean;
  15933. /**
  15934. * Is the texture preventing material to render while loading.
  15935. * If false, a default texture will be used instead of the loading one during the preparation step.
  15936. */
  15937. isBlocking: boolean;
  15938. /**
  15939. * Get the current sampling mode associated with the texture.
  15940. */
  15941. readonly samplingMode: number;
  15942. /**
  15943. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15944. */
  15945. readonly invertY: boolean;
  15946. /**
  15947. * Instantiates a new texture.
  15948. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15949. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15950. * @param url define the url of the picture to load as a texture
  15951. * @param scene define the scene or engine the texture will belong to
  15952. * @param noMipmap define if the texture will require mip maps or not
  15953. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15954. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15955. * @param onLoad define a callback triggered when the texture has been loaded
  15956. * @param onError define a callback triggered when an error occurred during the loading session
  15957. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15958. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15959. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15960. */
  15961. 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 | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15962. /**
  15963. * Update the url (and optional buffer) of this texture if url was null during construction.
  15964. * @param url the url of the texture
  15965. * @param buffer the buffer of the texture (defaults to null)
  15966. * @param onLoad callback called when the texture is loaded (defaults to null)
  15967. */
  15968. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15969. /**
  15970. * Finish the loading sequence of a texture flagged as delayed load.
  15971. * @hidden
  15972. */
  15973. delayLoad(): void;
  15974. private _prepareRowForTextureGeneration;
  15975. /**
  15976. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15977. * @returns the transform matrix of the texture.
  15978. */
  15979. getTextureMatrix(): Matrix;
  15980. /**
  15981. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15982. * @returns The reflection texture transform
  15983. */
  15984. getReflectionTextureMatrix(): Matrix;
  15985. /**
  15986. * Clones the texture.
  15987. * @returns the cloned texture
  15988. */
  15989. clone(): Texture;
  15990. /**
  15991. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15992. * @returns The JSON representation of the texture
  15993. */
  15994. serialize(): any;
  15995. /**
  15996. * Get the current class name of the texture useful for serialization or dynamic coding.
  15997. * @returns "Texture"
  15998. */
  15999. getClassName(): string;
  16000. /**
  16001. * Dispose the texture and release its associated resources.
  16002. */
  16003. dispose(): void;
  16004. /**
  16005. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16006. * @param parsedTexture Define the JSON representation of the texture
  16007. * @param scene Define the scene the parsed texture should be instantiated in
  16008. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16009. * @returns The parsed texture if successful
  16010. */
  16011. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16012. /**
  16013. * Creates a texture from its base 64 representation.
  16014. * @param data Define the base64 payload without the data: prefix
  16015. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16016. * @param scene Define the scene the texture should belong to
  16017. * @param noMipmap Forces the texture to not create mip map information if true
  16018. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16019. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16020. * @param onLoad define a callback triggered when the texture has been loaded
  16021. * @param onError define a callback triggered when an error occurred during the loading session
  16022. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16023. * @returns the created texture
  16024. */
  16025. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16026. /**
  16027. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16028. * @param data Define the base64 payload without the data: prefix
  16029. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16030. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16031. * @param scene Define the scene the texture should belong to
  16032. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16033. * @param noMipmap Forces the texture to not create mip map information if true
  16034. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16035. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16036. * @param onLoad define a callback triggered when the texture has been loaded
  16037. * @param onError define a callback triggered when an error occurred during the loading session
  16038. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16039. * @returns the created texture
  16040. */
  16041. 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;
  16042. }
  16043. }
  16044. declare module "babylonjs/PostProcesses/postProcessManager" {
  16045. import { Nullable } from "babylonjs/types";
  16046. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16047. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16048. import { Scene } from "babylonjs/scene";
  16049. /**
  16050. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16051. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16052. */
  16053. export class PostProcessManager {
  16054. private _scene;
  16055. private _indexBuffer;
  16056. private _vertexBuffers;
  16057. /**
  16058. * Creates a new instance PostProcess
  16059. * @param scene The scene that the post process is associated with.
  16060. */
  16061. constructor(scene: Scene);
  16062. private _prepareBuffers;
  16063. private _buildIndexBuffer;
  16064. /**
  16065. * Rebuilds the vertex buffers of the manager.
  16066. * @hidden
  16067. */
  16068. _rebuild(): void;
  16069. /**
  16070. * Prepares a frame to be run through a post process.
  16071. * @param sourceTexture The input texture to the post procesess. (default: null)
  16072. * @param postProcesses An array of post processes to be run. (default: null)
  16073. * @returns True if the post processes were able to be run.
  16074. * @hidden
  16075. */
  16076. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16077. /**
  16078. * Manually render a set of post processes to a texture.
  16079. * @param postProcesses An array of post processes to be run.
  16080. * @param targetTexture The target texture to render to.
  16081. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16082. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16083. * @param lodLevel defines which lod of the texture to render to
  16084. */
  16085. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16086. /**
  16087. * Finalize the result of the output of the postprocesses.
  16088. * @param doNotPresent If true the result will not be displayed to the screen.
  16089. * @param targetTexture The target texture to render to.
  16090. * @param faceIndex The index of the face to bind the target texture to.
  16091. * @param postProcesses The array of post processes to render.
  16092. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16093. * @hidden
  16094. */
  16095. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16096. /**
  16097. * Disposes of the post process manager.
  16098. */
  16099. dispose(): void;
  16100. }
  16101. }
  16102. declare module "babylonjs/Misc/gradients" {
  16103. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16104. /** Interface used by value gradients (color, factor, ...) */
  16105. export interface IValueGradient {
  16106. /**
  16107. * Gets or sets the gradient value (between 0 and 1)
  16108. */
  16109. gradient: number;
  16110. }
  16111. /** Class used to store color4 gradient */
  16112. export class ColorGradient implements IValueGradient {
  16113. /**
  16114. * Gets or sets the gradient value (between 0 and 1)
  16115. */
  16116. gradient: number;
  16117. /**
  16118. * Gets or sets first associated color
  16119. */
  16120. color1: Color4;
  16121. /**
  16122. * Gets or sets second associated color
  16123. */
  16124. color2?: Color4;
  16125. /**
  16126. * Will get a color picked randomly between color1 and color2.
  16127. * If color2 is undefined then color1 will be used
  16128. * @param result defines the target Color4 to store the result in
  16129. */
  16130. getColorToRef(result: Color4): void;
  16131. }
  16132. /** Class used to store color 3 gradient */
  16133. export class Color3Gradient implements IValueGradient {
  16134. /**
  16135. * Gets or sets the gradient value (between 0 and 1)
  16136. */
  16137. gradient: number;
  16138. /**
  16139. * Gets or sets the associated color
  16140. */
  16141. color: Color3;
  16142. }
  16143. /** Class used to store factor gradient */
  16144. export class FactorGradient implements IValueGradient {
  16145. /**
  16146. * Gets or sets the gradient value (between 0 and 1)
  16147. */
  16148. gradient: number;
  16149. /**
  16150. * Gets or sets first associated factor
  16151. */
  16152. factor1: number;
  16153. /**
  16154. * Gets or sets second associated factor
  16155. */
  16156. factor2?: number;
  16157. /**
  16158. * Will get a number picked randomly between factor1 and factor2.
  16159. * If factor2 is undefined then factor1 will be used
  16160. * @returns the picked number
  16161. */
  16162. getFactor(): number;
  16163. }
  16164. /**
  16165. * Helper used to simplify some generic gradient tasks
  16166. */
  16167. export class GradientHelper {
  16168. /**
  16169. * Gets the current gradient from an array of IValueGradient
  16170. * @param ratio defines the current ratio to get
  16171. * @param gradients defines the array of IValueGradient
  16172. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16173. */
  16174. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16175. }
  16176. }
  16177. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16178. import { Scene } from "babylonjs/scene";
  16179. import { Texture } from "babylonjs/Materials/Textures/texture";
  16180. /**
  16181. * A class extending Texture allowing drawing on a texture
  16182. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16183. */
  16184. export class DynamicTexture extends Texture {
  16185. private _generateMipMaps;
  16186. private _canvas;
  16187. private _context;
  16188. private _engine;
  16189. /**
  16190. * Creates a DynamicTexture
  16191. * @param name defines the name of the texture
  16192. * @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
  16193. * @param scene defines the scene where you want the texture
  16194. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16195. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16196. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16197. */
  16198. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16199. /**
  16200. * Get the current class name of the texture useful for serialization or dynamic coding.
  16201. * @returns "DynamicTexture"
  16202. */
  16203. getClassName(): string;
  16204. /**
  16205. * Gets the current state of canRescale
  16206. */
  16207. readonly canRescale: boolean;
  16208. private _recreate;
  16209. /**
  16210. * Scales the texture
  16211. * @param ratio the scale factor to apply to both width and height
  16212. */
  16213. scale(ratio: number): void;
  16214. /**
  16215. * Resizes the texture
  16216. * @param width the new width
  16217. * @param height the new height
  16218. */
  16219. scaleTo(width: number, height: number): void;
  16220. /**
  16221. * Gets the context of the canvas used by the texture
  16222. * @returns the canvas context of the dynamic texture
  16223. */
  16224. getContext(): CanvasRenderingContext2D;
  16225. /**
  16226. * Clears the texture
  16227. */
  16228. clear(): void;
  16229. /**
  16230. * Updates the texture
  16231. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16232. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16233. */
  16234. update(invertY?: boolean, premulAlpha?: boolean): void;
  16235. /**
  16236. * Draws text onto the texture
  16237. * @param text defines the text to be drawn
  16238. * @param x defines the placement of the text from the left
  16239. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16240. * @param font defines the font to be used with font-style, font-size, font-name
  16241. * @param color defines the color used for the text
  16242. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16243. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16244. * @param update defines whether texture is immediately update (default is true)
  16245. */
  16246. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16247. /**
  16248. * Clones the texture
  16249. * @returns the clone of the texture.
  16250. */
  16251. clone(): DynamicTexture;
  16252. /**
  16253. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16254. * @returns a serialized dynamic texture object
  16255. */
  16256. serialize(): any;
  16257. /** @hidden */
  16258. _rebuild(): void;
  16259. }
  16260. }
  16261. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16262. import { Scene } from "babylonjs/scene";
  16263. import { ISceneComponent } from "babylonjs/sceneComponent";
  16264. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16265. module "babylonjs/abstractScene" {
  16266. interface AbstractScene {
  16267. /**
  16268. * The list of procedural textures added to the scene
  16269. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16270. */
  16271. proceduralTextures: Array<ProceduralTexture>;
  16272. }
  16273. }
  16274. /**
  16275. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16276. * in a given scene.
  16277. */
  16278. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16279. /**
  16280. * The component name helpfull to identify the component in the list of scene components.
  16281. */
  16282. readonly name: string;
  16283. /**
  16284. * The scene the component belongs to.
  16285. */
  16286. scene: Scene;
  16287. /**
  16288. * Creates a new instance of the component for the given scene
  16289. * @param scene Defines the scene to register the component in
  16290. */
  16291. constructor(scene: Scene);
  16292. /**
  16293. * Registers the component in a given scene
  16294. */
  16295. register(): void;
  16296. /**
  16297. * Rebuilds the elements related to this component in case of
  16298. * context lost for instance.
  16299. */
  16300. rebuild(): void;
  16301. /**
  16302. * Disposes the component and the associated ressources.
  16303. */
  16304. dispose(): void;
  16305. private _beforeClear;
  16306. }
  16307. }
  16308. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16309. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16310. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16311. module "babylonjs/Engines/engine" {
  16312. interface Engine {
  16313. /**
  16314. * Creates a new render target cube texture
  16315. * @param size defines the size of the texture
  16316. * @param options defines the options used to create the texture
  16317. * @returns a new render target cube texture stored in an InternalTexture
  16318. */
  16319. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16320. }
  16321. }
  16322. }
  16323. declare module "babylonjs/Shaders/procedural.vertex" {
  16324. /** @hidden */
  16325. export var proceduralVertexShader: {
  16326. name: string;
  16327. shader: string;
  16328. };
  16329. }
  16330. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16331. import { Observable } from "babylonjs/Misc/observable";
  16332. import { Nullable } from "babylonjs/types";
  16333. import { Scene } from "babylonjs/scene";
  16334. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16335. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16336. import { Effect } from "babylonjs/Materials/effect";
  16337. import { Texture } from "babylonjs/Materials/Textures/texture";
  16338. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16339. import "babylonjs/Shaders/procedural.vertex";
  16340. /**
  16341. * 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.
  16342. * This is the base class of any Procedural texture and contains most of the shareable code.
  16343. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16344. */
  16345. export class ProceduralTexture extends Texture {
  16346. isCube: boolean;
  16347. /**
  16348. * Define if the texture is enabled or not (disabled texture will not render)
  16349. */
  16350. isEnabled: boolean;
  16351. /**
  16352. * Define if the texture must be cleared before rendering (default is true)
  16353. */
  16354. autoClear: boolean;
  16355. /**
  16356. * Callback called when the texture is generated
  16357. */
  16358. onGenerated: () => void;
  16359. /**
  16360. * Event raised when the texture is generated
  16361. */
  16362. onGeneratedObservable: Observable<ProceduralTexture>;
  16363. /** @hidden */
  16364. _generateMipMaps: boolean;
  16365. /** @hidden **/
  16366. _effect: Effect;
  16367. /** @hidden */
  16368. _textures: {
  16369. [key: string]: Texture;
  16370. };
  16371. private _size;
  16372. private _currentRefreshId;
  16373. private _refreshRate;
  16374. private _vertexBuffers;
  16375. private _indexBuffer;
  16376. private _uniforms;
  16377. private _samplers;
  16378. private _fragment;
  16379. private _floats;
  16380. private _ints;
  16381. private _floatsArrays;
  16382. private _colors3;
  16383. private _colors4;
  16384. private _vectors2;
  16385. private _vectors3;
  16386. private _matrices;
  16387. private _fallbackTexture;
  16388. private _fallbackTextureUsed;
  16389. private _engine;
  16390. private _cachedDefines;
  16391. private _contentUpdateId;
  16392. private _contentData;
  16393. /**
  16394. * Instantiates a new procedural texture.
  16395. * 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.
  16396. * This is the base class of any Procedural texture and contains most of the shareable code.
  16397. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16398. * @param name Define the name of the texture
  16399. * @param size Define the size of the texture to create
  16400. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16401. * @param scene Define the scene the texture belongs to
  16402. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16403. * @param generateMipMaps Define if the texture should creates mip maps or not
  16404. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16405. */
  16406. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16407. /**
  16408. * The effect that is created when initializing the post process.
  16409. * @returns The created effect corresponding the the postprocess.
  16410. */
  16411. getEffect(): Effect;
  16412. /**
  16413. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16414. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16415. */
  16416. getContent(): Nullable<ArrayBufferView>;
  16417. private _createIndexBuffer;
  16418. /** @hidden */
  16419. _rebuild(): void;
  16420. /**
  16421. * Resets the texture in order to recreate its associated resources.
  16422. * This can be called in case of context loss
  16423. */
  16424. reset(): void;
  16425. protected _getDefines(): string;
  16426. /**
  16427. * Is the texture ready to be used ? (rendered at least once)
  16428. * @returns true if ready, otherwise, false.
  16429. */
  16430. isReady(): boolean;
  16431. /**
  16432. * Resets the refresh counter of the texture and start bak from scratch.
  16433. * Could be useful to regenerate the texture if it is setup to render only once.
  16434. */
  16435. resetRefreshCounter(): void;
  16436. /**
  16437. * Set the fragment shader to use in order to render the texture.
  16438. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16439. */
  16440. setFragment(fragment: any): void;
  16441. /**
  16442. * Define the refresh rate of the texture or the rendering frequency.
  16443. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16444. */
  16445. refreshRate: number;
  16446. /** @hidden */
  16447. _shouldRender(): boolean;
  16448. /**
  16449. * Get the size the texture is rendering at.
  16450. * @returns the size (texture is always squared)
  16451. */
  16452. getRenderSize(): number;
  16453. /**
  16454. * Resize the texture to new value.
  16455. * @param size Define the new size the texture should have
  16456. * @param generateMipMaps Define whether the new texture should create mip maps
  16457. */
  16458. resize(size: number, generateMipMaps: boolean): void;
  16459. private _checkUniform;
  16460. /**
  16461. * Set a texture in the shader program used to render.
  16462. * @param name Define the name of the uniform samplers as defined in the shader
  16463. * @param texture Define the texture to bind to this sampler
  16464. * @return the texture itself allowing "fluent" like uniform updates
  16465. */
  16466. setTexture(name: string, texture: Texture): ProceduralTexture;
  16467. /**
  16468. * Set a float in the shader.
  16469. * @param name Define the name of the uniform as defined in the shader
  16470. * @param value Define the value to give to the uniform
  16471. * @return the texture itself allowing "fluent" like uniform updates
  16472. */
  16473. setFloat(name: string, value: number): ProceduralTexture;
  16474. /**
  16475. * Set a int in the shader.
  16476. * @param name Define the name of the uniform as defined in the shader
  16477. * @param value Define the value to give to the uniform
  16478. * @return the texture itself allowing "fluent" like uniform updates
  16479. */
  16480. setInt(name: string, value: number): ProceduralTexture;
  16481. /**
  16482. * Set an array of floats in the shader.
  16483. * @param name Define the name of the uniform as defined in the shader
  16484. * @param value Define the value to give to the uniform
  16485. * @return the texture itself allowing "fluent" like uniform updates
  16486. */
  16487. setFloats(name: string, value: number[]): ProceduralTexture;
  16488. /**
  16489. * Set a vec3 in the shader from a Color3.
  16490. * @param name Define the name of the uniform as defined in the shader
  16491. * @param value Define the value to give to the uniform
  16492. * @return the texture itself allowing "fluent" like uniform updates
  16493. */
  16494. setColor3(name: string, value: Color3): ProceduralTexture;
  16495. /**
  16496. * Set a vec4 in the shader from a Color4.
  16497. * @param name Define the name of the uniform as defined in the shader
  16498. * @param value Define the value to give to the uniform
  16499. * @return the texture itself allowing "fluent" like uniform updates
  16500. */
  16501. setColor4(name: string, value: Color4): ProceduralTexture;
  16502. /**
  16503. * Set a vec2 in the shader from a Vector2.
  16504. * @param name Define the name of the uniform as defined in the shader
  16505. * @param value Define the value to give to the uniform
  16506. * @return the texture itself allowing "fluent" like uniform updates
  16507. */
  16508. setVector2(name: string, value: Vector2): ProceduralTexture;
  16509. /**
  16510. * Set a vec3 in the shader from a Vector3.
  16511. * @param name Define the name of the uniform as defined in the shader
  16512. * @param value Define the value to give to the uniform
  16513. * @return the texture itself allowing "fluent" like uniform updates
  16514. */
  16515. setVector3(name: string, value: Vector3): ProceduralTexture;
  16516. /**
  16517. * Set a mat4 in the shader from a MAtrix.
  16518. * @param name Define the name of the uniform as defined in the shader
  16519. * @param value Define the value to give to the uniform
  16520. * @return the texture itself allowing "fluent" like uniform updates
  16521. */
  16522. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16523. /**
  16524. * Render the texture to its associated render target.
  16525. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16526. */
  16527. render(useCameraPostProcess?: boolean): void;
  16528. /**
  16529. * Clone the texture.
  16530. * @returns the cloned texture
  16531. */
  16532. clone(): ProceduralTexture;
  16533. /**
  16534. * Dispose the texture and release its asoociated resources.
  16535. */
  16536. dispose(): void;
  16537. }
  16538. }
  16539. declare module "babylonjs/Particles/baseParticleSystem" {
  16540. import { Nullable } from "babylonjs/types";
  16541. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16543. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16544. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16545. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16546. import { Scene } from "babylonjs/scene";
  16547. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16548. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16549. import { Texture } from "babylonjs/Materials/Textures/texture";
  16550. import { Color4 } from "babylonjs/Maths/math.color";
  16551. import { Animation } from "babylonjs/Animations/animation";
  16552. /**
  16553. * This represents the base class for particle system in Babylon.
  16554. * 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.
  16555. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16556. * @example https://doc.babylonjs.com/babylon101/particles
  16557. */
  16558. export class BaseParticleSystem {
  16559. /**
  16560. * Source color is added to the destination color without alpha affecting the result
  16561. */
  16562. static BLENDMODE_ONEONE: number;
  16563. /**
  16564. * Blend current color and particle color using particle’s alpha
  16565. */
  16566. static BLENDMODE_STANDARD: number;
  16567. /**
  16568. * Add current color and particle color multiplied by particle’s alpha
  16569. */
  16570. static BLENDMODE_ADD: number;
  16571. /**
  16572. * Multiply current color with particle color
  16573. */
  16574. static BLENDMODE_MULTIPLY: number;
  16575. /**
  16576. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16577. */
  16578. static BLENDMODE_MULTIPLYADD: number;
  16579. /**
  16580. * List of animations used by the particle system.
  16581. */
  16582. animations: Animation[];
  16583. /**
  16584. * The id of the Particle system.
  16585. */
  16586. id: string;
  16587. /**
  16588. * The friendly name of the Particle system.
  16589. */
  16590. name: string;
  16591. /**
  16592. * The rendering group used by the Particle system to chose when to render.
  16593. */
  16594. renderingGroupId: number;
  16595. /**
  16596. * The emitter represents the Mesh or position we are attaching the particle system to.
  16597. */
  16598. emitter: Nullable<AbstractMesh | Vector3>;
  16599. /**
  16600. * The maximum number of particles to emit per frame
  16601. */
  16602. emitRate: number;
  16603. /**
  16604. * If you want to launch only a few particles at once, that can be done, as well.
  16605. */
  16606. manualEmitCount: number;
  16607. /**
  16608. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16609. */
  16610. updateSpeed: number;
  16611. /**
  16612. * The amount of time the particle system is running (depends of the overall update speed).
  16613. */
  16614. targetStopDuration: number;
  16615. /**
  16616. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16617. */
  16618. disposeOnStop: boolean;
  16619. /**
  16620. * Minimum power of emitting particles.
  16621. */
  16622. minEmitPower: number;
  16623. /**
  16624. * Maximum power of emitting particles.
  16625. */
  16626. maxEmitPower: number;
  16627. /**
  16628. * Minimum life time of emitting particles.
  16629. */
  16630. minLifeTime: number;
  16631. /**
  16632. * Maximum life time of emitting particles.
  16633. */
  16634. maxLifeTime: number;
  16635. /**
  16636. * Minimum Size of emitting particles.
  16637. */
  16638. minSize: number;
  16639. /**
  16640. * Maximum Size of emitting particles.
  16641. */
  16642. maxSize: number;
  16643. /**
  16644. * Minimum scale of emitting particles on X axis.
  16645. */
  16646. minScaleX: number;
  16647. /**
  16648. * Maximum scale of emitting particles on X axis.
  16649. */
  16650. maxScaleX: number;
  16651. /**
  16652. * Minimum scale of emitting particles on Y axis.
  16653. */
  16654. minScaleY: number;
  16655. /**
  16656. * Maximum scale of emitting particles on Y axis.
  16657. */
  16658. maxScaleY: number;
  16659. /**
  16660. * Gets or sets the minimal initial rotation in radians.
  16661. */
  16662. minInitialRotation: number;
  16663. /**
  16664. * Gets or sets the maximal initial rotation in radians.
  16665. */
  16666. maxInitialRotation: number;
  16667. /**
  16668. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16669. */
  16670. minAngularSpeed: number;
  16671. /**
  16672. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16673. */
  16674. maxAngularSpeed: number;
  16675. /**
  16676. * The texture used to render each particle. (this can be a spritesheet)
  16677. */
  16678. particleTexture: Nullable<Texture>;
  16679. /**
  16680. * The layer mask we are rendering the particles through.
  16681. */
  16682. layerMask: number;
  16683. /**
  16684. * This can help using your own shader to render the particle system.
  16685. * The according effect will be created
  16686. */
  16687. customShader: any;
  16688. /**
  16689. * By default particle system starts as soon as they are created. This prevents the
  16690. * automatic start to happen and let you decide when to start emitting particles.
  16691. */
  16692. preventAutoStart: boolean;
  16693. private _noiseTexture;
  16694. /**
  16695. * Gets or sets a texture used to add random noise to particle positions
  16696. */
  16697. noiseTexture: Nullable<ProceduralTexture>;
  16698. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16699. noiseStrength: Vector3;
  16700. /**
  16701. * Callback triggered when the particle animation is ending.
  16702. */
  16703. onAnimationEnd: Nullable<() => void>;
  16704. /**
  16705. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16706. */
  16707. blendMode: number;
  16708. /**
  16709. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16710. * to override the particles.
  16711. */
  16712. forceDepthWrite: boolean;
  16713. /** 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 */
  16714. preWarmCycles: number;
  16715. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16716. preWarmStepOffset: number;
  16717. /**
  16718. * 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)
  16719. */
  16720. spriteCellChangeSpeed: number;
  16721. /**
  16722. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16723. */
  16724. startSpriteCellID: number;
  16725. /**
  16726. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16727. */
  16728. endSpriteCellID: number;
  16729. /**
  16730. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16731. */
  16732. spriteCellWidth: number;
  16733. /**
  16734. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16735. */
  16736. spriteCellHeight: number;
  16737. /**
  16738. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16739. */
  16740. spriteRandomStartCell: boolean;
  16741. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16742. translationPivot: Vector2;
  16743. /** @hidden */
  16744. protected _isAnimationSheetEnabled: boolean;
  16745. /**
  16746. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16747. */
  16748. beginAnimationOnStart: boolean;
  16749. /**
  16750. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16751. */
  16752. beginAnimationFrom: number;
  16753. /**
  16754. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16755. */
  16756. beginAnimationTo: number;
  16757. /**
  16758. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16759. */
  16760. beginAnimationLoop: boolean;
  16761. /**
  16762. * Gets or sets a world offset applied to all particles
  16763. */
  16764. worldOffset: Vector3;
  16765. /**
  16766. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16767. */
  16768. isAnimationSheetEnabled: boolean;
  16769. /**
  16770. * Get hosting scene
  16771. * @returns the scene
  16772. */
  16773. getScene(): Scene;
  16774. /**
  16775. * You can use gravity if you want to give an orientation to your particles.
  16776. */
  16777. gravity: Vector3;
  16778. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16779. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16780. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16781. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16782. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16783. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16784. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16785. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16786. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16787. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16788. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16789. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16790. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16791. /**
  16792. * Defines the delay in milliseconds before starting the system (0 by default)
  16793. */
  16794. startDelay: number;
  16795. /**
  16796. * Gets the current list of drag gradients.
  16797. * You must use addDragGradient and removeDragGradient to udpate this list
  16798. * @returns the list of drag gradients
  16799. */
  16800. getDragGradients(): Nullable<Array<FactorGradient>>;
  16801. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16802. limitVelocityDamping: number;
  16803. /**
  16804. * Gets the current list of limit velocity gradients.
  16805. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16806. * @returns the list of limit velocity gradients
  16807. */
  16808. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16809. /**
  16810. * Gets the current list of color gradients.
  16811. * You must use addColorGradient and removeColorGradient to udpate this list
  16812. * @returns the list of color gradients
  16813. */
  16814. getColorGradients(): Nullable<Array<ColorGradient>>;
  16815. /**
  16816. * Gets the current list of size gradients.
  16817. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16818. * @returns the list of size gradients
  16819. */
  16820. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16821. /**
  16822. * Gets the current list of color remap gradients.
  16823. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16824. * @returns the list of color remap gradients
  16825. */
  16826. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16827. /**
  16828. * Gets the current list of alpha remap gradients.
  16829. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16830. * @returns the list of alpha remap gradients
  16831. */
  16832. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16833. /**
  16834. * Gets the current list of life time gradients.
  16835. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16836. * @returns the list of life time gradients
  16837. */
  16838. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16839. /**
  16840. * Gets the current list of angular speed gradients.
  16841. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16842. * @returns the list of angular speed gradients
  16843. */
  16844. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16845. /**
  16846. * Gets the current list of velocity gradients.
  16847. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16848. * @returns the list of velocity gradients
  16849. */
  16850. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16851. /**
  16852. * Gets the current list of start size gradients.
  16853. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16854. * @returns the list of start size gradients
  16855. */
  16856. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16857. /**
  16858. * Gets the current list of emit rate gradients.
  16859. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16860. * @returns the list of emit rate gradients
  16861. */
  16862. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16863. /**
  16864. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16865. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16866. */
  16867. direction1: Vector3;
  16868. /**
  16869. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16870. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16871. */
  16872. direction2: Vector3;
  16873. /**
  16874. * 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.
  16875. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16876. */
  16877. minEmitBox: Vector3;
  16878. /**
  16879. * 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.
  16880. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16881. */
  16882. maxEmitBox: Vector3;
  16883. /**
  16884. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16885. */
  16886. color1: Color4;
  16887. /**
  16888. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16889. */
  16890. color2: Color4;
  16891. /**
  16892. * Color the particle will have at the end of its lifetime
  16893. */
  16894. colorDead: Color4;
  16895. /**
  16896. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16897. */
  16898. textureMask: Color4;
  16899. /**
  16900. * The particle emitter type defines the emitter used by the particle system.
  16901. * It can be for example box, sphere, or cone...
  16902. */
  16903. particleEmitterType: IParticleEmitterType;
  16904. /** @hidden */
  16905. _isSubEmitter: boolean;
  16906. /**
  16907. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16908. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16909. */
  16910. billboardMode: number;
  16911. protected _isBillboardBased: boolean;
  16912. /**
  16913. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16914. */
  16915. isBillboardBased: boolean;
  16916. /**
  16917. * The scene the particle system belongs to.
  16918. */
  16919. protected _scene: Scene;
  16920. /**
  16921. * Local cache of defines for image processing.
  16922. */
  16923. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16924. /**
  16925. * Default configuration related to image processing available in the standard Material.
  16926. */
  16927. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16928. /**
  16929. * Gets the image processing configuration used either in this material.
  16930. */
  16931. /**
  16932. * Sets the Default image processing configuration used either in the this material.
  16933. *
  16934. * If sets to null, the scene one is in use.
  16935. */
  16936. imageProcessingConfiguration: ImageProcessingConfiguration;
  16937. /**
  16938. * Attaches a new image processing configuration to the Standard Material.
  16939. * @param configuration
  16940. */
  16941. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16942. /** @hidden */
  16943. protected _reset(): void;
  16944. /** @hidden */
  16945. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16946. /**
  16947. * Instantiates a particle system.
  16948. * 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.
  16949. * @param name The name of the particle system
  16950. */
  16951. constructor(name: string);
  16952. /**
  16953. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16954. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16955. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16956. * @returns the emitter
  16957. */
  16958. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16959. /**
  16960. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16961. * @param radius The radius of the hemisphere to emit from
  16962. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16963. * @returns the emitter
  16964. */
  16965. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16966. /**
  16967. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16968. * @param radius The radius of the sphere to emit from
  16969. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16970. * @returns the emitter
  16971. */
  16972. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16973. /**
  16974. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16975. * @param radius The radius of the sphere to emit from
  16976. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16977. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16978. * @returns the emitter
  16979. */
  16980. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16981. /**
  16982. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16983. * @param radius The radius of the emission cylinder
  16984. * @param height The height of the emission cylinder
  16985. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16986. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16987. * @returns the emitter
  16988. */
  16989. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16990. /**
  16991. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16992. * @param radius The radius of the cylinder to emit from
  16993. * @param height The height of the emission cylinder
  16994. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16995. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16996. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16997. * @returns the emitter
  16998. */
  16999. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17000. /**
  17001. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17002. * @param radius The radius of the cone to emit from
  17003. * @param angle The base angle of the cone
  17004. * @returns the emitter
  17005. */
  17006. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17007. /**
  17008. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17009. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17010. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17011. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17012. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17013. * @returns the emitter
  17014. */
  17015. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17016. }
  17017. }
  17018. declare module "babylonjs/Particles/subEmitter" {
  17019. import { Scene } from "babylonjs/scene";
  17020. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17021. /**
  17022. * Type of sub emitter
  17023. */
  17024. export enum SubEmitterType {
  17025. /**
  17026. * Attached to the particle over it's lifetime
  17027. */
  17028. ATTACHED = 0,
  17029. /**
  17030. * Created when the particle dies
  17031. */
  17032. END = 1
  17033. }
  17034. /**
  17035. * Sub emitter class used to emit particles from an existing particle
  17036. */
  17037. export class SubEmitter {
  17038. /**
  17039. * the particle system to be used by the sub emitter
  17040. */
  17041. particleSystem: ParticleSystem;
  17042. /**
  17043. * Type of the submitter (Default: END)
  17044. */
  17045. type: SubEmitterType;
  17046. /**
  17047. * 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)
  17048. * Note: This only is supported when using an emitter of type Mesh
  17049. */
  17050. inheritDirection: boolean;
  17051. /**
  17052. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17053. */
  17054. inheritedVelocityAmount: number;
  17055. /**
  17056. * Creates a sub emitter
  17057. * @param particleSystem the particle system to be used by the sub emitter
  17058. */
  17059. constructor(
  17060. /**
  17061. * the particle system to be used by the sub emitter
  17062. */
  17063. particleSystem: ParticleSystem);
  17064. /**
  17065. * Clones the sub emitter
  17066. * @returns the cloned sub emitter
  17067. */
  17068. clone(): SubEmitter;
  17069. /**
  17070. * Serialize current object to a JSON object
  17071. * @returns the serialized object
  17072. */
  17073. serialize(): any;
  17074. /** @hidden */
  17075. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17076. /**
  17077. * Creates a new SubEmitter from a serialized JSON version
  17078. * @param serializationObject defines the JSON object to read from
  17079. * @param scene defines the hosting scene
  17080. * @param rootUrl defines the rootUrl for data loading
  17081. * @returns a new SubEmitter
  17082. */
  17083. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17084. /** Release associated resources */
  17085. dispose(): void;
  17086. }
  17087. }
  17088. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17089. /** @hidden */
  17090. export var clipPlaneFragmentDeclaration: {
  17091. name: string;
  17092. shader: string;
  17093. };
  17094. }
  17095. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17096. /** @hidden */
  17097. export var imageProcessingDeclaration: {
  17098. name: string;
  17099. shader: string;
  17100. };
  17101. }
  17102. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17103. /** @hidden */
  17104. export var imageProcessingFunctions: {
  17105. name: string;
  17106. shader: string;
  17107. };
  17108. }
  17109. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17110. /** @hidden */
  17111. export var clipPlaneFragment: {
  17112. name: string;
  17113. shader: string;
  17114. };
  17115. }
  17116. declare module "babylonjs/Shaders/particles.fragment" {
  17117. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17118. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17119. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17120. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17121. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17122. /** @hidden */
  17123. export var particlesPixelShader: {
  17124. name: string;
  17125. shader: string;
  17126. };
  17127. }
  17128. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17129. /** @hidden */
  17130. export var clipPlaneVertexDeclaration: {
  17131. name: string;
  17132. shader: string;
  17133. };
  17134. }
  17135. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17136. /** @hidden */
  17137. export var clipPlaneVertex: {
  17138. name: string;
  17139. shader: string;
  17140. };
  17141. }
  17142. declare module "babylonjs/Shaders/particles.vertex" {
  17143. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17144. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17145. /** @hidden */
  17146. export var particlesVertexShader: {
  17147. name: string;
  17148. shader: string;
  17149. };
  17150. }
  17151. declare module "babylonjs/Particles/particleSystem" {
  17152. import { Nullable } from "babylonjs/types";
  17153. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17154. import { Observable } from "babylonjs/Misc/observable";
  17155. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17156. import { Effect } from "babylonjs/Materials/effect";
  17157. import { Scene, IDisposable } from "babylonjs/scene";
  17158. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17159. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17160. import { Particle } from "babylonjs/Particles/particle";
  17161. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17162. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17163. import "babylonjs/Shaders/particles.fragment";
  17164. import "babylonjs/Shaders/particles.vertex";
  17165. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17166. /**
  17167. * This represents a particle system in Babylon.
  17168. * 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.
  17169. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17170. * @example https://doc.babylonjs.com/babylon101/particles
  17171. */
  17172. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17173. /**
  17174. * Billboard mode will only apply to Y axis
  17175. */
  17176. static readonly BILLBOARDMODE_Y: number;
  17177. /**
  17178. * Billboard mode will apply to all axes
  17179. */
  17180. static readonly BILLBOARDMODE_ALL: number;
  17181. /**
  17182. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17183. */
  17184. static readonly BILLBOARDMODE_STRETCHED: number;
  17185. /**
  17186. * This function can be defined to provide custom update for active particles.
  17187. * This function will be called instead of regular update (age, position, color, etc.).
  17188. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17189. */
  17190. updateFunction: (particles: Particle[]) => void;
  17191. private _emitterWorldMatrix;
  17192. /**
  17193. * This function can be defined to specify initial direction for every new particle.
  17194. * It by default use the emitterType defined function
  17195. */
  17196. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17197. /**
  17198. * This function can be defined to specify initial position for every new particle.
  17199. * It by default use the emitterType defined function
  17200. */
  17201. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17202. /**
  17203. * @hidden
  17204. */
  17205. _inheritedVelocityOffset: Vector3;
  17206. /**
  17207. * An event triggered when the system is disposed
  17208. */
  17209. onDisposeObservable: Observable<ParticleSystem>;
  17210. private _onDisposeObserver;
  17211. /**
  17212. * Sets a callback that will be triggered when the system is disposed
  17213. */
  17214. onDispose: () => void;
  17215. private _particles;
  17216. private _epsilon;
  17217. private _capacity;
  17218. private _stockParticles;
  17219. private _newPartsExcess;
  17220. private _vertexData;
  17221. private _vertexBuffer;
  17222. private _vertexBuffers;
  17223. private _spriteBuffer;
  17224. private _indexBuffer;
  17225. private _effect;
  17226. private _customEffect;
  17227. private _cachedDefines;
  17228. private _scaledColorStep;
  17229. private _colorDiff;
  17230. private _scaledDirection;
  17231. private _scaledGravity;
  17232. private _currentRenderId;
  17233. private _alive;
  17234. private _useInstancing;
  17235. private _started;
  17236. private _stopped;
  17237. private _actualFrame;
  17238. private _scaledUpdateSpeed;
  17239. private _vertexBufferSize;
  17240. /** @hidden */
  17241. _currentEmitRateGradient: Nullable<FactorGradient>;
  17242. /** @hidden */
  17243. _currentEmitRate1: number;
  17244. /** @hidden */
  17245. _currentEmitRate2: number;
  17246. /** @hidden */
  17247. _currentStartSizeGradient: Nullable<FactorGradient>;
  17248. /** @hidden */
  17249. _currentStartSize1: number;
  17250. /** @hidden */
  17251. _currentStartSize2: number;
  17252. private readonly _rawTextureWidth;
  17253. private _rampGradientsTexture;
  17254. private _useRampGradients;
  17255. /** Gets or sets a boolean indicating that ramp gradients must be used
  17256. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17257. */
  17258. useRampGradients: boolean;
  17259. /**
  17260. * 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.
  17261. * 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: [])
  17262. */
  17263. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17264. private _subEmitters;
  17265. /**
  17266. * @hidden
  17267. * If the particle systems emitter should be disposed when the particle system is disposed
  17268. */
  17269. _disposeEmitterOnDispose: boolean;
  17270. /**
  17271. * The current active Sub-systems, this property is used by the root particle system only.
  17272. */
  17273. activeSubSystems: Array<ParticleSystem>;
  17274. private _rootParticleSystem;
  17275. /**
  17276. * Gets the current list of active particles
  17277. */
  17278. readonly particles: Particle[];
  17279. /**
  17280. * Returns the string "ParticleSystem"
  17281. * @returns a string containing the class name
  17282. */
  17283. getClassName(): string;
  17284. /**
  17285. * Instantiates a particle system.
  17286. * 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.
  17287. * @param name The name of the particle system
  17288. * @param capacity The max number of particles alive at the same time
  17289. * @param scene The scene the particle system belongs to
  17290. * @param customEffect a custom effect used to change the way particles are rendered by default
  17291. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17292. * @param epsilon Offset used to render the particles
  17293. */
  17294. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17295. private _addFactorGradient;
  17296. private _removeFactorGradient;
  17297. /**
  17298. * Adds a new life time gradient
  17299. * @param gradient defines the gradient to use (between 0 and 1)
  17300. * @param factor defines the life time factor to affect to the specified gradient
  17301. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17302. * @returns the current particle system
  17303. */
  17304. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17305. /**
  17306. * Remove a specific life time gradient
  17307. * @param gradient defines the gradient to remove
  17308. * @returns the current particle system
  17309. */
  17310. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17311. /**
  17312. * Adds a new size gradient
  17313. * @param gradient defines the gradient to use (between 0 and 1)
  17314. * @param factor defines the size factor to affect to the specified gradient
  17315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17316. * @returns the current particle system
  17317. */
  17318. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17319. /**
  17320. * Remove a specific size gradient
  17321. * @param gradient defines the gradient to remove
  17322. * @returns the current particle system
  17323. */
  17324. removeSizeGradient(gradient: number): IParticleSystem;
  17325. /**
  17326. * Adds a new color remap gradient
  17327. * @param gradient defines the gradient to use (between 0 and 1)
  17328. * @param min defines the color remap minimal range
  17329. * @param max defines the color remap maximal range
  17330. * @returns the current particle system
  17331. */
  17332. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17333. /**
  17334. * Remove a specific color remap gradient
  17335. * @param gradient defines the gradient to remove
  17336. * @returns the current particle system
  17337. */
  17338. removeColorRemapGradient(gradient: number): IParticleSystem;
  17339. /**
  17340. * Adds a new alpha remap gradient
  17341. * @param gradient defines the gradient to use (between 0 and 1)
  17342. * @param min defines the alpha remap minimal range
  17343. * @param max defines the alpha remap maximal range
  17344. * @returns the current particle system
  17345. */
  17346. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17347. /**
  17348. * Remove a specific alpha remap gradient
  17349. * @param gradient defines the gradient to remove
  17350. * @returns the current particle system
  17351. */
  17352. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17353. /**
  17354. * Adds a new angular speed gradient
  17355. * @param gradient defines the gradient to use (between 0 and 1)
  17356. * @param factor defines the angular speed to affect to the specified gradient
  17357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17358. * @returns the current particle system
  17359. */
  17360. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17361. /**
  17362. * Remove a specific angular speed gradient
  17363. * @param gradient defines the gradient to remove
  17364. * @returns the current particle system
  17365. */
  17366. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17367. /**
  17368. * Adds a new velocity gradient
  17369. * @param gradient defines the gradient to use (between 0 and 1)
  17370. * @param factor defines the velocity to affect to the specified gradient
  17371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17372. * @returns the current particle system
  17373. */
  17374. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17375. /**
  17376. * Remove a specific velocity gradient
  17377. * @param gradient defines the gradient to remove
  17378. * @returns the current particle system
  17379. */
  17380. removeVelocityGradient(gradient: number): IParticleSystem;
  17381. /**
  17382. * Adds a new limit velocity gradient
  17383. * @param gradient defines the gradient to use (between 0 and 1)
  17384. * @param factor defines the limit velocity value to affect to the specified gradient
  17385. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17386. * @returns the current particle system
  17387. */
  17388. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17389. /**
  17390. * Remove a specific limit velocity gradient
  17391. * @param gradient defines the gradient to remove
  17392. * @returns the current particle system
  17393. */
  17394. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17395. /**
  17396. * Adds a new drag gradient
  17397. * @param gradient defines the gradient to use (between 0 and 1)
  17398. * @param factor defines the drag value to affect to the specified gradient
  17399. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17400. * @returns the current particle system
  17401. */
  17402. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17403. /**
  17404. * Remove a specific drag gradient
  17405. * @param gradient defines the gradient to remove
  17406. * @returns the current particle system
  17407. */
  17408. removeDragGradient(gradient: number): IParticleSystem;
  17409. /**
  17410. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17411. * @param gradient defines the gradient to use (between 0 and 1)
  17412. * @param factor defines the emit rate value to affect to the specified gradient
  17413. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17414. * @returns the current particle system
  17415. */
  17416. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17417. /**
  17418. * Remove a specific emit rate gradient
  17419. * @param gradient defines the gradient to remove
  17420. * @returns the current particle system
  17421. */
  17422. removeEmitRateGradient(gradient: number): IParticleSystem;
  17423. /**
  17424. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17425. * @param gradient defines the gradient to use (between 0 and 1)
  17426. * @param factor defines the start size value to affect to the specified gradient
  17427. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17428. * @returns the current particle system
  17429. */
  17430. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17431. /**
  17432. * Remove a specific start size gradient
  17433. * @param gradient defines the gradient to remove
  17434. * @returns the current particle system
  17435. */
  17436. removeStartSizeGradient(gradient: number): IParticleSystem;
  17437. private _createRampGradientTexture;
  17438. /**
  17439. * Gets the current list of ramp gradients.
  17440. * You must use addRampGradient and removeRampGradient to udpate this list
  17441. * @returns the list of ramp gradients
  17442. */
  17443. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17444. /**
  17445. * Adds a new ramp gradient used to remap particle colors
  17446. * @param gradient defines the gradient to use (between 0 and 1)
  17447. * @param color defines the color to affect to the specified gradient
  17448. * @returns the current particle system
  17449. */
  17450. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17451. /**
  17452. * Remove a specific ramp gradient
  17453. * @param gradient defines the gradient to remove
  17454. * @returns the current particle system
  17455. */
  17456. removeRampGradient(gradient: number): ParticleSystem;
  17457. /**
  17458. * Adds a new color gradient
  17459. * @param gradient defines the gradient to use (between 0 and 1)
  17460. * @param color1 defines the color to affect to the specified gradient
  17461. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17462. * @returns this particle system
  17463. */
  17464. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17465. /**
  17466. * Remove a specific color gradient
  17467. * @param gradient defines the gradient to remove
  17468. * @returns this particle system
  17469. */
  17470. removeColorGradient(gradient: number): IParticleSystem;
  17471. private _fetchR;
  17472. protected _reset(): void;
  17473. private _resetEffect;
  17474. private _createVertexBuffers;
  17475. private _createIndexBuffer;
  17476. /**
  17477. * Gets the maximum number of particles active at the same time.
  17478. * @returns The max number of active particles.
  17479. */
  17480. getCapacity(): number;
  17481. /**
  17482. * Gets whether there are still active particles in the system.
  17483. * @returns True if it is alive, otherwise false.
  17484. */
  17485. isAlive(): boolean;
  17486. /**
  17487. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17488. * @returns True if it has been started, otherwise false.
  17489. */
  17490. isStarted(): boolean;
  17491. private _prepareSubEmitterInternalArray;
  17492. /**
  17493. * Starts the particle system and begins to emit
  17494. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17495. */
  17496. start(delay?: number): void;
  17497. /**
  17498. * Stops the particle system.
  17499. * @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.
  17500. */
  17501. stop(stopSubEmitters?: boolean): void;
  17502. /**
  17503. * Remove all active particles
  17504. */
  17505. reset(): void;
  17506. /**
  17507. * @hidden (for internal use only)
  17508. */
  17509. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17510. /**
  17511. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17512. * Its lifetime will start back at 0.
  17513. */
  17514. recycleParticle: (particle: Particle) => void;
  17515. private _stopSubEmitters;
  17516. private _createParticle;
  17517. private _removeFromRoot;
  17518. private _emitFromParticle;
  17519. private _update;
  17520. /** @hidden */
  17521. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17522. /** @hidden */
  17523. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17524. /** @hidden */
  17525. private _getEffect;
  17526. /**
  17527. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17528. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17529. */
  17530. animate(preWarmOnly?: boolean): void;
  17531. private _appendParticleVertices;
  17532. /**
  17533. * Rebuilds the particle system.
  17534. */
  17535. rebuild(): void;
  17536. /**
  17537. * Is this system ready to be used/rendered
  17538. * @return true if the system is ready
  17539. */
  17540. isReady(): boolean;
  17541. private _render;
  17542. /**
  17543. * Renders the particle system in its current state.
  17544. * @returns the current number of particles
  17545. */
  17546. render(): number;
  17547. /**
  17548. * Disposes the particle system and free the associated resources
  17549. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17550. */
  17551. dispose(disposeTexture?: boolean): void;
  17552. /**
  17553. * Clones the particle system.
  17554. * @param name The name of the cloned object
  17555. * @param newEmitter The new emitter to use
  17556. * @returns the cloned particle system
  17557. */
  17558. clone(name: string, newEmitter: any): ParticleSystem;
  17559. /**
  17560. * Serializes the particle system to a JSON object.
  17561. * @returns the JSON object
  17562. */
  17563. serialize(): any;
  17564. /** @hidden */
  17565. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17566. /** @hidden */
  17567. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17568. /**
  17569. * Parses a JSON object to create a particle system.
  17570. * @param parsedParticleSystem The JSON object to parse
  17571. * @param scene The scene to create the particle system in
  17572. * @param rootUrl The root url to use to load external dependencies like texture
  17573. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17574. * @returns the Parsed particle system
  17575. */
  17576. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17577. }
  17578. }
  17579. declare module "babylonjs/Particles/particle" {
  17580. import { Nullable } from "babylonjs/types";
  17581. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17582. import { Color4 } from "babylonjs/Maths/math.color";
  17583. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17584. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17585. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17586. /**
  17587. * A particle represents one of the element emitted by a particle system.
  17588. * This is mainly define by its coordinates, direction, velocity and age.
  17589. */
  17590. export class Particle {
  17591. /**
  17592. * The particle system the particle belongs to.
  17593. */
  17594. particleSystem: ParticleSystem;
  17595. private static _Count;
  17596. /**
  17597. * Unique ID of the particle
  17598. */
  17599. id: number;
  17600. /**
  17601. * The world position of the particle in the scene.
  17602. */
  17603. position: Vector3;
  17604. /**
  17605. * The world direction of the particle in the scene.
  17606. */
  17607. direction: Vector3;
  17608. /**
  17609. * The color of the particle.
  17610. */
  17611. color: Color4;
  17612. /**
  17613. * The color change of the particle per step.
  17614. */
  17615. colorStep: Color4;
  17616. /**
  17617. * Defines how long will the life of the particle be.
  17618. */
  17619. lifeTime: number;
  17620. /**
  17621. * The current age of the particle.
  17622. */
  17623. age: number;
  17624. /**
  17625. * The current size of the particle.
  17626. */
  17627. size: number;
  17628. /**
  17629. * The current scale of the particle.
  17630. */
  17631. scale: Vector2;
  17632. /**
  17633. * The current angle of the particle.
  17634. */
  17635. angle: number;
  17636. /**
  17637. * Defines how fast is the angle changing.
  17638. */
  17639. angularSpeed: number;
  17640. /**
  17641. * Defines the cell index used by the particle to be rendered from a sprite.
  17642. */
  17643. cellIndex: number;
  17644. /**
  17645. * The information required to support color remapping
  17646. */
  17647. remapData: Vector4;
  17648. /** @hidden */
  17649. _randomCellOffset?: number;
  17650. /** @hidden */
  17651. _initialDirection: Nullable<Vector3>;
  17652. /** @hidden */
  17653. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17654. /** @hidden */
  17655. _initialStartSpriteCellID: number;
  17656. /** @hidden */
  17657. _initialEndSpriteCellID: number;
  17658. /** @hidden */
  17659. _currentColorGradient: Nullable<ColorGradient>;
  17660. /** @hidden */
  17661. _currentColor1: Color4;
  17662. /** @hidden */
  17663. _currentColor2: Color4;
  17664. /** @hidden */
  17665. _currentSizeGradient: Nullable<FactorGradient>;
  17666. /** @hidden */
  17667. _currentSize1: number;
  17668. /** @hidden */
  17669. _currentSize2: number;
  17670. /** @hidden */
  17671. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17672. /** @hidden */
  17673. _currentAngularSpeed1: number;
  17674. /** @hidden */
  17675. _currentAngularSpeed2: number;
  17676. /** @hidden */
  17677. _currentVelocityGradient: Nullable<FactorGradient>;
  17678. /** @hidden */
  17679. _currentVelocity1: number;
  17680. /** @hidden */
  17681. _currentVelocity2: number;
  17682. /** @hidden */
  17683. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17684. /** @hidden */
  17685. _currentLimitVelocity1: number;
  17686. /** @hidden */
  17687. _currentLimitVelocity2: number;
  17688. /** @hidden */
  17689. _currentDragGradient: Nullable<FactorGradient>;
  17690. /** @hidden */
  17691. _currentDrag1: number;
  17692. /** @hidden */
  17693. _currentDrag2: number;
  17694. /** @hidden */
  17695. _randomNoiseCoordinates1: Vector3;
  17696. /** @hidden */
  17697. _randomNoiseCoordinates2: Vector3;
  17698. /**
  17699. * Creates a new instance Particle
  17700. * @param particleSystem the particle system the particle belongs to
  17701. */
  17702. constructor(
  17703. /**
  17704. * The particle system the particle belongs to.
  17705. */
  17706. particleSystem: ParticleSystem);
  17707. private updateCellInfoFromSystem;
  17708. /**
  17709. * Defines how the sprite cell index is updated for the particle
  17710. */
  17711. updateCellIndex(): void;
  17712. /** @hidden */
  17713. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17714. /** @hidden */
  17715. _inheritParticleInfoToSubEmitters(): void;
  17716. /** @hidden */
  17717. _reset(): void;
  17718. /**
  17719. * Copy the properties of particle to another one.
  17720. * @param other the particle to copy the information to.
  17721. */
  17722. copyTo(other: Particle): void;
  17723. }
  17724. }
  17725. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17726. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17727. import { Effect } from "babylonjs/Materials/effect";
  17728. import { Particle } from "babylonjs/Particles/particle";
  17729. /**
  17730. * Particle emitter represents a volume emitting particles.
  17731. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17732. */
  17733. export interface IParticleEmitterType {
  17734. /**
  17735. * Called by the particle System when the direction is computed for the created particle.
  17736. * @param worldMatrix is the world matrix of the particle system
  17737. * @param directionToUpdate is the direction vector to update with the result
  17738. * @param particle is the particle we are computed the direction for
  17739. */
  17740. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17741. /**
  17742. * Called by the particle System when the position is computed for the created particle.
  17743. * @param worldMatrix is the world matrix of the particle system
  17744. * @param positionToUpdate is the position vector to update with the result
  17745. * @param particle is the particle we are computed the position for
  17746. */
  17747. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17748. /**
  17749. * Clones the current emitter and returns a copy of it
  17750. * @returns the new emitter
  17751. */
  17752. clone(): IParticleEmitterType;
  17753. /**
  17754. * Called by the GPUParticleSystem to setup the update shader
  17755. * @param effect defines the update shader
  17756. */
  17757. applyToShader(effect: Effect): void;
  17758. /**
  17759. * Returns a string to use to update the GPU particles update shader
  17760. * @returns the effect defines string
  17761. */
  17762. getEffectDefines(): string;
  17763. /**
  17764. * Returns a string representing the class name
  17765. * @returns a string containing the class name
  17766. */
  17767. getClassName(): string;
  17768. /**
  17769. * Serializes the particle system to a JSON object.
  17770. * @returns the JSON object
  17771. */
  17772. serialize(): any;
  17773. /**
  17774. * Parse properties from a JSON object
  17775. * @param serializationObject defines the JSON object
  17776. */
  17777. parse(serializationObject: any): void;
  17778. }
  17779. }
  17780. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17781. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17782. import { Effect } from "babylonjs/Materials/effect";
  17783. import { Particle } from "babylonjs/Particles/particle";
  17784. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17785. /**
  17786. * Particle emitter emitting particles from the inside of a box.
  17787. * It emits the particles randomly between 2 given directions.
  17788. */
  17789. export class BoxParticleEmitter implements IParticleEmitterType {
  17790. /**
  17791. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17792. */
  17793. direction1: Vector3;
  17794. /**
  17795. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17796. */
  17797. direction2: Vector3;
  17798. /**
  17799. * 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.
  17800. */
  17801. minEmitBox: Vector3;
  17802. /**
  17803. * 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.
  17804. */
  17805. maxEmitBox: Vector3;
  17806. /**
  17807. * Creates a new instance BoxParticleEmitter
  17808. */
  17809. constructor();
  17810. /**
  17811. * Called by the particle System when the direction is computed for the created particle.
  17812. * @param worldMatrix is the world matrix of the particle system
  17813. * @param directionToUpdate is the direction vector to update with the result
  17814. * @param particle is the particle we are computed the direction for
  17815. */
  17816. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17817. /**
  17818. * Called by the particle System when the position is computed for the created particle.
  17819. * @param worldMatrix is the world matrix of the particle system
  17820. * @param positionToUpdate is the position vector to update with the result
  17821. * @param particle is the particle we are computed the position for
  17822. */
  17823. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17824. /**
  17825. * Clones the current emitter and returns a copy of it
  17826. * @returns the new emitter
  17827. */
  17828. clone(): BoxParticleEmitter;
  17829. /**
  17830. * Called by the GPUParticleSystem to setup the update shader
  17831. * @param effect defines the update shader
  17832. */
  17833. applyToShader(effect: Effect): void;
  17834. /**
  17835. * Returns a string to use to update the GPU particles update shader
  17836. * @returns a string containng the defines string
  17837. */
  17838. getEffectDefines(): string;
  17839. /**
  17840. * Returns the string "BoxParticleEmitter"
  17841. * @returns a string containing the class name
  17842. */
  17843. getClassName(): string;
  17844. /**
  17845. * Serializes the particle system to a JSON object.
  17846. * @returns the JSON object
  17847. */
  17848. serialize(): any;
  17849. /**
  17850. * Parse properties from a JSON object
  17851. * @param serializationObject defines the JSON object
  17852. */
  17853. parse(serializationObject: any): void;
  17854. }
  17855. }
  17856. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  17857. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17858. import { Effect } from "babylonjs/Materials/effect";
  17859. import { Particle } from "babylonjs/Particles/particle";
  17860. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17861. /**
  17862. * Particle emitter emitting particles from the inside of a cone.
  17863. * It emits the particles alongside the cone volume from the base to the particle.
  17864. * The emission direction might be randomized.
  17865. */
  17866. export class ConeParticleEmitter implements IParticleEmitterType {
  17867. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17868. directionRandomizer: number;
  17869. private _radius;
  17870. private _angle;
  17871. private _height;
  17872. /**
  17873. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17874. */
  17875. radiusRange: number;
  17876. /**
  17877. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17878. */
  17879. heightRange: number;
  17880. /**
  17881. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17882. */
  17883. emitFromSpawnPointOnly: boolean;
  17884. /**
  17885. * Gets or sets the radius of the emission cone
  17886. */
  17887. radius: number;
  17888. /**
  17889. * Gets or sets the angle of the emission cone
  17890. */
  17891. angle: number;
  17892. private _buildHeight;
  17893. /**
  17894. * Creates a new instance ConeParticleEmitter
  17895. * @param radius the radius of the emission cone (1 by default)
  17896. * @param angle the cone base angle (PI by default)
  17897. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17898. */
  17899. constructor(radius?: number, angle?: number,
  17900. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17901. directionRandomizer?: number);
  17902. /**
  17903. * Called by the particle System when the direction is computed for the created particle.
  17904. * @param worldMatrix is the world matrix of the particle system
  17905. * @param directionToUpdate is the direction vector to update with the result
  17906. * @param particle is the particle we are computed the direction for
  17907. */
  17908. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17909. /**
  17910. * Called by the particle System when the position is computed for the created particle.
  17911. * @param worldMatrix is the world matrix of the particle system
  17912. * @param positionToUpdate is the position vector to update with the result
  17913. * @param particle is the particle we are computed the position for
  17914. */
  17915. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17916. /**
  17917. * Clones the current emitter and returns a copy of it
  17918. * @returns the new emitter
  17919. */
  17920. clone(): ConeParticleEmitter;
  17921. /**
  17922. * Called by the GPUParticleSystem to setup the update shader
  17923. * @param effect defines the update shader
  17924. */
  17925. applyToShader(effect: Effect): void;
  17926. /**
  17927. * Returns a string to use to update the GPU particles update shader
  17928. * @returns a string containng the defines string
  17929. */
  17930. getEffectDefines(): string;
  17931. /**
  17932. * Returns the string "ConeParticleEmitter"
  17933. * @returns a string containing the class name
  17934. */
  17935. getClassName(): string;
  17936. /**
  17937. * Serializes the particle system to a JSON object.
  17938. * @returns the JSON object
  17939. */
  17940. serialize(): any;
  17941. /**
  17942. * Parse properties from a JSON object
  17943. * @param serializationObject defines the JSON object
  17944. */
  17945. parse(serializationObject: any): void;
  17946. }
  17947. }
  17948. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  17949. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17950. import { Effect } from "babylonjs/Materials/effect";
  17951. import { Particle } from "babylonjs/Particles/particle";
  17952. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17953. /**
  17954. * Particle emitter emitting particles from the inside of a cylinder.
  17955. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17956. */
  17957. export class CylinderParticleEmitter implements IParticleEmitterType {
  17958. /**
  17959. * The radius of the emission cylinder.
  17960. */
  17961. radius: number;
  17962. /**
  17963. * The height of the emission cylinder.
  17964. */
  17965. height: number;
  17966. /**
  17967. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17968. */
  17969. radiusRange: number;
  17970. /**
  17971. * How much to randomize the particle direction [0-1].
  17972. */
  17973. directionRandomizer: number;
  17974. /**
  17975. * Creates a new instance CylinderParticleEmitter
  17976. * @param radius the radius of the emission cylinder (1 by default)
  17977. * @param height the height of the emission cylinder (1 by default)
  17978. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17979. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17980. */
  17981. constructor(
  17982. /**
  17983. * The radius of the emission cylinder.
  17984. */
  17985. radius?: number,
  17986. /**
  17987. * The height of the emission cylinder.
  17988. */
  17989. height?: number,
  17990. /**
  17991. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17992. */
  17993. radiusRange?: number,
  17994. /**
  17995. * How much to randomize the particle direction [0-1].
  17996. */
  17997. directionRandomizer?: number);
  17998. /**
  17999. * Called by the particle System when the direction is computed for the created particle.
  18000. * @param worldMatrix is the world matrix of the particle system
  18001. * @param directionToUpdate is the direction vector to update with the result
  18002. * @param particle is the particle we are computed the direction for
  18003. */
  18004. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18005. /**
  18006. * Called by the particle System when the position is computed for the created particle.
  18007. * @param worldMatrix is the world matrix of the particle system
  18008. * @param positionToUpdate is the position vector to update with the result
  18009. * @param particle is the particle we are computed the position for
  18010. */
  18011. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18012. /**
  18013. * Clones the current emitter and returns a copy of it
  18014. * @returns the new emitter
  18015. */
  18016. clone(): CylinderParticleEmitter;
  18017. /**
  18018. * Called by the GPUParticleSystem to setup the update shader
  18019. * @param effect defines the update shader
  18020. */
  18021. applyToShader(effect: Effect): void;
  18022. /**
  18023. * Returns a string to use to update the GPU particles update shader
  18024. * @returns a string containng the defines string
  18025. */
  18026. getEffectDefines(): string;
  18027. /**
  18028. * Returns the string "CylinderParticleEmitter"
  18029. * @returns a string containing the class name
  18030. */
  18031. getClassName(): string;
  18032. /**
  18033. * Serializes the particle system to a JSON object.
  18034. * @returns the JSON object
  18035. */
  18036. serialize(): any;
  18037. /**
  18038. * Parse properties from a JSON object
  18039. * @param serializationObject defines the JSON object
  18040. */
  18041. parse(serializationObject: any): void;
  18042. }
  18043. /**
  18044. * Particle emitter emitting particles from the inside of a cylinder.
  18045. * It emits the particles randomly between two vectors.
  18046. */
  18047. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18048. /**
  18049. * The min limit of the emission direction.
  18050. */
  18051. direction1: Vector3;
  18052. /**
  18053. * The max limit of the emission direction.
  18054. */
  18055. direction2: Vector3;
  18056. /**
  18057. * Creates a new instance CylinderDirectedParticleEmitter
  18058. * @param radius the radius of the emission cylinder (1 by default)
  18059. * @param height the height of the emission cylinder (1 by default)
  18060. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18061. * @param direction1 the min limit of the emission direction (up vector by default)
  18062. * @param direction2 the max limit of the emission direction (up vector by default)
  18063. */
  18064. constructor(radius?: number, height?: number, radiusRange?: number,
  18065. /**
  18066. * The min limit of the emission direction.
  18067. */
  18068. direction1?: Vector3,
  18069. /**
  18070. * The max limit of the emission direction.
  18071. */
  18072. direction2?: Vector3);
  18073. /**
  18074. * Called by the particle System when the direction is computed for the created particle.
  18075. * @param worldMatrix is the world matrix of the particle system
  18076. * @param directionToUpdate is the direction vector to update with the result
  18077. * @param particle is the particle we are computed the direction for
  18078. */
  18079. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18080. /**
  18081. * Clones the current emitter and returns a copy of it
  18082. * @returns the new emitter
  18083. */
  18084. clone(): CylinderDirectedParticleEmitter;
  18085. /**
  18086. * Called by the GPUParticleSystem to setup the update shader
  18087. * @param effect defines the update shader
  18088. */
  18089. applyToShader(effect: Effect): void;
  18090. /**
  18091. * Returns a string to use to update the GPU particles update shader
  18092. * @returns a string containng the defines string
  18093. */
  18094. getEffectDefines(): string;
  18095. /**
  18096. * Returns the string "CylinderDirectedParticleEmitter"
  18097. * @returns a string containing the class name
  18098. */
  18099. getClassName(): string;
  18100. /**
  18101. * Serializes the particle system to a JSON object.
  18102. * @returns the JSON object
  18103. */
  18104. serialize(): any;
  18105. /**
  18106. * Parse properties from a JSON object
  18107. * @param serializationObject defines the JSON object
  18108. */
  18109. parse(serializationObject: any): void;
  18110. }
  18111. }
  18112. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18113. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18114. import { Effect } from "babylonjs/Materials/effect";
  18115. import { Particle } from "babylonjs/Particles/particle";
  18116. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18117. /**
  18118. * Particle emitter emitting particles from the inside of a hemisphere.
  18119. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18120. */
  18121. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18122. /**
  18123. * The radius of the emission hemisphere.
  18124. */
  18125. radius: number;
  18126. /**
  18127. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18128. */
  18129. radiusRange: number;
  18130. /**
  18131. * How much to randomize the particle direction [0-1].
  18132. */
  18133. directionRandomizer: number;
  18134. /**
  18135. * Creates a new instance HemisphericParticleEmitter
  18136. * @param radius the radius of the emission hemisphere (1 by default)
  18137. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18138. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18139. */
  18140. constructor(
  18141. /**
  18142. * The radius of the emission hemisphere.
  18143. */
  18144. radius?: number,
  18145. /**
  18146. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18147. */
  18148. radiusRange?: number,
  18149. /**
  18150. * How much to randomize the particle direction [0-1].
  18151. */
  18152. directionRandomizer?: number);
  18153. /**
  18154. * Called by the particle System when the direction is computed for the created particle.
  18155. * @param worldMatrix is the world matrix of the particle system
  18156. * @param directionToUpdate is the direction vector to update with the result
  18157. * @param particle is the particle we are computed the direction for
  18158. */
  18159. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18160. /**
  18161. * Called by the particle System when the position is computed for the created particle.
  18162. * @param worldMatrix is the world matrix of the particle system
  18163. * @param positionToUpdate is the position vector to update with the result
  18164. * @param particle is the particle we are computed the position for
  18165. */
  18166. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18167. /**
  18168. * Clones the current emitter and returns a copy of it
  18169. * @returns the new emitter
  18170. */
  18171. clone(): HemisphericParticleEmitter;
  18172. /**
  18173. * Called by the GPUParticleSystem to setup the update shader
  18174. * @param effect defines the update shader
  18175. */
  18176. applyToShader(effect: Effect): void;
  18177. /**
  18178. * Returns a string to use to update the GPU particles update shader
  18179. * @returns a string containng the defines string
  18180. */
  18181. getEffectDefines(): string;
  18182. /**
  18183. * Returns the string "HemisphericParticleEmitter"
  18184. * @returns a string containing the class name
  18185. */
  18186. getClassName(): string;
  18187. /**
  18188. * Serializes the particle system to a JSON object.
  18189. * @returns the JSON object
  18190. */
  18191. serialize(): any;
  18192. /**
  18193. * Parse properties from a JSON object
  18194. * @param serializationObject defines the JSON object
  18195. */
  18196. parse(serializationObject: any): void;
  18197. }
  18198. }
  18199. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18200. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18201. import { Effect } from "babylonjs/Materials/effect";
  18202. import { Particle } from "babylonjs/Particles/particle";
  18203. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18204. /**
  18205. * Particle emitter emitting particles from a point.
  18206. * It emits the particles randomly between 2 given directions.
  18207. */
  18208. export class PointParticleEmitter implements IParticleEmitterType {
  18209. /**
  18210. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18211. */
  18212. direction1: Vector3;
  18213. /**
  18214. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18215. */
  18216. direction2: Vector3;
  18217. /**
  18218. * Creates a new instance PointParticleEmitter
  18219. */
  18220. constructor();
  18221. /**
  18222. * Called by the particle System when the direction is computed for the created particle.
  18223. * @param worldMatrix is the world matrix of the particle system
  18224. * @param directionToUpdate is the direction vector to update with the result
  18225. * @param particle is the particle we are computed the direction for
  18226. */
  18227. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18228. /**
  18229. * Called by the particle System when the position is computed for the created particle.
  18230. * @param worldMatrix is the world matrix of the particle system
  18231. * @param positionToUpdate is the position vector to update with the result
  18232. * @param particle is the particle we are computed the position for
  18233. */
  18234. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18235. /**
  18236. * Clones the current emitter and returns a copy of it
  18237. * @returns the new emitter
  18238. */
  18239. clone(): PointParticleEmitter;
  18240. /**
  18241. * Called by the GPUParticleSystem to setup the update shader
  18242. * @param effect defines the update shader
  18243. */
  18244. applyToShader(effect: Effect): void;
  18245. /**
  18246. * Returns a string to use to update the GPU particles update shader
  18247. * @returns a string containng the defines string
  18248. */
  18249. getEffectDefines(): string;
  18250. /**
  18251. * Returns the string "PointParticleEmitter"
  18252. * @returns a string containing the class name
  18253. */
  18254. getClassName(): string;
  18255. /**
  18256. * Serializes the particle system to a JSON object.
  18257. * @returns the JSON object
  18258. */
  18259. serialize(): any;
  18260. /**
  18261. * Parse properties from a JSON object
  18262. * @param serializationObject defines the JSON object
  18263. */
  18264. parse(serializationObject: any): void;
  18265. }
  18266. }
  18267. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18268. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18269. import { Effect } from "babylonjs/Materials/effect";
  18270. import { Particle } from "babylonjs/Particles/particle";
  18271. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18272. /**
  18273. * Particle emitter emitting particles from the inside of a sphere.
  18274. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18275. */
  18276. export class SphereParticleEmitter implements IParticleEmitterType {
  18277. /**
  18278. * The radius of the emission sphere.
  18279. */
  18280. radius: number;
  18281. /**
  18282. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18283. */
  18284. radiusRange: number;
  18285. /**
  18286. * How much to randomize the particle direction [0-1].
  18287. */
  18288. directionRandomizer: number;
  18289. /**
  18290. * Creates a new instance SphereParticleEmitter
  18291. * @param radius the radius of the emission sphere (1 by default)
  18292. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18293. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18294. */
  18295. constructor(
  18296. /**
  18297. * The radius of the emission sphere.
  18298. */
  18299. radius?: number,
  18300. /**
  18301. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18302. */
  18303. radiusRange?: number,
  18304. /**
  18305. * How much to randomize the particle direction [0-1].
  18306. */
  18307. directionRandomizer?: number);
  18308. /**
  18309. * Called by the particle System when the direction is computed for the created particle.
  18310. * @param worldMatrix is the world matrix of the particle system
  18311. * @param directionToUpdate is the direction vector to update with the result
  18312. * @param particle is the particle we are computed the direction for
  18313. */
  18314. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18315. /**
  18316. * Called by the particle System when the position is computed for the created particle.
  18317. * @param worldMatrix is the world matrix of the particle system
  18318. * @param positionToUpdate is the position vector to update with the result
  18319. * @param particle is the particle we are computed the position for
  18320. */
  18321. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18322. /**
  18323. * Clones the current emitter and returns a copy of it
  18324. * @returns the new emitter
  18325. */
  18326. clone(): SphereParticleEmitter;
  18327. /**
  18328. * Called by the GPUParticleSystem to setup the update shader
  18329. * @param effect defines the update shader
  18330. */
  18331. applyToShader(effect: Effect): void;
  18332. /**
  18333. * Returns a string to use to update the GPU particles update shader
  18334. * @returns a string containng the defines string
  18335. */
  18336. getEffectDefines(): string;
  18337. /**
  18338. * Returns the string "SphereParticleEmitter"
  18339. * @returns a string containing the class name
  18340. */
  18341. getClassName(): string;
  18342. /**
  18343. * Serializes the particle system to a JSON object.
  18344. * @returns the JSON object
  18345. */
  18346. serialize(): any;
  18347. /**
  18348. * Parse properties from a JSON object
  18349. * @param serializationObject defines the JSON object
  18350. */
  18351. parse(serializationObject: any): void;
  18352. }
  18353. /**
  18354. * Particle emitter emitting particles from the inside of a sphere.
  18355. * It emits the particles randomly between two vectors.
  18356. */
  18357. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18358. /**
  18359. * The min limit of the emission direction.
  18360. */
  18361. direction1: Vector3;
  18362. /**
  18363. * The max limit of the emission direction.
  18364. */
  18365. direction2: Vector3;
  18366. /**
  18367. * Creates a new instance SphereDirectedParticleEmitter
  18368. * @param radius the radius of the emission sphere (1 by default)
  18369. * @param direction1 the min limit of the emission direction (up vector by default)
  18370. * @param direction2 the max limit of the emission direction (up vector by default)
  18371. */
  18372. constructor(radius?: number,
  18373. /**
  18374. * The min limit of the emission direction.
  18375. */
  18376. direction1?: Vector3,
  18377. /**
  18378. * The max limit of the emission direction.
  18379. */
  18380. direction2?: Vector3);
  18381. /**
  18382. * Called by the particle System when the direction is computed for the created particle.
  18383. * @param worldMatrix is the world matrix of the particle system
  18384. * @param directionToUpdate is the direction vector to update with the result
  18385. * @param particle is the particle we are computed the direction for
  18386. */
  18387. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18388. /**
  18389. * Clones the current emitter and returns a copy of it
  18390. * @returns the new emitter
  18391. */
  18392. clone(): SphereDirectedParticleEmitter;
  18393. /**
  18394. * Called by the GPUParticleSystem to setup the update shader
  18395. * @param effect defines the update shader
  18396. */
  18397. applyToShader(effect: Effect): void;
  18398. /**
  18399. * Returns a string to use to update the GPU particles update shader
  18400. * @returns a string containng the defines string
  18401. */
  18402. getEffectDefines(): string;
  18403. /**
  18404. * Returns the string "SphereDirectedParticleEmitter"
  18405. * @returns a string containing the class name
  18406. */
  18407. getClassName(): string;
  18408. /**
  18409. * Serializes the particle system to a JSON object.
  18410. * @returns the JSON object
  18411. */
  18412. serialize(): any;
  18413. /**
  18414. * Parse properties from a JSON object
  18415. * @param serializationObject defines the JSON object
  18416. */
  18417. parse(serializationObject: any): void;
  18418. }
  18419. }
  18420. declare module "babylonjs/Particles/EmitterTypes/index" {
  18421. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18422. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18423. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18424. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18425. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18426. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18427. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18428. }
  18429. declare module "babylonjs/Particles/IParticleSystem" {
  18430. import { Nullable } from "babylonjs/types";
  18431. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18432. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18434. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18435. import { Texture } from "babylonjs/Materials/Textures/texture";
  18436. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18437. import { Scene } from "babylonjs/scene";
  18438. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18439. import { Animation } from "babylonjs/Animations/animation";
  18440. /**
  18441. * Interface representing a particle system in Babylon.js.
  18442. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18443. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18444. */
  18445. export interface IParticleSystem {
  18446. /**
  18447. * List of animations used by the particle system.
  18448. */
  18449. animations: Animation[];
  18450. /**
  18451. * The id of the Particle system.
  18452. */
  18453. id: string;
  18454. /**
  18455. * The name of the Particle system.
  18456. */
  18457. name: string;
  18458. /**
  18459. * The emitter represents the Mesh or position we are attaching the particle system to.
  18460. */
  18461. emitter: Nullable<AbstractMesh | Vector3>;
  18462. /**
  18463. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18464. */
  18465. isBillboardBased: boolean;
  18466. /**
  18467. * The rendering group used by the Particle system to chose when to render.
  18468. */
  18469. renderingGroupId: number;
  18470. /**
  18471. * The layer mask we are rendering the particles through.
  18472. */
  18473. layerMask: number;
  18474. /**
  18475. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18476. */
  18477. updateSpeed: number;
  18478. /**
  18479. * The amount of time the particle system is running (depends of the overall update speed).
  18480. */
  18481. targetStopDuration: number;
  18482. /**
  18483. * The texture used to render each particle. (this can be a spritesheet)
  18484. */
  18485. particleTexture: Nullable<Texture>;
  18486. /**
  18487. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18488. */
  18489. blendMode: number;
  18490. /**
  18491. * Minimum life time of emitting particles.
  18492. */
  18493. minLifeTime: number;
  18494. /**
  18495. * Maximum life time of emitting particles.
  18496. */
  18497. maxLifeTime: number;
  18498. /**
  18499. * Minimum Size of emitting particles.
  18500. */
  18501. minSize: number;
  18502. /**
  18503. * Maximum Size of emitting particles.
  18504. */
  18505. maxSize: number;
  18506. /**
  18507. * Minimum scale of emitting particles on X axis.
  18508. */
  18509. minScaleX: number;
  18510. /**
  18511. * Maximum scale of emitting particles on X axis.
  18512. */
  18513. maxScaleX: number;
  18514. /**
  18515. * Minimum scale of emitting particles on Y axis.
  18516. */
  18517. minScaleY: number;
  18518. /**
  18519. * Maximum scale of emitting particles on Y axis.
  18520. */
  18521. maxScaleY: number;
  18522. /**
  18523. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18524. */
  18525. color1: Color4;
  18526. /**
  18527. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18528. */
  18529. color2: Color4;
  18530. /**
  18531. * Color the particle will have at the end of its lifetime.
  18532. */
  18533. colorDead: Color4;
  18534. /**
  18535. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18536. */
  18537. emitRate: number;
  18538. /**
  18539. * You can use gravity if you want to give an orientation to your particles.
  18540. */
  18541. gravity: Vector3;
  18542. /**
  18543. * Minimum power of emitting particles.
  18544. */
  18545. minEmitPower: number;
  18546. /**
  18547. * Maximum power of emitting particles.
  18548. */
  18549. maxEmitPower: number;
  18550. /**
  18551. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18552. */
  18553. minAngularSpeed: number;
  18554. /**
  18555. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18556. */
  18557. maxAngularSpeed: number;
  18558. /**
  18559. * Gets or sets the minimal initial rotation in radians.
  18560. */
  18561. minInitialRotation: number;
  18562. /**
  18563. * Gets or sets the maximal initial rotation in radians.
  18564. */
  18565. maxInitialRotation: number;
  18566. /**
  18567. * The particle emitter type defines the emitter used by the particle system.
  18568. * It can be for example box, sphere, or cone...
  18569. */
  18570. particleEmitterType: Nullable<IParticleEmitterType>;
  18571. /**
  18572. * Defines the delay in milliseconds before starting the system (0 by default)
  18573. */
  18574. startDelay: number;
  18575. /**
  18576. * 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
  18577. */
  18578. preWarmCycles: number;
  18579. /**
  18580. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18581. */
  18582. preWarmStepOffset: number;
  18583. /**
  18584. * 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)
  18585. */
  18586. spriteCellChangeSpeed: number;
  18587. /**
  18588. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18589. */
  18590. startSpriteCellID: number;
  18591. /**
  18592. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18593. */
  18594. endSpriteCellID: number;
  18595. /**
  18596. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18597. */
  18598. spriteCellWidth: number;
  18599. /**
  18600. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18601. */
  18602. spriteCellHeight: number;
  18603. /**
  18604. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18605. */
  18606. spriteRandomStartCell: boolean;
  18607. /**
  18608. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18609. */
  18610. isAnimationSheetEnabled: boolean;
  18611. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18612. translationPivot: Vector2;
  18613. /**
  18614. * Gets or sets a texture used to add random noise to particle positions
  18615. */
  18616. noiseTexture: Nullable<BaseTexture>;
  18617. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18618. noiseStrength: Vector3;
  18619. /**
  18620. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18621. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18622. */
  18623. billboardMode: number;
  18624. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18625. limitVelocityDamping: number;
  18626. /**
  18627. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18628. */
  18629. beginAnimationOnStart: boolean;
  18630. /**
  18631. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18632. */
  18633. beginAnimationFrom: number;
  18634. /**
  18635. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18636. */
  18637. beginAnimationTo: number;
  18638. /**
  18639. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18640. */
  18641. beginAnimationLoop: boolean;
  18642. /**
  18643. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18644. */
  18645. disposeOnStop: boolean;
  18646. /**
  18647. * Gets the maximum number of particles active at the same time.
  18648. * @returns The max number of active particles.
  18649. */
  18650. getCapacity(): number;
  18651. /**
  18652. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18653. * @returns True if it has been started, otherwise false.
  18654. */
  18655. isStarted(): boolean;
  18656. /**
  18657. * Animates the particle system for this frame.
  18658. */
  18659. animate(): void;
  18660. /**
  18661. * Renders the particle system in its current state.
  18662. * @returns the current number of particles
  18663. */
  18664. render(): number;
  18665. /**
  18666. * Dispose the particle system and frees its associated resources.
  18667. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18668. */
  18669. dispose(disposeTexture?: boolean): void;
  18670. /**
  18671. * Clones the particle system.
  18672. * @param name The name of the cloned object
  18673. * @param newEmitter The new emitter to use
  18674. * @returns the cloned particle system
  18675. */
  18676. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18677. /**
  18678. * Serializes the particle system to a JSON object.
  18679. * @returns the JSON object
  18680. */
  18681. serialize(): any;
  18682. /**
  18683. * Rebuild the particle system
  18684. */
  18685. rebuild(): void;
  18686. /**
  18687. * Starts the particle system and begins to emit
  18688. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18689. */
  18690. start(delay?: number): void;
  18691. /**
  18692. * Stops the particle system.
  18693. */
  18694. stop(): void;
  18695. /**
  18696. * Remove all active particles
  18697. */
  18698. reset(): void;
  18699. /**
  18700. * Is this system ready to be used/rendered
  18701. * @return true if the system is ready
  18702. */
  18703. isReady(): boolean;
  18704. /**
  18705. * Adds a new color gradient
  18706. * @param gradient defines the gradient to use (between 0 and 1)
  18707. * @param color1 defines the color to affect to the specified gradient
  18708. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18709. * @returns the current particle system
  18710. */
  18711. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18712. /**
  18713. * Remove a specific color gradient
  18714. * @param gradient defines the gradient to remove
  18715. * @returns the current particle system
  18716. */
  18717. removeColorGradient(gradient: number): IParticleSystem;
  18718. /**
  18719. * Adds a new size gradient
  18720. * @param gradient defines the gradient to use (between 0 and 1)
  18721. * @param factor defines the size factor to affect to the specified gradient
  18722. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18723. * @returns the current particle system
  18724. */
  18725. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18726. /**
  18727. * Remove a specific size gradient
  18728. * @param gradient defines the gradient to remove
  18729. * @returns the current particle system
  18730. */
  18731. removeSizeGradient(gradient: number): IParticleSystem;
  18732. /**
  18733. * Gets the current list of color gradients.
  18734. * You must use addColorGradient and removeColorGradient to udpate this list
  18735. * @returns the list of color gradients
  18736. */
  18737. getColorGradients(): Nullable<Array<ColorGradient>>;
  18738. /**
  18739. * Gets the current list of size gradients.
  18740. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18741. * @returns the list of size gradients
  18742. */
  18743. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18744. /**
  18745. * Gets the current list of angular speed gradients.
  18746. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18747. * @returns the list of angular speed gradients
  18748. */
  18749. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18750. /**
  18751. * Adds a new angular speed gradient
  18752. * @param gradient defines the gradient to use (between 0 and 1)
  18753. * @param factor defines the angular speed to affect to the specified gradient
  18754. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18755. * @returns the current particle system
  18756. */
  18757. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18758. /**
  18759. * Remove a specific angular speed gradient
  18760. * @param gradient defines the gradient to remove
  18761. * @returns the current particle system
  18762. */
  18763. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18764. /**
  18765. * Gets the current list of velocity gradients.
  18766. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18767. * @returns the list of velocity gradients
  18768. */
  18769. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18770. /**
  18771. * Adds a new velocity gradient
  18772. * @param gradient defines the gradient to use (between 0 and 1)
  18773. * @param factor defines the velocity to affect to the specified gradient
  18774. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18775. * @returns the current particle system
  18776. */
  18777. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18778. /**
  18779. * Remove a specific velocity gradient
  18780. * @param gradient defines the gradient to remove
  18781. * @returns the current particle system
  18782. */
  18783. removeVelocityGradient(gradient: number): IParticleSystem;
  18784. /**
  18785. * Gets the current list of limit velocity gradients.
  18786. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18787. * @returns the list of limit velocity gradients
  18788. */
  18789. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18790. /**
  18791. * Adds a new limit velocity gradient
  18792. * @param gradient defines the gradient to use (between 0 and 1)
  18793. * @param factor defines the limit velocity to affect to the specified gradient
  18794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18795. * @returns the current particle system
  18796. */
  18797. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18798. /**
  18799. * Remove a specific limit velocity gradient
  18800. * @param gradient defines the gradient to remove
  18801. * @returns the current particle system
  18802. */
  18803. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18804. /**
  18805. * Adds a new drag gradient
  18806. * @param gradient defines the gradient to use (between 0 and 1)
  18807. * @param factor defines the drag to affect to the specified gradient
  18808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18809. * @returns the current particle system
  18810. */
  18811. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18812. /**
  18813. * Remove a specific drag gradient
  18814. * @param gradient defines the gradient to remove
  18815. * @returns the current particle system
  18816. */
  18817. removeDragGradient(gradient: number): IParticleSystem;
  18818. /**
  18819. * Gets the current list of drag gradients.
  18820. * You must use addDragGradient and removeDragGradient to udpate this list
  18821. * @returns the list of drag gradients
  18822. */
  18823. getDragGradients(): Nullable<Array<FactorGradient>>;
  18824. /**
  18825. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18826. * @param gradient defines the gradient to use (between 0 and 1)
  18827. * @param factor defines the emit rate to affect to the specified gradient
  18828. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18829. * @returns the current particle system
  18830. */
  18831. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18832. /**
  18833. * Remove a specific emit rate gradient
  18834. * @param gradient defines the gradient to remove
  18835. * @returns the current particle system
  18836. */
  18837. removeEmitRateGradient(gradient: number): IParticleSystem;
  18838. /**
  18839. * Gets the current list of emit rate gradients.
  18840. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18841. * @returns the list of emit rate gradients
  18842. */
  18843. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18844. /**
  18845. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18846. * @param gradient defines the gradient to use (between 0 and 1)
  18847. * @param factor defines the start size to affect to the specified gradient
  18848. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18849. * @returns the current particle system
  18850. */
  18851. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18852. /**
  18853. * Remove a specific start size gradient
  18854. * @param gradient defines the gradient to remove
  18855. * @returns the current particle system
  18856. */
  18857. removeStartSizeGradient(gradient: number): IParticleSystem;
  18858. /**
  18859. * Gets the current list of start size gradients.
  18860. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18861. * @returns the list of start size gradients
  18862. */
  18863. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18864. /**
  18865. * Adds a new life time gradient
  18866. * @param gradient defines the gradient to use (between 0 and 1)
  18867. * @param factor defines the life time factor to affect to the specified gradient
  18868. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18869. * @returns the current particle system
  18870. */
  18871. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18872. /**
  18873. * Remove a specific life time gradient
  18874. * @param gradient defines the gradient to remove
  18875. * @returns the current particle system
  18876. */
  18877. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18878. /**
  18879. * Gets the current list of life time gradients.
  18880. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18881. * @returns the list of life time gradients
  18882. */
  18883. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18884. /**
  18885. * Gets the current list of color gradients.
  18886. * You must use addColorGradient and removeColorGradient to udpate this list
  18887. * @returns the list of color gradients
  18888. */
  18889. getColorGradients(): Nullable<Array<ColorGradient>>;
  18890. /**
  18891. * Adds a new ramp gradient used to remap particle colors
  18892. * @param gradient defines the gradient to use (between 0 and 1)
  18893. * @param color defines the color to affect to the specified gradient
  18894. * @returns the current particle system
  18895. */
  18896. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18897. /**
  18898. * Gets the current list of ramp gradients.
  18899. * You must use addRampGradient and removeRampGradient to udpate this list
  18900. * @returns the list of ramp gradients
  18901. */
  18902. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18903. /** Gets or sets a boolean indicating that ramp gradients must be used
  18904. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18905. */
  18906. useRampGradients: boolean;
  18907. /**
  18908. * Adds a new color remap gradient
  18909. * @param gradient defines the gradient to use (between 0 and 1)
  18910. * @param min defines the color remap minimal range
  18911. * @param max defines the color remap maximal range
  18912. * @returns the current particle system
  18913. */
  18914. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18915. /**
  18916. * Gets the current list of color remap gradients.
  18917. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18918. * @returns the list of color remap gradients
  18919. */
  18920. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18921. /**
  18922. * Adds a new alpha remap gradient
  18923. * @param gradient defines the gradient to use (between 0 and 1)
  18924. * @param min defines the alpha remap minimal range
  18925. * @param max defines the alpha remap maximal range
  18926. * @returns the current particle system
  18927. */
  18928. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18929. /**
  18930. * Gets the current list of alpha remap gradients.
  18931. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18932. * @returns the list of alpha remap gradients
  18933. */
  18934. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18935. /**
  18936. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18937. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18938. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18939. * @returns the emitter
  18940. */
  18941. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18942. /**
  18943. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18944. * @param radius The radius of the hemisphere to emit from
  18945. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18946. * @returns the emitter
  18947. */
  18948. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18949. /**
  18950. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18951. * @param radius The radius of the sphere to emit from
  18952. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18953. * @returns the emitter
  18954. */
  18955. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18956. /**
  18957. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18958. * @param radius The radius of the sphere to emit from
  18959. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18960. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18961. * @returns the emitter
  18962. */
  18963. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18964. /**
  18965. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18966. * @param radius The radius of the emission cylinder
  18967. * @param height The height of the emission cylinder
  18968. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18969. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18970. * @returns the emitter
  18971. */
  18972. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18973. /**
  18974. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18975. * @param radius The radius of the cylinder to emit from
  18976. * @param height The height of the emission cylinder
  18977. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18978. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18979. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18980. * @returns the emitter
  18981. */
  18982. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18983. /**
  18984. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18985. * @param radius The radius of the cone to emit from
  18986. * @param angle The base angle of the cone
  18987. * @returns the emitter
  18988. */
  18989. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18990. /**
  18991. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18992. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18993. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18994. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18995. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18996. * @returns the emitter
  18997. */
  18998. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18999. /**
  19000. * Get hosting scene
  19001. * @returns the scene
  19002. */
  19003. getScene(): Scene;
  19004. }
  19005. }
  19006. declare module "babylonjs/Meshes/instancedMesh" {
  19007. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19008. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19009. import { Camera } from "babylonjs/Cameras/camera";
  19010. import { Node } from "babylonjs/node";
  19011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19012. import { Mesh } from "babylonjs/Meshes/mesh";
  19013. import { Material } from "babylonjs/Materials/material";
  19014. import { Skeleton } from "babylonjs/Bones/skeleton";
  19015. import { Light } from "babylonjs/Lights/light";
  19016. /**
  19017. * Creates an instance based on a source mesh.
  19018. */
  19019. export class InstancedMesh extends AbstractMesh {
  19020. private _sourceMesh;
  19021. private _currentLOD;
  19022. /** @hidden */
  19023. _indexInSourceMeshInstanceArray: number;
  19024. constructor(name: string, source: Mesh);
  19025. /**
  19026. * Returns the string "InstancedMesh".
  19027. */
  19028. getClassName(): string;
  19029. /** Gets the list of lights affecting that mesh */
  19030. readonly lightSources: Light[];
  19031. _resyncLightSources(): void;
  19032. _resyncLighSource(light: Light): void;
  19033. _removeLightSource(light: Light, dispose: boolean): void;
  19034. /**
  19035. * If the source mesh receives shadows
  19036. */
  19037. readonly receiveShadows: boolean;
  19038. /**
  19039. * The material of the source mesh
  19040. */
  19041. readonly material: Nullable<Material>;
  19042. /**
  19043. * Visibility of the source mesh
  19044. */
  19045. readonly visibility: number;
  19046. /**
  19047. * Skeleton of the source mesh
  19048. */
  19049. readonly skeleton: Nullable<Skeleton>;
  19050. /**
  19051. * Rendering ground id of the source mesh
  19052. */
  19053. renderingGroupId: number;
  19054. /**
  19055. * Returns the total number of vertices (integer).
  19056. */
  19057. getTotalVertices(): number;
  19058. /**
  19059. * Returns a positive integer : the total number of indices in this mesh geometry.
  19060. * @returns the numner of indices or zero if the mesh has no geometry.
  19061. */
  19062. getTotalIndices(): number;
  19063. /**
  19064. * The source mesh of the instance
  19065. */
  19066. readonly sourceMesh: Mesh;
  19067. /**
  19068. * Is this node ready to be used/rendered
  19069. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19070. * @return {boolean} is it ready
  19071. */
  19072. isReady(completeCheck?: boolean): boolean;
  19073. /**
  19074. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19075. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19076. * @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.
  19077. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19078. */
  19079. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19080. /**
  19081. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19082. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19083. * The `data` are either a numeric array either a Float32Array.
  19084. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19085. * 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).
  19086. * Note that a new underlying VertexBuffer object is created each call.
  19087. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19088. *
  19089. * Possible `kind` values :
  19090. * - VertexBuffer.PositionKind
  19091. * - VertexBuffer.UVKind
  19092. * - VertexBuffer.UV2Kind
  19093. * - VertexBuffer.UV3Kind
  19094. * - VertexBuffer.UV4Kind
  19095. * - VertexBuffer.UV5Kind
  19096. * - VertexBuffer.UV6Kind
  19097. * - VertexBuffer.ColorKind
  19098. * - VertexBuffer.MatricesIndicesKind
  19099. * - VertexBuffer.MatricesIndicesExtraKind
  19100. * - VertexBuffer.MatricesWeightsKind
  19101. * - VertexBuffer.MatricesWeightsExtraKind
  19102. *
  19103. * Returns the Mesh.
  19104. */
  19105. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19106. /**
  19107. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19108. * If the mesh has no geometry, it is simply returned as it is.
  19109. * The `data` are either a numeric array either a Float32Array.
  19110. * No new underlying VertexBuffer object is created.
  19111. * 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.
  19112. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19113. *
  19114. * Possible `kind` values :
  19115. * - VertexBuffer.PositionKind
  19116. * - VertexBuffer.UVKind
  19117. * - VertexBuffer.UV2Kind
  19118. * - VertexBuffer.UV3Kind
  19119. * - VertexBuffer.UV4Kind
  19120. * - VertexBuffer.UV5Kind
  19121. * - VertexBuffer.UV6Kind
  19122. * - VertexBuffer.ColorKind
  19123. * - VertexBuffer.MatricesIndicesKind
  19124. * - VertexBuffer.MatricesIndicesExtraKind
  19125. * - VertexBuffer.MatricesWeightsKind
  19126. * - VertexBuffer.MatricesWeightsExtraKind
  19127. *
  19128. * Returns the Mesh.
  19129. */
  19130. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19131. /**
  19132. * Sets the mesh indices.
  19133. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19134. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19135. * This method creates a new index buffer each call.
  19136. * Returns the Mesh.
  19137. */
  19138. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19139. /**
  19140. * Boolean : True if the mesh owns the requested kind of data.
  19141. */
  19142. isVerticesDataPresent(kind: string): boolean;
  19143. /**
  19144. * Returns an array of indices (IndicesArray).
  19145. */
  19146. getIndices(): Nullable<IndicesArray>;
  19147. readonly _positions: Nullable<Vector3[]>;
  19148. /**
  19149. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19150. * This means the mesh underlying bounding box and sphere are recomputed.
  19151. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19152. * @returns the current mesh
  19153. */
  19154. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19155. /** @hidden */
  19156. _preActivate(): InstancedMesh;
  19157. /** @hidden */
  19158. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19159. /** @hidden */
  19160. _postActivate(): void;
  19161. getWorldMatrix(): Matrix;
  19162. readonly isAnInstance: boolean;
  19163. /**
  19164. * Returns the current associated LOD AbstractMesh.
  19165. */
  19166. getLOD(camera: Camera): AbstractMesh;
  19167. /** @hidden */
  19168. _syncSubMeshes(): InstancedMesh;
  19169. /** @hidden */
  19170. _generatePointsArray(): boolean;
  19171. /**
  19172. * Creates a new InstancedMesh from the current mesh.
  19173. * - name (string) : the cloned mesh name
  19174. * - newParent (optional Node) : the optional Node to parent the clone to.
  19175. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19176. *
  19177. * Returns the clone.
  19178. */
  19179. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19180. /**
  19181. * Disposes the InstancedMesh.
  19182. * Returns nothing.
  19183. */
  19184. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19185. }
  19186. }
  19187. declare module "babylonjs/Materials/shaderMaterial" {
  19188. import { Scene } from "babylonjs/scene";
  19189. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19191. import { Mesh } from "babylonjs/Meshes/mesh";
  19192. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19194. import { Texture } from "babylonjs/Materials/Textures/texture";
  19195. import { Material } from "babylonjs/Materials/material";
  19196. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19197. /**
  19198. * Defines the options associated with the creation of a shader material.
  19199. */
  19200. export interface IShaderMaterialOptions {
  19201. /**
  19202. * Does the material work in alpha blend mode
  19203. */
  19204. needAlphaBlending: boolean;
  19205. /**
  19206. * Does the material work in alpha test mode
  19207. */
  19208. needAlphaTesting: boolean;
  19209. /**
  19210. * The list of attribute names used in the shader
  19211. */
  19212. attributes: string[];
  19213. /**
  19214. * The list of unifrom names used in the shader
  19215. */
  19216. uniforms: string[];
  19217. /**
  19218. * The list of UBO names used in the shader
  19219. */
  19220. uniformBuffers: string[];
  19221. /**
  19222. * The list of sampler names used in the shader
  19223. */
  19224. samplers: string[];
  19225. /**
  19226. * The list of defines used in the shader
  19227. */
  19228. defines: string[];
  19229. }
  19230. /**
  19231. * 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.
  19232. *
  19233. * This returned material effects how the mesh will look based on the code in the shaders.
  19234. *
  19235. * @see http://doc.babylonjs.com/how_to/shader_material
  19236. */
  19237. export class ShaderMaterial extends Material {
  19238. private _shaderPath;
  19239. private _options;
  19240. private _textures;
  19241. private _textureArrays;
  19242. private _floats;
  19243. private _ints;
  19244. private _floatsArrays;
  19245. private _colors3;
  19246. private _colors3Arrays;
  19247. private _colors4;
  19248. private _colors4Arrays;
  19249. private _vectors2;
  19250. private _vectors3;
  19251. private _vectors4;
  19252. private _matrices;
  19253. private _matrices3x3;
  19254. private _matrices2x2;
  19255. private _vectors2Arrays;
  19256. private _vectors3Arrays;
  19257. private _vectors4Arrays;
  19258. private _cachedWorldViewMatrix;
  19259. private _cachedWorldViewProjectionMatrix;
  19260. private _renderId;
  19261. /**
  19262. * Instantiate a new shader material.
  19263. * 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.
  19264. * This returned material effects how the mesh will look based on the code in the shaders.
  19265. * @see http://doc.babylonjs.com/how_to/shader_material
  19266. * @param name Define the name of the material in the scene
  19267. * @param scene Define the scene the material belongs to
  19268. * @param shaderPath Defines the route to the shader code in one of three ways:
  19269. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19270. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19271. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19272. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19273. * @param options Define the options used to create the shader
  19274. */
  19275. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19276. /**
  19277. * Gets the options used to compile the shader.
  19278. * They can be modified to trigger a new compilation
  19279. */
  19280. readonly options: IShaderMaterialOptions;
  19281. /**
  19282. * Gets the current class name of the material e.g. "ShaderMaterial"
  19283. * Mainly use in serialization.
  19284. * @returns the class name
  19285. */
  19286. getClassName(): string;
  19287. /**
  19288. * Specifies if the material will require alpha blending
  19289. * @returns a boolean specifying if alpha blending is needed
  19290. */
  19291. needAlphaBlending(): boolean;
  19292. /**
  19293. * Specifies if this material should be rendered in alpha test mode
  19294. * @returns a boolean specifying if an alpha test is needed.
  19295. */
  19296. needAlphaTesting(): boolean;
  19297. private _checkUniform;
  19298. /**
  19299. * Set a texture in the shader.
  19300. * @param name Define the name of the uniform samplers as defined in the shader
  19301. * @param texture Define the texture to bind to this sampler
  19302. * @return the material itself allowing "fluent" like uniform updates
  19303. */
  19304. setTexture(name: string, texture: Texture): ShaderMaterial;
  19305. /**
  19306. * Set a texture array in the shader.
  19307. * @param name Define the name of the uniform sampler array as defined in the shader
  19308. * @param textures Define the list of textures to bind to this sampler
  19309. * @return the material itself allowing "fluent" like uniform updates
  19310. */
  19311. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19312. /**
  19313. * Set a float in the shader.
  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. setFloat(name: string, value: number): ShaderMaterial;
  19319. /**
  19320. * Set a int in the shader.
  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. setInt(name: string, value: number): ShaderMaterial;
  19326. /**
  19327. * Set an array of floats in the shader.
  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. setFloats(name: string, value: number[]): ShaderMaterial;
  19333. /**
  19334. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ShaderMaterial;
  19340. /**
  19341. * Set a vec3 array in the shader from a Color3 array.
  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. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19347. /**
  19348. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ShaderMaterial;
  19354. /**
  19355. * Set a vec4 array in the shader from a Color4 array.
  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. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19361. /**
  19362. * Set a vec2 in the shader from a Vector2.
  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. setVector2(name: string, value: Vector2): ShaderMaterial;
  19368. /**
  19369. * Set a vec3 in the shader from a Vector3.
  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. setVector3(name: string, value: Vector3): ShaderMaterial;
  19375. /**
  19376. * Set a vec4 in the shader from a Vector4.
  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. setVector4(name: string, value: Vector4): ShaderMaterial;
  19382. /**
  19383. * Set a mat4 in the shader from a Matrix.
  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. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19389. /**
  19390. * Set a mat3 in the shader from a Float32Array.
  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. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19396. /**
  19397. * Set a mat2 in the shader from a Float32Array.
  19398. * @param name Define the name of the uniform as defined in the shader
  19399. * @param value Define the value to give to the uniform
  19400. * @return the material itself allowing "fluent" like uniform updates
  19401. */
  19402. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19403. /**
  19404. * Set a vec2 array in the shader from a number array.
  19405. * @param name Define the name of the uniform as defined in the shader
  19406. * @param value Define the value to give to the uniform
  19407. * @return the material itself allowing "fluent" like uniform updates
  19408. */
  19409. setArray2(name: string, value: number[]): ShaderMaterial;
  19410. /**
  19411. * Set a vec3 array in the shader from a number array.
  19412. * @param name Define the name of the uniform as defined in the shader
  19413. * @param value Define the value to give to the uniform
  19414. * @return the material itself allowing "fluent" like uniform updates
  19415. */
  19416. setArray3(name: string, value: number[]): ShaderMaterial;
  19417. /**
  19418. * Set a vec4 array in the shader from a number array.
  19419. * @param name Define the name of the uniform as defined in the shader
  19420. * @param value Define the value to give to the uniform
  19421. * @return the material itself allowing "fluent" like uniform updates
  19422. */
  19423. setArray4(name: string, value: number[]): ShaderMaterial;
  19424. private _checkCache;
  19425. /**
  19426. * Specifies that the submesh is ready to be used
  19427. * @param mesh defines the mesh to check
  19428. * @param subMesh defines which submesh to check
  19429. * @param useInstances specifies that instances should be used
  19430. * @returns a boolean indicating that the submesh is ready or not
  19431. */
  19432. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19433. /**
  19434. * Checks if the material is ready to render the requested mesh
  19435. * @param mesh Define the mesh to render
  19436. * @param useInstances Define whether or not the material is used with instances
  19437. * @returns true if ready, otherwise false
  19438. */
  19439. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19440. /**
  19441. * Binds the world matrix to the material
  19442. * @param world defines the world transformation matrix
  19443. */
  19444. bindOnlyWorldMatrix(world: Matrix): void;
  19445. /**
  19446. * Binds the material to the mesh
  19447. * @param world defines the world transformation matrix
  19448. * @param mesh defines the mesh to bind the material to
  19449. */
  19450. bind(world: Matrix, mesh?: Mesh): void;
  19451. /**
  19452. * Gets the active textures from the material
  19453. * @returns an array of textures
  19454. */
  19455. getActiveTextures(): BaseTexture[];
  19456. /**
  19457. * Specifies if the material uses a texture
  19458. * @param texture defines the texture to check against the material
  19459. * @returns a boolean specifying if the material uses the texture
  19460. */
  19461. hasTexture(texture: BaseTexture): boolean;
  19462. /**
  19463. * Makes a duplicate of the material, and gives it a new name
  19464. * @param name defines the new name for the duplicated material
  19465. * @returns the cloned material
  19466. */
  19467. clone(name: string): ShaderMaterial;
  19468. /**
  19469. * Disposes the material
  19470. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19471. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19472. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19473. */
  19474. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19475. /**
  19476. * Serializes this material in a JSON representation
  19477. * @returns the serialized material object
  19478. */
  19479. serialize(): any;
  19480. /**
  19481. * Creates a shader material from parsed shader material data
  19482. * @param source defines the JSON represnetation of the material
  19483. * @param scene defines the hosting scene
  19484. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19485. * @returns a new material
  19486. */
  19487. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19488. }
  19489. }
  19490. declare module "babylonjs/Shaders/color.fragment" {
  19491. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19492. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19493. /** @hidden */
  19494. export var colorPixelShader: {
  19495. name: string;
  19496. shader: string;
  19497. };
  19498. }
  19499. declare module "babylonjs/Shaders/color.vertex" {
  19500. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19501. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19502. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19503. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19504. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19505. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19506. /** @hidden */
  19507. export var colorVertexShader: {
  19508. name: string;
  19509. shader: string;
  19510. };
  19511. }
  19512. declare module "babylonjs/Meshes/linesMesh" {
  19513. import { Nullable } from "babylonjs/types";
  19514. import { Scene } from "babylonjs/scene";
  19515. import { Color3 } from "babylonjs/Maths/math.color";
  19516. import { Node } from "babylonjs/node";
  19517. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19518. import { Mesh } from "babylonjs/Meshes/mesh";
  19519. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19520. import { Effect } from "babylonjs/Materials/effect";
  19521. import { Material } from "babylonjs/Materials/material";
  19522. import "babylonjs/Shaders/color.fragment";
  19523. import "babylonjs/Shaders/color.vertex";
  19524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19525. /**
  19526. * Line mesh
  19527. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19528. */
  19529. export class LinesMesh extends Mesh {
  19530. /**
  19531. * If vertex color should be applied to the mesh
  19532. */
  19533. readonly useVertexColor?: boolean | undefined;
  19534. /**
  19535. * If vertex alpha should be applied to the mesh
  19536. */
  19537. readonly useVertexAlpha?: boolean | undefined;
  19538. /**
  19539. * Color of the line (Default: White)
  19540. */
  19541. color: Color3;
  19542. /**
  19543. * Alpha of the line (Default: 1)
  19544. */
  19545. alpha: number;
  19546. /**
  19547. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19548. * This margin is expressed in world space coordinates, so its value may vary.
  19549. * Default value is 0.1
  19550. */
  19551. intersectionThreshold: number;
  19552. private _colorShader;
  19553. private color4;
  19554. /**
  19555. * Creates a new LinesMesh
  19556. * @param name defines the name
  19557. * @param scene defines the hosting scene
  19558. * @param parent defines the parent mesh if any
  19559. * @param source defines the optional source LinesMesh used to clone data from
  19560. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19561. * When false, achieved by calling a clone(), also passing False.
  19562. * This will make creation of children, recursive.
  19563. * @param useVertexColor defines if this LinesMesh supports vertex color
  19564. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19565. */
  19566. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19567. /**
  19568. * If vertex color should be applied to the mesh
  19569. */
  19570. useVertexColor?: boolean | undefined,
  19571. /**
  19572. * If vertex alpha should be applied to the mesh
  19573. */
  19574. useVertexAlpha?: boolean | undefined);
  19575. private _addClipPlaneDefine;
  19576. private _removeClipPlaneDefine;
  19577. isReady(): boolean;
  19578. /**
  19579. * Returns the string "LineMesh"
  19580. */
  19581. getClassName(): string;
  19582. /**
  19583. * @hidden
  19584. */
  19585. /**
  19586. * @hidden
  19587. */
  19588. material: Material;
  19589. /**
  19590. * @hidden
  19591. */
  19592. readonly checkCollisions: boolean;
  19593. /** @hidden */
  19594. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19595. /** @hidden */
  19596. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19597. /**
  19598. * Disposes of the line mesh
  19599. * @param doNotRecurse If children should be disposed
  19600. */
  19601. dispose(doNotRecurse?: boolean): void;
  19602. /**
  19603. * Returns a new LineMesh object cloned from the current one.
  19604. */
  19605. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19606. /**
  19607. * Creates a new InstancedLinesMesh object from the mesh model.
  19608. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19609. * @param name defines the name of the new instance
  19610. * @returns a new InstancedLinesMesh
  19611. */
  19612. createInstance(name: string): InstancedLinesMesh;
  19613. }
  19614. /**
  19615. * Creates an instance based on a source LinesMesh
  19616. */
  19617. export class InstancedLinesMesh extends InstancedMesh {
  19618. /**
  19619. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19620. * This margin is expressed in world space coordinates, so its value may vary.
  19621. * Initilized with the intersectionThreshold value of the source LinesMesh
  19622. */
  19623. intersectionThreshold: number;
  19624. constructor(name: string, source: LinesMesh);
  19625. /**
  19626. * Returns the string "InstancedLinesMesh".
  19627. */
  19628. getClassName(): string;
  19629. }
  19630. }
  19631. declare module "babylonjs/Shaders/line.fragment" {
  19632. /** @hidden */
  19633. export var linePixelShader: {
  19634. name: string;
  19635. shader: string;
  19636. };
  19637. }
  19638. declare module "babylonjs/Shaders/line.vertex" {
  19639. /** @hidden */
  19640. export var lineVertexShader: {
  19641. name: string;
  19642. shader: string;
  19643. };
  19644. }
  19645. declare module "babylonjs/Rendering/edgesRenderer" {
  19646. import { Nullable } from "babylonjs/types";
  19647. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19649. import { Vector3 } from "babylonjs/Maths/math.vector";
  19650. import { IDisposable } from "babylonjs/scene";
  19651. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19652. import "babylonjs/Shaders/line.fragment";
  19653. import "babylonjs/Shaders/line.vertex";
  19654. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19655. module "babylonjs/Meshes/abstractMesh" {
  19656. interface AbstractMesh {
  19657. /**
  19658. * Gets the edgesRenderer associated with the mesh
  19659. */
  19660. edgesRenderer: Nullable<EdgesRenderer>;
  19661. }
  19662. }
  19663. module "babylonjs/Meshes/linesMesh" {
  19664. interface LinesMesh {
  19665. /**
  19666. * Enables the edge rendering mode on the mesh.
  19667. * This mode makes the mesh edges visible
  19668. * @param epsilon defines the maximal distance between two angles to detect a face
  19669. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19670. * @returns the currentAbstractMesh
  19671. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19672. */
  19673. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19674. }
  19675. }
  19676. module "babylonjs/Meshes/linesMesh" {
  19677. interface InstancedLinesMesh {
  19678. /**
  19679. * Enables the edge rendering mode on the mesh.
  19680. * This mode makes the mesh edges visible
  19681. * @param epsilon defines the maximal distance between two angles to detect a face
  19682. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19683. * @returns the current InstancedLinesMesh
  19684. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19685. */
  19686. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19687. }
  19688. }
  19689. /**
  19690. * Defines the minimum contract an Edges renderer should follow.
  19691. */
  19692. export interface IEdgesRenderer extends IDisposable {
  19693. /**
  19694. * Gets or sets a boolean indicating if the edgesRenderer is active
  19695. */
  19696. isEnabled: boolean;
  19697. /**
  19698. * Renders the edges of the attached mesh,
  19699. */
  19700. render(): void;
  19701. /**
  19702. * Checks wether or not the edges renderer is ready to render.
  19703. * @return true if ready, otherwise false.
  19704. */
  19705. isReady(): boolean;
  19706. }
  19707. /**
  19708. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19709. */
  19710. export class EdgesRenderer implements IEdgesRenderer {
  19711. /**
  19712. * Define the size of the edges with an orthographic camera
  19713. */
  19714. edgesWidthScalerForOrthographic: number;
  19715. /**
  19716. * Define the size of the edges with a perspective camera
  19717. */
  19718. edgesWidthScalerForPerspective: number;
  19719. protected _source: AbstractMesh;
  19720. protected _linesPositions: number[];
  19721. protected _linesNormals: number[];
  19722. protected _linesIndices: number[];
  19723. protected _epsilon: number;
  19724. protected _indicesCount: number;
  19725. protected _lineShader: ShaderMaterial;
  19726. protected _ib: DataBuffer;
  19727. protected _buffers: {
  19728. [key: string]: Nullable<VertexBuffer>;
  19729. };
  19730. protected _checkVerticesInsteadOfIndices: boolean;
  19731. private _meshRebuildObserver;
  19732. private _meshDisposeObserver;
  19733. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19734. isEnabled: boolean;
  19735. /**
  19736. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19737. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19738. * @param source Mesh used to create edges
  19739. * @param epsilon sum of angles in adjacency to check for edge
  19740. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19741. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19742. */
  19743. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19744. protected _prepareRessources(): void;
  19745. /** @hidden */
  19746. _rebuild(): void;
  19747. /**
  19748. * Releases the required resources for the edges renderer
  19749. */
  19750. dispose(): void;
  19751. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19752. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19753. /**
  19754. * Checks if the pair of p0 and p1 is en edge
  19755. * @param faceIndex
  19756. * @param edge
  19757. * @param faceNormals
  19758. * @param p0
  19759. * @param p1
  19760. * @private
  19761. */
  19762. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19763. /**
  19764. * push line into the position, normal and index buffer
  19765. * @protected
  19766. */
  19767. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19768. /**
  19769. * Generates lines edges from adjacencjes
  19770. * @private
  19771. */
  19772. _generateEdgesLines(): void;
  19773. /**
  19774. * Checks wether or not the edges renderer is ready to render.
  19775. * @return true if ready, otherwise false.
  19776. */
  19777. isReady(): boolean;
  19778. /**
  19779. * Renders the edges of the attached mesh,
  19780. */
  19781. render(): void;
  19782. }
  19783. /**
  19784. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19785. */
  19786. export class LineEdgesRenderer extends EdgesRenderer {
  19787. /**
  19788. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19789. * @param source LineMesh used to generate edges
  19790. * @param epsilon not important (specified angle for edge detection)
  19791. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19792. */
  19793. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19794. /**
  19795. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19796. */
  19797. _generateEdgesLines(): void;
  19798. }
  19799. }
  19800. declare module "babylonjs/Rendering/renderingGroup" {
  19801. import { SmartArray } from "babylonjs/Misc/smartArray";
  19802. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19804. import { Nullable } from "babylonjs/types";
  19805. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19806. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19807. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19808. import { Material } from "babylonjs/Materials/material";
  19809. import { Scene } from "babylonjs/scene";
  19810. /**
  19811. * This represents the object necessary to create a rendering group.
  19812. * This is exclusively used and created by the rendering manager.
  19813. * To modify the behavior, you use the available helpers in your scene or meshes.
  19814. * @hidden
  19815. */
  19816. export class RenderingGroup {
  19817. index: number;
  19818. private static _zeroVector;
  19819. private _scene;
  19820. private _opaqueSubMeshes;
  19821. private _transparentSubMeshes;
  19822. private _alphaTestSubMeshes;
  19823. private _depthOnlySubMeshes;
  19824. private _particleSystems;
  19825. private _spriteManagers;
  19826. private _opaqueSortCompareFn;
  19827. private _alphaTestSortCompareFn;
  19828. private _transparentSortCompareFn;
  19829. private _renderOpaque;
  19830. private _renderAlphaTest;
  19831. private _renderTransparent;
  19832. /** @hidden */
  19833. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19834. onBeforeTransparentRendering: () => void;
  19835. /**
  19836. * Set the opaque sort comparison function.
  19837. * If null the sub meshes will be render in the order they were created
  19838. */
  19839. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19840. /**
  19841. * Set the alpha test sort comparison function.
  19842. * If null the sub meshes will be render in the order they were created
  19843. */
  19844. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19845. /**
  19846. * Set the transparent sort comparison function.
  19847. * If null the sub meshes will be render in the order they were created
  19848. */
  19849. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19850. /**
  19851. * Creates a new rendering group.
  19852. * @param index The rendering group index
  19853. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19854. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19855. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19856. */
  19857. 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>);
  19858. /**
  19859. * Render all the sub meshes contained in the group.
  19860. * @param customRenderFunction Used to override the default render behaviour of the group.
  19861. * @returns true if rendered some submeshes.
  19862. */
  19863. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19864. /**
  19865. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19866. * @param subMeshes The submeshes to render
  19867. */
  19868. private renderOpaqueSorted;
  19869. /**
  19870. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19871. * @param subMeshes The submeshes to render
  19872. */
  19873. private renderAlphaTestSorted;
  19874. /**
  19875. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19876. * @param subMeshes The submeshes to render
  19877. */
  19878. private renderTransparentSorted;
  19879. /**
  19880. * Renders the submeshes in a specified order.
  19881. * @param subMeshes The submeshes to sort before render
  19882. * @param sortCompareFn The comparison function use to sort
  19883. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19884. * @param transparent Specifies to activate blending if true
  19885. */
  19886. private static renderSorted;
  19887. /**
  19888. * Renders the submeshes in the order they were dispatched (no sort applied).
  19889. * @param subMeshes The submeshes to render
  19890. */
  19891. private static renderUnsorted;
  19892. /**
  19893. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19894. * are rendered back to front if in the same alpha index.
  19895. *
  19896. * @param a The first submesh
  19897. * @param b The second submesh
  19898. * @returns The result of the comparison
  19899. */
  19900. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19901. /**
  19902. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19903. * are rendered back to front.
  19904. *
  19905. * @param a The first submesh
  19906. * @param b The second submesh
  19907. * @returns The result of the comparison
  19908. */
  19909. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19910. /**
  19911. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19912. * are rendered front to back (prevent overdraw).
  19913. *
  19914. * @param a The first submesh
  19915. * @param b The second submesh
  19916. * @returns The result of the comparison
  19917. */
  19918. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19919. /**
  19920. * Resets the different lists of submeshes to prepare a new frame.
  19921. */
  19922. prepare(): void;
  19923. dispose(): void;
  19924. /**
  19925. * Inserts the submesh in its correct queue depending on its material.
  19926. * @param subMesh The submesh to dispatch
  19927. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19928. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19929. */
  19930. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19931. dispatchSprites(spriteManager: ISpriteManager): void;
  19932. dispatchParticles(particleSystem: IParticleSystem): void;
  19933. private _renderParticles;
  19934. private _renderSprites;
  19935. }
  19936. }
  19937. declare module "babylonjs/Rendering/renderingManager" {
  19938. import { Nullable } from "babylonjs/types";
  19939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19940. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19941. import { SmartArray } from "babylonjs/Misc/smartArray";
  19942. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19943. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19944. import { Material } from "babylonjs/Materials/material";
  19945. import { Scene } from "babylonjs/scene";
  19946. import { Camera } from "babylonjs/Cameras/camera";
  19947. /**
  19948. * Interface describing the different options available in the rendering manager
  19949. * regarding Auto Clear between groups.
  19950. */
  19951. export interface IRenderingManagerAutoClearSetup {
  19952. /**
  19953. * Defines whether or not autoclear is enable.
  19954. */
  19955. autoClear: boolean;
  19956. /**
  19957. * Defines whether or not to autoclear the depth buffer.
  19958. */
  19959. depth: boolean;
  19960. /**
  19961. * Defines whether or not to autoclear the stencil buffer.
  19962. */
  19963. stencil: boolean;
  19964. }
  19965. /**
  19966. * This class is used by the onRenderingGroupObservable
  19967. */
  19968. export class RenderingGroupInfo {
  19969. /**
  19970. * The Scene that being rendered
  19971. */
  19972. scene: Scene;
  19973. /**
  19974. * The camera currently used for the rendering pass
  19975. */
  19976. camera: Nullable<Camera>;
  19977. /**
  19978. * The ID of the renderingGroup being processed
  19979. */
  19980. renderingGroupId: number;
  19981. }
  19982. /**
  19983. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19984. * It is enable to manage the different groups as well as the different necessary sort functions.
  19985. * This should not be used directly aside of the few static configurations
  19986. */
  19987. export class RenderingManager {
  19988. /**
  19989. * The max id used for rendering groups (not included)
  19990. */
  19991. static MAX_RENDERINGGROUPS: number;
  19992. /**
  19993. * The min id used for rendering groups (included)
  19994. */
  19995. static MIN_RENDERINGGROUPS: number;
  19996. /**
  19997. * Used to globally prevent autoclearing scenes.
  19998. */
  19999. static AUTOCLEAR: boolean;
  20000. /**
  20001. * @hidden
  20002. */
  20003. _useSceneAutoClearSetup: boolean;
  20004. private _scene;
  20005. private _renderingGroups;
  20006. private _depthStencilBufferAlreadyCleaned;
  20007. private _autoClearDepthStencil;
  20008. private _customOpaqueSortCompareFn;
  20009. private _customAlphaTestSortCompareFn;
  20010. private _customTransparentSortCompareFn;
  20011. private _renderingGroupInfo;
  20012. /**
  20013. * Instantiates a new rendering group for a particular scene
  20014. * @param scene Defines the scene the groups belongs to
  20015. */
  20016. constructor(scene: Scene);
  20017. private _clearDepthStencilBuffer;
  20018. /**
  20019. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20020. * @hidden
  20021. */
  20022. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20023. /**
  20024. * Resets the different information of the group to prepare a new frame
  20025. * @hidden
  20026. */
  20027. reset(): void;
  20028. /**
  20029. * Dispose and release the group and its associated resources.
  20030. * @hidden
  20031. */
  20032. dispose(): void;
  20033. /**
  20034. * Clear the info related to rendering groups preventing retention points during dispose.
  20035. */
  20036. freeRenderingGroups(): void;
  20037. private _prepareRenderingGroup;
  20038. /**
  20039. * Add a sprite manager to the rendering manager in order to render it this frame.
  20040. * @param spriteManager Define the sprite manager to render
  20041. */
  20042. dispatchSprites(spriteManager: ISpriteManager): void;
  20043. /**
  20044. * Add a particle system to the rendering manager in order to render it this frame.
  20045. * @param particleSystem Define the particle system to render
  20046. */
  20047. dispatchParticles(particleSystem: IParticleSystem): void;
  20048. /**
  20049. * Add a submesh to the manager in order to render it this frame
  20050. * @param subMesh The submesh to dispatch
  20051. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20052. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20053. */
  20054. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20055. /**
  20056. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20057. * This allowed control for front to back rendering or reversly depending of the special needs.
  20058. *
  20059. * @param renderingGroupId The rendering group id corresponding to its index
  20060. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20061. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20062. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20063. */
  20064. 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;
  20065. /**
  20066. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20067. *
  20068. * @param renderingGroupId The rendering group id corresponding to its index
  20069. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20070. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20071. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20072. */
  20073. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20074. /**
  20075. * Gets the current auto clear configuration for one rendering group of the rendering
  20076. * manager.
  20077. * @param index the rendering group index to get the information for
  20078. * @returns The auto clear setup for the requested rendering group
  20079. */
  20080. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20081. }
  20082. }
  20083. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20084. import { Observable } from "babylonjs/Misc/observable";
  20085. import { SmartArray } from "babylonjs/Misc/smartArray";
  20086. import { Nullable } from "babylonjs/types";
  20087. import { Camera } from "babylonjs/Cameras/camera";
  20088. import { Scene } from "babylonjs/scene";
  20089. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20090. import { Color4 } from "babylonjs/Maths/math.color";
  20091. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20093. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20094. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20095. import { Texture } from "babylonjs/Materials/Textures/texture";
  20096. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20097. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20098. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20099. import { Engine } from "babylonjs/Engines/engine";
  20100. /**
  20101. * This Helps creating a texture that will be created from a camera in your scene.
  20102. * It is basically a dynamic texture that could be used to create special effects for instance.
  20103. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20104. */
  20105. export class RenderTargetTexture extends Texture {
  20106. isCube: boolean;
  20107. /**
  20108. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20109. */
  20110. static readonly REFRESHRATE_RENDER_ONCE: number;
  20111. /**
  20112. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20113. */
  20114. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20115. /**
  20116. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20117. * the central point of your effect and can save a lot of performances.
  20118. */
  20119. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20120. /**
  20121. * Use this predicate to dynamically define the list of mesh you want to render.
  20122. * If set, the renderList property will be overwritten.
  20123. */
  20124. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20125. private _renderList;
  20126. /**
  20127. * Use this list to define the list of mesh you want to render.
  20128. */
  20129. renderList: Nullable<Array<AbstractMesh>>;
  20130. private _hookArray;
  20131. /**
  20132. * Define if particles should be rendered in your texture.
  20133. */
  20134. renderParticles: boolean;
  20135. /**
  20136. * Define if sprites should be rendered in your texture.
  20137. */
  20138. renderSprites: boolean;
  20139. /**
  20140. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20141. */
  20142. coordinatesMode: number;
  20143. /**
  20144. * Define the camera used to render the texture.
  20145. */
  20146. activeCamera: Nullable<Camera>;
  20147. /**
  20148. * Override the render function of the texture with your own one.
  20149. */
  20150. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20151. /**
  20152. * Define if camera post processes should be use while rendering the texture.
  20153. */
  20154. useCameraPostProcesses: boolean;
  20155. /**
  20156. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20157. */
  20158. ignoreCameraViewport: boolean;
  20159. private _postProcessManager;
  20160. private _postProcesses;
  20161. private _resizeObserver;
  20162. /**
  20163. * An event triggered when the texture is unbind.
  20164. */
  20165. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20166. /**
  20167. * An event triggered when the texture is unbind.
  20168. */
  20169. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20170. private _onAfterUnbindObserver;
  20171. /**
  20172. * Set a after unbind callback in the texture.
  20173. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20174. */
  20175. onAfterUnbind: () => void;
  20176. /**
  20177. * An event triggered before rendering the texture
  20178. */
  20179. onBeforeRenderObservable: Observable<number>;
  20180. private _onBeforeRenderObserver;
  20181. /**
  20182. * Set a before render callback in the texture.
  20183. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20184. */
  20185. onBeforeRender: (faceIndex: number) => void;
  20186. /**
  20187. * An event triggered after rendering the texture
  20188. */
  20189. onAfterRenderObservable: Observable<number>;
  20190. private _onAfterRenderObserver;
  20191. /**
  20192. * Set a after render callback in the texture.
  20193. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20194. */
  20195. onAfterRender: (faceIndex: number) => void;
  20196. /**
  20197. * An event triggered after the texture clear
  20198. */
  20199. onClearObservable: Observable<Engine>;
  20200. private _onClearObserver;
  20201. /**
  20202. * Set a clear callback in the texture.
  20203. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20204. */
  20205. onClear: (Engine: Engine) => void;
  20206. /**
  20207. * An event triggered when the texture is resized.
  20208. */
  20209. onResizeObservable: Observable<RenderTargetTexture>;
  20210. /**
  20211. * Define the clear color of the Render Target if it should be different from the scene.
  20212. */
  20213. clearColor: Color4;
  20214. protected _size: number | {
  20215. width: number;
  20216. height: number;
  20217. };
  20218. protected _initialSizeParameter: number | {
  20219. width: number;
  20220. height: number;
  20221. } | {
  20222. ratio: number;
  20223. };
  20224. protected _sizeRatio: Nullable<number>;
  20225. /** @hidden */
  20226. _generateMipMaps: boolean;
  20227. protected _renderingManager: RenderingManager;
  20228. /** @hidden */
  20229. _waitingRenderList: string[];
  20230. protected _doNotChangeAspectRatio: boolean;
  20231. protected _currentRefreshId: number;
  20232. protected _refreshRate: number;
  20233. protected _textureMatrix: Matrix;
  20234. protected _samples: number;
  20235. protected _renderTargetOptions: RenderTargetCreationOptions;
  20236. /**
  20237. * Gets render target creation options that were used.
  20238. */
  20239. readonly renderTargetOptions: RenderTargetCreationOptions;
  20240. protected _engine: Engine;
  20241. protected _onRatioRescale(): void;
  20242. /**
  20243. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20244. * It must define where the camera used to render the texture is set
  20245. */
  20246. boundingBoxPosition: Vector3;
  20247. private _boundingBoxSize;
  20248. /**
  20249. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20250. * When defined, the cubemap will switch to local mode
  20251. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20252. * @example https://www.babylonjs-playground.com/#RNASML
  20253. */
  20254. boundingBoxSize: Vector3;
  20255. /**
  20256. * In case the RTT has been created with a depth texture, get the associated
  20257. * depth texture.
  20258. * Otherwise, return null.
  20259. */
  20260. depthStencilTexture: Nullable<InternalTexture>;
  20261. /**
  20262. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20263. * or used a shadow, depth texture...
  20264. * @param name The friendly name of the texture
  20265. * @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)
  20266. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20267. * @param generateMipMaps True if mip maps need to be generated after render.
  20268. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20269. * @param type The type of the buffer in the RTT (int, half float, float...)
  20270. * @param isCube True if a cube texture needs to be created
  20271. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20272. * @param generateDepthBuffer True to generate a depth buffer
  20273. * @param generateStencilBuffer True to generate a stencil buffer
  20274. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20275. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20276. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20277. */
  20278. constructor(name: string, size: number | {
  20279. width: number;
  20280. height: number;
  20281. } | {
  20282. ratio: number;
  20283. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20284. /**
  20285. * Creates a depth stencil texture.
  20286. * This is only available in WebGL 2 or with the depth texture extension available.
  20287. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20288. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20289. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20290. */
  20291. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20292. private _processSizeParameter;
  20293. /**
  20294. * Define the number of samples to use in case of MSAA.
  20295. * It defaults to one meaning no MSAA has been enabled.
  20296. */
  20297. samples: number;
  20298. /**
  20299. * Resets the refresh counter of the texture and start bak from scratch.
  20300. * Could be useful to regenerate the texture if it is setup to render only once.
  20301. */
  20302. resetRefreshCounter(): void;
  20303. /**
  20304. * Define the refresh rate of the texture or the rendering frequency.
  20305. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20306. */
  20307. refreshRate: number;
  20308. /**
  20309. * Adds a post process to the render target rendering passes.
  20310. * @param postProcess define the post process to add
  20311. */
  20312. addPostProcess(postProcess: PostProcess): void;
  20313. /**
  20314. * Clear all the post processes attached to the render target
  20315. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20316. */
  20317. clearPostProcesses(dispose?: boolean): void;
  20318. /**
  20319. * Remove one of the post process from the list of attached post processes to the texture
  20320. * @param postProcess define the post process to remove from the list
  20321. */
  20322. removePostProcess(postProcess: PostProcess): void;
  20323. /** @hidden */
  20324. _shouldRender(): boolean;
  20325. /**
  20326. * Gets the actual render size of the texture.
  20327. * @returns the width of the render size
  20328. */
  20329. getRenderSize(): number;
  20330. /**
  20331. * Gets the actual render width of the texture.
  20332. * @returns the width of the render size
  20333. */
  20334. getRenderWidth(): number;
  20335. /**
  20336. * Gets the actual render height of the texture.
  20337. * @returns the height of the render size
  20338. */
  20339. getRenderHeight(): number;
  20340. /**
  20341. * Get if the texture can be rescaled or not.
  20342. */
  20343. readonly canRescale: boolean;
  20344. /**
  20345. * Resize the texture using a ratio.
  20346. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20347. */
  20348. scale(ratio: number): void;
  20349. /**
  20350. * Get the texture reflection matrix used to rotate/transform the reflection.
  20351. * @returns the reflection matrix
  20352. */
  20353. getReflectionTextureMatrix(): Matrix;
  20354. /**
  20355. * Resize the texture to a new desired size.
  20356. * Be carrefull as it will recreate all the data in the new texture.
  20357. * @param size Define the new size. It can be:
  20358. * - a number for squared texture,
  20359. * - an object containing { width: number, height: number }
  20360. * - or an object containing a ratio { ratio: number }
  20361. */
  20362. resize(size: number | {
  20363. width: number;
  20364. height: number;
  20365. } | {
  20366. ratio: number;
  20367. }): void;
  20368. /**
  20369. * Renders all the objects from the render list into the texture.
  20370. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20371. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20372. */
  20373. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20374. private _bestReflectionRenderTargetDimension;
  20375. /**
  20376. * @hidden
  20377. * @param faceIndex face index to bind to if this is a cubetexture
  20378. */
  20379. _bindFrameBuffer(faceIndex?: number): void;
  20380. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20381. private renderToTarget;
  20382. /**
  20383. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20384. * This allowed control for front to back rendering or reversly depending of the special needs.
  20385. *
  20386. * @param renderingGroupId The rendering group id corresponding to its index
  20387. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20388. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20389. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20390. */
  20391. 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;
  20392. /**
  20393. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20394. *
  20395. * @param renderingGroupId The rendering group id corresponding to its index
  20396. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20397. */
  20398. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20399. /**
  20400. * Clones the texture.
  20401. * @returns the cloned texture
  20402. */
  20403. clone(): RenderTargetTexture;
  20404. /**
  20405. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20406. * @returns The JSON representation of the texture
  20407. */
  20408. serialize(): any;
  20409. /**
  20410. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20411. */
  20412. disposeFramebufferObjects(): void;
  20413. /**
  20414. * Dispose the texture and release its associated resources.
  20415. */
  20416. dispose(): void;
  20417. /** @hidden */
  20418. _rebuild(): void;
  20419. /**
  20420. * Clear the info related to rendering groups preventing retention point in material dispose.
  20421. */
  20422. freeRenderingGroups(): void;
  20423. /**
  20424. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20425. * @returns the view count
  20426. */
  20427. getViewCount(): number;
  20428. }
  20429. }
  20430. declare module "babylonjs/Materials/material" {
  20431. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20432. import { SmartArray } from "babylonjs/Misc/smartArray";
  20433. import { Observable } from "babylonjs/Misc/observable";
  20434. import { Nullable } from "babylonjs/types";
  20435. import { Scene } from "babylonjs/scene";
  20436. import { Matrix } from "babylonjs/Maths/math.vector";
  20437. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20439. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20440. import { Effect } from "babylonjs/Materials/effect";
  20441. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20442. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20443. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20444. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20445. import { Mesh } from "babylonjs/Meshes/mesh";
  20446. import { Animation } from "babylonjs/Animations/animation";
  20447. /**
  20448. * Base class for the main features of a material in Babylon.js
  20449. */
  20450. export class Material implements IAnimatable {
  20451. /**
  20452. * Returns the triangle fill mode
  20453. */
  20454. static readonly TriangleFillMode: number;
  20455. /**
  20456. * Returns the wireframe mode
  20457. */
  20458. static readonly WireFrameFillMode: number;
  20459. /**
  20460. * Returns the point fill mode
  20461. */
  20462. static readonly PointFillMode: number;
  20463. /**
  20464. * Returns the point list draw mode
  20465. */
  20466. static readonly PointListDrawMode: number;
  20467. /**
  20468. * Returns the line list draw mode
  20469. */
  20470. static readonly LineListDrawMode: number;
  20471. /**
  20472. * Returns the line loop draw mode
  20473. */
  20474. static readonly LineLoopDrawMode: number;
  20475. /**
  20476. * Returns the line strip draw mode
  20477. */
  20478. static readonly LineStripDrawMode: number;
  20479. /**
  20480. * Returns the triangle strip draw mode
  20481. */
  20482. static readonly TriangleStripDrawMode: number;
  20483. /**
  20484. * Returns the triangle fan draw mode
  20485. */
  20486. static readonly TriangleFanDrawMode: number;
  20487. /**
  20488. * Stores the clock-wise side orientation
  20489. */
  20490. static readonly ClockWiseSideOrientation: number;
  20491. /**
  20492. * Stores the counter clock-wise side orientation
  20493. */
  20494. static readonly CounterClockWiseSideOrientation: number;
  20495. /**
  20496. * The dirty texture flag value
  20497. */
  20498. static readonly TextureDirtyFlag: number;
  20499. /**
  20500. * The dirty light flag value
  20501. */
  20502. static readonly LightDirtyFlag: number;
  20503. /**
  20504. * The dirty fresnel flag value
  20505. */
  20506. static readonly FresnelDirtyFlag: number;
  20507. /**
  20508. * The dirty attribute flag value
  20509. */
  20510. static readonly AttributesDirtyFlag: number;
  20511. /**
  20512. * The dirty misc flag value
  20513. */
  20514. static readonly MiscDirtyFlag: number;
  20515. /**
  20516. * The all dirty flag value
  20517. */
  20518. static readonly AllDirtyFlag: number;
  20519. /**
  20520. * The ID of the material
  20521. */
  20522. id: string;
  20523. /**
  20524. * Gets or sets the unique id of the material
  20525. */
  20526. uniqueId: number;
  20527. /**
  20528. * The name of the material
  20529. */
  20530. name: string;
  20531. /**
  20532. * Gets or sets user defined metadata
  20533. */
  20534. metadata: any;
  20535. /**
  20536. * For internal use only. Please do not use.
  20537. */
  20538. reservedDataStore: any;
  20539. /**
  20540. * Specifies if the ready state should be checked on each call
  20541. */
  20542. checkReadyOnEveryCall: boolean;
  20543. /**
  20544. * Specifies if the ready state should be checked once
  20545. */
  20546. checkReadyOnlyOnce: boolean;
  20547. /**
  20548. * The state of the material
  20549. */
  20550. state: string;
  20551. /**
  20552. * The alpha value of the material
  20553. */
  20554. protected _alpha: number;
  20555. /**
  20556. * List of inspectable custom properties (used by the Inspector)
  20557. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20558. */
  20559. inspectableCustomProperties: IInspectable[];
  20560. /**
  20561. * Sets the alpha value of the material
  20562. */
  20563. /**
  20564. * Gets the alpha value of the material
  20565. */
  20566. alpha: number;
  20567. /**
  20568. * Specifies if back face culling is enabled
  20569. */
  20570. protected _backFaceCulling: boolean;
  20571. /**
  20572. * Sets the back-face culling state
  20573. */
  20574. /**
  20575. * Gets the back-face culling state
  20576. */
  20577. backFaceCulling: boolean;
  20578. /**
  20579. * Stores the value for side orientation
  20580. */
  20581. sideOrientation: number;
  20582. /**
  20583. * Callback triggered when the material is compiled
  20584. */
  20585. onCompiled: Nullable<(effect: Effect) => void>;
  20586. /**
  20587. * Callback triggered when an error occurs
  20588. */
  20589. onError: Nullable<(effect: Effect, errors: string) => void>;
  20590. /**
  20591. * Callback triggered to get the render target textures
  20592. */
  20593. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20594. /**
  20595. * Gets a boolean indicating that current material needs to register RTT
  20596. */
  20597. readonly hasRenderTargetTextures: boolean;
  20598. /**
  20599. * Specifies if the material should be serialized
  20600. */
  20601. doNotSerialize: boolean;
  20602. /**
  20603. * @hidden
  20604. */
  20605. _storeEffectOnSubMeshes: boolean;
  20606. /**
  20607. * Stores the animations for the material
  20608. */
  20609. animations: Nullable<Array<Animation>>;
  20610. /**
  20611. * An event triggered when the material is disposed
  20612. */
  20613. onDisposeObservable: Observable<Material>;
  20614. /**
  20615. * An observer which watches for dispose events
  20616. */
  20617. private _onDisposeObserver;
  20618. private _onUnBindObservable;
  20619. /**
  20620. * Called during a dispose event
  20621. */
  20622. onDispose: () => void;
  20623. private _onBindObservable;
  20624. /**
  20625. * An event triggered when the material is bound
  20626. */
  20627. readonly onBindObservable: Observable<AbstractMesh>;
  20628. /**
  20629. * An observer which watches for bind events
  20630. */
  20631. private _onBindObserver;
  20632. /**
  20633. * Called during a bind event
  20634. */
  20635. onBind: (Mesh: AbstractMesh) => void;
  20636. /**
  20637. * An event triggered when the material is unbound
  20638. */
  20639. readonly onUnBindObservable: Observable<Material>;
  20640. /**
  20641. * Stores the value of the alpha mode
  20642. */
  20643. private _alphaMode;
  20644. /**
  20645. * Sets the value of the alpha mode.
  20646. *
  20647. * | Value | Type | Description |
  20648. * | --- | --- | --- |
  20649. * | 0 | ALPHA_DISABLE | |
  20650. * | 1 | ALPHA_ADD | |
  20651. * | 2 | ALPHA_COMBINE | |
  20652. * | 3 | ALPHA_SUBTRACT | |
  20653. * | 4 | ALPHA_MULTIPLY | |
  20654. * | 5 | ALPHA_MAXIMIZED | |
  20655. * | 6 | ALPHA_ONEONE | |
  20656. * | 7 | ALPHA_PREMULTIPLIED | |
  20657. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20658. * | 9 | ALPHA_INTERPOLATE | |
  20659. * | 10 | ALPHA_SCREENMODE | |
  20660. *
  20661. */
  20662. /**
  20663. * Gets the value of the alpha mode
  20664. */
  20665. alphaMode: number;
  20666. /**
  20667. * Stores the state of the need depth pre-pass value
  20668. */
  20669. private _needDepthPrePass;
  20670. /**
  20671. * Sets the need depth pre-pass value
  20672. */
  20673. /**
  20674. * Gets the depth pre-pass value
  20675. */
  20676. needDepthPrePass: boolean;
  20677. /**
  20678. * Specifies if depth writing should be disabled
  20679. */
  20680. disableDepthWrite: boolean;
  20681. /**
  20682. * Specifies if depth writing should be forced
  20683. */
  20684. forceDepthWrite: boolean;
  20685. /**
  20686. * Specifies if there should be a separate pass for culling
  20687. */
  20688. separateCullingPass: boolean;
  20689. /**
  20690. * Stores the state specifing if fog should be enabled
  20691. */
  20692. private _fogEnabled;
  20693. /**
  20694. * Sets the state for enabling fog
  20695. */
  20696. /**
  20697. * Gets the value of the fog enabled state
  20698. */
  20699. fogEnabled: boolean;
  20700. /**
  20701. * Stores the size of points
  20702. */
  20703. pointSize: number;
  20704. /**
  20705. * Stores the z offset value
  20706. */
  20707. zOffset: number;
  20708. /**
  20709. * Gets a value specifying if wireframe mode is enabled
  20710. */
  20711. /**
  20712. * Sets the state of wireframe mode
  20713. */
  20714. wireframe: boolean;
  20715. /**
  20716. * Gets the value specifying if point clouds are enabled
  20717. */
  20718. /**
  20719. * Sets the state of point cloud mode
  20720. */
  20721. pointsCloud: boolean;
  20722. /**
  20723. * Gets the material fill mode
  20724. */
  20725. /**
  20726. * Sets the material fill mode
  20727. */
  20728. fillMode: number;
  20729. /**
  20730. * @hidden
  20731. * Stores the effects for the material
  20732. */
  20733. _effect: Nullable<Effect>;
  20734. /**
  20735. * @hidden
  20736. * Specifies if the material was previously ready
  20737. */
  20738. _wasPreviouslyReady: boolean;
  20739. /**
  20740. * Specifies if uniform buffers should be used
  20741. */
  20742. private _useUBO;
  20743. /**
  20744. * Stores a reference to the scene
  20745. */
  20746. private _scene;
  20747. /**
  20748. * Stores the fill mode state
  20749. */
  20750. private _fillMode;
  20751. /**
  20752. * Specifies if the depth write state should be cached
  20753. */
  20754. private _cachedDepthWriteState;
  20755. /**
  20756. * Stores the uniform buffer
  20757. */
  20758. protected _uniformBuffer: UniformBuffer;
  20759. /** @hidden */
  20760. _indexInSceneMaterialArray: number;
  20761. /** @hidden */
  20762. meshMap: Nullable<{
  20763. [id: string]: AbstractMesh | undefined;
  20764. }>;
  20765. /**
  20766. * Creates a material instance
  20767. * @param name defines the name of the material
  20768. * @param scene defines the scene to reference
  20769. * @param doNotAdd specifies if the material should be added to the scene
  20770. */
  20771. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20772. /**
  20773. * Returns a string representation of the current material
  20774. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20775. * @returns a string with material information
  20776. */
  20777. toString(fullDetails?: boolean): string;
  20778. /**
  20779. * Gets the class name of the material
  20780. * @returns a string with the class name of the material
  20781. */
  20782. getClassName(): string;
  20783. /**
  20784. * Specifies if updates for the material been locked
  20785. */
  20786. readonly isFrozen: boolean;
  20787. /**
  20788. * Locks updates for the material
  20789. */
  20790. freeze(): void;
  20791. /**
  20792. * Unlocks updates for the material
  20793. */
  20794. unfreeze(): void;
  20795. /**
  20796. * Specifies if the material is ready to be used
  20797. * @param mesh defines the mesh to check
  20798. * @param useInstances specifies if instances should be used
  20799. * @returns a boolean indicating if the material is ready to be used
  20800. */
  20801. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20802. /**
  20803. * Specifies that the submesh is ready to be used
  20804. * @param mesh defines the mesh to check
  20805. * @param subMesh defines which submesh to check
  20806. * @param useInstances specifies that instances should be used
  20807. * @returns a boolean indicating that the submesh is ready or not
  20808. */
  20809. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20810. /**
  20811. * Returns the material effect
  20812. * @returns the effect associated with the material
  20813. */
  20814. getEffect(): Nullable<Effect>;
  20815. /**
  20816. * Returns the current scene
  20817. * @returns a Scene
  20818. */
  20819. getScene(): Scene;
  20820. /**
  20821. * Specifies if the material will require alpha blending
  20822. * @returns a boolean specifying if alpha blending is needed
  20823. */
  20824. needAlphaBlending(): boolean;
  20825. /**
  20826. * Specifies if the mesh will require alpha blending
  20827. * @param mesh defines the mesh to check
  20828. * @returns a boolean specifying if alpha blending is needed for the mesh
  20829. */
  20830. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20831. /**
  20832. * Specifies if this material should be rendered in alpha test mode
  20833. * @returns a boolean specifying if an alpha test is needed.
  20834. */
  20835. needAlphaTesting(): boolean;
  20836. /**
  20837. * Gets the texture used for the alpha test
  20838. * @returns the texture to use for alpha testing
  20839. */
  20840. getAlphaTestTexture(): Nullable<BaseTexture>;
  20841. /**
  20842. * Marks the material to indicate that it needs to be re-calculated
  20843. */
  20844. markDirty(): void;
  20845. /** @hidden */
  20846. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20847. /**
  20848. * Binds the material to the mesh
  20849. * @param world defines the world transformation matrix
  20850. * @param mesh defines the mesh to bind the material to
  20851. */
  20852. bind(world: Matrix, mesh?: Mesh): void;
  20853. /**
  20854. * Binds the submesh to the material
  20855. * @param world defines the world transformation matrix
  20856. * @param mesh defines the mesh containing the submesh
  20857. * @param subMesh defines the submesh to bind the material to
  20858. */
  20859. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20860. /**
  20861. * Binds the world matrix to the material
  20862. * @param world defines the world transformation matrix
  20863. */
  20864. bindOnlyWorldMatrix(world: Matrix): void;
  20865. /**
  20866. * Binds the scene's uniform buffer to the effect.
  20867. * @param effect defines the effect to bind to the scene uniform buffer
  20868. * @param sceneUbo defines the uniform buffer storing scene data
  20869. */
  20870. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20871. /**
  20872. * Binds the view matrix to the effect
  20873. * @param effect defines the effect to bind the view matrix to
  20874. */
  20875. bindView(effect: Effect): void;
  20876. /**
  20877. * Binds the view projection matrix to the effect
  20878. * @param effect defines the effect to bind the view projection matrix to
  20879. */
  20880. bindViewProjection(effect: Effect): void;
  20881. /**
  20882. * Specifies if material alpha testing should be turned on for the mesh
  20883. * @param mesh defines the mesh to check
  20884. */
  20885. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20886. /**
  20887. * Processes to execute after binding the material to a mesh
  20888. * @param mesh defines the rendered mesh
  20889. */
  20890. protected _afterBind(mesh?: Mesh): void;
  20891. /**
  20892. * Unbinds the material from the mesh
  20893. */
  20894. unbind(): void;
  20895. /**
  20896. * Gets the active textures from the material
  20897. * @returns an array of textures
  20898. */
  20899. getActiveTextures(): BaseTexture[];
  20900. /**
  20901. * Specifies if the material uses a texture
  20902. * @param texture defines the texture to check against the material
  20903. * @returns a boolean specifying if the material uses the texture
  20904. */
  20905. hasTexture(texture: BaseTexture): boolean;
  20906. /**
  20907. * Makes a duplicate of the material, and gives it a new name
  20908. * @param name defines the new name for the duplicated material
  20909. * @returns the cloned material
  20910. */
  20911. clone(name: string): Nullable<Material>;
  20912. /**
  20913. * Gets the meshes bound to the material
  20914. * @returns an array of meshes bound to the material
  20915. */
  20916. getBindedMeshes(): AbstractMesh[];
  20917. /**
  20918. * Force shader compilation
  20919. * @param mesh defines the mesh associated with this material
  20920. * @param onCompiled defines a function to execute once the material is compiled
  20921. * @param options defines the options to configure the compilation
  20922. */
  20923. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20924. clipPlane: boolean;
  20925. }>): void;
  20926. /**
  20927. * Force shader compilation
  20928. * @param mesh defines the mesh that will use this material
  20929. * @param options defines additional options for compiling the shaders
  20930. * @returns a promise that resolves when the compilation completes
  20931. */
  20932. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20933. clipPlane: boolean;
  20934. }>): Promise<void>;
  20935. private static readonly _AllDirtyCallBack;
  20936. private static readonly _ImageProcessingDirtyCallBack;
  20937. private static readonly _TextureDirtyCallBack;
  20938. private static readonly _FresnelDirtyCallBack;
  20939. private static readonly _MiscDirtyCallBack;
  20940. private static readonly _LightsDirtyCallBack;
  20941. private static readonly _AttributeDirtyCallBack;
  20942. private static _FresnelAndMiscDirtyCallBack;
  20943. private static _TextureAndMiscDirtyCallBack;
  20944. private static readonly _DirtyCallbackArray;
  20945. private static readonly _RunDirtyCallBacks;
  20946. /**
  20947. * Marks a define in the material to indicate that it needs to be re-computed
  20948. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20949. */
  20950. markAsDirty(flag: number): void;
  20951. /**
  20952. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20953. * @param func defines a function which checks material defines against the submeshes
  20954. */
  20955. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20956. /**
  20957. * Indicates that we need to re-calculated for all submeshes
  20958. */
  20959. protected _markAllSubMeshesAsAllDirty(): void;
  20960. /**
  20961. * Indicates that image processing needs to be re-calculated for all submeshes
  20962. */
  20963. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20964. /**
  20965. * Indicates that textures need to be re-calculated for all submeshes
  20966. */
  20967. protected _markAllSubMeshesAsTexturesDirty(): void;
  20968. /**
  20969. * Indicates that fresnel needs to be re-calculated for all submeshes
  20970. */
  20971. protected _markAllSubMeshesAsFresnelDirty(): void;
  20972. /**
  20973. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20974. */
  20975. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20976. /**
  20977. * Indicates that lights need to be re-calculated for all submeshes
  20978. */
  20979. protected _markAllSubMeshesAsLightsDirty(): void;
  20980. /**
  20981. * Indicates that attributes need to be re-calculated for all submeshes
  20982. */
  20983. protected _markAllSubMeshesAsAttributesDirty(): void;
  20984. /**
  20985. * Indicates that misc needs to be re-calculated for all submeshes
  20986. */
  20987. protected _markAllSubMeshesAsMiscDirty(): void;
  20988. /**
  20989. * Indicates that textures and misc need to be re-calculated for all submeshes
  20990. */
  20991. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20992. /**
  20993. * Disposes the material
  20994. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20995. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20996. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20997. */
  20998. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20999. /** @hidden */
  21000. private releaseVertexArrayObject;
  21001. /**
  21002. * Serializes this material
  21003. * @returns the serialized material object
  21004. */
  21005. serialize(): any;
  21006. /**
  21007. * Creates a material from parsed material data
  21008. * @param parsedMaterial defines parsed material data
  21009. * @param scene defines the hosting scene
  21010. * @param rootUrl defines the root URL to use to load textures
  21011. * @returns a new material
  21012. */
  21013. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21014. }
  21015. }
  21016. declare module "babylonjs/Materials/multiMaterial" {
  21017. import { Nullable } from "babylonjs/types";
  21018. import { Scene } from "babylonjs/scene";
  21019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21020. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21021. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21022. import { Material } from "babylonjs/Materials/material";
  21023. /**
  21024. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21025. * separate meshes. This can be use to improve performances.
  21026. * @see http://doc.babylonjs.com/how_to/multi_materials
  21027. */
  21028. export class MultiMaterial extends Material {
  21029. private _subMaterials;
  21030. /**
  21031. * Gets or Sets the list of Materials used within the multi material.
  21032. * They need to be ordered according to the submeshes order in the associated mesh
  21033. */
  21034. subMaterials: Nullable<Material>[];
  21035. /**
  21036. * Function used to align with Node.getChildren()
  21037. * @returns the list of Materials used within the multi material
  21038. */
  21039. getChildren(): Nullable<Material>[];
  21040. /**
  21041. * Instantiates a new Multi Material
  21042. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21043. * separate meshes. This can be use to improve performances.
  21044. * @see http://doc.babylonjs.com/how_to/multi_materials
  21045. * @param name Define the name in the scene
  21046. * @param scene Define the scene the material belongs to
  21047. */
  21048. constructor(name: string, scene: Scene);
  21049. private _hookArray;
  21050. /**
  21051. * Get one of the submaterial by its index in the submaterials array
  21052. * @param index The index to look the sub material at
  21053. * @returns The Material if the index has been defined
  21054. */
  21055. getSubMaterial(index: number): Nullable<Material>;
  21056. /**
  21057. * Get the list of active textures for the whole sub materials list.
  21058. * @returns All the textures that will be used during the rendering
  21059. */
  21060. getActiveTextures(): BaseTexture[];
  21061. /**
  21062. * Gets the current class name of the material e.g. "MultiMaterial"
  21063. * Mainly use in serialization.
  21064. * @returns the class name
  21065. */
  21066. getClassName(): string;
  21067. /**
  21068. * Checks if the material is ready to render the requested sub mesh
  21069. * @param mesh Define the mesh the submesh belongs to
  21070. * @param subMesh Define the sub mesh to look readyness for
  21071. * @param useInstances Define whether or not the material is used with instances
  21072. * @returns true if ready, otherwise false
  21073. */
  21074. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21075. /**
  21076. * Clones the current material and its related sub materials
  21077. * @param name Define the name of the newly cloned material
  21078. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21079. * @returns the cloned material
  21080. */
  21081. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21082. /**
  21083. * Serializes the materials into a JSON representation.
  21084. * @returns the JSON representation
  21085. */
  21086. serialize(): any;
  21087. /**
  21088. * Dispose the material and release its associated resources
  21089. * @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)
  21090. * @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)
  21091. * @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)
  21092. */
  21093. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21094. /**
  21095. * Creates a MultiMaterial from parsed MultiMaterial data.
  21096. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21097. * @param scene defines the hosting scene
  21098. * @returns a new MultiMaterial
  21099. */
  21100. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21101. }
  21102. }
  21103. declare module "babylonjs/Meshes/subMesh" {
  21104. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21105. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21106. import { Engine } from "babylonjs/Engines/engine";
  21107. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21108. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21109. import { Effect } from "babylonjs/Materials/effect";
  21110. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21111. import { Plane } from "babylonjs/Maths/math.plane";
  21112. import { Collider } from "babylonjs/Collisions/collider";
  21113. import { Material } from "babylonjs/Materials/material";
  21114. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21116. import { Mesh } from "babylonjs/Meshes/mesh";
  21117. import { Ray } from "babylonjs/Culling/ray";
  21118. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21119. /**
  21120. * Base class for submeshes
  21121. */
  21122. export class BaseSubMesh {
  21123. /** @hidden */
  21124. _materialDefines: Nullable<MaterialDefines>;
  21125. /** @hidden */
  21126. _materialEffect: Nullable<Effect>;
  21127. /**
  21128. * Gets associated effect
  21129. */
  21130. readonly effect: Nullable<Effect>;
  21131. /**
  21132. * Sets associated effect (effect used to render this submesh)
  21133. * @param effect defines the effect to associate with
  21134. * @param defines defines the set of defines used to compile this effect
  21135. */
  21136. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21137. }
  21138. /**
  21139. * Defines a subdivision inside a mesh
  21140. */
  21141. export class SubMesh extends BaseSubMesh implements ICullable {
  21142. /** the material index to use */
  21143. materialIndex: number;
  21144. /** vertex index start */
  21145. verticesStart: number;
  21146. /** vertices count */
  21147. verticesCount: number;
  21148. /** index start */
  21149. indexStart: number;
  21150. /** indices count */
  21151. indexCount: number;
  21152. /** @hidden */
  21153. _linesIndexCount: number;
  21154. private _mesh;
  21155. private _renderingMesh;
  21156. private _boundingInfo;
  21157. private _linesIndexBuffer;
  21158. /** @hidden */
  21159. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21160. /** @hidden */
  21161. _trianglePlanes: Plane[];
  21162. /** @hidden */
  21163. _lastColliderTransformMatrix: Nullable<Matrix>;
  21164. /** @hidden */
  21165. _renderId: number;
  21166. /** @hidden */
  21167. _alphaIndex: number;
  21168. /** @hidden */
  21169. _distanceToCamera: number;
  21170. /** @hidden */
  21171. _id: number;
  21172. private _currentMaterial;
  21173. /**
  21174. * Add a new submesh to a mesh
  21175. * @param materialIndex defines the material index to use
  21176. * @param verticesStart defines vertex index start
  21177. * @param verticesCount defines vertices count
  21178. * @param indexStart defines index start
  21179. * @param indexCount defines indices count
  21180. * @param mesh defines the parent mesh
  21181. * @param renderingMesh defines an optional rendering mesh
  21182. * @param createBoundingBox defines if bounding box should be created for this submesh
  21183. * @returns the new submesh
  21184. */
  21185. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21186. /**
  21187. * Creates a new submesh
  21188. * @param materialIndex defines the material index to use
  21189. * @param verticesStart defines vertex index start
  21190. * @param verticesCount defines vertices count
  21191. * @param indexStart defines index start
  21192. * @param indexCount defines indices count
  21193. * @param mesh defines the parent mesh
  21194. * @param renderingMesh defines an optional rendering mesh
  21195. * @param createBoundingBox defines if bounding box should be created for this submesh
  21196. */
  21197. constructor(
  21198. /** the material index to use */
  21199. materialIndex: number,
  21200. /** vertex index start */
  21201. verticesStart: number,
  21202. /** vertices count */
  21203. verticesCount: number,
  21204. /** index start */
  21205. indexStart: number,
  21206. /** indices count */
  21207. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21208. /**
  21209. * Returns true if this submesh covers the entire parent mesh
  21210. * @ignorenaming
  21211. */
  21212. readonly IsGlobal: boolean;
  21213. /**
  21214. * Returns the submesh BoudingInfo object
  21215. * @returns current bounding info (or mesh's one if the submesh is global)
  21216. */
  21217. getBoundingInfo(): BoundingInfo;
  21218. /**
  21219. * Sets the submesh BoundingInfo
  21220. * @param boundingInfo defines the new bounding info to use
  21221. * @returns the SubMesh
  21222. */
  21223. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21224. /**
  21225. * Returns the mesh of the current submesh
  21226. * @return the parent mesh
  21227. */
  21228. getMesh(): AbstractMesh;
  21229. /**
  21230. * Returns the rendering mesh of the submesh
  21231. * @returns the rendering mesh (could be different from parent mesh)
  21232. */
  21233. getRenderingMesh(): Mesh;
  21234. /**
  21235. * Returns the submesh material
  21236. * @returns null or the current material
  21237. */
  21238. getMaterial(): Nullable<Material>;
  21239. /**
  21240. * Sets a new updated BoundingInfo object to the submesh
  21241. * @param data defines an optional position array to use to determine the bounding info
  21242. * @returns the SubMesh
  21243. */
  21244. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21245. /** @hidden */
  21246. _checkCollision(collider: Collider): boolean;
  21247. /**
  21248. * Updates the submesh BoundingInfo
  21249. * @param world defines the world matrix to use to update the bounding info
  21250. * @returns the submesh
  21251. */
  21252. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21253. /**
  21254. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21255. * @param frustumPlanes defines the frustum planes
  21256. * @returns true if the submesh is intersecting with the frustum
  21257. */
  21258. isInFrustum(frustumPlanes: Plane[]): boolean;
  21259. /**
  21260. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21261. * @param frustumPlanes defines the frustum planes
  21262. * @returns true if the submesh is inside the frustum
  21263. */
  21264. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21265. /**
  21266. * Renders the submesh
  21267. * @param enableAlphaMode defines if alpha needs to be used
  21268. * @returns the submesh
  21269. */
  21270. render(enableAlphaMode: boolean): SubMesh;
  21271. /**
  21272. * @hidden
  21273. */
  21274. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21275. /**
  21276. * Checks if the submesh intersects with a ray
  21277. * @param ray defines the ray to test
  21278. * @returns true is the passed ray intersects the submesh bounding box
  21279. */
  21280. canIntersects(ray: Ray): boolean;
  21281. /**
  21282. * Intersects current submesh with a ray
  21283. * @param ray defines the ray to test
  21284. * @param positions defines mesh's positions array
  21285. * @param indices defines mesh's indices array
  21286. * @param fastCheck defines if only bounding info should be used
  21287. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21288. * @returns intersection info or null if no intersection
  21289. */
  21290. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21291. /** @hidden */
  21292. private _intersectLines;
  21293. /** @hidden */
  21294. private _intersectUnIndexedLines;
  21295. /** @hidden */
  21296. private _intersectTriangles;
  21297. /** @hidden */
  21298. private _intersectUnIndexedTriangles;
  21299. /** @hidden */
  21300. _rebuild(): void;
  21301. /**
  21302. * Creates a new submesh from the passed mesh
  21303. * @param newMesh defines the new hosting mesh
  21304. * @param newRenderingMesh defines an optional rendering mesh
  21305. * @returns the new submesh
  21306. */
  21307. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21308. /**
  21309. * Release associated resources
  21310. */
  21311. dispose(): void;
  21312. /**
  21313. * Gets the class name
  21314. * @returns the string "SubMesh".
  21315. */
  21316. getClassName(): string;
  21317. /**
  21318. * Creates a new submesh from indices data
  21319. * @param materialIndex the index of the main mesh material
  21320. * @param startIndex the index where to start the copy in the mesh indices array
  21321. * @param indexCount the number of indices to copy then from the startIndex
  21322. * @param mesh the main mesh to create the submesh from
  21323. * @param renderingMesh the optional rendering mesh
  21324. * @returns a new submesh
  21325. */
  21326. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21327. }
  21328. }
  21329. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21330. /**
  21331. * Class used to represent data loading progression
  21332. */
  21333. export class SceneLoaderFlags {
  21334. private static _ForceFullSceneLoadingForIncremental;
  21335. private static _ShowLoadingScreen;
  21336. private static _CleanBoneMatrixWeights;
  21337. private static _loggingLevel;
  21338. /**
  21339. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21340. */
  21341. static ForceFullSceneLoadingForIncremental: boolean;
  21342. /**
  21343. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21344. */
  21345. static ShowLoadingScreen: boolean;
  21346. /**
  21347. * Defines the current logging level (while loading the scene)
  21348. * @ignorenaming
  21349. */
  21350. static loggingLevel: number;
  21351. /**
  21352. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21353. */
  21354. static CleanBoneMatrixWeights: boolean;
  21355. }
  21356. }
  21357. declare module "babylonjs/Meshes/geometry" {
  21358. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21359. import { Scene } from "babylonjs/scene";
  21360. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21361. import { Engine } from "babylonjs/Engines/engine";
  21362. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21363. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21364. import { Effect } from "babylonjs/Materials/effect";
  21365. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21366. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21367. import { Mesh } from "babylonjs/Meshes/mesh";
  21368. /**
  21369. * Class used to store geometry data (vertex buffers + index buffer)
  21370. */
  21371. export class Geometry implements IGetSetVerticesData {
  21372. /**
  21373. * Gets or sets the ID of the geometry
  21374. */
  21375. id: string;
  21376. /**
  21377. * Gets or sets the unique ID of the geometry
  21378. */
  21379. uniqueId: number;
  21380. /**
  21381. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21382. */
  21383. delayLoadState: number;
  21384. /**
  21385. * Gets the file containing the data to load when running in delay load state
  21386. */
  21387. delayLoadingFile: Nullable<string>;
  21388. /**
  21389. * Callback called when the geometry is updated
  21390. */
  21391. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21392. private _scene;
  21393. private _engine;
  21394. private _meshes;
  21395. private _totalVertices;
  21396. /** @hidden */
  21397. _indices: IndicesArray;
  21398. /** @hidden */
  21399. _vertexBuffers: {
  21400. [key: string]: VertexBuffer;
  21401. };
  21402. private _isDisposed;
  21403. private _extend;
  21404. private _boundingBias;
  21405. /** @hidden */
  21406. _delayInfo: Array<string>;
  21407. private _indexBuffer;
  21408. private _indexBufferIsUpdatable;
  21409. /** @hidden */
  21410. _boundingInfo: Nullable<BoundingInfo>;
  21411. /** @hidden */
  21412. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21413. /** @hidden */
  21414. _softwareSkinningFrameId: number;
  21415. private _vertexArrayObjects;
  21416. private _updatable;
  21417. /** @hidden */
  21418. _positions: Nullable<Vector3[]>;
  21419. /**
  21420. * 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
  21421. */
  21422. /**
  21423. * 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
  21424. */
  21425. boundingBias: Vector2;
  21426. /**
  21427. * Static function used to attach a new empty geometry to a mesh
  21428. * @param mesh defines the mesh to attach the geometry to
  21429. * @returns the new Geometry
  21430. */
  21431. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21432. /**
  21433. * Creates a new geometry
  21434. * @param id defines the unique ID
  21435. * @param scene defines the hosting scene
  21436. * @param vertexData defines the VertexData used to get geometry data
  21437. * @param updatable defines if geometry must be updatable (false by default)
  21438. * @param mesh defines the mesh that will be associated with the geometry
  21439. */
  21440. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21441. /**
  21442. * Gets the current extend of the geometry
  21443. */
  21444. readonly extend: {
  21445. minimum: Vector3;
  21446. maximum: Vector3;
  21447. };
  21448. /**
  21449. * Gets the hosting scene
  21450. * @returns the hosting Scene
  21451. */
  21452. getScene(): Scene;
  21453. /**
  21454. * Gets the hosting engine
  21455. * @returns the hosting Engine
  21456. */
  21457. getEngine(): Engine;
  21458. /**
  21459. * Defines if the geometry is ready to use
  21460. * @returns true if the geometry is ready to be used
  21461. */
  21462. isReady(): boolean;
  21463. /**
  21464. * Gets a value indicating that the geometry should not be serialized
  21465. */
  21466. readonly doNotSerialize: boolean;
  21467. /** @hidden */
  21468. _rebuild(): void;
  21469. /**
  21470. * Affects all geometry data in one call
  21471. * @param vertexData defines the geometry data
  21472. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21473. */
  21474. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21475. /**
  21476. * Set specific vertex data
  21477. * @param kind defines the data kind (Position, normal, etc...)
  21478. * @param data defines the vertex data to use
  21479. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21480. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21481. */
  21482. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21483. /**
  21484. * Removes a specific vertex data
  21485. * @param kind defines the data kind (Position, normal, etc...)
  21486. */
  21487. removeVerticesData(kind: string): void;
  21488. /**
  21489. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21490. * @param buffer defines the vertex buffer to use
  21491. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21492. */
  21493. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21494. /**
  21495. * Update a specific vertex buffer
  21496. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21497. * It will do nothing if the buffer is not updatable
  21498. * @param kind defines the data kind (Position, normal, etc...)
  21499. * @param data defines the data to use
  21500. * @param offset defines the offset in the target buffer where to store the data
  21501. * @param useBytes set to true if the offset is in bytes
  21502. */
  21503. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21504. /**
  21505. * Update a specific vertex buffer
  21506. * This function will create a new buffer if the current one is not updatable
  21507. * @param kind defines the data kind (Position, normal, etc...)
  21508. * @param data defines the data to use
  21509. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21510. */
  21511. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21512. private _updateBoundingInfo;
  21513. /** @hidden */
  21514. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21515. /**
  21516. * Gets total number of vertices
  21517. * @returns the total number of vertices
  21518. */
  21519. getTotalVertices(): number;
  21520. /**
  21521. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21522. * @param kind defines the data kind (Position, normal, etc...)
  21523. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21524. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21525. * @returns a float array containing vertex data
  21526. */
  21527. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21528. /**
  21529. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21530. * @param kind defines the data kind (Position, normal, etc...)
  21531. * @returns true if the vertex buffer with the specified kind is updatable
  21532. */
  21533. isVertexBufferUpdatable(kind: string): boolean;
  21534. /**
  21535. * Gets a specific vertex buffer
  21536. * @param kind defines the data kind (Position, normal, etc...)
  21537. * @returns a VertexBuffer
  21538. */
  21539. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21540. /**
  21541. * Returns all vertex buffers
  21542. * @return an object holding all vertex buffers indexed by kind
  21543. */
  21544. getVertexBuffers(): Nullable<{
  21545. [key: string]: VertexBuffer;
  21546. }>;
  21547. /**
  21548. * Gets a boolean indicating if specific vertex buffer is present
  21549. * @param kind defines the data kind (Position, normal, etc...)
  21550. * @returns true if data is present
  21551. */
  21552. isVerticesDataPresent(kind: string): boolean;
  21553. /**
  21554. * Gets a list of all attached data kinds (Position, normal, etc...)
  21555. * @returns a list of string containing all kinds
  21556. */
  21557. getVerticesDataKinds(): string[];
  21558. /**
  21559. * Update index buffer
  21560. * @param indices defines the indices to store in the index buffer
  21561. * @param offset defines the offset in the target buffer where to store the data
  21562. * @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)
  21563. */
  21564. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21565. /**
  21566. * Creates a new index buffer
  21567. * @param indices defines the indices to store in the index buffer
  21568. * @param totalVertices defines the total number of vertices (could be null)
  21569. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21570. */
  21571. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21572. /**
  21573. * Return the total number of indices
  21574. * @returns the total number of indices
  21575. */
  21576. getTotalIndices(): number;
  21577. /**
  21578. * Gets the index buffer array
  21579. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21580. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21581. * @returns the index buffer array
  21582. */
  21583. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21584. /**
  21585. * Gets the index buffer
  21586. * @return the index buffer
  21587. */
  21588. getIndexBuffer(): Nullable<DataBuffer>;
  21589. /** @hidden */
  21590. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21591. /**
  21592. * Release the associated resources for a specific mesh
  21593. * @param mesh defines the source mesh
  21594. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21595. */
  21596. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21597. /**
  21598. * Apply current geometry to a given mesh
  21599. * @param mesh defines the mesh to apply geometry to
  21600. */
  21601. applyToMesh(mesh: Mesh): void;
  21602. private _updateExtend;
  21603. private _applyToMesh;
  21604. private notifyUpdate;
  21605. /**
  21606. * Load the geometry if it was flagged as delay loaded
  21607. * @param scene defines the hosting scene
  21608. * @param onLoaded defines a callback called when the geometry is loaded
  21609. */
  21610. load(scene: Scene, onLoaded?: () => void): void;
  21611. private _queueLoad;
  21612. /**
  21613. * Invert the geometry to move from a right handed system to a left handed one.
  21614. */
  21615. toLeftHanded(): void;
  21616. /** @hidden */
  21617. _resetPointsArrayCache(): void;
  21618. /** @hidden */
  21619. _generatePointsArray(): boolean;
  21620. /**
  21621. * Gets a value indicating if the geometry is disposed
  21622. * @returns true if the geometry was disposed
  21623. */
  21624. isDisposed(): boolean;
  21625. private _disposeVertexArrayObjects;
  21626. /**
  21627. * Free all associated resources
  21628. */
  21629. dispose(): void;
  21630. /**
  21631. * Clone the current geometry into a new geometry
  21632. * @param id defines the unique ID of the new geometry
  21633. * @returns a new geometry object
  21634. */
  21635. copy(id: string): Geometry;
  21636. /**
  21637. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21638. * @return a JSON representation of the current geometry data (without the vertices data)
  21639. */
  21640. serialize(): any;
  21641. private toNumberArray;
  21642. /**
  21643. * Serialize all vertices data into a JSON oject
  21644. * @returns a JSON representation of the current geometry data
  21645. */
  21646. serializeVerticeData(): any;
  21647. /**
  21648. * Extracts a clone of a mesh geometry
  21649. * @param mesh defines the source mesh
  21650. * @param id defines the unique ID of the new geometry object
  21651. * @returns the new geometry object
  21652. */
  21653. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21654. /**
  21655. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21656. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21657. * Be aware Math.random() could cause collisions, but:
  21658. * "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"
  21659. * @returns a string containing a new GUID
  21660. */
  21661. static RandomId(): string;
  21662. /** @hidden */
  21663. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21664. private static _CleanMatricesWeights;
  21665. /**
  21666. * Create a new geometry from persisted data (Using .babylon file format)
  21667. * @param parsedVertexData defines the persisted data
  21668. * @param scene defines the hosting scene
  21669. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21670. * @returns the new geometry object
  21671. */
  21672. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21673. }
  21674. }
  21675. declare module "babylonjs/Meshes/mesh.vertexData" {
  21676. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21677. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21678. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21679. import { Geometry } from "babylonjs/Meshes/geometry";
  21680. import { Mesh } from "babylonjs/Meshes/mesh";
  21681. /**
  21682. * Define an interface for all classes that will get and set the data on vertices
  21683. */
  21684. export interface IGetSetVerticesData {
  21685. /**
  21686. * Gets a boolean indicating if specific vertex data is present
  21687. * @param kind defines the vertex data kind to use
  21688. * @returns true is data kind is present
  21689. */
  21690. isVerticesDataPresent(kind: string): boolean;
  21691. /**
  21692. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21693. * @param kind defines the data kind (Position, normal, etc...)
  21694. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21695. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21696. * @returns a float array containing vertex data
  21697. */
  21698. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21699. /**
  21700. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21701. * @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.
  21702. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21703. * @returns the indices array or an empty array if the mesh has no geometry
  21704. */
  21705. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21706. /**
  21707. * Set specific vertex data
  21708. * @param kind defines the data kind (Position, normal, etc...)
  21709. * @param data defines the vertex data to use
  21710. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21711. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21712. */
  21713. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21714. /**
  21715. * Update a specific associated vertex buffer
  21716. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21717. * - VertexBuffer.PositionKind
  21718. * - VertexBuffer.UVKind
  21719. * - VertexBuffer.UV2Kind
  21720. * - VertexBuffer.UV3Kind
  21721. * - VertexBuffer.UV4Kind
  21722. * - VertexBuffer.UV5Kind
  21723. * - VertexBuffer.UV6Kind
  21724. * - VertexBuffer.ColorKind
  21725. * - VertexBuffer.MatricesIndicesKind
  21726. * - VertexBuffer.MatricesIndicesExtraKind
  21727. * - VertexBuffer.MatricesWeightsKind
  21728. * - VertexBuffer.MatricesWeightsExtraKind
  21729. * @param data defines the data source
  21730. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21731. * @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)
  21732. */
  21733. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21734. /**
  21735. * Creates a new index buffer
  21736. * @param indices defines the indices to store in the index buffer
  21737. * @param totalVertices defines the total number of vertices (could be null)
  21738. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21739. */
  21740. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21741. }
  21742. /**
  21743. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21744. */
  21745. export class VertexData {
  21746. /**
  21747. * Mesh side orientation : usually the external or front surface
  21748. */
  21749. static readonly FRONTSIDE: number;
  21750. /**
  21751. * Mesh side orientation : usually the internal or back surface
  21752. */
  21753. static readonly BACKSIDE: number;
  21754. /**
  21755. * Mesh side orientation : both internal and external or front and back surfaces
  21756. */
  21757. static readonly DOUBLESIDE: number;
  21758. /**
  21759. * Mesh side orientation : by default, `FRONTSIDE`
  21760. */
  21761. static readonly DEFAULTSIDE: number;
  21762. /**
  21763. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21764. */
  21765. positions: Nullable<FloatArray>;
  21766. /**
  21767. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21768. */
  21769. normals: Nullable<FloatArray>;
  21770. /**
  21771. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21772. */
  21773. tangents: Nullable<FloatArray>;
  21774. /**
  21775. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21776. */
  21777. uvs: Nullable<FloatArray>;
  21778. /**
  21779. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21780. */
  21781. uvs2: Nullable<FloatArray>;
  21782. /**
  21783. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21784. */
  21785. uvs3: Nullable<FloatArray>;
  21786. /**
  21787. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21788. */
  21789. uvs4: Nullable<FloatArray>;
  21790. /**
  21791. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21792. */
  21793. uvs5: Nullable<FloatArray>;
  21794. /**
  21795. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21796. */
  21797. uvs6: Nullable<FloatArray>;
  21798. /**
  21799. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21800. */
  21801. colors: Nullable<FloatArray>;
  21802. /**
  21803. * 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).
  21804. */
  21805. matricesIndices: Nullable<FloatArray>;
  21806. /**
  21807. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21808. */
  21809. matricesWeights: Nullable<FloatArray>;
  21810. /**
  21811. * An array extending the number of possible indices
  21812. */
  21813. matricesIndicesExtra: Nullable<FloatArray>;
  21814. /**
  21815. * An array extending the number of possible weights when the number of indices is extended
  21816. */
  21817. matricesWeightsExtra: Nullable<FloatArray>;
  21818. /**
  21819. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21820. */
  21821. indices: Nullable<IndicesArray>;
  21822. /**
  21823. * Uses the passed data array to set the set the values for the specified kind of data
  21824. * @param data a linear array of floating numbers
  21825. * @param kind the type of data that is being set, eg positions, colors etc
  21826. */
  21827. set(data: FloatArray, kind: string): void;
  21828. /**
  21829. * Associates the vertexData to the passed Mesh.
  21830. * Sets it as updatable or not (default `false`)
  21831. * @param mesh the mesh the vertexData is applied to
  21832. * @param updatable when used and having the value true allows new data to update the vertexData
  21833. * @returns the VertexData
  21834. */
  21835. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21836. /**
  21837. * Associates the vertexData to the passed Geometry.
  21838. * Sets it as updatable or not (default `false`)
  21839. * @param geometry the geometry the vertexData is applied to
  21840. * @param updatable when used and having the value true allows new data to update the vertexData
  21841. * @returns VertexData
  21842. */
  21843. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21844. /**
  21845. * Updates the associated mesh
  21846. * @param mesh the mesh to be updated
  21847. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21848. * @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
  21849. * @returns VertexData
  21850. */
  21851. updateMesh(mesh: Mesh): VertexData;
  21852. /**
  21853. * Updates the associated geometry
  21854. * @param geometry the geometry to be updated
  21855. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21856. * @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
  21857. * @returns VertexData.
  21858. */
  21859. updateGeometry(geometry: Geometry): VertexData;
  21860. private _applyTo;
  21861. private _update;
  21862. /**
  21863. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21864. * @param matrix the transforming matrix
  21865. * @returns the VertexData
  21866. */
  21867. transform(matrix: Matrix): VertexData;
  21868. /**
  21869. * Merges the passed VertexData into the current one
  21870. * @param other the VertexData to be merged into the current one
  21871. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21872. * @returns the modified VertexData
  21873. */
  21874. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21875. private _mergeElement;
  21876. private _validate;
  21877. /**
  21878. * Serializes the VertexData
  21879. * @returns a serialized object
  21880. */
  21881. serialize(): any;
  21882. /**
  21883. * Extracts the vertexData from a mesh
  21884. * @param mesh the mesh from which to extract the VertexData
  21885. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21886. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21887. * @returns the object VertexData associated to the passed mesh
  21888. */
  21889. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21890. /**
  21891. * Extracts the vertexData from the geometry
  21892. * @param geometry the geometry from which to extract the VertexData
  21893. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21894. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21895. * @returns the object VertexData associated to the passed mesh
  21896. */
  21897. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21898. private static _ExtractFrom;
  21899. /**
  21900. * Creates the VertexData for a Ribbon
  21901. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21902. * * pathArray array of paths, each of which an array of successive Vector3
  21903. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21904. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21905. * * 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
  21906. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21907. * * 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)
  21908. * * 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)
  21909. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21910. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21911. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21912. * @returns the VertexData of the ribbon
  21913. */
  21914. static CreateRibbon(options: {
  21915. pathArray: Vector3[][];
  21916. closeArray?: boolean;
  21917. closePath?: boolean;
  21918. offset?: number;
  21919. sideOrientation?: number;
  21920. frontUVs?: Vector4;
  21921. backUVs?: Vector4;
  21922. invertUV?: boolean;
  21923. uvs?: Vector2[];
  21924. colors?: Color4[];
  21925. }): VertexData;
  21926. /**
  21927. * Creates the VertexData for a box
  21928. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21929. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21930. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21931. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21932. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21933. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21934. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21935. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21936. * * 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)
  21937. * * 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)
  21938. * @returns the VertexData of the box
  21939. */
  21940. static CreateBox(options: {
  21941. size?: number;
  21942. width?: number;
  21943. height?: number;
  21944. depth?: number;
  21945. faceUV?: Vector4[];
  21946. faceColors?: Color4[];
  21947. sideOrientation?: number;
  21948. frontUVs?: Vector4;
  21949. backUVs?: Vector4;
  21950. }): VertexData;
  21951. /**
  21952. * Creates the VertexData for a tiled box
  21953. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21954. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21955. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21956. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21957. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21958. * @returns the VertexData of the box
  21959. */
  21960. static CreateTiledBox(options: {
  21961. pattern?: number;
  21962. width?: number;
  21963. height?: number;
  21964. depth?: number;
  21965. tileSize?: number;
  21966. tileWidth?: number;
  21967. tileHeight?: number;
  21968. alignHorizontal?: number;
  21969. alignVertical?: number;
  21970. faceUV?: Vector4[];
  21971. faceColors?: Color4[];
  21972. sideOrientation?: number;
  21973. }): VertexData;
  21974. /**
  21975. * Creates the VertexData for a tiled plane
  21976. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21977. * * pattern a limited pattern arrangement depending on the number
  21978. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21979. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21980. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21981. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21982. * * 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)
  21983. * * 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)
  21984. * @returns the VertexData of the tiled plane
  21985. */
  21986. static CreateTiledPlane(options: {
  21987. pattern?: number;
  21988. tileSize?: number;
  21989. tileWidth?: number;
  21990. tileHeight?: number;
  21991. size?: number;
  21992. width?: number;
  21993. height?: number;
  21994. alignHorizontal?: number;
  21995. alignVertical?: number;
  21996. sideOrientation?: number;
  21997. frontUVs?: Vector4;
  21998. backUVs?: Vector4;
  21999. }): VertexData;
  22000. /**
  22001. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22002. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22003. * * segments sets the number of horizontal strips optional, default 32
  22004. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22005. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22006. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22007. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22008. * * 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
  22009. * * 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
  22010. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22011. * * 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)
  22012. * * 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)
  22013. * @returns the VertexData of the ellipsoid
  22014. */
  22015. static CreateSphere(options: {
  22016. segments?: number;
  22017. diameter?: number;
  22018. diameterX?: number;
  22019. diameterY?: number;
  22020. diameterZ?: number;
  22021. arc?: number;
  22022. slice?: number;
  22023. sideOrientation?: number;
  22024. frontUVs?: Vector4;
  22025. backUVs?: Vector4;
  22026. }): VertexData;
  22027. /**
  22028. * Creates the VertexData for a cylinder, cone or prism
  22029. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22030. * * height sets the height (y direction) of the cylinder, optional, default 2
  22031. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22032. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22033. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22034. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22035. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22036. * * 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
  22037. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22038. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22039. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22040. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22041. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22042. * * 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)
  22043. * * 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)
  22044. * @returns the VertexData of the cylinder, cone or prism
  22045. */
  22046. static CreateCylinder(options: {
  22047. height?: number;
  22048. diameterTop?: number;
  22049. diameterBottom?: number;
  22050. diameter?: number;
  22051. tessellation?: number;
  22052. subdivisions?: number;
  22053. arc?: number;
  22054. faceColors?: Color4[];
  22055. faceUV?: Vector4[];
  22056. hasRings?: boolean;
  22057. enclose?: boolean;
  22058. sideOrientation?: number;
  22059. frontUVs?: Vector4;
  22060. backUVs?: Vector4;
  22061. }): VertexData;
  22062. /**
  22063. * Creates the VertexData for a torus
  22064. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22065. * * diameter the diameter of the torus, optional default 1
  22066. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22067. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22068. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22069. * * 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)
  22070. * * 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)
  22071. * @returns the VertexData of the torus
  22072. */
  22073. static CreateTorus(options: {
  22074. diameter?: number;
  22075. thickness?: number;
  22076. tessellation?: number;
  22077. sideOrientation?: number;
  22078. frontUVs?: Vector4;
  22079. backUVs?: Vector4;
  22080. }): VertexData;
  22081. /**
  22082. * Creates the VertexData of the LineSystem
  22083. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22084. * - lines an array of lines, each line being an array of successive Vector3
  22085. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22086. * @returns the VertexData of the LineSystem
  22087. */
  22088. static CreateLineSystem(options: {
  22089. lines: Vector3[][];
  22090. colors?: Nullable<Color4[][]>;
  22091. }): VertexData;
  22092. /**
  22093. * Create the VertexData for a DashedLines
  22094. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22095. * - points an array successive Vector3
  22096. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22097. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22098. * - dashNb the intended total number of dashes, optional, default 200
  22099. * @returns the VertexData for the DashedLines
  22100. */
  22101. static CreateDashedLines(options: {
  22102. points: Vector3[];
  22103. dashSize?: number;
  22104. gapSize?: number;
  22105. dashNb?: number;
  22106. }): VertexData;
  22107. /**
  22108. * Creates the VertexData for a Ground
  22109. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22110. * - width the width (x direction) of the ground, optional, default 1
  22111. * - height the height (z direction) of the ground, optional, default 1
  22112. * - subdivisions the number of subdivisions per side, optional, default 1
  22113. * @returns the VertexData of the Ground
  22114. */
  22115. static CreateGround(options: {
  22116. width?: number;
  22117. height?: number;
  22118. subdivisions?: number;
  22119. subdivisionsX?: number;
  22120. subdivisionsY?: number;
  22121. }): VertexData;
  22122. /**
  22123. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22124. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22125. * * xmin the ground minimum X coordinate, optional, default -1
  22126. * * zmin the ground minimum Z coordinate, optional, default -1
  22127. * * xmax the ground maximum X coordinate, optional, default 1
  22128. * * zmax the ground maximum Z coordinate, optional, default 1
  22129. * * 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}
  22130. * * 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}
  22131. * @returns the VertexData of the TiledGround
  22132. */
  22133. static CreateTiledGround(options: {
  22134. xmin: number;
  22135. zmin: number;
  22136. xmax: number;
  22137. zmax: number;
  22138. subdivisions?: {
  22139. w: number;
  22140. h: number;
  22141. };
  22142. precision?: {
  22143. w: number;
  22144. h: number;
  22145. };
  22146. }): VertexData;
  22147. /**
  22148. * Creates the VertexData of the Ground designed from a heightmap
  22149. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22150. * * width the width (x direction) of the ground
  22151. * * height the height (z direction) of the ground
  22152. * * subdivisions the number of subdivisions per side
  22153. * * minHeight the minimum altitude on the ground, optional, default 0
  22154. * * maxHeight the maximum altitude on the ground, optional default 1
  22155. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22156. * * buffer the array holding the image color data
  22157. * * bufferWidth the width of image
  22158. * * bufferHeight the height of image
  22159. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22160. * @returns the VertexData of the Ground designed from a heightmap
  22161. */
  22162. static CreateGroundFromHeightMap(options: {
  22163. width: number;
  22164. height: number;
  22165. subdivisions: number;
  22166. minHeight: number;
  22167. maxHeight: number;
  22168. colorFilter: Color3;
  22169. buffer: Uint8Array;
  22170. bufferWidth: number;
  22171. bufferHeight: number;
  22172. alphaFilter: number;
  22173. }): VertexData;
  22174. /**
  22175. * Creates the VertexData for a Plane
  22176. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22177. * * size sets the width and height of the plane to the value of size, optional default 1
  22178. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22179. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22180. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22181. * * 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)
  22182. * * 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)
  22183. * @returns the VertexData of the box
  22184. */
  22185. static CreatePlane(options: {
  22186. size?: number;
  22187. width?: number;
  22188. height?: number;
  22189. sideOrientation?: number;
  22190. frontUVs?: Vector4;
  22191. backUVs?: Vector4;
  22192. }): VertexData;
  22193. /**
  22194. * Creates the VertexData of the Disc or regular Polygon
  22195. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22196. * * radius the radius of the disc, optional default 0.5
  22197. * * tessellation the number of polygon sides, optional, default 64
  22198. * * 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
  22199. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22200. * * 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)
  22201. * * 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)
  22202. * @returns the VertexData of the box
  22203. */
  22204. static CreateDisc(options: {
  22205. radius?: number;
  22206. tessellation?: number;
  22207. arc?: number;
  22208. sideOrientation?: number;
  22209. frontUVs?: Vector4;
  22210. backUVs?: Vector4;
  22211. }): VertexData;
  22212. /**
  22213. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22214. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22215. * @param polygon a mesh built from polygonTriangulation.build()
  22216. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22217. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22218. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22219. * @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)
  22220. * @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)
  22221. * @returns the VertexData of the Polygon
  22222. */
  22223. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22224. /**
  22225. * Creates the VertexData of the IcoSphere
  22226. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22227. * * radius the radius of the IcoSphere, optional default 1
  22228. * * radiusX allows stretching in the x direction, optional, default radius
  22229. * * radiusY allows stretching in the y direction, optional, default radius
  22230. * * radiusZ allows stretching in the z direction, optional, default radius
  22231. * * flat when true creates a flat shaded mesh, optional, default true
  22232. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22233. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22234. * * 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)
  22235. * * 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)
  22236. * @returns the VertexData of the IcoSphere
  22237. */
  22238. static CreateIcoSphere(options: {
  22239. radius?: number;
  22240. radiusX?: number;
  22241. radiusY?: number;
  22242. radiusZ?: number;
  22243. flat?: boolean;
  22244. subdivisions?: number;
  22245. sideOrientation?: number;
  22246. frontUVs?: Vector4;
  22247. backUVs?: Vector4;
  22248. }): VertexData;
  22249. /**
  22250. * Creates the VertexData for a Polyhedron
  22251. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22252. * * type provided types are:
  22253. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22254. * * 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)
  22255. * * size the size of the IcoSphere, optional default 1
  22256. * * sizeX allows stretching in the x direction, optional, default size
  22257. * * sizeY allows stretching in the y direction, optional, default size
  22258. * * sizeZ allows stretching in the z direction, optional, default size
  22259. * * 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
  22260. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22261. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22262. * * flat when true creates a flat shaded mesh, optional, default true
  22263. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22264. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22265. * * 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)
  22266. * * 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)
  22267. * @returns the VertexData of the Polyhedron
  22268. */
  22269. static CreatePolyhedron(options: {
  22270. type?: number;
  22271. size?: number;
  22272. sizeX?: number;
  22273. sizeY?: number;
  22274. sizeZ?: number;
  22275. custom?: any;
  22276. faceUV?: Vector4[];
  22277. faceColors?: Color4[];
  22278. flat?: boolean;
  22279. sideOrientation?: number;
  22280. frontUVs?: Vector4;
  22281. backUVs?: Vector4;
  22282. }): VertexData;
  22283. /**
  22284. * Creates the VertexData for a TorusKnot
  22285. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22286. * * radius the radius of the torus knot, optional, default 2
  22287. * * tube the thickness of the tube, optional, default 0.5
  22288. * * radialSegments the number of sides on each tube segments, optional, default 32
  22289. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22290. * * p the number of windings around the z axis, optional, default 2
  22291. * * q the number of windings around the x axis, optional, default 3
  22292. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22293. * * 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)
  22294. * * 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)
  22295. * @returns the VertexData of the Torus Knot
  22296. */
  22297. static CreateTorusKnot(options: {
  22298. radius?: number;
  22299. tube?: number;
  22300. radialSegments?: number;
  22301. tubularSegments?: number;
  22302. p?: number;
  22303. q?: number;
  22304. sideOrientation?: number;
  22305. frontUVs?: Vector4;
  22306. backUVs?: Vector4;
  22307. }): VertexData;
  22308. /**
  22309. * Compute normals for given positions and indices
  22310. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22311. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22312. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22313. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22314. * * facetNormals : optional array of facet normals (vector3)
  22315. * * facetPositions : optional array of facet positions (vector3)
  22316. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22317. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22318. * * bInfo : optional bounding info, required for facetPartitioning computation
  22319. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22320. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22321. * * useRightHandedSystem: optional boolean to for right handed system computation
  22322. * * depthSort : optional boolean to enable the facet depth sort computation
  22323. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22324. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22325. */
  22326. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22327. facetNormals?: any;
  22328. facetPositions?: any;
  22329. facetPartitioning?: any;
  22330. ratio?: number;
  22331. bInfo?: any;
  22332. bbSize?: Vector3;
  22333. subDiv?: any;
  22334. useRightHandedSystem?: boolean;
  22335. depthSort?: boolean;
  22336. distanceTo?: Vector3;
  22337. depthSortedFacets?: any;
  22338. }): void;
  22339. /** @hidden */
  22340. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22341. /**
  22342. * Applies VertexData created from the imported parameters to the geometry
  22343. * @param parsedVertexData the parsed data from an imported file
  22344. * @param geometry the geometry to apply the VertexData to
  22345. */
  22346. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22347. }
  22348. }
  22349. declare module "babylonjs/Morph/morphTarget" {
  22350. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22351. import { Observable } from "babylonjs/Misc/observable";
  22352. import { Nullable, FloatArray } from "babylonjs/types";
  22353. import { Scene } from "babylonjs/scene";
  22354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22355. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22356. /**
  22357. * Defines a target to use with MorphTargetManager
  22358. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22359. */
  22360. export class MorphTarget implements IAnimatable {
  22361. /** defines the name of the target */
  22362. name: string;
  22363. /**
  22364. * Gets or sets the list of animations
  22365. */
  22366. animations: import("babylonjs/Animations/animation").Animation[];
  22367. private _scene;
  22368. private _positions;
  22369. private _normals;
  22370. private _tangents;
  22371. private _uvs;
  22372. private _influence;
  22373. /**
  22374. * Observable raised when the influence changes
  22375. */
  22376. onInfluenceChanged: Observable<boolean>;
  22377. /** @hidden */
  22378. _onDataLayoutChanged: Observable<void>;
  22379. /**
  22380. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22381. */
  22382. influence: number;
  22383. /**
  22384. * Gets or sets the id of the morph Target
  22385. */
  22386. id: string;
  22387. private _animationPropertiesOverride;
  22388. /**
  22389. * Gets or sets the animation properties override
  22390. */
  22391. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22392. /**
  22393. * Creates a new MorphTarget
  22394. * @param name defines the name of the target
  22395. * @param influence defines the influence to use
  22396. * @param scene defines the scene the morphtarget belongs to
  22397. */
  22398. constructor(
  22399. /** defines the name of the target */
  22400. name: string, influence?: number, scene?: Nullable<Scene>);
  22401. /**
  22402. * Gets a boolean defining if the target contains position data
  22403. */
  22404. readonly hasPositions: boolean;
  22405. /**
  22406. * Gets a boolean defining if the target contains normal data
  22407. */
  22408. readonly hasNormals: boolean;
  22409. /**
  22410. * Gets a boolean defining if the target contains tangent data
  22411. */
  22412. readonly hasTangents: boolean;
  22413. /**
  22414. * Gets a boolean defining if the target contains texture coordinates data
  22415. */
  22416. readonly hasUVs: boolean;
  22417. /**
  22418. * Affects position data to this target
  22419. * @param data defines the position data to use
  22420. */
  22421. setPositions(data: Nullable<FloatArray>): void;
  22422. /**
  22423. * Gets the position data stored in this target
  22424. * @returns a FloatArray containing the position data (or null if not present)
  22425. */
  22426. getPositions(): Nullable<FloatArray>;
  22427. /**
  22428. * Affects normal data to this target
  22429. * @param data defines the normal data to use
  22430. */
  22431. setNormals(data: Nullable<FloatArray>): void;
  22432. /**
  22433. * Gets the normal data stored in this target
  22434. * @returns a FloatArray containing the normal data (or null if not present)
  22435. */
  22436. getNormals(): Nullable<FloatArray>;
  22437. /**
  22438. * Affects tangent data to this target
  22439. * @param data defines the tangent data to use
  22440. */
  22441. setTangents(data: Nullable<FloatArray>): void;
  22442. /**
  22443. * Gets the tangent data stored in this target
  22444. * @returns a FloatArray containing the tangent data (or null if not present)
  22445. */
  22446. getTangents(): Nullable<FloatArray>;
  22447. /**
  22448. * Affects texture coordinates data to this target
  22449. * @param data defines the texture coordinates data to use
  22450. */
  22451. setUVs(data: Nullable<FloatArray>): void;
  22452. /**
  22453. * Gets the texture coordinates data stored in this target
  22454. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22455. */
  22456. getUVs(): Nullable<FloatArray>;
  22457. /**
  22458. * Serializes the current target into a Serialization object
  22459. * @returns the serialized object
  22460. */
  22461. serialize(): any;
  22462. /**
  22463. * Returns the string "MorphTarget"
  22464. * @returns "MorphTarget"
  22465. */
  22466. getClassName(): string;
  22467. /**
  22468. * Creates a new target from serialized data
  22469. * @param serializationObject defines the serialized data to use
  22470. * @returns a new MorphTarget
  22471. */
  22472. static Parse(serializationObject: any): MorphTarget;
  22473. /**
  22474. * Creates a MorphTarget from mesh data
  22475. * @param mesh defines the source mesh
  22476. * @param name defines the name to use for the new target
  22477. * @param influence defines the influence to attach to the target
  22478. * @returns a new MorphTarget
  22479. */
  22480. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22481. }
  22482. }
  22483. declare module "babylonjs/Morph/morphTargetManager" {
  22484. import { Nullable } from "babylonjs/types";
  22485. import { Scene } from "babylonjs/scene";
  22486. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22487. /**
  22488. * This class is used to deform meshes using morphing between different targets
  22489. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22490. */
  22491. export class MorphTargetManager {
  22492. private _targets;
  22493. private _targetInfluenceChangedObservers;
  22494. private _targetDataLayoutChangedObservers;
  22495. private _activeTargets;
  22496. private _scene;
  22497. private _influences;
  22498. private _supportsNormals;
  22499. private _supportsTangents;
  22500. private _supportsUVs;
  22501. private _vertexCount;
  22502. private _uniqueId;
  22503. private _tempInfluences;
  22504. /**
  22505. * Gets or sets a boolean indicating if normals must be morphed
  22506. */
  22507. enableNormalMorphing: boolean;
  22508. /**
  22509. * Gets or sets a boolean indicating if tangents must be morphed
  22510. */
  22511. enableTangentMorphing: boolean;
  22512. /**
  22513. * Gets or sets a boolean indicating if UV must be morphed
  22514. */
  22515. enableUVMorphing: boolean;
  22516. /**
  22517. * Creates a new MorphTargetManager
  22518. * @param scene defines the current scene
  22519. */
  22520. constructor(scene?: Nullable<Scene>);
  22521. /**
  22522. * Gets the unique ID of this manager
  22523. */
  22524. readonly uniqueId: number;
  22525. /**
  22526. * Gets the number of vertices handled by this manager
  22527. */
  22528. readonly vertexCount: number;
  22529. /**
  22530. * Gets a boolean indicating if this manager supports morphing of normals
  22531. */
  22532. readonly supportsNormals: boolean;
  22533. /**
  22534. * Gets a boolean indicating if this manager supports morphing of tangents
  22535. */
  22536. readonly supportsTangents: boolean;
  22537. /**
  22538. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22539. */
  22540. readonly supportsUVs: boolean;
  22541. /**
  22542. * Gets the number of targets stored in this manager
  22543. */
  22544. readonly numTargets: number;
  22545. /**
  22546. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22547. */
  22548. readonly numInfluencers: number;
  22549. /**
  22550. * Gets the list of influences (one per target)
  22551. */
  22552. readonly influences: Float32Array;
  22553. /**
  22554. * Gets the active target at specified index. An active target is a target with an influence > 0
  22555. * @param index defines the index to check
  22556. * @returns the requested target
  22557. */
  22558. getActiveTarget(index: number): MorphTarget;
  22559. /**
  22560. * Gets the target at specified index
  22561. * @param index defines the index to check
  22562. * @returns the requested target
  22563. */
  22564. getTarget(index: number): MorphTarget;
  22565. /**
  22566. * Add a new target to this manager
  22567. * @param target defines the target to add
  22568. */
  22569. addTarget(target: MorphTarget): void;
  22570. /**
  22571. * Removes a target from the manager
  22572. * @param target defines the target to remove
  22573. */
  22574. removeTarget(target: MorphTarget): void;
  22575. /**
  22576. * Serializes the current manager into a Serialization object
  22577. * @returns the serialized object
  22578. */
  22579. serialize(): any;
  22580. private _syncActiveTargets;
  22581. /**
  22582. * Syncrhonize the targets with all the meshes using this morph target manager
  22583. */
  22584. synchronize(): void;
  22585. /**
  22586. * Creates a new MorphTargetManager from serialized data
  22587. * @param serializationObject defines the serialized data
  22588. * @param scene defines the hosting scene
  22589. * @returns the new MorphTargetManager
  22590. */
  22591. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22592. }
  22593. }
  22594. declare module "babylonjs/Meshes/meshLODLevel" {
  22595. import { Mesh } from "babylonjs/Meshes/mesh";
  22596. import { Nullable } from "babylonjs/types";
  22597. /**
  22598. * Class used to represent a specific level of detail of a mesh
  22599. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22600. */
  22601. export class MeshLODLevel {
  22602. /** Defines the distance where this level should start being displayed */
  22603. distance: number;
  22604. /** Defines the mesh to use to render this level */
  22605. mesh: Nullable<Mesh>;
  22606. /**
  22607. * Creates a new LOD level
  22608. * @param distance defines the distance where this level should star being displayed
  22609. * @param mesh defines the mesh to use to render this level
  22610. */
  22611. constructor(
  22612. /** Defines the distance where this level should start being displayed */
  22613. distance: number,
  22614. /** Defines the mesh to use to render this level */
  22615. mesh: Nullable<Mesh>);
  22616. }
  22617. }
  22618. declare module "babylonjs/Meshes/groundMesh" {
  22619. import { Scene } from "babylonjs/scene";
  22620. import { Vector3 } from "babylonjs/Maths/math.vector";
  22621. import { Mesh } from "babylonjs/Meshes/mesh";
  22622. /**
  22623. * Mesh representing the gorund
  22624. */
  22625. export class GroundMesh extends Mesh {
  22626. /** If octree should be generated */
  22627. generateOctree: boolean;
  22628. private _heightQuads;
  22629. /** @hidden */
  22630. _subdivisionsX: number;
  22631. /** @hidden */
  22632. _subdivisionsY: number;
  22633. /** @hidden */
  22634. _width: number;
  22635. /** @hidden */
  22636. _height: number;
  22637. /** @hidden */
  22638. _minX: number;
  22639. /** @hidden */
  22640. _maxX: number;
  22641. /** @hidden */
  22642. _minZ: number;
  22643. /** @hidden */
  22644. _maxZ: number;
  22645. constructor(name: string, scene: Scene);
  22646. /**
  22647. * "GroundMesh"
  22648. * @returns "GroundMesh"
  22649. */
  22650. getClassName(): string;
  22651. /**
  22652. * The minimum of x and y subdivisions
  22653. */
  22654. readonly subdivisions: number;
  22655. /**
  22656. * X subdivisions
  22657. */
  22658. readonly subdivisionsX: number;
  22659. /**
  22660. * Y subdivisions
  22661. */
  22662. readonly subdivisionsY: number;
  22663. /**
  22664. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22665. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22666. * @param chunksCount the number of subdivisions for x and y
  22667. * @param octreeBlocksSize (Default: 32)
  22668. */
  22669. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22670. /**
  22671. * Returns a height (y) value in the Worl system :
  22672. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22673. * @param x x coordinate
  22674. * @param z z coordinate
  22675. * @returns the ground y position if (x, z) are outside the ground surface.
  22676. */
  22677. getHeightAtCoordinates(x: number, z: number): number;
  22678. /**
  22679. * Returns a normalized vector (Vector3) orthogonal to the ground
  22680. * at the ground coordinates (x, z) expressed in the World system.
  22681. * @param x x coordinate
  22682. * @param z z coordinate
  22683. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22684. */
  22685. getNormalAtCoordinates(x: number, z: number): Vector3;
  22686. /**
  22687. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22688. * at the ground coordinates (x, z) expressed in the World system.
  22689. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22690. * @param x x coordinate
  22691. * @param z z coordinate
  22692. * @param ref vector to store the result
  22693. * @returns the GroundMesh.
  22694. */
  22695. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22696. /**
  22697. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22698. * if the ground has been updated.
  22699. * This can be used in the render loop.
  22700. * @returns the GroundMesh.
  22701. */
  22702. updateCoordinateHeights(): GroundMesh;
  22703. private _getFacetAt;
  22704. private _initHeightQuads;
  22705. private _computeHeightQuads;
  22706. /**
  22707. * Serializes this ground mesh
  22708. * @param serializationObject object to write serialization to
  22709. */
  22710. serialize(serializationObject: any): void;
  22711. /**
  22712. * Parses a serialized ground mesh
  22713. * @param parsedMesh the serialized mesh
  22714. * @param scene the scene to create the ground mesh in
  22715. * @returns the created ground mesh
  22716. */
  22717. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22718. }
  22719. }
  22720. declare module "babylonjs/Physics/physicsJoint" {
  22721. import { Vector3 } from "babylonjs/Maths/math.vector";
  22722. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22723. /**
  22724. * Interface for Physics-Joint data
  22725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22726. */
  22727. export interface PhysicsJointData {
  22728. /**
  22729. * The main pivot of the joint
  22730. */
  22731. mainPivot?: Vector3;
  22732. /**
  22733. * The connected pivot of the joint
  22734. */
  22735. connectedPivot?: Vector3;
  22736. /**
  22737. * The main axis of the joint
  22738. */
  22739. mainAxis?: Vector3;
  22740. /**
  22741. * The connected axis of the joint
  22742. */
  22743. connectedAxis?: Vector3;
  22744. /**
  22745. * The collision of the joint
  22746. */
  22747. collision?: boolean;
  22748. /**
  22749. * Native Oimo/Cannon/Energy data
  22750. */
  22751. nativeParams?: any;
  22752. }
  22753. /**
  22754. * This is a holder class for the physics joint created by the physics plugin
  22755. * It holds a set of functions to control the underlying joint
  22756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22757. */
  22758. export class PhysicsJoint {
  22759. /**
  22760. * The type of the physics joint
  22761. */
  22762. type: number;
  22763. /**
  22764. * The data for the physics joint
  22765. */
  22766. jointData: PhysicsJointData;
  22767. private _physicsJoint;
  22768. protected _physicsPlugin: IPhysicsEnginePlugin;
  22769. /**
  22770. * Initializes the physics joint
  22771. * @param type The type of the physics joint
  22772. * @param jointData The data for the physics joint
  22773. */
  22774. constructor(
  22775. /**
  22776. * The type of the physics joint
  22777. */
  22778. type: number,
  22779. /**
  22780. * The data for the physics joint
  22781. */
  22782. jointData: PhysicsJointData);
  22783. /**
  22784. * Gets the physics joint
  22785. */
  22786. /**
  22787. * Sets the physics joint
  22788. */
  22789. physicsJoint: any;
  22790. /**
  22791. * Sets the physics plugin
  22792. */
  22793. physicsPlugin: IPhysicsEnginePlugin;
  22794. /**
  22795. * Execute a function that is physics-plugin specific.
  22796. * @param {Function} func the function that will be executed.
  22797. * It accepts two parameters: the physics world and the physics joint
  22798. */
  22799. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22800. /**
  22801. * Distance-Joint type
  22802. */
  22803. static DistanceJoint: number;
  22804. /**
  22805. * Hinge-Joint type
  22806. */
  22807. static HingeJoint: number;
  22808. /**
  22809. * Ball-and-Socket joint type
  22810. */
  22811. static BallAndSocketJoint: number;
  22812. /**
  22813. * Wheel-Joint type
  22814. */
  22815. static WheelJoint: number;
  22816. /**
  22817. * Slider-Joint type
  22818. */
  22819. static SliderJoint: number;
  22820. /**
  22821. * Prismatic-Joint type
  22822. */
  22823. static PrismaticJoint: number;
  22824. /**
  22825. * Universal-Joint type
  22826. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22827. */
  22828. static UniversalJoint: number;
  22829. /**
  22830. * Hinge-Joint 2 type
  22831. */
  22832. static Hinge2Joint: number;
  22833. /**
  22834. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22835. */
  22836. static PointToPointJoint: number;
  22837. /**
  22838. * Spring-Joint type
  22839. */
  22840. static SpringJoint: number;
  22841. /**
  22842. * Lock-Joint type
  22843. */
  22844. static LockJoint: number;
  22845. }
  22846. /**
  22847. * A class representing a physics distance joint
  22848. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22849. */
  22850. export class DistanceJoint extends PhysicsJoint {
  22851. /**
  22852. *
  22853. * @param jointData The data for the Distance-Joint
  22854. */
  22855. constructor(jointData: DistanceJointData);
  22856. /**
  22857. * Update the predefined distance.
  22858. * @param maxDistance The maximum preferred distance
  22859. * @param minDistance The minimum preferred distance
  22860. */
  22861. updateDistance(maxDistance: number, minDistance?: number): void;
  22862. }
  22863. /**
  22864. * Represents a Motor-Enabled Joint
  22865. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22866. */
  22867. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22868. /**
  22869. * Initializes the Motor-Enabled Joint
  22870. * @param type The type of the joint
  22871. * @param jointData The physica joint data for the joint
  22872. */
  22873. constructor(type: number, jointData: PhysicsJointData);
  22874. /**
  22875. * Set the motor values.
  22876. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22877. * @param force the force to apply
  22878. * @param maxForce max force for this motor.
  22879. */
  22880. setMotor(force?: number, maxForce?: number): void;
  22881. /**
  22882. * Set the motor's limits.
  22883. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22884. * @param upperLimit The upper limit of the motor
  22885. * @param lowerLimit The lower limit of the motor
  22886. */
  22887. setLimit(upperLimit: number, lowerLimit?: number): void;
  22888. }
  22889. /**
  22890. * This class represents a single physics Hinge-Joint
  22891. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22892. */
  22893. export class HingeJoint extends MotorEnabledJoint {
  22894. /**
  22895. * Initializes the Hinge-Joint
  22896. * @param jointData The joint data for the Hinge-Joint
  22897. */
  22898. constructor(jointData: PhysicsJointData);
  22899. /**
  22900. * Set the motor values.
  22901. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22902. * @param {number} force the force to apply
  22903. * @param {number} maxForce max force for this motor.
  22904. */
  22905. setMotor(force?: number, maxForce?: number): void;
  22906. /**
  22907. * Set the motor's limits.
  22908. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22909. * @param upperLimit The upper limit of the motor
  22910. * @param lowerLimit The lower limit of the motor
  22911. */
  22912. setLimit(upperLimit: number, lowerLimit?: number): void;
  22913. }
  22914. /**
  22915. * This class represents a dual hinge physics joint (same as wheel joint)
  22916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22917. */
  22918. export class Hinge2Joint extends MotorEnabledJoint {
  22919. /**
  22920. * Initializes the Hinge2-Joint
  22921. * @param jointData The joint data for the Hinge2-Joint
  22922. */
  22923. constructor(jointData: PhysicsJointData);
  22924. /**
  22925. * Set the motor values.
  22926. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22927. * @param {number} targetSpeed the speed the motor is to reach
  22928. * @param {number} maxForce max force for this motor.
  22929. * @param {motorIndex} the motor's index, 0 or 1.
  22930. */
  22931. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22932. /**
  22933. * Set the motor limits.
  22934. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22935. * @param {number} upperLimit the upper limit
  22936. * @param {number} lowerLimit lower limit
  22937. * @param {motorIndex} the motor's index, 0 or 1.
  22938. */
  22939. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22940. }
  22941. /**
  22942. * Interface for a motor enabled joint
  22943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22944. */
  22945. export interface IMotorEnabledJoint {
  22946. /**
  22947. * Physics joint
  22948. */
  22949. physicsJoint: any;
  22950. /**
  22951. * Sets the motor of the motor-enabled joint
  22952. * @param force The force of the motor
  22953. * @param maxForce The maximum force of the motor
  22954. * @param motorIndex The index of the motor
  22955. */
  22956. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22957. /**
  22958. * Sets the limit of the motor
  22959. * @param upperLimit The upper limit of the motor
  22960. * @param lowerLimit The lower limit of the motor
  22961. * @param motorIndex The index of the motor
  22962. */
  22963. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22964. }
  22965. /**
  22966. * Joint data for a Distance-Joint
  22967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22968. */
  22969. export interface DistanceJointData extends PhysicsJointData {
  22970. /**
  22971. * Max distance the 2 joint objects can be apart
  22972. */
  22973. maxDistance: number;
  22974. }
  22975. /**
  22976. * Joint data from a spring joint
  22977. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22978. */
  22979. export interface SpringJointData extends PhysicsJointData {
  22980. /**
  22981. * Length of the spring
  22982. */
  22983. length: number;
  22984. /**
  22985. * Stiffness of the spring
  22986. */
  22987. stiffness: number;
  22988. /**
  22989. * Damping of the spring
  22990. */
  22991. damping: number;
  22992. /** this callback will be called when applying the force to the impostors. */
  22993. forceApplicationCallback: () => void;
  22994. }
  22995. }
  22996. declare module "babylonjs/Physics/physicsRaycastResult" {
  22997. import { Vector3 } from "babylonjs/Maths/math.vector";
  22998. /**
  22999. * Holds the data for the raycast result
  23000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23001. */
  23002. export class PhysicsRaycastResult {
  23003. private _hasHit;
  23004. private _hitDistance;
  23005. private _hitNormalWorld;
  23006. private _hitPointWorld;
  23007. private _rayFromWorld;
  23008. private _rayToWorld;
  23009. /**
  23010. * Gets if there was a hit
  23011. */
  23012. readonly hasHit: boolean;
  23013. /**
  23014. * Gets the distance from the hit
  23015. */
  23016. readonly hitDistance: number;
  23017. /**
  23018. * Gets the hit normal/direction in the world
  23019. */
  23020. readonly hitNormalWorld: Vector3;
  23021. /**
  23022. * Gets the hit point in the world
  23023. */
  23024. readonly hitPointWorld: Vector3;
  23025. /**
  23026. * Gets the ray "start point" of the ray in the world
  23027. */
  23028. readonly rayFromWorld: Vector3;
  23029. /**
  23030. * Gets the ray "end point" of the ray in the world
  23031. */
  23032. readonly rayToWorld: Vector3;
  23033. /**
  23034. * Sets the hit data (normal & point in world space)
  23035. * @param hitNormalWorld defines the normal in world space
  23036. * @param hitPointWorld defines the point in world space
  23037. */
  23038. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23039. /**
  23040. * Sets the distance from the start point to the hit point
  23041. * @param distance
  23042. */
  23043. setHitDistance(distance: number): void;
  23044. /**
  23045. * Calculates the distance manually
  23046. */
  23047. calculateHitDistance(): void;
  23048. /**
  23049. * Resets all the values to default
  23050. * @param from The from point on world space
  23051. * @param to The to point on world space
  23052. */
  23053. reset(from?: Vector3, to?: Vector3): void;
  23054. }
  23055. /**
  23056. * Interface for the size containing width and height
  23057. */
  23058. interface IXYZ {
  23059. /**
  23060. * X
  23061. */
  23062. x: number;
  23063. /**
  23064. * Y
  23065. */
  23066. y: number;
  23067. /**
  23068. * Z
  23069. */
  23070. z: number;
  23071. }
  23072. }
  23073. declare module "babylonjs/Physics/IPhysicsEngine" {
  23074. import { Nullable } from "babylonjs/types";
  23075. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23077. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23078. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23079. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23080. /**
  23081. * Interface used to describe a physics joint
  23082. */
  23083. export interface PhysicsImpostorJoint {
  23084. /** Defines the main impostor to which the joint is linked */
  23085. mainImpostor: PhysicsImpostor;
  23086. /** Defines the impostor that is connected to the main impostor using this joint */
  23087. connectedImpostor: PhysicsImpostor;
  23088. /** Defines the joint itself */
  23089. joint: PhysicsJoint;
  23090. }
  23091. /** @hidden */
  23092. export interface IPhysicsEnginePlugin {
  23093. world: any;
  23094. name: string;
  23095. setGravity(gravity: Vector3): void;
  23096. setTimeStep(timeStep: number): void;
  23097. getTimeStep(): number;
  23098. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23099. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23100. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23101. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23102. removePhysicsBody(impostor: PhysicsImpostor): void;
  23103. generateJoint(joint: PhysicsImpostorJoint): void;
  23104. removeJoint(joint: PhysicsImpostorJoint): void;
  23105. isSupported(): boolean;
  23106. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23107. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23108. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23109. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23110. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23111. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23112. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23113. getBodyMass(impostor: PhysicsImpostor): number;
  23114. getBodyFriction(impostor: PhysicsImpostor): number;
  23115. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23116. getBodyRestitution(impostor: PhysicsImpostor): number;
  23117. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23118. getBodyPressure?(impostor: PhysicsImpostor): number;
  23119. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23120. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23121. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23122. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23123. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23124. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23125. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23126. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23127. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23128. sleepBody(impostor: PhysicsImpostor): void;
  23129. wakeUpBody(impostor: PhysicsImpostor): void;
  23130. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23131. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23132. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23133. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23134. getRadius(impostor: PhysicsImpostor): number;
  23135. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23136. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23137. dispose(): void;
  23138. }
  23139. /**
  23140. * Interface used to define a physics engine
  23141. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23142. */
  23143. export interface IPhysicsEngine {
  23144. /**
  23145. * Gets the gravity vector used by the simulation
  23146. */
  23147. gravity: Vector3;
  23148. /**
  23149. * Sets the gravity vector used by the simulation
  23150. * @param gravity defines the gravity vector to use
  23151. */
  23152. setGravity(gravity: Vector3): void;
  23153. /**
  23154. * Set the time step of the physics engine.
  23155. * Default is 1/60.
  23156. * To slow it down, enter 1/600 for example.
  23157. * To speed it up, 1/30
  23158. * @param newTimeStep the new timestep to apply to this world.
  23159. */
  23160. setTimeStep(newTimeStep: number): void;
  23161. /**
  23162. * Get the time step of the physics engine.
  23163. * @returns the current time step
  23164. */
  23165. getTimeStep(): number;
  23166. /**
  23167. * Release all resources
  23168. */
  23169. dispose(): void;
  23170. /**
  23171. * Gets the name of the current physics plugin
  23172. * @returns the name of the plugin
  23173. */
  23174. getPhysicsPluginName(): string;
  23175. /**
  23176. * Adding a new impostor for the impostor tracking.
  23177. * This will be done by the impostor itself.
  23178. * @param impostor the impostor to add
  23179. */
  23180. addImpostor(impostor: PhysicsImpostor): void;
  23181. /**
  23182. * Remove an impostor from the engine.
  23183. * This impostor and its mesh will not longer be updated by the physics engine.
  23184. * @param impostor the impostor to remove
  23185. */
  23186. removeImpostor(impostor: PhysicsImpostor): void;
  23187. /**
  23188. * Add a joint to the physics engine
  23189. * @param mainImpostor defines the main impostor to which the joint is added.
  23190. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23191. * @param joint defines the joint that will connect both impostors.
  23192. */
  23193. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23194. /**
  23195. * Removes a joint from the simulation
  23196. * @param mainImpostor defines the impostor used with the joint
  23197. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23198. * @param joint defines the joint to remove
  23199. */
  23200. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23201. /**
  23202. * Gets the current plugin used to run the simulation
  23203. * @returns current plugin
  23204. */
  23205. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23206. /**
  23207. * Gets the list of physic impostors
  23208. * @returns an array of PhysicsImpostor
  23209. */
  23210. getImpostors(): Array<PhysicsImpostor>;
  23211. /**
  23212. * Gets the impostor for a physics enabled object
  23213. * @param object defines the object impersonated by the impostor
  23214. * @returns the PhysicsImpostor or null if not found
  23215. */
  23216. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23217. /**
  23218. * Gets the impostor for a physics body object
  23219. * @param body defines physics body used by the impostor
  23220. * @returns the PhysicsImpostor or null if not found
  23221. */
  23222. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23223. /**
  23224. * Does a raycast in the physics world
  23225. * @param from when should the ray start?
  23226. * @param to when should the ray end?
  23227. * @returns PhysicsRaycastResult
  23228. */
  23229. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23230. /**
  23231. * Called by the scene. No need to call it.
  23232. * @param delta defines the timespam between frames
  23233. */
  23234. _step(delta: number): void;
  23235. }
  23236. }
  23237. declare module "babylonjs/Physics/physicsImpostor" {
  23238. import { Nullable, IndicesArray } from "babylonjs/types";
  23239. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23240. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23242. import { Scene } from "babylonjs/scene";
  23243. import { Bone } from "babylonjs/Bones/bone";
  23244. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23245. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23246. import { Space } from "babylonjs/Maths/math.axis";
  23247. /**
  23248. * The interface for the physics imposter parameters
  23249. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23250. */
  23251. export interface PhysicsImpostorParameters {
  23252. /**
  23253. * The mass of the physics imposter
  23254. */
  23255. mass: number;
  23256. /**
  23257. * The friction of the physics imposter
  23258. */
  23259. friction?: number;
  23260. /**
  23261. * The coefficient of restitution of the physics imposter
  23262. */
  23263. restitution?: number;
  23264. /**
  23265. * The native options of the physics imposter
  23266. */
  23267. nativeOptions?: any;
  23268. /**
  23269. * Specifies if the parent should be ignored
  23270. */
  23271. ignoreParent?: boolean;
  23272. /**
  23273. * Specifies if bi-directional transformations should be disabled
  23274. */
  23275. disableBidirectionalTransformation?: boolean;
  23276. /**
  23277. * The pressure inside the physics imposter, soft object only
  23278. */
  23279. pressure?: number;
  23280. /**
  23281. * The stiffness the physics imposter, soft object only
  23282. */
  23283. stiffness?: number;
  23284. /**
  23285. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23286. */
  23287. velocityIterations?: number;
  23288. /**
  23289. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23290. */
  23291. positionIterations?: number;
  23292. /**
  23293. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23294. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23295. * Add to fix multiple points
  23296. */
  23297. fixedPoints?: number;
  23298. /**
  23299. * The collision margin around a soft object
  23300. */
  23301. margin?: number;
  23302. /**
  23303. * The collision margin around a soft object
  23304. */
  23305. damping?: number;
  23306. /**
  23307. * The path for a rope based on an extrusion
  23308. */
  23309. path?: any;
  23310. /**
  23311. * The shape of an extrusion used for a rope based on an extrusion
  23312. */
  23313. shape?: any;
  23314. }
  23315. /**
  23316. * Interface for a physics-enabled object
  23317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23318. */
  23319. export interface IPhysicsEnabledObject {
  23320. /**
  23321. * The position of the physics-enabled object
  23322. */
  23323. position: Vector3;
  23324. /**
  23325. * The rotation of the physics-enabled object
  23326. */
  23327. rotationQuaternion: Nullable<Quaternion>;
  23328. /**
  23329. * The scale of the physics-enabled object
  23330. */
  23331. scaling: Vector3;
  23332. /**
  23333. * The rotation of the physics-enabled object
  23334. */
  23335. rotation?: Vector3;
  23336. /**
  23337. * The parent of the physics-enabled object
  23338. */
  23339. parent?: any;
  23340. /**
  23341. * The bounding info of the physics-enabled object
  23342. * @returns The bounding info of the physics-enabled object
  23343. */
  23344. getBoundingInfo(): BoundingInfo;
  23345. /**
  23346. * Computes the world matrix
  23347. * @param force Specifies if the world matrix should be computed by force
  23348. * @returns A world matrix
  23349. */
  23350. computeWorldMatrix(force: boolean): Matrix;
  23351. /**
  23352. * Gets the world matrix
  23353. * @returns A world matrix
  23354. */
  23355. getWorldMatrix?(): Matrix;
  23356. /**
  23357. * Gets the child meshes
  23358. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23359. * @returns An array of abstract meshes
  23360. */
  23361. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23362. /**
  23363. * Gets the vertex data
  23364. * @param kind The type of vertex data
  23365. * @returns A nullable array of numbers, or a float32 array
  23366. */
  23367. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23368. /**
  23369. * Gets the indices from the mesh
  23370. * @returns A nullable array of index arrays
  23371. */
  23372. getIndices?(): Nullable<IndicesArray>;
  23373. /**
  23374. * Gets the scene from the mesh
  23375. * @returns the indices array or null
  23376. */
  23377. getScene?(): Scene;
  23378. /**
  23379. * Gets the absolute position from the mesh
  23380. * @returns the absolute position
  23381. */
  23382. getAbsolutePosition(): Vector3;
  23383. /**
  23384. * Gets the absolute pivot point from the mesh
  23385. * @returns the absolute pivot point
  23386. */
  23387. getAbsolutePivotPoint(): Vector3;
  23388. /**
  23389. * Rotates the mesh
  23390. * @param axis The axis of rotation
  23391. * @param amount The amount of rotation
  23392. * @param space The space of the rotation
  23393. * @returns The rotation transform node
  23394. */
  23395. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23396. /**
  23397. * Translates the mesh
  23398. * @param axis The axis of translation
  23399. * @param distance The distance of translation
  23400. * @param space The space of the translation
  23401. * @returns The transform node
  23402. */
  23403. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23404. /**
  23405. * Sets the absolute position of the mesh
  23406. * @param absolutePosition The absolute position of the mesh
  23407. * @returns The transform node
  23408. */
  23409. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23410. /**
  23411. * Gets the class name of the mesh
  23412. * @returns The class name
  23413. */
  23414. getClassName(): string;
  23415. }
  23416. /**
  23417. * Represents a physics imposter
  23418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23419. */
  23420. export class PhysicsImpostor {
  23421. /**
  23422. * The physics-enabled object used as the physics imposter
  23423. */
  23424. object: IPhysicsEnabledObject;
  23425. /**
  23426. * The type of the physics imposter
  23427. */
  23428. type: number;
  23429. private _options;
  23430. private _scene?;
  23431. /**
  23432. * The default object size of the imposter
  23433. */
  23434. static DEFAULT_OBJECT_SIZE: Vector3;
  23435. /**
  23436. * The identity quaternion of the imposter
  23437. */
  23438. static IDENTITY_QUATERNION: Quaternion;
  23439. /** @hidden */
  23440. _pluginData: any;
  23441. private _physicsEngine;
  23442. private _physicsBody;
  23443. private _bodyUpdateRequired;
  23444. private _onBeforePhysicsStepCallbacks;
  23445. private _onAfterPhysicsStepCallbacks;
  23446. /** @hidden */
  23447. _onPhysicsCollideCallbacks: Array<{
  23448. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23449. otherImpostors: Array<PhysicsImpostor>;
  23450. }>;
  23451. private _deltaPosition;
  23452. private _deltaRotation;
  23453. private _deltaRotationConjugated;
  23454. /** @hidden */
  23455. _isFromLine: boolean;
  23456. private _parent;
  23457. private _isDisposed;
  23458. private static _tmpVecs;
  23459. private static _tmpQuat;
  23460. /**
  23461. * Specifies if the physics imposter is disposed
  23462. */
  23463. readonly isDisposed: boolean;
  23464. /**
  23465. * Gets the mass of the physics imposter
  23466. */
  23467. mass: number;
  23468. /**
  23469. * Gets the coefficient of friction
  23470. */
  23471. /**
  23472. * Sets the coefficient of friction
  23473. */
  23474. friction: number;
  23475. /**
  23476. * Gets the coefficient of restitution
  23477. */
  23478. /**
  23479. * Sets the coefficient of restitution
  23480. */
  23481. restitution: number;
  23482. /**
  23483. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23484. */
  23485. /**
  23486. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23487. */
  23488. pressure: number;
  23489. /**
  23490. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23491. */
  23492. /**
  23493. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23494. */
  23495. stiffness: number;
  23496. /**
  23497. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23498. */
  23499. /**
  23500. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23501. */
  23502. velocityIterations: number;
  23503. /**
  23504. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23505. */
  23506. /**
  23507. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23508. */
  23509. positionIterations: number;
  23510. /**
  23511. * The unique id of the physics imposter
  23512. * set by the physics engine when adding this impostor to the array
  23513. */
  23514. uniqueId: number;
  23515. /**
  23516. * @hidden
  23517. */
  23518. soft: boolean;
  23519. /**
  23520. * @hidden
  23521. */
  23522. segments: number;
  23523. private _joints;
  23524. /**
  23525. * Initializes the physics imposter
  23526. * @param object The physics-enabled object used as the physics imposter
  23527. * @param type The type of the physics imposter
  23528. * @param _options The options for the physics imposter
  23529. * @param _scene The Babylon scene
  23530. */
  23531. constructor(
  23532. /**
  23533. * The physics-enabled object used as the physics imposter
  23534. */
  23535. object: IPhysicsEnabledObject,
  23536. /**
  23537. * The type of the physics imposter
  23538. */
  23539. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23540. /**
  23541. * This function will completly initialize this impostor.
  23542. * It will create a new body - but only if this mesh has no parent.
  23543. * If it has, this impostor will not be used other than to define the impostor
  23544. * of the child mesh.
  23545. * @hidden
  23546. */
  23547. _init(): void;
  23548. private _getPhysicsParent;
  23549. /**
  23550. * Should a new body be generated.
  23551. * @returns boolean specifying if body initialization is required
  23552. */
  23553. isBodyInitRequired(): boolean;
  23554. /**
  23555. * Sets the updated scaling
  23556. * @param updated Specifies if the scaling is updated
  23557. */
  23558. setScalingUpdated(): void;
  23559. /**
  23560. * Force a regeneration of this or the parent's impostor's body.
  23561. * Use under cautious - This will remove all joints already implemented.
  23562. */
  23563. forceUpdate(): void;
  23564. /**
  23565. * Gets the body that holds this impostor. Either its own, or its parent.
  23566. */
  23567. /**
  23568. * Set the physics body. Used mainly by the physics engine/plugin
  23569. */
  23570. physicsBody: any;
  23571. /**
  23572. * Get the parent of the physics imposter
  23573. * @returns Physics imposter or null
  23574. */
  23575. /**
  23576. * Sets the parent of the physics imposter
  23577. */
  23578. parent: Nullable<PhysicsImpostor>;
  23579. /**
  23580. * Resets the update flags
  23581. */
  23582. resetUpdateFlags(): void;
  23583. /**
  23584. * Gets the object extend size
  23585. * @returns the object extend size
  23586. */
  23587. getObjectExtendSize(): Vector3;
  23588. /**
  23589. * Gets the object center
  23590. * @returns The object center
  23591. */
  23592. getObjectCenter(): Vector3;
  23593. /**
  23594. * Get a specific parametes from the options parameter
  23595. * @param paramName The object parameter name
  23596. * @returns The object parameter
  23597. */
  23598. getParam(paramName: string): any;
  23599. /**
  23600. * Sets a specific parameter in the options given to the physics plugin
  23601. * @param paramName The parameter name
  23602. * @param value The value of the parameter
  23603. */
  23604. setParam(paramName: string, value: number): void;
  23605. /**
  23606. * Specifically change the body's mass option. Won't recreate the physics body object
  23607. * @param mass The mass of the physics imposter
  23608. */
  23609. setMass(mass: number): void;
  23610. /**
  23611. * Gets the linear velocity
  23612. * @returns linear velocity or null
  23613. */
  23614. getLinearVelocity(): Nullable<Vector3>;
  23615. /**
  23616. * Sets the linear velocity
  23617. * @param velocity linear velocity or null
  23618. */
  23619. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23620. /**
  23621. * Gets the angular velocity
  23622. * @returns angular velocity or null
  23623. */
  23624. getAngularVelocity(): Nullable<Vector3>;
  23625. /**
  23626. * Sets the angular velocity
  23627. * @param velocity The velocity or null
  23628. */
  23629. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23630. /**
  23631. * Execute a function with the physics plugin native code
  23632. * Provide a function the will have two variables - the world object and the physics body object
  23633. * @param func The function to execute with the physics plugin native code
  23634. */
  23635. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23636. /**
  23637. * Register a function that will be executed before the physics world is stepping forward
  23638. * @param func The function to execute before the physics world is stepped forward
  23639. */
  23640. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23641. /**
  23642. * Unregister a function that will be executed before the physics world is stepping forward
  23643. * @param func The function to execute before the physics world is stepped forward
  23644. */
  23645. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23646. /**
  23647. * Register a function that will be executed after the physics step
  23648. * @param func The function to execute after physics step
  23649. */
  23650. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23651. /**
  23652. * Unregisters a function that will be executed after the physics step
  23653. * @param func The function to execute after physics step
  23654. */
  23655. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23656. /**
  23657. * register a function that will be executed when this impostor collides against a different body
  23658. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23659. * @param func Callback that is executed on collision
  23660. */
  23661. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23662. /**
  23663. * Unregisters the physics imposter on contact
  23664. * @param collideAgainst The physics object to collide against
  23665. * @param func Callback to execute on collision
  23666. */
  23667. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23668. private _tmpQuat;
  23669. private _tmpQuat2;
  23670. /**
  23671. * Get the parent rotation
  23672. * @returns The parent rotation
  23673. */
  23674. getParentsRotation(): Quaternion;
  23675. /**
  23676. * this function is executed by the physics engine.
  23677. */
  23678. beforeStep: () => void;
  23679. /**
  23680. * this function is executed by the physics engine
  23681. */
  23682. afterStep: () => void;
  23683. /**
  23684. * Legacy collision detection event support
  23685. */
  23686. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23687. /**
  23688. * event and body object due to cannon's event-based architecture.
  23689. */
  23690. onCollide: (e: {
  23691. body: any;
  23692. }) => void;
  23693. /**
  23694. * Apply a force
  23695. * @param force The force to apply
  23696. * @param contactPoint The contact point for the force
  23697. * @returns The physics imposter
  23698. */
  23699. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23700. /**
  23701. * Apply an impulse
  23702. * @param force The impulse force
  23703. * @param contactPoint The contact point for the impulse force
  23704. * @returns The physics imposter
  23705. */
  23706. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23707. /**
  23708. * A help function to create a joint
  23709. * @param otherImpostor A physics imposter used to create a joint
  23710. * @param jointType The type of joint
  23711. * @param jointData The data for the joint
  23712. * @returns The physics imposter
  23713. */
  23714. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23715. /**
  23716. * Add a joint to this impostor with a different impostor
  23717. * @param otherImpostor A physics imposter used to add a joint
  23718. * @param joint The joint to add
  23719. * @returns The physics imposter
  23720. */
  23721. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23722. /**
  23723. * Add an anchor to a cloth impostor
  23724. * @param otherImpostor rigid impostor to anchor to
  23725. * @param width ratio across width from 0 to 1
  23726. * @param height ratio up height from 0 to 1
  23727. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23728. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23729. * @returns impostor the soft imposter
  23730. */
  23731. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23732. /**
  23733. * Add a hook to a rope impostor
  23734. * @param otherImpostor rigid impostor to anchor to
  23735. * @param length ratio across rope from 0 to 1
  23736. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23737. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23738. * @returns impostor the rope imposter
  23739. */
  23740. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23741. /**
  23742. * Will keep this body still, in a sleep mode.
  23743. * @returns the physics imposter
  23744. */
  23745. sleep(): PhysicsImpostor;
  23746. /**
  23747. * Wake the body up.
  23748. * @returns The physics imposter
  23749. */
  23750. wakeUp(): PhysicsImpostor;
  23751. /**
  23752. * Clones the physics imposter
  23753. * @param newObject The physics imposter clones to this physics-enabled object
  23754. * @returns A nullable physics imposter
  23755. */
  23756. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23757. /**
  23758. * Disposes the physics imposter
  23759. */
  23760. dispose(): void;
  23761. /**
  23762. * Sets the delta position
  23763. * @param position The delta position amount
  23764. */
  23765. setDeltaPosition(position: Vector3): void;
  23766. /**
  23767. * Sets the delta rotation
  23768. * @param rotation The delta rotation amount
  23769. */
  23770. setDeltaRotation(rotation: Quaternion): void;
  23771. /**
  23772. * Gets the box size of the physics imposter and stores the result in the input parameter
  23773. * @param result Stores the box size
  23774. * @returns The physics imposter
  23775. */
  23776. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23777. /**
  23778. * Gets the radius of the physics imposter
  23779. * @returns Radius of the physics imposter
  23780. */
  23781. getRadius(): number;
  23782. /**
  23783. * Sync a bone with this impostor
  23784. * @param bone The bone to sync to the impostor.
  23785. * @param boneMesh The mesh that the bone is influencing.
  23786. * @param jointPivot The pivot of the joint / bone in local space.
  23787. * @param distToJoint Optional distance from the impostor to the joint.
  23788. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23789. */
  23790. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23791. /**
  23792. * Sync impostor to a bone
  23793. * @param bone The bone that the impostor will be synced to.
  23794. * @param boneMesh The mesh that the bone is influencing.
  23795. * @param jointPivot The pivot of the joint / bone in local space.
  23796. * @param distToJoint Optional distance from the impostor to the joint.
  23797. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23798. * @param boneAxis Optional vector3 axis the bone is aligned with
  23799. */
  23800. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23801. /**
  23802. * No-Imposter type
  23803. */
  23804. static NoImpostor: number;
  23805. /**
  23806. * Sphere-Imposter type
  23807. */
  23808. static SphereImpostor: number;
  23809. /**
  23810. * Box-Imposter type
  23811. */
  23812. static BoxImpostor: number;
  23813. /**
  23814. * Plane-Imposter type
  23815. */
  23816. static PlaneImpostor: number;
  23817. /**
  23818. * Mesh-imposter type
  23819. */
  23820. static MeshImpostor: number;
  23821. /**
  23822. * Capsule-Impostor type (Ammo.js plugin only)
  23823. */
  23824. static CapsuleImpostor: number;
  23825. /**
  23826. * Cylinder-Imposter type
  23827. */
  23828. static CylinderImpostor: number;
  23829. /**
  23830. * Particle-Imposter type
  23831. */
  23832. static ParticleImpostor: number;
  23833. /**
  23834. * Heightmap-Imposter type
  23835. */
  23836. static HeightmapImpostor: number;
  23837. /**
  23838. * ConvexHull-Impostor type (Ammo.js plugin only)
  23839. */
  23840. static ConvexHullImpostor: number;
  23841. /**
  23842. * Rope-Imposter type
  23843. */
  23844. static RopeImpostor: number;
  23845. /**
  23846. * Cloth-Imposter type
  23847. */
  23848. static ClothImpostor: number;
  23849. /**
  23850. * Softbody-Imposter type
  23851. */
  23852. static SoftbodyImpostor: number;
  23853. }
  23854. }
  23855. declare module "babylonjs/Meshes/mesh" {
  23856. import { Observable } from "babylonjs/Misc/observable";
  23857. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23858. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23859. import { Camera } from "babylonjs/Cameras/camera";
  23860. import { Scene } from "babylonjs/scene";
  23861. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23862. import { Color4 } from "babylonjs/Maths/math.color";
  23863. import { Engine } from "babylonjs/Engines/engine";
  23864. import { Node } from "babylonjs/node";
  23865. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23866. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23867. import { Buffer } from "babylonjs/Meshes/buffer";
  23868. import { Geometry } from "babylonjs/Meshes/geometry";
  23869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23870. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23871. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  23872. import { Effect } from "babylonjs/Materials/effect";
  23873. import { Material } from "babylonjs/Materials/material";
  23874. import { Skeleton } from "babylonjs/Bones/skeleton";
  23875. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  23876. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  23877. import { Path3D } from "babylonjs/Maths/math.path";
  23878. import { Plane } from "babylonjs/Maths/math.plane";
  23879. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23880. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23881. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  23882. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23883. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23884. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  23885. /**
  23886. * @hidden
  23887. **/
  23888. export class _CreationDataStorage {
  23889. closePath?: boolean;
  23890. closeArray?: boolean;
  23891. idx: number[];
  23892. dashSize: number;
  23893. gapSize: number;
  23894. path3D: Path3D;
  23895. pathArray: Vector3[][];
  23896. arc: number;
  23897. radius: number;
  23898. cap: number;
  23899. tessellation: number;
  23900. }
  23901. /**
  23902. * @hidden
  23903. **/
  23904. class _InstanceDataStorage {
  23905. visibleInstances: any;
  23906. batchCache: _InstancesBatch;
  23907. instancesBufferSize: number;
  23908. instancesBuffer: Nullable<Buffer>;
  23909. instancesData: Float32Array;
  23910. overridenInstanceCount: number;
  23911. isFrozen: boolean;
  23912. previousBatch: Nullable<_InstancesBatch>;
  23913. hardwareInstancedRendering: boolean;
  23914. sideOrientation: number;
  23915. }
  23916. /**
  23917. * @hidden
  23918. **/
  23919. export class _InstancesBatch {
  23920. mustReturn: boolean;
  23921. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  23922. renderSelf: boolean[];
  23923. hardwareInstancedRendering: boolean[];
  23924. }
  23925. /**
  23926. * Class used to represent renderable models
  23927. */
  23928. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23929. /**
  23930. * Mesh side orientation : usually the external or front surface
  23931. */
  23932. static readonly FRONTSIDE: number;
  23933. /**
  23934. * Mesh side orientation : usually the internal or back surface
  23935. */
  23936. static readonly BACKSIDE: number;
  23937. /**
  23938. * Mesh side orientation : both internal and external or front and back surfaces
  23939. */
  23940. static readonly DOUBLESIDE: number;
  23941. /**
  23942. * Mesh side orientation : by default, `FRONTSIDE`
  23943. */
  23944. static readonly DEFAULTSIDE: number;
  23945. /**
  23946. * Mesh cap setting : no cap
  23947. */
  23948. static readonly NO_CAP: number;
  23949. /**
  23950. * Mesh cap setting : one cap at the beginning of the mesh
  23951. */
  23952. static readonly CAP_START: number;
  23953. /**
  23954. * Mesh cap setting : one cap at the end of the mesh
  23955. */
  23956. static readonly CAP_END: number;
  23957. /**
  23958. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23959. */
  23960. static readonly CAP_ALL: number;
  23961. /**
  23962. * Mesh pattern setting : no flip or rotate
  23963. */
  23964. static readonly NO_FLIP: number;
  23965. /**
  23966. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23967. */
  23968. static readonly FLIP_TILE: number;
  23969. /**
  23970. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23971. */
  23972. static readonly ROTATE_TILE: number;
  23973. /**
  23974. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23975. */
  23976. static readonly FLIP_ROW: number;
  23977. /**
  23978. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23979. */
  23980. static readonly ROTATE_ROW: number;
  23981. /**
  23982. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23983. */
  23984. static readonly FLIP_N_ROTATE_TILE: number;
  23985. /**
  23986. * Mesh pattern setting : rotate pattern and rotate
  23987. */
  23988. static readonly FLIP_N_ROTATE_ROW: number;
  23989. /**
  23990. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23991. */
  23992. static readonly CENTER: number;
  23993. /**
  23994. * Mesh tile positioning : part tiles on left
  23995. */
  23996. static readonly LEFT: number;
  23997. /**
  23998. * Mesh tile positioning : part tiles on right
  23999. */
  24000. static readonly RIGHT: number;
  24001. /**
  24002. * Mesh tile positioning : part tiles on top
  24003. */
  24004. static readonly TOP: number;
  24005. /**
  24006. * Mesh tile positioning : part tiles on bottom
  24007. */
  24008. static readonly BOTTOM: number;
  24009. /**
  24010. * Gets the default side orientation.
  24011. * @param orientation the orientation to value to attempt to get
  24012. * @returns the default orientation
  24013. * @hidden
  24014. */
  24015. static _GetDefaultSideOrientation(orientation?: number): number;
  24016. private _internalMeshDataInfo;
  24017. /**
  24018. * An event triggered before rendering the mesh
  24019. */
  24020. readonly onBeforeRenderObservable: Observable<Mesh>;
  24021. /**
  24022. * An event triggered before binding the mesh
  24023. */
  24024. readonly onBeforeBindObservable: Observable<Mesh>;
  24025. /**
  24026. * An event triggered after rendering the mesh
  24027. */
  24028. readonly onAfterRenderObservable: Observable<Mesh>;
  24029. /**
  24030. * An event triggered before drawing the mesh
  24031. */
  24032. readonly onBeforeDrawObservable: Observable<Mesh>;
  24033. private _onBeforeDrawObserver;
  24034. /**
  24035. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24036. */
  24037. onBeforeDraw: () => void;
  24038. readonly hasInstances: boolean;
  24039. /**
  24040. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24041. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24042. */
  24043. delayLoadState: number;
  24044. /**
  24045. * Gets the list of instances created from this mesh
  24046. * it is not supposed to be modified manually.
  24047. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24048. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24049. */
  24050. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24051. /**
  24052. * Gets the file containing delay loading data for this mesh
  24053. */
  24054. delayLoadingFile: string;
  24055. /** @hidden */
  24056. _binaryInfo: any;
  24057. /**
  24058. * User defined function used to change how LOD level selection is done
  24059. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24060. */
  24061. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24062. /**
  24063. * Gets or sets the morph target manager
  24064. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24065. */
  24066. morphTargetManager: Nullable<MorphTargetManager>;
  24067. /** @hidden */
  24068. _creationDataStorage: Nullable<_CreationDataStorage>;
  24069. /** @hidden */
  24070. _geometry: Nullable<Geometry>;
  24071. /** @hidden */
  24072. _delayInfo: Array<string>;
  24073. /** @hidden */
  24074. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24075. /** @hidden */
  24076. _instanceDataStorage: _InstanceDataStorage;
  24077. private _effectiveMaterial;
  24078. /** @hidden */
  24079. _shouldGenerateFlatShading: boolean;
  24080. /** @hidden */
  24081. _originalBuilderSideOrientation: number;
  24082. /**
  24083. * Use this property to change the original side orientation defined at construction time
  24084. */
  24085. overrideMaterialSideOrientation: Nullable<number>;
  24086. /**
  24087. * Gets the source mesh (the one used to clone this one from)
  24088. */
  24089. readonly source: Nullable<Mesh>;
  24090. /**
  24091. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24092. */
  24093. isUnIndexed: boolean;
  24094. /**
  24095. * @constructor
  24096. * @param name The value used by scene.getMeshByName() to do a lookup.
  24097. * @param scene The scene to add this mesh to.
  24098. * @param parent The parent of this mesh, if it has one
  24099. * @param source An optional Mesh from which geometry is shared, cloned.
  24100. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24101. * When false, achieved by calling a clone(), also passing False.
  24102. * This will make creation of children, recursive.
  24103. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24104. */
  24105. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24106. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24107. /**
  24108. * Gets the class name
  24109. * @returns the string "Mesh".
  24110. */
  24111. getClassName(): string;
  24112. /** @hidden */
  24113. readonly _isMesh: boolean;
  24114. /**
  24115. * Returns a description of this mesh
  24116. * @param fullDetails define if full details about this mesh must be used
  24117. * @returns a descriptive string representing this mesh
  24118. */
  24119. toString(fullDetails?: boolean): string;
  24120. /** @hidden */
  24121. _unBindEffect(): void;
  24122. /**
  24123. * Gets a boolean indicating if this mesh has LOD
  24124. */
  24125. readonly hasLODLevels: boolean;
  24126. /**
  24127. * Gets the list of MeshLODLevel associated with the current mesh
  24128. * @returns an array of MeshLODLevel
  24129. */
  24130. getLODLevels(): MeshLODLevel[];
  24131. private _sortLODLevels;
  24132. /**
  24133. * Add a mesh as LOD level triggered at the given distance.
  24134. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24135. * @param distance The distance from the center of the object to show this level
  24136. * @param mesh The mesh to be added as LOD level (can be null)
  24137. * @return This mesh (for chaining)
  24138. */
  24139. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24140. /**
  24141. * Returns the LOD level mesh at the passed distance or null if not found.
  24142. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24143. * @param distance The distance from the center of the object to show this level
  24144. * @returns a Mesh or `null`
  24145. */
  24146. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24147. /**
  24148. * Remove a mesh from the LOD array
  24149. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24150. * @param mesh defines the mesh to be removed
  24151. * @return This mesh (for chaining)
  24152. */
  24153. removeLODLevel(mesh: Mesh): Mesh;
  24154. /**
  24155. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24156. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24157. * @param camera defines the camera to use to compute distance
  24158. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24159. * @return This mesh (for chaining)
  24160. */
  24161. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24162. /**
  24163. * Gets the mesh internal Geometry object
  24164. */
  24165. readonly geometry: Nullable<Geometry>;
  24166. /**
  24167. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24168. * @returns the total number of vertices
  24169. */
  24170. getTotalVertices(): number;
  24171. /**
  24172. * Returns the content of an associated vertex buffer
  24173. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24174. * - VertexBuffer.PositionKind
  24175. * - VertexBuffer.UVKind
  24176. * - VertexBuffer.UV2Kind
  24177. * - VertexBuffer.UV3Kind
  24178. * - VertexBuffer.UV4Kind
  24179. * - VertexBuffer.UV5Kind
  24180. * - VertexBuffer.UV6Kind
  24181. * - VertexBuffer.ColorKind
  24182. * - VertexBuffer.MatricesIndicesKind
  24183. * - VertexBuffer.MatricesIndicesExtraKind
  24184. * - VertexBuffer.MatricesWeightsKind
  24185. * - VertexBuffer.MatricesWeightsExtraKind
  24186. * @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
  24187. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24188. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24189. */
  24190. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24191. /**
  24192. * Returns the mesh VertexBuffer object from the requested `kind`
  24193. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24194. * - VertexBuffer.PositionKind
  24195. * - VertexBuffer.NormalKind
  24196. * - VertexBuffer.UVKind
  24197. * - VertexBuffer.UV2Kind
  24198. * - VertexBuffer.UV3Kind
  24199. * - VertexBuffer.UV4Kind
  24200. * - VertexBuffer.UV5Kind
  24201. * - VertexBuffer.UV6Kind
  24202. * - VertexBuffer.ColorKind
  24203. * - VertexBuffer.MatricesIndicesKind
  24204. * - VertexBuffer.MatricesIndicesExtraKind
  24205. * - VertexBuffer.MatricesWeightsKind
  24206. * - VertexBuffer.MatricesWeightsExtraKind
  24207. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24208. */
  24209. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24210. /**
  24211. * Tests if a specific vertex buffer is associated with this mesh
  24212. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24213. * - VertexBuffer.PositionKind
  24214. * - VertexBuffer.NormalKind
  24215. * - VertexBuffer.UVKind
  24216. * - VertexBuffer.UV2Kind
  24217. * - VertexBuffer.UV3Kind
  24218. * - VertexBuffer.UV4Kind
  24219. * - VertexBuffer.UV5Kind
  24220. * - VertexBuffer.UV6Kind
  24221. * - VertexBuffer.ColorKind
  24222. * - VertexBuffer.MatricesIndicesKind
  24223. * - VertexBuffer.MatricesIndicesExtraKind
  24224. * - VertexBuffer.MatricesWeightsKind
  24225. * - VertexBuffer.MatricesWeightsExtraKind
  24226. * @returns a boolean
  24227. */
  24228. isVerticesDataPresent(kind: string): boolean;
  24229. /**
  24230. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24231. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24232. * - VertexBuffer.PositionKind
  24233. * - VertexBuffer.UVKind
  24234. * - VertexBuffer.UV2Kind
  24235. * - VertexBuffer.UV3Kind
  24236. * - VertexBuffer.UV4Kind
  24237. * - VertexBuffer.UV5Kind
  24238. * - VertexBuffer.UV6Kind
  24239. * - VertexBuffer.ColorKind
  24240. * - VertexBuffer.MatricesIndicesKind
  24241. * - VertexBuffer.MatricesIndicesExtraKind
  24242. * - VertexBuffer.MatricesWeightsKind
  24243. * - VertexBuffer.MatricesWeightsExtraKind
  24244. * @returns a boolean
  24245. */
  24246. isVertexBufferUpdatable(kind: string): boolean;
  24247. /**
  24248. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24249. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24250. * - VertexBuffer.PositionKind
  24251. * - VertexBuffer.NormalKind
  24252. * - VertexBuffer.UVKind
  24253. * - VertexBuffer.UV2Kind
  24254. * - VertexBuffer.UV3Kind
  24255. * - VertexBuffer.UV4Kind
  24256. * - VertexBuffer.UV5Kind
  24257. * - VertexBuffer.UV6Kind
  24258. * - VertexBuffer.ColorKind
  24259. * - VertexBuffer.MatricesIndicesKind
  24260. * - VertexBuffer.MatricesIndicesExtraKind
  24261. * - VertexBuffer.MatricesWeightsKind
  24262. * - VertexBuffer.MatricesWeightsExtraKind
  24263. * @returns an array of strings
  24264. */
  24265. getVerticesDataKinds(): string[];
  24266. /**
  24267. * Returns a positive integer : the total number of indices in this mesh geometry.
  24268. * @returns the numner of indices or zero if the mesh has no geometry.
  24269. */
  24270. getTotalIndices(): number;
  24271. /**
  24272. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24273. * @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.
  24274. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24275. * @returns the indices array or an empty array if the mesh has no geometry
  24276. */
  24277. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24278. readonly isBlocked: boolean;
  24279. /**
  24280. * Determine if the current mesh is ready to be rendered
  24281. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24282. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24283. * @returns true if all associated assets are ready (material, textures, shaders)
  24284. */
  24285. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24286. /**
  24287. * 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.
  24288. */
  24289. readonly areNormalsFrozen: boolean;
  24290. /**
  24291. * 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.
  24292. * @returns the current mesh
  24293. */
  24294. freezeNormals(): Mesh;
  24295. /**
  24296. * 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
  24297. * @returns the current mesh
  24298. */
  24299. unfreezeNormals(): Mesh;
  24300. /**
  24301. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24302. */
  24303. overridenInstanceCount: number;
  24304. /** @hidden */
  24305. _preActivate(): Mesh;
  24306. /** @hidden */
  24307. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24308. /** @hidden */
  24309. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24310. /**
  24311. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24312. * This means the mesh underlying bounding box and sphere are recomputed.
  24313. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24314. * @returns the current mesh
  24315. */
  24316. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24317. /** @hidden */
  24318. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24319. /**
  24320. * This function will subdivide the mesh into multiple submeshes
  24321. * @param count defines the expected number of submeshes
  24322. */
  24323. subdivide(count: number): void;
  24324. /**
  24325. * Copy a FloatArray into a specific associated vertex buffer
  24326. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24327. * - VertexBuffer.PositionKind
  24328. * - VertexBuffer.UVKind
  24329. * - VertexBuffer.UV2Kind
  24330. * - VertexBuffer.UV3Kind
  24331. * - VertexBuffer.UV4Kind
  24332. * - VertexBuffer.UV5Kind
  24333. * - VertexBuffer.UV6Kind
  24334. * - VertexBuffer.ColorKind
  24335. * - VertexBuffer.MatricesIndicesKind
  24336. * - VertexBuffer.MatricesIndicesExtraKind
  24337. * - VertexBuffer.MatricesWeightsKind
  24338. * - VertexBuffer.MatricesWeightsExtraKind
  24339. * @param data defines the data source
  24340. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24341. * @param stride defines the data stride size (can be null)
  24342. * @returns the current mesh
  24343. */
  24344. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24345. /**
  24346. * Flags an associated vertex buffer as updatable
  24347. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24348. * - VertexBuffer.PositionKind
  24349. * - VertexBuffer.UVKind
  24350. * - VertexBuffer.UV2Kind
  24351. * - VertexBuffer.UV3Kind
  24352. * - VertexBuffer.UV4Kind
  24353. * - VertexBuffer.UV5Kind
  24354. * - VertexBuffer.UV6Kind
  24355. * - VertexBuffer.ColorKind
  24356. * - VertexBuffer.MatricesIndicesKind
  24357. * - VertexBuffer.MatricesIndicesExtraKind
  24358. * - VertexBuffer.MatricesWeightsKind
  24359. * - VertexBuffer.MatricesWeightsExtraKind
  24360. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24361. */
  24362. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24363. /**
  24364. * Sets the mesh global Vertex Buffer
  24365. * @param buffer defines the buffer to use
  24366. * @returns the current mesh
  24367. */
  24368. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24369. /**
  24370. * Update a specific associated vertex buffer
  24371. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24372. * - VertexBuffer.PositionKind
  24373. * - VertexBuffer.UVKind
  24374. * - VertexBuffer.UV2Kind
  24375. * - VertexBuffer.UV3Kind
  24376. * - VertexBuffer.UV4Kind
  24377. * - VertexBuffer.UV5Kind
  24378. * - VertexBuffer.UV6Kind
  24379. * - VertexBuffer.ColorKind
  24380. * - VertexBuffer.MatricesIndicesKind
  24381. * - VertexBuffer.MatricesIndicesExtraKind
  24382. * - VertexBuffer.MatricesWeightsKind
  24383. * - VertexBuffer.MatricesWeightsExtraKind
  24384. * @param data defines the data source
  24385. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24386. * @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)
  24387. * @returns the current mesh
  24388. */
  24389. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24390. /**
  24391. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24392. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24393. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24394. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24395. * @returns the current mesh
  24396. */
  24397. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24398. /**
  24399. * Creates a un-shared specific occurence of the geometry for the mesh.
  24400. * @returns the current mesh
  24401. */
  24402. makeGeometryUnique(): Mesh;
  24403. /**
  24404. * Set the index buffer of this mesh
  24405. * @param indices defines the source data
  24406. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24407. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24408. * @returns the current mesh
  24409. */
  24410. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24411. /**
  24412. * Update the current index buffer
  24413. * @param indices defines the source data
  24414. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24415. * @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)
  24416. * @returns the current mesh
  24417. */
  24418. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24419. /**
  24420. * Invert the geometry to move from a right handed system to a left handed one.
  24421. * @returns the current mesh
  24422. */
  24423. toLeftHanded(): Mesh;
  24424. /** @hidden */
  24425. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24426. /** @hidden */
  24427. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24428. /**
  24429. * Registers for this mesh a javascript function called just before the rendering process
  24430. * @param func defines the function to call before rendering this mesh
  24431. * @returns the current mesh
  24432. */
  24433. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24434. /**
  24435. * Disposes a previously registered javascript function called before the rendering
  24436. * @param func defines the function to remove
  24437. * @returns the current mesh
  24438. */
  24439. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24440. /**
  24441. * Registers for this mesh a javascript function called just after the rendering is complete
  24442. * @param func defines the function to call after rendering this mesh
  24443. * @returns the current mesh
  24444. */
  24445. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24446. /**
  24447. * Disposes a previously registered javascript function called after the rendering.
  24448. * @param func defines the function to remove
  24449. * @returns the current mesh
  24450. */
  24451. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24452. /** @hidden */
  24453. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24454. /** @hidden */
  24455. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24456. /** @hidden */
  24457. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24458. /** @hidden */
  24459. _rebuild(): void;
  24460. /** @hidden */
  24461. _freeze(): void;
  24462. /** @hidden */
  24463. _unFreeze(): void;
  24464. /**
  24465. * 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
  24466. * @param subMesh defines the subMesh to render
  24467. * @param enableAlphaMode defines if alpha mode can be changed
  24468. * @returns the current mesh
  24469. */
  24470. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24471. private _onBeforeDraw;
  24472. /**
  24473. * Renormalize the mesh and patch it up if there are no weights
  24474. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24475. * However in the case of zero weights then we set just a single influence to 1.
  24476. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24477. */
  24478. cleanMatrixWeights(): void;
  24479. private normalizeSkinFourWeights;
  24480. private normalizeSkinWeightsAndExtra;
  24481. /**
  24482. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24483. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24484. * the user know there was an issue with importing the mesh
  24485. * @returns a validation object with skinned, valid and report string
  24486. */
  24487. validateSkinning(): {
  24488. skinned: boolean;
  24489. valid: boolean;
  24490. report: string;
  24491. };
  24492. /** @hidden */
  24493. _checkDelayState(): Mesh;
  24494. private _queueLoad;
  24495. /**
  24496. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24497. * A mesh is in the frustum if its bounding box intersects the frustum
  24498. * @param frustumPlanes defines the frustum to test
  24499. * @returns true if the mesh is in the frustum planes
  24500. */
  24501. isInFrustum(frustumPlanes: Plane[]): boolean;
  24502. /**
  24503. * Sets the mesh material by the material or multiMaterial `id` property
  24504. * @param id is a string identifying the material or the multiMaterial
  24505. * @returns the current mesh
  24506. */
  24507. setMaterialByID(id: string): Mesh;
  24508. /**
  24509. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24510. * @returns an array of IAnimatable
  24511. */
  24512. getAnimatables(): IAnimatable[];
  24513. /**
  24514. * Modifies the mesh geometry according to the passed transformation matrix.
  24515. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24516. * The mesh normals are modified using the same transformation.
  24517. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24518. * @param transform defines the transform matrix to use
  24519. * @see http://doc.babylonjs.com/resources/baking_transformations
  24520. * @returns the current mesh
  24521. */
  24522. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24523. /**
  24524. * Modifies the mesh geometry according to its own current World Matrix.
  24525. * The mesh World Matrix is then reset.
  24526. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24527. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24528. * @see http://doc.babylonjs.com/resources/baking_transformations
  24529. * @returns the current mesh
  24530. */
  24531. bakeCurrentTransformIntoVertices(): Mesh;
  24532. /** @hidden */
  24533. readonly _positions: Nullable<Vector3[]>;
  24534. /** @hidden */
  24535. _resetPointsArrayCache(): Mesh;
  24536. /** @hidden */
  24537. _generatePointsArray(): boolean;
  24538. /**
  24539. * Returns a new Mesh object generated from the current mesh properties.
  24540. * This method must not get confused with createInstance()
  24541. * @param name is a string, the name given to the new mesh
  24542. * @param newParent can be any Node object (default `null`)
  24543. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24544. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24545. * @returns a new mesh
  24546. */
  24547. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24548. /**
  24549. * Releases resources associated with this mesh.
  24550. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24551. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24552. */
  24553. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24554. /**
  24555. * Modifies the mesh geometry according to a displacement map.
  24556. * 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.
  24557. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24558. * @param url is a string, the URL from the image file is to be downloaded.
  24559. * @param minHeight is the lower limit of the displacement.
  24560. * @param maxHeight is the upper limit of the displacement.
  24561. * @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.
  24562. * @param uvOffset is an optional vector2 used to offset UV.
  24563. * @param uvScale is an optional vector2 used to scale UV.
  24564. * @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.
  24565. * @returns the Mesh.
  24566. */
  24567. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24568. /**
  24569. * Modifies the mesh geometry according to a displacementMap buffer.
  24570. * 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.
  24571. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24572. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24573. * @param heightMapWidth is the width of the buffer image.
  24574. * @param heightMapHeight is the height of the buffer image.
  24575. * @param minHeight is the lower limit of the displacement.
  24576. * @param maxHeight is the upper limit of the displacement.
  24577. * @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.
  24578. * @param uvOffset is an optional vector2 used to offset UV.
  24579. * @param uvScale is an optional vector2 used to scale UV.
  24580. * @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.
  24581. * @returns the Mesh.
  24582. */
  24583. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24584. /**
  24585. * Modify the mesh to get a flat shading rendering.
  24586. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24587. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24588. * @returns current mesh
  24589. */
  24590. convertToFlatShadedMesh(): Mesh;
  24591. /**
  24592. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24593. * In other words, more vertices, no more indices and a single bigger VBO.
  24594. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24595. * @returns current mesh
  24596. */
  24597. convertToUnIndexedMesh(): Mesh;
  24598. /**
  24599. * Inverses facet orientations.
  24600. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24601. * @param flipNormals will also inverts the normals
  24602. * @returns current mesh
  24603. */
  24604. flipFaces(flipNormals?: boolean): Mesh;
  24605. /**
  24606. * Increase the number of facets and hence vertices in a mesh
  24607. * Vertex normals are interpolated from existing vertex normals
  24608. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24609. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24610. */
  24611. increaseVertices(numberPerEdge: number): void;
  24612. /**
  24613. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24614. * This will undo any application of covertToFlatShadedMesh
  24615. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24616. */
  24617. forceSharedVertices(): void;
  24618. /** @hidden */
  24619. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24620. /** @hidden */
  24621. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24622. /**
  24623. * Creates a new InstancedMesh object from the mesh model.
  24624. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24625. * @param name defines the name of the new instance
  24626. * @returns a new InstancedMesh
  24627. */
  24628. createInstance(name: string): InstancedMesh;
  24629. /**
  24630. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24631. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24632. * @returns the current mesh
  24633. */
  24634. synchronizeInstances(): Mesh;
  24635. /**
  24636. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24637. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24638. * This should be used together with the simplification to avoid disappearing triangles.
  24639. * @param successCallback an optional success callback to be called after the optimization finished.
  24640. * @returns the current mesh
  24641. */
  24642. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24643. /**
  24644. * Serialize current mesh
  24645. * @param serializationObject defines the object which will receive the serialization data
  24646. */
  24647. serialize(serializationObject: any): void;
  24648. /** @hidden */
  24649. _syncGeometryWithMorphTargetManager(): void;
  24650. /** @hidden */
  24651. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24652. /**
  24653. * Returns a new Mesh object parsed from the source provided.
  24654. * @param parsedMesh is the source
  24655. * @param scene defines the hosting scene
  24656. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24657. * @returns a new Mesh
  24658. */
  24659. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24660. /**
  24661. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24662. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24663. * @param name defines the name of the mesh to create
  24664. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24665. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24666. * @param closePath creates a seam between the first and the last points of each path of the path array
  24667. * @param offset is taken in account only if the `pathArray` is containing a single path
  24668. * @param scene defines the hosting scene
  24669. * @param updatable defines if the mesh must be flagged as updatable
  24670. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24671. * @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)
  24672. * @returns a new Mesh
  24673. */
  24674. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24675. /**
  24676. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24677. * @param name defines the name of the mesh to create
  24678. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24679. * @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
  24680. * @param scene defines the hosting scene
  24681. * @param updatable defines if the mesh must be flagged as updatable
  24682. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24683. * @returns a new Mesh
  24684. */
  24685. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24686. /**
  24687. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24688. * @param name defines the name of the mesh to create
  24689. * @param size sets the size (float) of each box side (default 1)
  24690. * @param scene defines the hosting scene
  24691. * @param updatable defines if the mesh must be flagged as updatable
  24692. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24693. * @returns a new Mesh
  24694. */
  24695. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24696. /**
  24697. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24698. * @param name defines the name of the mesh to create
  24699. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24700. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24701. * @param scene defines the hosting scene
  24702. * @param updatable defines if the mesh must be flagged as updatable
  24703. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24704. * @returns a new Mesh
  24705. */
  24706. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24707. /**
  24708. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24709. * @param name defines the name of the mesh to create
  24710. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24711. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24712. * @param scene defines the hosting scene
  24713. * @returns a new Mesh
  24714. */
  24715. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24716. /**
  24717. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24718. * @param name defines the name of the mesh to create
  24719. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24720. * @param diameterTop set the top cap diameter (floats, default 1)
  24721. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24722. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24723. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24724. * @param scene defines the hosting scene
  24725. * @param updatable defines if the mesh must be flagged as updatable
  24726. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24727. * @returns a new Mesh
  24728. */
  24729. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24730. /**
  24731. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24732. * @param name defines the name of the mesh to create
  24733. * @param diameter sets the diameter size (float) of the torus (default 1)
  24734. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24735. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24736. * @param scene defines the hosting scene
  24737. * @param updatable defines if the mesh must be flagged as updatable
  24738. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24739. * @returns a new Mesh
  24740. */
  24741. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24742. /**
  24743. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24744. * @param name defines the name of the mesh to create
  24745. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24746. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24747. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24748. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24749. * @param p the number of windings on X axis (positive integers, default 2)
  24750. * @param q the number of windings on Y axis (positive integers, default 3)
  24751. * @param scene defines the hosting scene
  24752. * @param updatable defines if the mesh must be flagged as updatable
  24753. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24754. * @returns a new Mesh
  24755. */
  24756. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24757. /**
  24758. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24759. * @param name defines the name of the mesh to create
  24760. * @param points is an array successive Vector3
  24761. * @param scene defines the hosting scene
  24762. * @param updatable defines if the mesh must be flagged as updatable
  24763. * @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).
  24764. * @returns a new Mesh
  24765. */
  24766. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24767. /**
  24768. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24769. * @param name defines the name of the mesh to create
  24770. * @param points is an array successive Vector3
  24771. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24772. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24773. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24774. * @param scene defines the hosting scene
  24775. * @param updatable defines if the mesh must be flagged as updatable
  24776. * @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)
  24777. * @returns a new Mesh
  24778. */
  24779. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24780. /**
  24781. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24782. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24783. * 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.
  24784. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24785. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24786. * Remember you can only change the shape positions, not their number when updating a polygon.
  24787. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24788. * @param name defines the name of the mesh to create
  24789. * @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
  24790. * @param scene defines the hosting scene
  24791. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24792. * @param updatable defines if the mesh must be flagged as updatable
  24793. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24794. * @param earcutInjection can be used to inject your own earcut reference
  24795. * @returns a new Mesh
  24796. */
  24797. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24798. /**
  24799. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24800. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24801. * @param name defines the name of the mesh to create
  24802. * @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
  24803. * @param depth defines the height of extrusion
  24804. * @param scene defines the hosting scene
  24805. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24806. * @param updatable defines if the mesh must be flagged as updatable
  24807. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24808. * @param earcutInjection can be used to inject your own earcut reference
  24809. * @returns a new Mesh
  24810. */
  24811. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24812. /**
  24813. * Creates an extruded shape mesh.
  24814. * 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
  24815. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24816. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24817. * @param name defines the name of the mesh to create
  24818. * @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
  24819. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24820. * @param scale is the value to scale the shape
  24821. * @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
  24822. * @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
  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. * @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)
  24827. * @returns a new Mesh
  24828. */
  24829. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24830. /**
  24831. * Creates an custom extruded shape mesh.
  24832. * The custom extrusion is a parametric shape.
  24833. * It has no predefined shape. Its final shape will depend on the input parameters.
  24834. * Please consider using the same method from the MeshBuilder class instead
  24835. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24836. * @param name defines the name of the mesh to create
  24837. * @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
  24838. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24839. * @param scaleFunction is a custom Javascript function called on each path point
  24840. * @param rotationFunction is a custom Javascript function called on each path point
  24841. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24842. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24843. * @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
  24844. * @param scene defines the hosting scene
  24845. * @param updatable defines if the mesh must be flagged as updatable
  24846. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24847. * @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)
  24848. * @returns a new Mesh
  24849. */
  24850. 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;
  24851. /**
  24852. * Creates lathe mesh.
  24853. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24854. * Please consider using the same method from the MeshBuilder class instead
  24855. * @param name defines the name of the mesh to create
  24856. * @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
  24857. * @param radius is the radius value of the lathe
  24858. * @param tessellation is the side number of the lathe.
  24859. * @param scene defines the hosting scene
  24860. * @param updatable defines if the mesh must be flagged as updatable
  24861. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24862. * @returns a new Mesh
  24863. */
  24864. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24865. /**
  24866. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24867. * @param name defines the name of the mesh to create
  24868. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24869. * @param scene defines the hosting scene
  24870. * @param updatable defines if the mesh must be flagged as updatable
  24871. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24872. * @returns a new Mesh
  24873. */
  24874. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24875. /**
  24876. * Creates a ground mesh.
  24877. * Please consider using the same method from the MeshBuilder class instead
  24878. * @param name defines the name of the mesh to create
  24879. * @param width set the width of the ground
  24880. * @param height set the height of the ground
  24881. * @param subdivisions sets the number of subdivisions per side
  24882. * @param scene defines the hosting scene
  24883. * @param updatable defines if the mesh must be flagged as updatable
  24884. * @returns a new Mesh
  24885. */
  24886. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24887. /**
  24888. * Creates a tiled ground mesh.
  24889. * Please consider using the same method from the MeshBuilder class instead
  24890. * @param name defines the name of the mesh to create
  24891. * @param xmin set the ground minimum X coordinate
  24892. * @param zmin set the ground minimum Y coordinate
  24893. * @param xmax set the ground maximum X coordinate
  24894. * @param zmax set the ground maximum Z coordinate
  24895. * @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
  24896. * @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
  24897. * @param scene defines the hosting scene
  24898. * @param updatable defines if the mesh must be flagged as updatable
  24899. * @returns a new Mesh
  24900. */
  24901. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24902. w: number;
  24903. h: number;
  24904. }, precision: {
  24905. w: number;
  24906. h: number;
  24907. }, scene: Scene, updatable?: boolean): Mesh;
  24908. /**
  24909. * Creates a ground mesh from a height map.
  24910. * Please consider using the same method from the MeshBuilder class instead
  24911. * @see http://doc.babylonjs.com/babylon101/height_map
  24912. * @param name defines the name of the mesh to create
  24913. * @param url sets the URL of the height map image resource
  24914. * @param width set the ground width size
  24915. * @param height set the ground height size
  24916. * @param subdivisions sets the number of subdivision per side
  24917. * @param minHeight is the minimum altitude on the ground
  24918. * @param maxHeight is the maximum altitude on the ground
  24919. * @param scene defines the hosting scene
  24920. * @param updatable defines if the mesh must be flagged as updatable
  24921. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24922. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24923. * @returns a new Mesh
  24924. */
  24925. 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;
  24926. /**
  24927. * Creates a tube mesh.
  24928. * The tube is a parametric shape.
  24929. * It has no predefined shape. Its final shape will depend on the input parameters.
  24930. * Please consider using the same method from the MeshBuilder class instead
  24931. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24932. * @param name defines the name of the mesh to create
  24933. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24934. * @param radius sets the tube radius size
  24935. * @param tessellation is the number of sides on the tubular surface
  24936. * @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
  24937. * @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
  24938. * @param scene defines the hosting scene
  24939. * @param updatable defines if the mesh must be flagged as updatable
  24940. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24941. * @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)
  24942. * @returns a new Mesh
  24943. */
  24944. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24945. (i: number, distance: number): number;
  24946. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24947. /**
  24948. * Creates a polyhedron mesh.
  24949. * Please consider using the same method from the MeshBuilder class instead.
  24950. * * 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
  24951. * * The parameter `size` (positive float, default 1) sets the polygon size
  24952. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24953. * * 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`
  24954. * * 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
  24955. * * 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)`)
  24956. * * 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
  24957. * * 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
  24958. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24959. * * If you create a double-sided mesh, you can choose what parts of 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
  24960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24961. * @param name defines the name of the mesh to create
  24962. * @param options defines the options used to create the mesh
  24963. * @param scene defines the hosting scene
  24964. * @returns a new Mesh
  24965. */
  24966. static CreatePolyhedron(name: string, options: {
  24967. type?: number;
  24968. size?: number;
  24969. sizeX?: number;
  24970. sizeY?: number;
  24971. sizeZ?: number;
  24972. custom?: any;
  24973. faceUV?: Vector4[];
  24974. faceColors?: Color4[];
  24975. updatable?: boolean;
  24976. sideOrientation?: number;
  24977. }, scene: Scene): Mesh;
  24978. /**
  24979. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24980. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24981. * * 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`)
  24982. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24983. * * 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
  24984. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24985. * * If you create a double-sided mesh, you can choose what parts of 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
  24986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24987. * @param name defines the name of the mesh
  24988. * @param options defines the options used to create the mesh
  24989. * @param scene defines the hosting scene
  24990. * @returns a new Mesh
  24991. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24992. */
  24993. static CreateIcoSphere(name: string, options: {
  24994. radius?: number;
  24995. flat?: boolean;
  24996. subdivisions?: number;
  24997. sideOrientation?: number;
  24998. updatable?: boolean;
  24999. }, scene: Scene): Mesh;
  25000. /**
  25001. * Creates a decal mesh.
  25002. * Please consider using the same method from the MeshBuilder class instead.
  25003. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25004. * @param name defines the name of the mesh
  25005. * @param sourceMesh defines the mesh receiving the decal
  25006. * @param position sets the position of the decal in world coordinates
  25007. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25008. * @param size sets the decal scaling
  25009. * @param angle sets the angle to rotate the decal
  25010. * @returns a new Mesh
  25011. */
  25012. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25013. /**
  25014. * Prepare internal position array for software CPU skinning
  25015. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25016. */
  25017. setPositionsForCPUSkinning(): Float32Array;
  25018. /**
  25019. * Prepare internal normal array for software CPU skinning
  25020. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25021. */
  25022. setNormalsForCPUSkinning(): Float32Array;
  25023. /**
  25024. * Updates the vertex buffer by applying transformation from the bones
  25025. * @param skeleton defines the skeleton to apply to current mesh
  25026. * @returns the current mesh
  25027. */
  25028. applySkeleton(skeleton: Skeleton): Mesh;
  25029. /**
  25030. * 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
  25031. * @param meshes defines the list of meshes to scan
  25032. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25033. */
  25034. static MinMax(meshes: AbstractMesh[]): {
  25035. min: Vector3;
  25036. max: Vector3;
  25037. };
  25038. /**
  25039. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25040. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25041. * @returns a vector3
  25042. */
  25043. static Center(meshesOrMinMaxVector: {
  25044. min: Vector3;
  25045. max: Vector3;
  25046. } | AbstractMesh[]): Vector3;
  25047. /**
  25048. * Merge the array of meshes into a single mesh for performance reasons.
  25049. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25050. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25051. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25052. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25053. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25054. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25055. * @returns a new mesh
  25056. */
  25057. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25058. /** @hidden */
  25059. addInstance(instance: InstancedMesh): void;
  25060. /** @hidden */
  25061. removeInstance(instance: InstancedMesh): void;
  25062. }
  25063. }
  25064. declare module "babylonjs/Cameras/camera" {
  25065. import { SmartArray } from "babylonjs/Misc/smartArray";
  25066. import { Observable } from "babylonjs/Misc/observable";
  25067. import { Nullable } from "babylonjs/types";
  25068. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25069. import { Scene } from "babylonjs/scene";
  25070. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25071. import { Node } from "babylonjs/node";
  25072. import { Mesh } from "babylonjs/Meshes/mesh";
  25073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25074. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25075. import { Viewport } from "babylonjs/Maths/math.viewport";
  25076. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25077. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25078. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25079. import { Ray } from "babylonjs/Culling/ray";
  25080. /**
  25081. * This is the base class of all the camera used in the application.
  25082. * @see http://doc.babylonjs.com/features/cameras
  25083. */
  25084. export class Camera extends Node {
  25085. /** @hidden */
  25086. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25087. /**
  25088. * This is the default projection mode used by the cameras.
  25089. * It helps recreating a feeling of perspective and better appreciate depth.
  25090. * This is the best way to simulate real life cameras.
  25091. */
  25092. static readonly PERSPECTIVE_CAMERA: number;
  25093. /**
  25094. * This helps creating camera with an orthographic mode.
  25095. * 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.
  25096. */
  25097. static readonly ORTHOGRAPHIC_CAMERA: number;
  25098. /**
  25099. * This is the default FOV mode for perspective cameras.
  25100. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25101. */
  25102. static readonly FOVMODE_VERTICAL_FIXED: number;
  25103. /**
  25104. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25105. */
  25106. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25107. /**
  25108. * This specifies ther is no need for a camera rig.
  25109. * Basically only one eye is rendered corresponding to the camera.
  25110. */
  25111. static readonly RIG_MODE_NONE: number;
  25112. /**
  25113. * Simulates a camera Rig with one blue eye and one red eye.
  25114. * This can be use with 3d blue and red glasses.
  25115. */
  25116. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25117. /**
  25118. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25119. */
  25120. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25121. /**
  25122. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25123. */
  25124. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25125. /**
  25126. * Defines that both eyes of the camera will be rendered over under each other.
  25127. */
  25128. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25129. /**
  25130. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25131. */
  25132. static readonly RIG_MODE_VR: number;
  25133. /**
  25134. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25135. */
  25136. static readonly RIG_MODE_WEBVR: number;
  25137. /**
  25138. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25139. */
  25140. static readonly RIG_MODE_CUSTOM: number;
  25141. /**
  25142. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25143. */
  25144. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25145. /**
  25146. * Define the input manager associated with the camera.
  25147. */
  25148. inputs: CameraInputsManager<Camera>;
  25149. /** @hidden */
  25150. _position: Vector3;
  25151. /**
  25152. * Define the current local position of the camera in the scene
  25153. */
  25154. position: Vector3;
  25155. /**
  25156. * The vector the camera should consider as up.
  25157. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25158. */
  25159. upVector: Vector3;
  25160. /**
  25161. * Define the current limit on the left side for an orthographic camera
  25162. * In scene unit
  25163. */
  25164. orthoLeft: Nullable<number>;
  25165. /**
  25166. * Define the current limit on the right side for an orthographic camera
  25167. * In scene unit
  25168. */
  25169. orthoRight: Nullable<number>;
  25170. /**
  25171. * Define the current limit on the bottom side for an orthographic camera
  25172. * In scene unit
  25173. */
  25174. orthoBottom: Nullable<number>;
  25175. /**
  25176. * Define the current limit on the top side for an orthographic camera
  25177. * In scene unit
  25178. */
  25179. orthoTop: Nullable<number>;
  25180. /**
  25181. * Field Of View is set in Radians. (default is 0.8)
  25182. */
  25183. fov: number;
  25184. /**
  25185. * Define the minimum distance the camera can see from.
  25186. * This is important to note that the depth buffer are not infinite and the closer it starts
  25187. * the more your scene might encounter depth fighting issue.
  25188. */
  25189. minZ: number;
  25190. /**
  25191. * Define the maximum distance the camera can see to.
  25192. * This is important to note that the depth buffer are not infinite and the further it end
  25193. * the more your scene might encounter depth fighting issue.
  25194. */
  25195. maxZ: number;
  25196. /**
  25197. * Define the default inertia of the camera.
  25198. * This helps giving a smooth feeling to the camera movement.
  25199. */
  25200. inertia: number;
  25201. /**
  25202. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25203. */
  25204. mode: number;
  25205. /**
  25206. * Define wether the camera is intermediate.
  25207. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25208. */
  25209. isIntermediate: boolean;
  25210. /**
  25211. * Define the viewport of the camera.
  25212. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25213. */
  25214. viewport: Viewport;
  25215. /**
  25216. * Restricts the camera to viewing objects with the same layerMask.
  25217. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25218. */
  25219. layerMask: number;
  25220. /**
  25221. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25222. */
  25223. fovMode: number;
  25224. /**
  25225. * Rig mode of the camera.
  25226. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25227. * This is normally controlled byt the camera themselves as internal use.
  25228. */
  25229. cameraRigMode: number;
  25230. /**
  25231. * Defines the distance between both "eyes" in case of a RIG
  25232. */
  25233. interaxialDistance: number;
  25234. /**
  25235. * Defines if stereoscopic rendering is done side by side or over under.
  25236. */
  25237. isStereoscopicSideBySide: boolean;
  25238. /**
  25239. * 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
  25240. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25241. * else in the scene. (Eg. security camera)
  25242. *
  25243. * 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)
  25244. */
  25245. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25246. /**
  25247. * When set, the camera will render to this render target instead of the default canvas
  25248. *
  25249. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25250. */
  25251. outputRenderTarget: Nullable<RenderTargetTexture>;
  25252. /**
  25253. * Observable triggered when the camera view matrix has changed.
  25254. */
  25255. onViewMatrixChangedObservable: Observable<Camera>;
  25256. /**
  25257. * Observable triggered when the camera Projection matrix has changed.
  25258. */
  25259. onProjectionMatrixChangedObservable: Observable<Camera>;
  25260. /**
  25261. * Observable triggered when the inputs have been processed.
  25262. */
  25263. onAfterCheckInputsObservable: Observable<Camera>;
  25264. /**
  25265. * Observable triggered when reset has been called and applied to the camera.
  25266. */
  25267. onRestoreStateObservable: Observable<Camera>;
  25268. /** @hidden */
  25269. _cameraRigParams: any;
  25270. /** @hidden */
  25271. _rigCameras: Camera[];
  25272. /** @hidden */
  25273. _rigPostProcess: Nullable<PostProcess>;
  25274. protected _webvrViewMatrix: Matrix;
  25275. /** @hidden */
  25276. _skipRendering: boolean;
  25277. /** @hidden */
  25278. _projectionMatrix: Matrix;
  25279. /** @hidden */
  25280. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25281. /** @hidden */
  25282. _activeMeshes: SmartArray<AbstractMesh>;
  25283. protected _globalPosition: Vector3;
  25284. /** @hidden */
  25285. _computedViewMatrix: Matrix;
  25286. private _doNotComputeProjectionMatrix;
  25287. private _transformMatrix;
  25288. private _frustumPlanes;
  25289. private _refreshFrustumPlanes;
  25290. private _storedFov;
  25291. private _stateStored;
  25292. /**
  25293. * Instantiates a new camera object.
  25294. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25295. * @see http://doc.babylonjs.com/features/cameras
  25296. * @param name Defines the name of the camera in the scene
  25297. * @param position Defines the position of the camera
  25298. * @param scene Defines the scene the camera belongs too
  25299. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25300. */
  25301. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25302. /**
  25303. * Store current camera state (fov, position, etc..)
  25304. * @returns the camera
  25305. */
  25306. storeState(): Camera;
  25307. /**
  25308. * Restores the camera state values if it has been stored. You must call storeState() first
  25309. */
  25310. protected _restoreStateValues(): boolean;
  25311. /**
  25312. * Restored camera state. You must call storeState() first.
  25313. * @returns true if restored and false otherwise
  25314. */
  25315. restoreState(): boolean;
  25316. /**
  25317. * Gets the class name of the camera.
  25318. * @returns the class name
  25319. */
  25320. getClassName(): string;
  25321. /** @hidden */
  25322. readonly _isCamera: boolean;
  25323. /**
  25324. * Gets a string representation of the camera useful for debug purpose.
  25325. * @param fullDetails Defines that a more verboe level of logging is required
  25326. * @returns the string representation
  25327. */
  25328. toString(fullDetails?: boolean): string;
  25329. /**
  25330. * Gets the current world space position of the camera.
  25331. */
  25332. readonly globalPosition: Vector3;
  25333. /**
  25334. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25335. * @returns the active meshe list
  25336. */
  25337. getActiveMeshes(): SmartArray<AbstractMesh>;
  25338. /**
  25339. * Check wether a mesh is part of the current active mesh list of the camera
  25340. * @param mesh Defines the mesh to check
  25341. * @returns true if active, false otherwise
  25342. */
  25343. isActiveMesh(mesh: Mesh): boolean;
  25344. /**
  25345. * Is this camera ready to be used/rendered
  25346. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25347. * @return true if the camera is ready
  25348. */
  25349. isReady(completeCheck?: boolean): boolean;
  25350. /** @hidden */
  25351. _initCache(): void;
  25352. /** @hidden */
  25353. _updateCache(ignoreParentClass?: boolean): void;
  25354. /** @hidden */
  25355. _isSynchronized(): boolean;
  25356. /** @hidden */
  25357. _isSynchronizedViewMatrix(): boolean;
  25358. /** @hidden */
  25359. _isSynchronizedProjectionMatrix(): boolean;
  25360. /**
  25361. * Attach the input controls to a specific dom element to get the input from.
  25362. * @param element Defines the element the controls should be listened from
  25363. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25364. */
  25365. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25366. /**
  25367. * Detach the current controls from the specified dom element.
  25368. * @param element Defines the element to stop listening the inputs from
  25369. */
  25370. detachControl(element: HTMLElement): void;
  25371. /**
  25372. * Update the camera state according to the different inputs gathered during the frame.
  25373. */
  25374. update(): void;
  25375. /** @hidden */
  25376. _checkInputs(): void;
  25377. /** @hidden */
  25378. readonly rigCameras: Camera[];
  25379. /**
  25380. * Gets the post process used by the rig cameras
  25381. */
  25382. readonly rigPostProcess: Nullable<PostProcess>;
  25383. /**
  25384. * Internal, gets the first post proces.
  25385. * @returns the first post process to be run on this camera.
  25386. */
  25387. _getFirstPostProcess(): Nullable<PostProcess>;
  25388. private _cascadePostProcessesToRigCams;
  25389. /**
  25390. * Attach a post process to the camera.
  25391. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25392. * @param postProcess The post process to attach to the camera
  25393. * @param insertAt The position of the post process in case several of them are in use in the scene
  25394. * @returns the position the post process has been inserted at
  25395. */
  25396. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25397. /**
  25398. * Detach a post process to the camera.
  25399. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25400. * @param postProcess The post process to detach from the camera
  25401. */
  25402. detachPostProcess(postProcess: PostProcess): void;
  25403. /**
  25404. * Gets the current world matrix of the camera
  25405. */
  25406. getWorldMatrix(): Matrix;
  25407. /** @hidden */
  25408. _getViewMatrix(): Matrix;
  25409. /**
  25410. * Gets the current view matrix of the camera.
  25411. * @param force forces the camera to recompute the matrix without looking at the cached state
  25412. * @returns the view matrix
  25413. */
  25414. getViewMatrix(force?: boolean): Matrix;
  25415. /**
  25416. * Freeze the projection matrix.
  25417. * It will prevent the cache check of the camera projection compute and can speed up perf
  25418. * if no parameter of the camera are meant to change
  25419. * @param projection Defines manually a projection if necessary
  25420. */
  25421. freezeProjectionMatrix(projection?: Matrix): void;
  25422. /**
  25423. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25424. */
  25425. unfreezeProjectionMatrix(): void;
  25426. /**
  25427. * Gets the current projection matrix of the camera.
  25428. * @param force forces the camera to recompute the matrix without looking at the cached state
  25429. * @returns the projection matrix
  25430. */
  25431. getProjectionMatrix(force?: boolean): Matrix;
  25432. /**
  25433. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25434. * @returns a Matrix
  25435. */
  25436. getTransformationMatrix(): Matrix;
  25437. private _updateFrustumPlanes;
  25438. /**
  25439. * Checks if a cullable object (mesh...) is in the camera frustum
  25440. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25441. * @param target The object to check
  25442. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25443. * @returns true if the object is in frustum otherwise false
  25444. */
  25445. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25446. /**
  25447. * Checks if a cullable object (mesh...) is in the camera frustum
  25448. * Unlike isInFrustum this cheks the full bounding box
  25449. * @param target The object to check
  25450. * @returns true if the object is in frustum otherwise false
  25451. */
  25452. isCompletelyInFrustum(target: ICullable): boolean;
  25453. /**
  25454. * Gets a ray in the forward direction from the camera.
  25455. * @param length Defines the length of the ray to create
  25456. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25457. * @param origin Defines the start point of the ray which defaults to the camera position
  25458. * @returns the forward ray
  25459. */
  25460. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25461. /**
  25462. * Releases resources associated with this node.
  25463. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25464. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25465. */
  25466. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25467. /** @hidden */
  25468. _isLeftCamera: boolean;
  25469. /**
  25470. * Gets the left camera of a rig setup in case of Rigged Camera
  25471. */
  25472. readonly isLeftCamera: boolean;
  25473. /** @hidden */
  25474. _isRightCamera: boolean;
  25475. /**
  25476. * Gets the right camera of a rig setup in case of Rigged Camera
  25477. */
  25478. readonly isRightCamera: boolean;
  25479. /**
  25480. * Gets the left camera of a rig setup in case of Rigged Camera
  25481. */
  25482. readonly leftCamera: Nullable<FreeCamera>;
  25483. /**
  25484. * Gets the right camera of a rig setup in case of Rigged Camera
  25485. */
  25486. readonly rightCamera: Nullable<FreeCamera>;
  25487. /**
  25488. * Gets the left camera target of a rig setup in case of Rigged Camera
  25489. * @returns the target position
  25490. */
  25491. getLeftTarget(): Nullable<Vector3>;
  25492. /**
  25493. * Gets the right camera target of a rig setup in case of Rigged Camera
  25494. * @returns the target position
  25495. */
  25496. getRightTarget(): Nullable<Vector3>;
  25497. /**
  25498. * @hidden
  25499. */
  25500. setCameraRigMode(mode: number, rigParams: any): void;
  25501. /** @hidden */
  25502. static _setStereoscopicRigMode(camera: Camera): void;
  25503. /** @hidden */
  25504. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25505. /** @hidden */
  25506. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25507. /** @hidden */
  25508. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25509. /** @hidden */
  25510. _getVRProjectionMatrix(): Matrix;
  25511. protected _updateCameraRotationMatrix(): void;
  25512. protected _updateWebVRCameraRotationMatrix(): void;
  25513. /**
  25514. * This function MUST be overwritten by the different WebVR cameras available.
  25515. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25516. * @hidden
  25517. */
  25518. _getWebVRProjectionMatrix(): Matrix;
  25519. /**
  25520. * This function MUST be overwritten by the different WebVR cameras available.
  25521. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25522. * @hidden
  25523. */
  25524. _getWebVRViewMatrix(): Matrix;
  25525. /** @hidden */
  25526. setCameraRigParameter(name: string, value: any): void;
  25527. /**
  25528. * needs to be overridden by children so sub has required properties to be copied
  25529. * @hidden
  25530. */
  25531. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25532. /**
  25533. * May need to be overridden by children
  25534. * @hidden
  25535. */
  25536. _updateRigCameras(): void;
  25537. /** @hidden */
  25538. _setupInputs(): void;
  25539. /**
  25540. * Serialiaze the camera setup to a json represention
  25541. * @returns the JSON representation
  25542. */
  25543. serialize(): any;
  25544. /**
  25545. * Clones the current camera.
  25546. * @param name The cloned camera name
  25547. * @returns the cloned camera
  25548. */
  25549. clone(name: string): Camera;
  25550. /**
  25551. * Gets the direction of the camera relative to a given local axis.
  25552. * @param localAxis Defines the reference axis to provide a relative direction.
  25553. * @return the direction
  25554. */
  25555. getDirection(localAxis: Vector3): Vector3;
  25556. /**
  25557. * Returns the current camera absolute rotation
  25558. */
  25559. readonly absoluteRotation: Quaternion;
  25560. /**
  25561. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25562. * @param localAxis Defines the reference axis to provide a relative direction.
  25563. * @param result Defines the vector to store the result in
  25564. */
  25565. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25566. /**
  25567. * Gets a camera constructor for a given camera type
  25568. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25569. * @param name The name of the camera the result will be able to instantiate
  25570. * @param scene The scene the result will construct the camera in
  25571. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25572. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25573. * @returns a factory method to construc the camera
  25574. */
  25575. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25576. /**
  25577. * Compute the world matrix of the camera.
  25578. * @returns the camera workd matrix
  25579. */
  25580. computeWorldMatrix(): Matrix;
  25581. /**
  25582. * Parse a JSON and creates the camera from the parsed information
  25583. * @param parsedCamera The JSON to parse
  25584. * @param scene The scene to instantiate the camera in
  25585. * @returns the newly constructed camera
  25586. */
  25587. static Parse(parsedCamera: any, scene: Scene): Camera;
  25588. }
  25589. }
  25590. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25591. import { Nullable } from "babylonjs/types";
  25592. import { Scene } from "babylonjs/scene";
  25593. import { Vector4 } from "babylonjs/Maths/math.vector";
  25594. import { Mesh } from "babylonjs/Meshes/mesh";
  25595. /**
  25596. * Class containing static functions to help procedurally build meshes
  25597. */
  25598. export class DiscBuilder {
  25599. /**
  25600. * Creates a plane polygonal mesh. By default, this is a disc
  25601. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25602. * * 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
  25603. * * 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
  25604. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25605. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25607. * @param name defines the name of the mesh
  25608. * @param options defines the options used to create the mesh
  25609. * @param scene defines the hosting scene
  25610. * @returns the plane polygonal mesh
  25611. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25612. */
  25613. static CreateDisc(name: string, options: {
  25614. radius?: number;
  25615. tessellation?: number;
  25616. arc?: number;
  25617. updatable?: boolean;
  25618. sideOrientation?: number;
  25619. frontUVs?: Vector4;
  25620. backUVs?: Vector4;
  25621. }, scene?: Nullable<Scene>): Mesh;
  25622. }
  25623. }
  25624. declare module "babylonjs/Particles/solidParticleSystem" {
  25625. import { Vector3 } from "babylonjs/Maths/math.vector";
  25626. import { Mesh } from "babylonjs/Meshes/mesh";
  25627. import { Scene, IDisposable } from "babylonjs/scene";
  25628. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25629. /**
  25630. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25631. *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.
  25632. * The SPS is also a particle system. It provides some methods to manage the particles.
  25633. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25634. *
  25635. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25636. */
  25637. export class SolidParticleSystem implements IDisposable {
  25638. /**
  25639. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25640. * Example : var p = SPS.particles[i];
  25641. */
  25642. particles: SolidParticle[];
  25643. /**
  25644. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25645. */
  25646. nbParticles: number;
  25647. /**
  25648. * If the particles must ever face the camera (default false). Useful for planar particles.
  25649. */
  25650. billboard: boolean;
  25651. /**
  25652. * Recompute normals when adding a shape
  25653. */
  25654. recomputeNormals: boolean;
  25655. /**
  25656. * This a counter ofr your own usage. It's not set by any SPS functions.
  25657. */
  25658. counter: number;
  25659. /**
  25660. * The SPS name. This name is also given to the underlying mesh.
  25661. */
  25662. name: string;
  25663. /**
  25664. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25665. */
  25666. mesh: Mesh;
  25667. /**
  25668. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25669. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25670. */
  25671. vars: any;
  25672. /**
  25673. * This array is populated when the SPS is set as 'pickable'.
  25674. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25675. * Each element of this array is an object `{idx: int, faceId: int}`.
  25676. * `idx` is the picked particle index in the `SPS.particles` array
  25677. * `faceId` is the picked face index counted within this particle.
  25678. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25679. */
  25680. pickedParticles: {
  25681. idx: number;
  25682. faceId: number;
  25683. }[];
  25684. /**
  25685. * This array is populated when `enableDepthSort` is set to true.
  25686. * Each element of this array is an instance of the class DepthSortedParticle.
  25687. */
  25688. depthSortedParticles: DepthSortedParticle[];
  25689. /**
  25690. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25691. * @hidden
  25692. */
  25693. _bSphereOnly: boolean;
  25694. /**
  25695. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25696. * @hidden
  25697. */
  25698. _bSphereRadiusFactor: number;
  25699. private _scene;
  25700. private _positions;
  25701. private _indices;
  25702. private _normals;
  25703. private _colors;
  25704. private _uvs;
  25705. private _indices32;
  25706. private _positions32;
  25707. private _normals32;
  25708. private _fixedNormal32;
  25709. private _colors32;
  25710. private _uvs32;
  25711. private _index;
  25712. private _updatable;
  25713. private _pickable;
  25714. private _isVisibilityBoxLocked;
  25715. private _alwaysVisible;
  25716. private _depthSort;
  25717. private _shapeCounter;
  25718. private _copy;
  25719. private _color;
  25720. private _computeParticleColor;
  25721. private _computeParticleTexture;
  25722. private _computeParticleRotation;
  25723. private _computeParticleVertex;
  25724. private _computeBoundingBox;
  25725. private _depthSortParticles;
  25726. private _camera;
  25727. private _mustUnrotateFixedNormals;
  25728. private _particlesIntersect;
  25729. private _needs32Bits;
  25730. /**
  25731. * Creates a SPS (Solid Particle System) object.
  25732. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25733. * @param scene (Scene) is the scene in which the SPS is added.
  25734. * @param options defines the options of the sps e.g.
  25735. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25736. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25737. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25738. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25739. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25740. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25741. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25742. */
  25743. constructor(name: string, scene: Scene, options?: {
  25744. updatable?: boolean;
  25745. isPickable?: boolean;
  25746. enableDepthSort?: boolean;
  25747. particleIntersection?: boolean;
  25748. boundingSphereOnly?: boolean;
  25749. bSphereRadiusFactor?: number;
  25750. });
  25751. /**
  25752. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25753. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25754. * @returns the created mesh
  25755. */
  25756. buildMesh(): Mesh;
  25757. /**
  25758. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25759. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25760. * Thus the particles generated from `digest()` have their property `position` set yet.
  25761. * @param mesh ( Mesh ) is the mesh to be digested
  25762. * @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
  25763. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25764. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25765. * @returns the current SPS
  25766. */
  25767. digest(mesh: Mesh, options?: {
  25768. facetNb?: number;
  25769. number?: number;
  25770. delta?: number;
  25771. }): SolidParticleSystem;
  25772. private _unrotateFixedNormals;
  25773. private _resetCopy;
  25774. private _meshBuilder;
  25775. private _posToShape;
  25776. private _uvsToShapeUV;
  25777. private _addParticle;
  25778. /**
  25779. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25780. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25781. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25782. * @param nb (positive integer) the number of particles to be created from this model
  25783. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25784. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25785. * @returns the number of shapes in the system
  25786. */
  25787. addShape(mesh: Mesh, nb: number, options?: {
  25788. positionFunction?: any;
  25789. vertexFunction?: any;
  25790. }): number;
  25791. private _rebuildParticle;
  25792. /**
  25793. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25794. * @returns the SPS.
  25795. */
  25796. rebuildMesh(): SolidParticleSystem;
  25797. /**
  25798. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25799. * This method calls `updateParticle()` for each particle of the SPS.
  25800. * For an animated SPS, it is usually called within the render loop.
  25801. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25802. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25803. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25804. * @returns the SPS.
  25805. */
  25806. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25807. /**
  25808. * Disposes the SPS.
  25809. */
  25810. dispose(): void;
  25811. /**
  25812. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25813. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25814. * @returns the SPS.
  25815. */
  25816. refreshVisibleSize(): SolidParticleSystem;
  25817. /**
  25818. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25819. * @param size the size (float) of the visibility box
  25820. * note : this doesn't lock the SPS mesh bounding box.
  25821. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25822. */
  25823. setVisibilityBox(size: number): void;
  25824. /**
  25825. * Gets whether the SPS as always visible or not
  25826. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25827. */
  25828. /**
  25829. * Sets the SPS as always visible or not
  25830. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25831. */
  25832. isAlwaysVisible: boolean;
  25833. /**
  25834. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25835. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25836. */
  25837. /**
  25838. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25839. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25840. */
  25841. isVisibilityBoxLocked: boolean;
  25842. /**
  25843. * Tells to `setParticles()` to compute the particle rotations or not.
  25844. * Default value : true. The SPS is faster when it's set to false.
  25845. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25846. */
  25847. /**
  25848. * Gets if `setParticles()` computes the particle rotations or not.
  25849. * Default value : true. The SPS is faster when it's set to false.
  25850. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25851. */
  25852. computeParticleRotation: boolean;
  25853. /**
  25854. * Tells to `setParticles()` to compute the particle colors or not.
  25855. * Default value : true. The SPS is faster when it's set to false.
  25856. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25857. */
  25858. /**
  25859. * Gets if `setParticles()` computes the particle colors or not.
  25860. * Default value : true. The SPS is faster when it's set to false.
  25861. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25862. */
  25863. computeParticleColor: boolean;
  25864. /**
  25865. * Gets if `setParticles()` computes the particle textures or not.
  25866. * Default value : true. The SPS is faster when it's set to false.
  25867. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25868. */
  25869. computeParticleTexture: boolean;
  25870. /**
  25871. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25872. * Default value : false. The SPS is faster when it's set to false.
  25873. * Note : the particle custom vertex positions aren't stored values.
  25874. */
  25875. /**
  25876. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25877. * Default value : false. The SPS is faster when it's set to false.
  25878. * Note : the particle custom vertex positions aren't stored values.
  25879. */
  25880. computeParticleVertex: boolean;
  25881. /**
  25882. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25883. */
  25884. /**
  25885. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25886. */
  25887. computeBoundingBox: boolean;
  25888. /**
  25889. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25890. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25891. * Default : `true`
  25892. */
  25893. /**
  25894. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25895. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25896. * Default : `true`
  25897. */
  25898. depthSortParticles: boolean;
  25899. /**
  25900. * This function does nothing. It may be overwritten to set all the particle first values.
  25901. * The SPS doesn't call this function, you may have to call it by your own.
  25902. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25903. */
  25904. initParticles(): void;
  25905. /**
  25906. * This function does nothing. It may be overwritten to recycle a particle.
  25907. * The SPS doesn't call this function, you may have to call it by your own.
  25908. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25909. * @param particle The particle to recycle
  25910. * @returns the recycled particle
  25911. */
  25912. recycleParticle(particle: SolidParticle): SolidParticle;
  25913. /**
  25914. * Updates a particle : this function should be overwritten by the user.
  25915. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25916. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25917. * @example : just set a particle position or velocity and recycle conditions
  25918. * @param particle The particle to update
  25919. * @returns the updated particle
  25920. */
  25921. updateParticle(particle: SolidParticle): SolidParticle;
  25922. /**
  25923. * Updates a vertex of a particle : it can be overwritten by the user.
  25924. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25925. * @param particle the current particle
  25926. * @param vertex the current index of the current particle
  25927. * @param pt the index of the current vertex in the particle shape
  25928. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25929. * @example : just set a vertex particle position
  25930. * @returns the updated vertex
  25931. */
  25932. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25933. /**
  25934. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25935. * This does nothing and may be overwritten by the user.
  25936. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25937. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25938. * @param update the boolean update value actually passed to setParticles()
  25939. */
  25940. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25941. /**
  25942. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25943. * This will be passed three parameters.
  25944. * This does nothing and may be overwritten by the user.
  25945. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25946. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25947. * @param update the boolean update value actually passed to setParticles()
  25948. */
  25949. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25950. }
  25951. }
  25952. declare module "babylonjs/Particles/solidParticle" {
  25953. import { Nullable } from "babylonjs/types";
  25954. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  25955. import { Color4 } from "babylonjs/Maths/math.color";
  25956. import { Mesh } from "babylonjs/Meshes/mesh";
  25957. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25958. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  25959. import { Plane } from "babylonjs/Maths/math.plane";
  25960. /**
  25961. * Represents one particle of a solid particle system.
  25962. */
  25963. export class SolidParticle {
  25964. /**
  25965. * particle global index
  25966. */
  25967. idx: number;
  25968. /**
  25969. * The color of the particle
  25970. */
  25971. color: Nullable<Color4>;
  25972. /**
  25973. * The world space position of the particle.
  25974. */
  25975. position: Vector3;
  25976. /**
  25977. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25978. */
  25979. rotation: Vector3;
  25980. /**
  25981. * The world space rotation quaternion of the particle.
  25982. */
  25983. rotationQuaternion: Nullable<Quaternion>;
  25984. /**
  25985. * The scaling of the particle.
  25986. */
  25987. scaling: Vector3;
  25988. /**
  25989. * The uvs of the particle.
  25990. */
  25991. uvs: Vector4;
  25992. /**
  25993. * The current speed of the particle.
  25994. */
  25995. velocity: Vector3;
  25996. /**
  25997. * The pivot point in the particle local space.
  25998. */
  25999. pivot: Vector3;
  26000. /**
  26001. * Must the particle be translated from its pivot point in its local space ?
  26002. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26003. * Default : false
  26004. */
  26005. translateFromPivot: boolean;
  26006. /**
  26007. * Is the particle active or not ?
  26008. */
  26009. alive: boolean;
  26010. /**
  26011. * Is the particle visible or not ?
  26012. */
  26013. isVisible: boolean;
  26014. /**
  26015. * Index of this particle in the global "positions" array (Internal use)
  26016. * @hidden
  26017. */
  26018. _pos: number;
  26019. /**
  26020. * @hidden Index of this particle in the global "indices" array (Internal use)
  26021. */
  26022. _ind: number;
  26023. /**
  26024. * @hidden ModelShape of this particle (Internal use)
  26025. */
  26026. _model: ModelShape;
  26027. /**
  26028. * ModelShape id of this particle
  26029. */
  26030. shapeId: number;
  26031. /**
  26032. * Index of the particle in its shape id
  26033. */
  26034. idxInShape: number;
  26035. /**
  26036. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26037. */
  26038. _modelBoundingInfo: BoundingInfo;
  26039. /**
  26040. * @hidden Particle BoundingInfo object (Internal use)
  26041. */
  26042. _boundingInfo: BoundingInfo;
  26043. /**
  26044. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26045. */
  26046. _sps: SolidParticleSystem;
  26047. /**
  26048. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26049. */
  26050. _stillInvisible: boolean;
  26051. /**
  26052. * @hidden Last computed particle rotation matrix
  26053. */
  26054. _rotationMatrix: number[];
  26055. /**
  26056. * Parent particle Id, if any.
  26057. * Default null.
  26058. */
  26059. parentId: Nullable<number>;
  26060. /**
  26061. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26062. * The possible values are :
  26063. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26064. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26065. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26066. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26067. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26068. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26069. * */
  26070. cullingStrategy: number;
  26071. /**
  26072. * @hidden Internal global position in the SPS.
  26073. */
  26074. _globalPosition: Vector3;
  26075. /**
  26076. * Creates a Solid Particle object.
  26077. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26078. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26079. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26080. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26081. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26082. * @param shapeId (integer) is the model shape identifier in the SPS.
  26083. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26084. * @param sps defines the sps it is associated to
  26085. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26086. */
  26087. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26088. /**
  26089. * Legacy support, changed scale to scaling
  26090. */
  26091. /**
  26092. * Legacy support, changed scale to scaling
  26093. */
  26094. scale: Vector3;
  26095. /**
  26096. * Legacy support, changed quaternion to rotationQuaternion
  26097. */
  26098. /**
  26099. * Legacy support, changed quaternion to rotationQuaternion
  26100. */
  26101. quaternion: Nullable<Quaternion>;
  26102. /**
  26103. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26104. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26105. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26106. * @returns true if it intersects
  26107. */
  26108. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26109. /**
  26110. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26111. * A particle is in the frustum if its bounding box intersects the frustum
  26112. * @param frustumPlanes defines the frustum to test
  26113. * @returns true if the particle is in the frustum planes
  26114. */
  26115. isInFrustum(frustumPlanes: Plane[]): boolean;
  26116. /**
  26117. * get the rotation matrix of the particle
  26118. * @hidden
  26119. */
  26120. getRotationMatrix(m: Matrix): void;
  26121. }
  26122. /**
  26123. * Represents the shape of the model used by one particle of a solid particle system.
  26124. * SPS internal tool, don't use it manually.
  26125. */
  26126. export class ModelShape {
  26127. /**
  26128. * The shape id
  26129. * @hidden
  26130. */
  26131. shapeID: number;
  26132. /**
  26133. * flat array of model positions (internal use)
  26134. * @hidden
  26135. */
  26136. _shape: Vector3[];
  26137. /**
  26138. * flat array of model UVs (internal use)
  26139. * @hidden
  26140. */
  26141. _shapeUV: number[];
  26142. /**
  26143. * length of the shape in the model indices array (internal use)
  26144. * @hidden
  26145. */
  26146. _indicesLength: number;
  26147. /**
  26148. * Custom position function (internal use)
  26149. * @hidden
  26150. */
  26151. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26152. /**
  26153. * Custom vertex function (internal use)
  26154. * @hidden
  26155. */
  26156. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26157. /**
  26158. * 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.
  26159. * SPS internal tool, don't use it manually.
  26160. * @hidden
  26161. */
  26162. 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>);
  26163. }
  26164. /**
  26165. * Represents a Depth Sorted Particle in the solid particle system.
  26166. */
  26167. export class DepthSortedParticle {
  26168. /**
  26169. * Index of the particle in the "indices" array
  26170. */
  26171. ind: number;
  26172. /**
  26173. * Length of the particle shape in the "indices" array
  26174. */
  26175. indicesLength: number;
  26176. /**
  26177. * Squared distance from the particle to the camera
  26178. */
  26179. sqDistance: number;
  26180. }
  26181. }
  26182. declare module "babylonjs/Collisions/meshCollisionData" {
  26183. import { Collider } from "babylonjs/Collisions/collider";
  26184. import { Vector3 } from "babylonjs/Maths/math.vector";
  26185. import { Nullable } from "babylonjs/types";
  26186. import { Observer } from "babylonjs/Misc/observable";
  26187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26188. /**
  26189. * @hidden
  26190. */
  26191. export class _MeshCollisionData {
  26192. _checkCollisions: boolean;
  26193. _collisionMask: number;
  26194. _collisionGroup: number;
  26195. _collider: Nullable<Collider>;
  26196. _oldPositionForCollisions: Vector3;
  26197. _diffPositionForCollisions: Vector3;
  26198. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26199. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26200. }
  26201. }
  26202. declare module "babylonjs/Meshes/abstractMesh" {
  26203. import { Observable } from "babylonjs/Misc/observable";
  26204. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26205. import { Camera } from "babylonjs/Cameras/camera";
  26206. import { Scene, IDisposable } from "babylonjs/scene";
  26207. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26208. import { Node } from "babylonjs/node";
  26209. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26210. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26211. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26212. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26213. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26214. import { Material } from "babylonjs/Materials/material";
  26215. import { Light } from "babylonjs/Lights/light";
  26216. import { Skeleton } from "babylonjs/Bones/skeleton";
  26217. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26218. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26219. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26220. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26221. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26222. import { Plane } from "babylonjs/Maths/math.plane";
  26223. import { Ray } from "babylonjs/Culling/ray";
  26224. import { Collider } from "babylonjs/Collisions/collider";
  26225. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26226. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26227. /** @hidden */
  26228. class _FacetDataStorage {
  26229. facetPositions: Vector3[];
  26230. facetNormals: Vector3[];
  26231. facetPartitioning: number[][];
  26232. facetNb: number;
  26233. partitioningSubdivisions: number;
  26234. partitioningBBoxRatio: number;
  26235. facetDataEnabled: boolean;
  26236. facetParameters: any;
  26237. bbSize: Vector3;
  26238. subDiv: {
  26239. max: number;
  26240. X: number;
  26241. Y: number;
  26242. Z: number;
  26243. };
  26244. facetDepthSort: boolean;
  26245. facetDepthSortEnabled: boolean;
  26246. depthSortedIndices: IndicesArray;
  26247. depthSortedFacets: {
  26248. ind: number;
  26249. sqDistance: number;
  26250. }[];
  26251. facetDepthSortFunction: (f1: {
  26252. ind: number;
  26253. sqDistance: number;
  26254. }, f2: {
  26255. ind: number;
  26256. sqDistance: number;
  26257. }) => number;
  26258. facetDepthSortFrom: Vector3;
  26259. facetDepthSortOrigin: Vector3;
  26260. invertedMatrix: Matrix;
  26261. }
  26262. /**
  26263. * @hidden
  26264. **/
  26265. class _InternalAbstractMeshDataInfo {
  26266. _hasVertexAlpha: boolean;
  26267. _useVertexColors: boolean;
  26268. _numBoneInfluencers: number;
  26269. _applyFog: boolean;
  26270. _receiveShadows: boolean;
  26271. _facetData: _FacetDataStorage;
  26272. _visibility: number;
  26273. _skeleton: Nullable<Skeleton>;
  26274. _layerMask: number;
  26275. _computeBonesUsingShaders: boolean;
  26276. _isActive: boolean;
  26277. _onlyForInstances: boolean;
  26278. _isActiveIntermediate: boolean;
  26279. _onlyForInstancesIntermediate: boolean;
  26280. }
  26281. /**
  26282. * Class used to store all common mesh properties
  26283. */
  26284. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26285. /** No occlusion */
  26286. static OCCLUSION_TYPE_NONE: number;
  26287. /** Occlusion set to optimisitic */
  26288. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26289. /** Occlusion set to strict */
  26290. static OCCLUSION_TYPE_STRICT: number;
  26291. /** Use an accurante occlusion algorithm */
  26292. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26293. /** Use a conservative occlusion algorithm */
  26294. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26295. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26296. * Test order :
  26297. * Is the bounding sphere outside the frustum ?
  26298. * If not, are the bounding box vertices outside the frustum ?
  26299. * It not, then the cullable object is in the frustum.
  26300. */
  26301. static readonly CULLINGSTRATEGY_STANDARD: number;
  26302. /** Culling strategy : Bounding Sphere Only.
  26303. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26304. * It's also less accurate than the standard because some not visible objects can still be selected.
  26305. * Test : is the bounding sphere outside the frustum ?
  26306. * If not, then the cullable object is in the frustum.
  26307. */
  26308. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26309. /** Culling strategy : Optimistic Inclusion.
  26310. * This in an inclusion test first, then the standard exclusion test.
  26311. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26312. * 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.
  26313. * Anyway, it's as accurate as the standard strategy.
  26314. * Test :
  26315. * Is the cullable object bounding sphere center in the frustum ?
  26316. * If not, apply the default culling strategy.
  26317. */
  26318. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26319. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26320. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26321. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26322. * 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.
  26323. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26324. * Test :
  26325. * Is the cullable object bounding sphere center in the frustum ?
  26326. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26327. */
  26328. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26329. /**
  26330. * No billboard
  26331. */
  26332. static readonly BILLBOARDMODE_NONE: number;
  26333. /** Billboard on X axis */
  26334. static readonly BILLBOARDMODE_X: number;
  26335. /** Billboard on Y axis */
  26336. static readonly BILLBOARDMODE_Y: number;
  26337. /** Billboard on Z axis */
  26338. static readonly BILLBOARDMODE_Z: number;
  26339. /** Billboard on all axes */
  26340. static readonly BILLBOARDMODE_ALL: number;
  26341. /** Billboard on using position instead of orientation */
  26342. static readonly BILLBOARDMODE_USE_POSITION: number;
  26343. /** @hidden */
  26344. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26345. /**
  26346. * The culling strategy to use to check whether the mesh must be rendered or not.
  26347. * This value can be changed at any time and will be used on the next render mesh selection.
  26348. * The possible values are :
  26349. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26350. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26351. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26352. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26353. * Please read each static variable documentation to get details about the culling process.
  26354. * */
  26355. cullingStrategy: number;
  26356. /**
  26357. * Gets the number of facets in the mesh
  26358. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26359. */
  26360. readonly facetNb: number;
  26361. /**
  26362. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26363. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26364. */
  26365. partitioningSubdivisions: number;
  26366. /**
  26367. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26368. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26369. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26370. */
  26371. partitioningBBoxRatio: number;
  26372. /**
  26373. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26374. * Works only for updatable meshes.
  26375. * Doesn't work with multi-materials
  26376. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26377. */
  26378. mustDepthSortFacets: boolean;
  26379. /**
  26380. * The location (Vector3) where the facet depth sort must be computed from.
  26381. * By default, the active camera position.
  26382. * Used only when facet depth sort is enabled
  26383. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26384. */
  26385. facetDepthSortFrom: Vector3;
  26386. /**
  26387. * gets a boolean indicating if facetData is enabled
  26388. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26389. */
  26390. readonly isFacetDataEnabled: boolean;
  26391. /** @hidden */
  26392. _updateNonUniformScalingState(value: boolean): boolean;
  26393. /**
  26394. * An event triggered when this mesh collides with another one
  26395. */
  26396. onCollideObservable: Observable<AbstractMesh>;
  26397. /** Set a function to call when this mesh collides with another one */
  26398. onCollide: () => void;
  26399. /**
  26400. * An event triggered when the collision's position changes
  26401. */
  26402. onCollisionPositionChangeObservable: Observable<Vector3>;
  26403. /** Set a function to call when the collision's position changes */
  26404. onCollisionPositionChange: () => void;
  26405. /**
  26406. * An event triggered when material is changed
  26407. */
  26408. onMaterialChangedObservable: Observable<AbstractMesh>;
  26409. /**
  26410. * Gets or sets the orientation for POV movement & rotation
  26411. */
  26412. definedFacingForward: boolean;
  26413. /** @hidden */
  26414. _occlusionQuery: Nullable<WebGLQuery>;
  26415. /** @hidden */
  26416. _renderingGroup: Nullable<RenderingGroup>;
  26417. /**
  26418. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26419. */
  26420. /**
  26421. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26422. */
  26423. visibility: number;
  26424. /** Gets or sets the alpha index used to sort transparent meshes
  26425. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26426. */
  26427. alphaIndex: number;
  26428. /**
  26429. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26430. */
  26431. isVisible: boolean;
  26432. /**
  26433. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26434. */
  26435. isPickable: boolean;
  26436. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26437. showSubMeshesBoundingBox: boolean;
  26438. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26439. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26440. */
  26441. isBlocker: boolean;
  26442. /**
  26443. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26444. */
  26445. enablePointerMoveEvents: boolean;
  26446. /**
  26447. * Specifies the rendering group id for this mesh (0 by default)
  26448. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26449. */
  26450. renderingGroupId: number;
  26451. private _material;
  26452. /** Gets or sets current material */
  26453. material: Nullable<Material>;
  26454. /**
  26455. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26456. * @see http://doc.babylonjs.com/babylon101/shadows
  26457. */
  26458. receiveShadows: boolean;
  26459. /** Defines color to use when rendering outline */
  26460. outlineColor: Color3;
  26461. /** Define width to use when rendering outline */
  26462. outlineWidth: number;
  26463. /** Defines color to use when rendering overlay */
  26464. overlayColor: Color3;
  26465. /** Defines alpha to use when rendering overlay */
  26466. overlayAlpha: number;
  26467. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26468. hasVertexAlpha: boolean;
  26469. /** 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) */
  26470. useVertexColors: boolean;
  26471. /**
  26472. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26473. */
  26474. computeBonesUsingShaders: boolean;
  26475. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26476. numBoneInfluencers: number;
  26477. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26478. applyFog: boolean;
  26479. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26480. useOctreeForRenderingSelection: boolean;
  26481. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26482. useOctreeForPicking: boolean;
  26483. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26484. useOctreeForCollisions: boolean;
  26485. /**
  26486. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26487. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26488. */
  26489. layerMask: number;
  26490. /**
  26491. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26492. */
  26493. alwaysSelectAsActiveMesh: boolean;
  26494. /**
  26495. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26496. */
  26497. doNotSyncBoundingInfo: boolean;
  26498. /**
  26499. * Gets or sets the current action manager
  26500. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26501. */
  26502. actionManager: Nullable<AbstractActionManager>;
  26503. private _meshCollisionData;
  26504. /**
  26505. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26506. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26507. */
  26508. ellipsoid: Vector3;
  26509. /**
  26510. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26511. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26512. */
  26513. ellipsoidOffset: Vector3;
  26514. /**
  26515. * Gets or sets a collision mask used to mask collisions (default is -1).
  26516. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26517. */
  26518. collisionMask: number;
  26519. /**
  26520. * Gets or sets the current collision group mask (-1 by default).
  26521. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26522. */
  26523. collisionGroup: number;
  26524. /**
  26525. * Defines edge width used when edgesRenderer is enabled
  26526. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26527. */
  26528. edgesWidth: number;
  26529. /**
  26530. * Defines edge color used when edgesRenderer is enabled
  26531. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26532. */
  26533. edgesColor: Color4;
  26534. /** @hidden */
  26535. _edgesRenderer: Nullable<IEdgesRenderer>;
  26536. /** @hidden */
  26537. _masterMesh: Nullable<AbstractMesh>;
  26538. /** @hidden */
  26539. _boundingInfo: Nullable<BoundingInfo>;
  26540. /** @hidden */
  26541. _renderId: number;
  26542. /**
  26543. * Gets or sets the list of subMeshes
  26544. * @see http://doc.babylonjs.com/how_to/multi_materials
  26545. */
  26546. subMeshes: SubMesh[];
  26547. /** @hidden */
  26548. _intersectionsInProgress: AbstractMesh[];
  26549. /** @hidden */
  26550. _unIndexed: boolean;
  26551. /** @hidden */
  26552. _lightSources: Light[];
  26553. /** Gets the list of lights affecting that mesh */
  26554. readonly lightSources: Light[];
  26555. /** @hidden */
  26556. readonly _positions: Nullable<Vector3[]>;
  26557. /** @hidden */
  26558. _waitingData: {
  26559. lods: Nullable<any>;
  26560. actions: Nullable<any>;
  26561. freezeWorldMatrix: Nullable<boolean>;
  26562. };
  26563. /** @hidden */
  26564. _bonesTransformMatrices: Nullable<Float32Array>;
  26565. /** @hidden */
  26566. _transformMatrixTexture: Nullable<RawTexture>;
  26567. /**
  26568. * Gets or sets a skeleton to apply skining transformations
  26569. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26570. */
  26571. skeleton: Nullable<Skeleton>;
  26572. /**
  26573. * An event triggered when the mesh is rebuilt.
  26574. */
  26575. onRebuildObservable: Observable<AbstractMesh>;
  26576. /**
  26577. * Creates a new AbstractMesh
  26578. * @param name defines the name of the mesh
  26579. * @param scene defines the hosting scene
  26580. */
  26581. constructor(name: string, scene?: Nullable<Scene>);
  26582. /**
  26583. * Returns the string "AbstractMesh"
  26584. * @returns "AbstractMesh"
  26585. */
  26586. getClassName(): string;
  26587. /**
  26588. * Gets a string representation of the current mesh
  26589. * @param fullDetails defines a boolean indicating if full details must be included
  26590. * @returns a string representation of the current mesh
  26591. */
  26592. toString(fullDetails?: boolean): string;
  26593. /**
  26594. * @hidden
  26595. */
  26596. protected _getEffectiveParent(): Nullable<Node>;
  26597. /** @hidden */
  26598. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26599. /** @hidden */
  26600. _rebuild(): void;
  26601. /** @hidden */
  26602. _resyncLightSources(): void;
  26603. /** @hidden */
  26604. _resyncLighSource(light: Light): void;
  26605. /** @hidden */
  26606. _unBindEffect(): void;
  26607. /** @hidden */
  26608. _removeLightSource(light: Light, dispose: boolean): void;
  26609. private _markSubMeshesAsDirty;
  26610. /** @hidden */
  26611. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26612. /** @hidden */
  26613. _markSubMeshesAsAttributesDirty(): void;
  26614. /** @hidden */
  26615. _markSubMeshesAsMiscDirty(): void;
  26616. /**
  26617. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26618. */
  26619. scaling: Vector3;
  26620. /**
  26621. * Returns true if the mesh is blocked. Implemented by child classes
  26622. */
  26623. readonly isBlocked: boolean;
  26624. /**
  26625. * Returns the mesh itself by default. Implemented by child classes
  26626. * @param camera defines the camera to use to pick the right LOD level
  26627. * @returns the currentAbstractMesh
  26628. */
  26629. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26630. /**
  26631. * Returns 0 by default. Implemented by child classes
  26632. * @returns an integer
  26633. */
  26634. getTotalVertices(): number;
  26635. /**
  26636. * Returns a positive integer : the total number of indices in this mesh geometry.
  26637. * @returns the numner of indices or zero if the mesh has no geometry.
  26638. */
  26639. getTotalIndices(): number;
  26640. /**
  26641. * Returns null by default. Implemented by child classes
  26642. * @returns null
  26643. */
  26644. getIndices(): Nullable<IndicesArray>;
  26645. /**
  26646. * Returns the array of the requested vertex data kind. Implemented by child classes
  26647. * @param kind defines the vertex data kind to use
  26648. * @returns null
  26649. */
  26650. getVerticesData(kind: string): Nullable<FloatArray>;
  26651. /**
  26652. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26653. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26654. * Note that a new underlying VertexBuffer object is created each call.
  26655. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26656. * @param kind defines vertex data kind:
  26657. * * VertexBuffer.PositionKind
  26658. * * VertexBuffer.UVKind
  26659. * * VertexBuffer.UV2Kind
  26660. * * VertexBuffer.UV3Kind
  26661. * * VertexBuffer.UV4Kind
  26662. * * VertexBuffer.UV5Kind
  26663. * * VertexBuffer.UV6Kind
  26664. * * VertexBuffer.ColorKind
  26665. * * VertexBuffer.MatricesIndicesKind
  26666. * * VertexBuffer.MatricesIndicesExtraKind
  26667. * * VertexBuffer.MatricesWeightsKind
  26668. * * VertexBuffer.MatricesWeightsExtraKind
  26669. * @param data defines the data source
  26670. * @param updatable defines if the data must be flagged as updatable (or static)
  26671. * @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
  26672. * @returns the current mesh
  26673. */
  26674. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26675. /**
  26676. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26677. * If the mesh has no geometry, it is simply returned as it is.
  26678. * @param kind defines vertex data kind:
  26679. * * VertexBuffer.PositionKind
  26680. * * VertexBuffer.UVKind
  26681. * * VertexBuffer.UV2Kind
  26682. * * VertexBuffer.UV3Kind
  26683. * * VertexBuffer.UV4Kind
  26684. * * VertexBuffer.UV5Kind
  26685. * * VertexBuffer.UV6Kind
  26686. * * VertexBuffer.ColorKind
  26687. * * VertexBuffer.MatricesIndicesKind
  26688. * * VertexBuffer.MatricesIndicesExtraKind
  26689. * * VertexBuffer.MatricesWeightsKind
  26690. * * VertexBuffer.MatricesWeightsExtraKind
  26691. * @param data defines the data source
  26692. * @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
  26693. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26694. * @returns the current mesh
  26695. */
  26696. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26697. /**
  26698. * Sets the mesh indices,
  26699. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26700. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26701. * @param totalVertices Defines the total number of vertices
  26702. * @returns the current mesh
  26703. */
  26704. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26705. /**
  26706. * Gets a boolean indicating if specific vertex data is present
  26707. * @param kind defines the vertex data kind to use
  26708. * @returns true is data kind is present
  26709. */
  26710. isVerticesDataPresent(kind: string): boolean;
  26711. /**
  26712. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26713. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26714. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26715. * @returns a BoundingInfo
  26716. */
  26717. getBoundingInfo(): BoundingInfo;
  26718. /**
  26719. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26720. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26721. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26722. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26723. * @returns the current mesh
  26724. */
  26725. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26726. /**
  26727. * Overwrite the current bounding info
  26728. * @param boundingInfo defines the new bounding info
  26729. * @returns the current mesh
  26730. */
  26731. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26732. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26733. readonly useBones: boolean;
  26734. /** @hidden */
  26735. _preActivate(): void;
  26736. /** @hidden */
  26737. _preActivateForIntermediateRendering(renderId: number): void;
  26738. /** @hidden */
  26739. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26740. /** @hidden */
  26741. _postActivate(): void;
  26742. /** @hidden */
  26743. _freeze(): void;
  26744. /** @hidden */
  26745. _unFreeze(): void;
  26746. /**
  26747. * Gets the current world matrix
  26748. * @returns a Matrix
  26749. */
  26750. getWorldMatrix(): Matrix;
  26751. /** @hidden */
  26752. _getWorldMatrixDeterminant(): number;
  26753. /**
  26754. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26755. */
  26756. readonly isAnInstance: boolean;
  26757. /**
  26758. * Gets a boolean indicating if this mesh has instances
  26759. */
  26760. readonly hasInstances: boolean;
  26761. /**
  26762. * Perform relative position change from the point of view of behind the front of the mesh.
  26763. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26764. * Supports definition of mesh facing forward or backward
  26765. * @param amountRight defines the distance on the right axis
  26766. * @param amountUp defines the distance on the up axis
  26767. * @param amountForward defines the distance on the forward axis
  26768. * @returns the current mesh
  26769. */
  26770. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26771. /**
  26772. * Calculate relative position change from the point of view of behind the front of the mesh.
  26773. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26774. * Supports definition of mesh facing forward or backward
  26775. * @param amountRight defines the distance on the right axis
  26776. * @param amountUp defines the distance on the up axis
  26777. * @param amountForward defines the distance on the forward axis
  26778. * @returns the new displacement vector
  26779. */
  26780. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26781. /**
  26782. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26783. * Supports definition of mesh facing forward or backward
  26784. * @param flipBack defines the flip
  26785. * @param twirlClockwise defines the twirl
  26786. * @param tiltRight defines the tilt
  26787. * @returns the current mesh
  26788. */
  26789. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26790. /**
  26791. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26792. * Supports definition of mesh facing forward or backward.
  26793. * @param flipBack defines the flip
  26794. * @param twirlClockwise defines the twirl
  26795. * @param tiltRight defines the tilt
  26796. * @returns the new rotation vector
  26797. */
  26798. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26799. /**
  26800. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26801. * This means the mesh underlying bounding box and sphere are recomputed.
  26802. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26803. * @returns the current mesh
  26804. */
  26805. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26806. /** @hidden */
  26807. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26808. /** @hidden */
  26809. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26810. /** @hidden */
  26811. _updateBoundingInfo(): AbstractMesh;
  26812. /** @hidden */
  26813. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26814. /** @hidden */
  26815. protected _afterComputeWorldMatrix(): void;
  26816. /** @hidden */
  26817. readonly _effectiveMesh: AbstractMesh;
  26818. /**
  26819. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26820. * A mesh is in the frustum if its bounding box intersects the frustum
  26821. * @param frustumPlanes defines the frustum to test
  26822. * @returns true if the mesh is in the frustum planes
  26823. */
  26824. isInFrustum(frustumPlanes: Plane[]): boolean;
  26825. /**
  26826. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26827. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26828. * @param frustumPlanes defines the frustum to test
  26829. * @returns true if the mesh is completely in the frustum planes
  26830. */
  26831. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26832. /**
  26833. * True if the mesh intersects another mesh or a SolidParticle object
  26834. * @param mesh defines a target mesh or SolidParticle to test
  26835. * @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)
  26836. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26837. * @returns true if there is an intersection
  26838. */
  26839. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26840. /**
  26841. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26842. * @param point defines the point to test
  26843. * @returns true if there is an intersection
  26844. */
  26845. intersectsPoint(point: Vector3): boolean;
  26846. /**
  26847. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26848. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26849. */
  26850. checkCollisions: boolean;
  26851. /**
  26852. * Gets Collider object used to compute collisions (not physics)
  26853. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26854. */
  26855. readonly collider: Nullable<Collider>;
  26856. /**
  26857. * Move the mesh using collision engine
  26858. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26859. * @param displacement defines the requested displacement vector
  26860. * @returns the current mesh
  26861. */
  26862. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26863. private _onCollisionPositionChange;
  26864. /** @hidden */
  26865. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26866. /** @hidden */
  26867. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26868. /** @hidden */
  26869. _checkCollision(collider: Collider): AbstractMesh;
  26870. /** @hidden */
  26871. _generatePointsArray(): boolean;
  26872. /**
  26873. * Checks if the passed Ray intersects with the mesh
  26874. * @param ray defines the ray to use
  26875. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26876. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26877. * @returns the picking info
  26878. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26879. */
  26880. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26881. /**
  26882. * Clones the current mesh
  26883. * @param name defines the mesh name
  26884. * @param newParent defines the new mesh parent
  26885. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26886. * @returns the new mesh
  26887. */
  26888. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26889. /**
  26890. * Disposes all the submeshes of the current meshnp
  26891. * @returns the current mesh
  26892. */
  26893. releaseSubMeshes(): AbstractMesh;
  26894. /**
  26895. * Releases resources associated with this abstract mesh.
  26896. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26897. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26898. */
  26899. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26900. /**
  26901. * Adds the passed mesh as a child to the current mesh
  26902. * @param mesh defines the child mesh
  26903. * @returns the current mesh
  26904. */
  26905. addChild(mesh: AbstractMesh): AbstractMesh;
  26906. /**
  26907. * Removes the passed mesh from the current mesh children list
  26908. * @param mesh defines the child mesh
  26909. * @returns the current mesh
  26910. */
  26911. removeChild(mesh: AbstractMesh): AbstractMesh;
  26912. /** @hidden */
  26913. private _initFacetData;
  26914. /**
  26915. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26916. * This method can be called within the render loop.
  26917. * 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
  26918. * @returns the current mesh
  26919. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26920. */
  26921. updateFacetData(): AbstractMesh;
  26922. /**
  26923. * Returns the facetLocalNormals array.
  26924. * The normals are expressed in the mesh local spac
  26925. * @returns an array of Vector3
  26926. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26927. */
  26928. getFacetLocalNormals(): Vector3[];
  26929. /**
  26930. * Returns the facetLocalPositions array.
  26931. * The facet positions are expressed in the mesh local space
  26932. * @returns an array of Vector3
  26933. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26934. */
  26935. getFacetLocalPositions(): Vector3[];
  26936. /**
  26937. * Returns the facetLocalPartioning array
  26938. * @returns an array of array of numbers
  26939. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26940. */
  26941. getFacetLocalPartitioning(): number[][];
  26942. /**
  26943. * Returns the i-th facet position in the world system.
  26944. * This method allocates a new Vector3 per call
  26945. * @param i defines the facet index
  26946. * @returns a new Vector3
  26947. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26948. */
  26949. getFacetPosition(i: number): Vector3;
  26950. /**
  26951. * Sets the reference Vector3 with the i-th facet position in the world system
  26952. * @param i defines the facet index
  26953. * @param ref defines the target vector
  26954. * @returns the current mesh
  26955. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26956. */
  26957. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26958. /**
  26959. * Returns the i-th facet normal in the world system.
  26960. * This method allocates a new Vector3 per call
  26961. * @param i defines the facet index
  26962. * @returns a new Vector3
  26963. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26964. */
  26965. getFacetNormal(i: number): Vector3;
  26966. /**
  26967. * Sets the reference Vector3 with the i-th facet normal in the world system
  26968. * @param i defines the facet index
  26969. * @param ref defines the target vector
  26970. * @returns the current mesh
  26971. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26972. */
  26973. getFacetNormalToRef(i: number, ref: Vector3): this;
  26974. /**
  26975. * 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)
  26976. * @param x defines x coordinate
  26977. * @param y defines y coordinate
  26978. * @param z defines z coordinate
  26979. * @returns the array of facet indexes
  26980. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26981. */
  26982. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26983. /**
  26984. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26985. * @param projected sets as the (x,y,z) world projection on the facet
  26986. * @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
  26987. * @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
  26988. * @param x defines x coordinate
  26989. * @param y defines y coordinate
  26990. * @param z defines z coordinate
  26991. * @returns the face index if found (or null instead)
  26992. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26993. */
  26994. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26995. /**
  26996. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26997. * @param projected sets as the (x,y,z) local projection on the facet
  26998. * @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
  26999. * @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
  27000. * @param x defines x coordinate
  27001. * @param y defines y coordinate
  27002. * @param z defines z coordinate
  27003. * @returns the face index if found (or null instead)
  27004. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27005. */
  27006. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27007. /**
  27008. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27009. * @returns the parameters
  27010. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27011. */
  27012. getFacetDataParameters(): any;
  27013. /**
  27014. * Disables the feature FacetData and frees the related memory
  27015. * @returns the current mesh
  27016. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27017. */
  27018. disableFacetData(): AbstractMesh;
  27019. /**
  27020. * Updates the AbstractMesh indices array
  27021. * @param indices defines the data source
  27022. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27023. * @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)
  27024. * @returns the current mesh
  27025. */
  27026. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27027. /**
  27028. * Creates new normals data for the mesh
  27029. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27030. * @returns the current mesh
  27031. */
  27032. createNormals(updatable: boolean): AbstractMesh;
  27033. /**
  27034. * Align the mesh with a normal
  27035. * @param normal defines the normal to use
  27036. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27037. * @returns the current mesh
  27038. */
  27039. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27040. /** @hidden */
  27041. _checkOcclusionQuery(): boolean;
  27042. /**
  27043. * Disables the mesh edge rendering mode
  27044. * @returns the currentAbstractMesh
  27045. */
  27046. disableEdgesRendering(): AbstractMesh;
  27047. /**
  27048. * Enables the edge rendering mode on the mesh.
  27049. * This mode makes the mesh edges visible
  27050. * @param epsilon defines the maximal distance between two angles to detect a face
  27051. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27052. * @returns the currentAbstractMesh
  27053. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27054. */
  27055. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27056. }
  27057. }
  27058. declare module "babylonjs/Actions/actionEvent" {
  27059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27060. import { Nullable } from "babylonjs/types";
  27061. import { Sprite } from "babylonjs/Sprites/sprite";
  27062. import { Scene } from "babylonjs/scene";
  27063. import { Vector2 } from "babylonjs/Maths/math.vector";
  27064. /**
  27065. * Interface used to define ActionEvent
  27066. */
  27067. export interface IActionEvent {
  27068. /** The mesh or sprite that triggered the action */
  27069. source: any;
  27070. /** The X mouse cursor position at the time of the event */
  27071. pointerX: number;
  27072. /** The Y mouse cursor position at the time of the event */
  27073. pointerY: number;
  27074. /** The mesh that is currently pointed at (can be null) */
  27075. meshUnderPointer: Nullable<AbstractMesh>;
  27076. /** the original (browser) event that triggered the ActionEvent */
  27077. sourceEvent?: any;
  27078. /** additional data for the event */
  27079. additionalData?: any;
  27080. }
  27081. /**
  27082. * ActionEvent is the event being sent when an action is triggered.
  27083. */
  27084. export class ActionEvent implements IActionEvent {
  27085. /** The mesh or sprite that triggered the action */
  27086. source: any;
  27087. /** The X mouse cursor position at the time of the event */
  27088. pointerX: number;
  27089. /** The Y mouse cursor position at the time of the event */
  27090. pointerY: number;
  27091. /** The mesh that is currently pointed at (can be null) */
  27092. meshUnderPointer: Nullable<AbstractMesh>;
  27093. /** the original (browser) event that triggered the ActionEvent */
  27094. sourceEvent?: any;
  27095. /** additional data for the event */
  27096. additionalData?: any;
  27097. /**
  27098. * Creates a new ActionEvent
  27099. * @param source The mesh or sprite that triggered the action
  27100. * @param pointerX The X mouse cursor position at the time of the event
  27101. * @param pointerY The Y mouse cursor position at the time of the event
  27102. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27103. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27104. * @param additionalData additional data for the event
  27105. */
  27106. constructor(
  27107. /** The mesh or sprite that triggered the action */
  27108. source: any,
  27109. /** The X mouse cursor position at the time of the event */
  27110. pointerX: number,
  27111. /** The Y mouse cursor position at the time of the event */
  27112. pointerY: number,
  27113. /** The mesh that is currently pointed at (can be null) */
  27114. meshUnderPointer: Nullable<AbstractMesh>,
  27115. /** the original (browser) event that triggered the ActionEvent */
  27116. sourceEvent?: any,
  27117. /** additional data for the event */
  27118. additionalData?: any);
  27119. /**
  27120. * Helper function to auto-create an ActionEvent from a source mesh.
  27121. * @param source The source mesh that triggered the event
  27122. * @param evt The original (browser) event
  27123. * @param additionalData additional data for the event
  27124. * @returns the new ActionEvent
  27125. */
  27126. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27127. /**
  27128. * Helper function to auto-create an ActionEvent from a source sprite
  27129. * @param source The source sprite that triggered the event
  27130. * @param scene Scene associated with the sprite
  27131. * @param evt The original (browser) event
  27132. * @param additionalData additional data for the event
  27133. * @returns the new ActionEvent
  27134. */
  27135. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27136. /**
  27137. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27138. * @param scene the scene where the event occurred
  27139. * @param evt The original (browser) event
  27140. * @returns the new ActionEvent
  27141. */
  27142. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27143. /**
  27144. * Helper function to auto-create an ActionEvent from a primitive
  27145. * @param prim defines the target primitive
  27146. * @param pointerPos defines the pointer position
  27147. * @param evt The original (browser) event
  27148. * @param additionalData additional data for the event
  27149. * @returns the new ActionEvent
  27150. */
  27151. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27152. }
  27153. }
  27154. declare module "babylonjs/Actions/abstractActionManager" {
  27155. import { IDisposable } from "babylonjs/scene";
  27156. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27157. import { IAction } from "babylonjs/Actions/action";
  27158. import { Nullable } from "babylonjs/types";
  27159. /**
  27160. * Abstract class used to decouple action Manager from scene and meshes.
  27161. * Do not instantiate.
  27162. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27163. */
  27164. export abstract class AbstractActionManager implements IDisposable {
  27165. /** Gets the list of active triggers */
  27166. static Triggers: {
  27167. [key: string]: number;
  27168. };
  27169. /** Gets the cursor to use when hovering items */
  27170. hoverCursor: string;
  27171. /** Gets the list of actions */
  27172. actions: IAction[];
  27173. /**
  27174. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27175. */
  27176. isRecursive: boolean;
  27177. /**
  27178. * Releases all associated resources
  27179. */
  27180. abstract dispose(): void;
  27181. /**
  27182. * Does this action manager has pointer triggers
  27183. */
  27184. abstract readonly hasPointerTriggers: boolean;
  27185. /**
  27186. * Does this action manager has pick triggers
  27187. */
  27188. abstract readonly hasPickTriggers: boolean;
  27189. /**
  27190. * Process a specific trigger
  27191. * @param trigger defines the trigger to process
  27192. * @param evt defines the event details to be processed
  27193. */
  27194. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27195. /**
  27196. * Does this action manager handles actions of any of the given triggers
  27197. * @param triggers defines the triggers to be tested
  27198. * @return a boolean indicating whether one (or more) of the triggers is handled
  27199. */
  27200. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27201. /**
  27202. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27203. * speed.
  27204. * @param triggerA defines the trigger to be tested
  27205. * @param triggerB defines the trigger to be tested
  27206. * @return a boolean indicating whether one (or more) of the triggers is handled
  27207. */
  27208. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27209. /**
  27210. * Does this action manager handles actions of a given trigger
  27211. * @param trigger defines the trigger to be tested
  27212. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27213. * @return whether the trigger is handled
  27214. */
  27215. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27216. /**
  27217. * Serialize this manager to a JSON object
  27218. * @param name defines the property name to store this manager
  27219. * @returns a JSON representation of this manager
  27220. */
  27221. abstract serialize(name: string): any;
  27222. /**
  27223. * Registers an action to this action manager
  27224. * @param action defines the action to be registered
  27225. * @return the action amended (prepared) after registration
  27226. */
  27227. abstract registerAction(action: IAction): Nullable<IAction>;
  27228. /**
  27229. * Unregisters an action to this action manager
  27230. * @param action defines the action to be unregistered
  27231. * @return a boolean indicating whether the action has been unregistered
  27232. */
  27233. abstract unregisterAction(action: IAction): Boolean;
  27234. /**
  27235. * Does exist one action manager with at least one trigger
  27236. **/
  27237. static readonly HasTriggers: boolean;
  27238. /**
  27239. * Does exist one action manager with at least one pick trigger
  27240. **/
  27241. static readonly HasPickTriggers: boolean;
  27242. /**
  27243. * Does exist one action manager that handles actions of a given trigger
  27244. * @param trigger defines the trigger to be tested
  27245. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27246. **/
  27247. static HasSpecificTrigger(trigger: number): boolean;
  27248. }
  27249. }
  27250. declare module "babylonjs/node" {
  27251. import { Scene } from "babylonjs/scene";
  27252. import { Nullable } from "babylonjs/types";
  27253. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27254. import { Engine } from "babylonjs/Engines/engine";
  27255. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27256. import { Observable } from "babylonjs/Misc/observable";
  27257. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27258. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27259. import { Animatable } from "babylonjs/Animations/animatable";
  27260. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27261. import { Animation } from "babylonjs/Animations/animation";
  27262. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27264. /**
  27265. * Defines how a node can be built from a string name.
  27266. */
  27267. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27268. /**
  27269. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27270. */
  27271. export class Node implements IBehaviorAware<Node> {
  27272. /** @hidden */
  27273. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27274. private static _NodeConstructors;
  27275. /**
  27276. * Add a new node constructor
  27277. * @param type defines the type name of the node to construct
  27278. * @param constructorFunc defines the constructor function
  27279. */
  27280. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27281. /**
  27282. * Returns a node constructor based on type name
  27283. * @param type defines the type name
  27284. * @param name defines the new node name
  27285. * @param scene defines the hosting scene
  27286. * @param options defines optional options to transmit to constructors
  27287. * @returns the new constructor or null
  27288. */
  27289. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27290. /**
  27291. * Gets or sets the name of the node
  27292. */
  27293. name: string;
  27294. /**
  27295. * Gets or sets the id of the node
  27296. */
  27297. id: string;
  27298. /**
  27299. * Gets or sets the unique id of the node
  27300. */
  27301. uniqueId: number;
  27302. /**
  27303. * Gets or sets a string used to store user defined state for the node
  27304. */
  27305. state: string;
  27306. /**
  27307. * Gets or sets an object used to store user defined information for the node
  27308. */
  27309. metadata: any;
  27310. /**
  27311. * For internal use only. Please do not use.
  27312. */
  27313. reservedDataStore: any;
  27314. /**
  27315. * List of inspectable custom properties (used by the Inspector)
  27316. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27317. */
  27318. inspectableCustomProperties: IInspectable[];
  27319. /**
  27320. * Gets or sets a boolean used to define if the node must be serialized
  27321. */
  27322. doNotSerialize: boolean;
  27323. /** @hidden */
  27324. _isDisposed: boolean;
  27325. /**
  27326. * Gets a list of Animations associated with the node
  27327. */
  27328. animations: import("babylonjs/Animations/animation").Animation[];
  27329. protected _ranges: {
  27330. [name: string]: Nullable<AnimationRange>;
  27331. };
  27332. /**
  27333. * Callback raised when the node is ready to be used
  27334. */
  27335. onReady: Nullable<(node: Node) => void>;
  27336. private _isEnabled;
  27337. private _isParentEnabled;
  27338. private _isReady;
  27339. /** @hidden */
  27340. _currentRenderId: number;
  27341. private _parentUpdateId;
  27342. /** @hidden */
  27343. _childUpdateId: number;
  27344. /** @hidden */
  27345. _waitingParentId: Nullable<string>;
  27346. /** @hidden */
  27347. _scene: Scene;
  27348. /** @hidden */
  27349. _cache: any;
  27350. private _parentNode;
  27351. private _children;
  27352. /** @hidden */
  27353. _worldMatrix: Matrix;
  27354. /** @hidden */
  27355. _worldMatrixDeterminant: number;
  27356. /** @hidden */
  27357. _worldMatrixDeterminantIsDirty: boolean;
  27358. /** @hidden */
  27359. private _sceneRootNodesIndex;
  27360. /**
  27361. * Gets a boolean indicating if the node has been disposed
  27362. * @returns true if the node was disposed
  27363. */
  27364. isDisposed(): boolean;
  27365. /**
  27366. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27367. * @see https://doc.babylonjs.com/how_to/parenting
  27368. */
  27369. parent: Nullable<Node>;
  27370. private addToSceneRootNodes;
  27371. private removeFromSceneRootNodes;
  27372. private _animationPropertiesOverride;
  27373. /**
  27374. * Gets or sets the animation properties override
  27375. */
  27376. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27377. /**
  27378. * Gets a string idenfifying the name of the class
  27379. * @returns "Node" string
  27380. */
  27381. getClassName(): string;
  27382. /** @hidden */
  27383. readonly _isNode: boolean;
  27384. /**
  27385. * An event triggered when the mesh is disposed
  27386. */
  27387. onDisposeObservable: Observable<Node>;
  27388. private _onDisposeObserver;
  27389. /**
  27390. * Sets a callback that will be raised when the node will be disposed
  27391. */
  27392. onDispose: () => void;
  27393. /**
  27394. * Creates a new Node
  27395. * @param name the name and id to be given to this node
  27396. * @param scene the scene this node will be added to
  27397. * @param addToRootNodes the node will be added to scene.rootNodes
  27398. */
  27399. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27400. /**
  27401. * Gets the scene of the node
  27402. * @returns a scene
  27403. */
  27404. getScene(): Scene;
  27405. /**
  27406. * Gets the engine of the node
  27407. * @returns a Engine
  27408. */
  27409. getEngine(): Engine;
  27410. private _behaviors;
  27411. /**
  27412. * Attach a behavior to the node
  27413. * @see http://doc.babylonjs.com/features/behaviour
  27414. * @param behavior defines the behavior to attach
  27415. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27416. * @returns the current Node
  27417. */
  27418. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27419. /**
  27420. * Remove an attached behavior
  27421. * @see http://doc.babylonjs.com/features/behaviour
  27422. * @param behavior defines the behavior to attach
  27423. * @returns the current Node
  27424. */
  27425. removeBehavior(behavior: Behavior<Node>): Node;
  27426. /**
  27427. * Gets the list of attached behaviors
  27428. * @see http://doc.babylonjs.com/features/behaviour
  27429. */
  27430. readonly behaviors: Behavior<Node>[];
  27431. /**
  27432. * Gets an attached behavior by name
  27433. * @param name defines the name of the behavior to look for
  27434. * @see http://doc.babylonjs.com/features/behaviour
  27435. * @returns null if behavior was not found else the requested behavior
  27436. */
  27437. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27438. /**
  27439. * Returns the latest update of the World matrix
  27440. * @returns a Matrix
  27441. */
  27442. getWorldMatrix(): Matrix;
  27443. /** @hidden */
  27444. _getWorldMatrixDeterminant(): number;
  27445. /**
  27446. * Returns directly the latest state of the mesh World matrix.
  27447. * A Matrix is returned.
  27448. */
  27449. readonly worldMatrixFromCache: Matrix;
  27450. /** @hidden */
  27451. _initCache(): void;
  27452. /** @hidden */
  27453. updateCache(force?: boolean): void;
  27454. /** @hidden */
  27455. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27456. /** @hidden */
  27457. _updateCache(ignoreParentClass?: boolean): void;
  27458. /** @hidden */
  27459. _isSynchronized(): boolean;
  27460. /** @hidden */
  27461. _markSyncedWithParent(): void;
  27462. /** @hidden */
  27463. isSynchronizedWithParent(): boolean;
  27464. /** @hidden */
  27465. isSynchronized(): boolean;
  27466. /**
  27467. * Is this node ready to be used/rendered
  27468. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27469. * @return true if the node is ready
  27470. */
  27471. isReady(completeCheck?: boolean): boolean;
  27472. /**
  27473. * Is this node enabled?
  27474. * 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
  27475. * @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
  27476. * @return whether this node (and its parent) is enabled
  27477. */
  27478. isEnabled(checkAncestors?: boolean): boolean;
  27479. /** @hidden */
  27480. protected _syncParentEnabledState(): void;
  27481. /**
  27482. * Set the enabled state of this node
  27483. * @param value defines the new enabled state
  27484. */
  27485. setEnabled(value: boolean): void;
  27486. /**
  27487. * Is this node a descendant of the given node?
  27488. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27489. * @param ancestor defines the parent node to inspect
  27490. * @returns a boolean indicating if this node is a descendant of the given node
  27491. */
  27492. isDescendantOf(ancestor: Node): boolean;
  27493. /** @hidden */
  27494. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27495. /**
  27496. * Will return all nodes that have this node as ascendant
  27497. * @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
  27498. * @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
  27499. * @return all children nodes of all types
  27500. */
  27501. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27502. /**
  27503. * Get all child-meshes of this node
  27504. * @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)
  27505. * @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
  27506. * @returns an array of AbstractMesh
  27507. */
  27508. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27509. /**
  27510. * Get all direct children of this node
  27511. * @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
  27512. * @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)
  27513. * @returns an array of Node
  27514. */
  27515. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27516. /** @hidden */
  27517. _setReady(state: boolean): void;
  27518. /**
  27519. * Get an animation by name
  27520. * @param name defines the name of the animation to look for
  27521. * @returns null if not found else the requested animation
  27522. */
  27523. getAnimationByName(name: string): Nullable<Animation>;
  27524. /**
  27525. * Creates an animation range for this node
  27526. * @param name defines the name of the range
  27527. * @param from defines the starting key
  27528. * @param to defines the end key
  27529. */
  27530. createAnimationRange(name: string, from: number, to: number): void;
  27531. /**
  27532. * Delete a specific animation range
  27533. * @param name defines the name of the range to delete
  27534. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27535. */
  27536. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27537. /**
  27538. * Get an animation range by name
  27539. * @param name defines the name of the animation range to look for
  27540. * @returns null if not found else the requested animation range
  27541. */
  27542. getAnimationRange(name: string): Nullable<AnimationRange>;
  27543. /**
  27544. * Gets the list of all animation ranges defined on this node
  27545. * @returns an array
  27546. */
  27547. getAnimationRanges(): Nullable<AnimationRange>[];
  27548. /**
  27549. * Will start the animation sequence
  27550. * @param name defines the range frames for animation sequence
  27551. * @param loop defines if the animation should loop (false by default)
  27552. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27553. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27554. * @returns the object created for this animation. If range does not exist, it will return null
  27555. */
  27556. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27557. /**
  27558. * Serialize animation ranges into a JSON compatible object
  27559. * @returns serialization object
  27560. */
  27561. serializeAnimationRanges(): any;
  27562. /**
  27563. * Computes the world matrix of the node
  27564. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27565. * @returns the world matrix
  27566. */
  27567. computeWorldMatrix(force?: boolean): Matrix;
  27568. /**
  27569. * Releases resources associated with this node.
  27570. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27571. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27572. */
  27573. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27574. /**
  27575. * Parse animation range data from a serialization object and store them into a given node
  27576. * @param node defines where to store the animation ranges
  27577. * @param parsedNode defines the serialization object to read data from
  27578. * @param scene defines the hosting scene
  27579. */
  27580. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27581. /**
  27582. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27583. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27584. * @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
  27585. * @returns the new bounding vectors
  27586. */
  27587. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27588. min: Vector3;
  27589. max: Vector3;
  27590. };
  27591. }
  27592. }
  27593. declare module "babylonjs/Animations/animation" {
  27594. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27595. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27596. import { Color3 } from "babylonjs/Maths/math.color";
  27597. import { Nullable } from "babylonjs/types";
  27598. import { Scene } from "babylonjs/scene";
  27599. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27600. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27601. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27602. import { Node } from "babylonjs/node";
  27603. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27604. import { Size } from "babylonjs/Maths/math.size";
  27605. import { Animatable } from "babylonjs/Animations/animatable";
  27606. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27607. /**
  27608. * @hidden
  27609. */
  27610. export class _IAnimationState {
  27611. key: number;
  27612. repeatCount: number;
  27613. workValue?: any;
  27614. loopMode?: number;
  27615. offsetValue?: any;
  27616. highLimitValue?: any;
  27617. }
  27618. /**
  27619. * Class used to store any kind of animation
  27620. */
  27621. export class Animation {
  27622. /**Name of the animation */
  27623. name: string;
  27624. /**Property to animate */
  27625. targetProperty: string;
  27626. /**The frames per second of the animation */
  27627. framePerSecond: number;
  27628. /**The data type of the animation */
  27629. dataType: number;
  27630. /**The loop mode of the animation */
  27631. loopMode?: number | undefined;
  27632. /**Specifies if blending should be enabled */
  27633. enableBlending?: boolean | undefined;
  27634. /**
  27635. * Use matrix interpolation instead of using direct key value when animating matrices
  27636. */
  27637. static AllowMatricesInterpolation: boolean;
  27638. /**
  27639. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27640. */
  27641. static AllowMatrixDecomposeForInterpolation: boolean;
  27642. /**
  27643. * Stores the key frames of the animation
  27644. */
  27645. private _keys;
  27646. /**
  27647. * Stores the easing function of the animation
  27648. */
  27649. private _easingFunction;
  27650. /**
  27651. * @hidden Internal use only
  27652. */
  27653. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27654. /**
  27655. * The set of event that will be linked to this animation
  27656. */
  27657. private _events;
  27658. /**
  27659. * Stores an array of target property paths
  27660. */
  27661. targetPropertyPath: string[];
  27662. /**
  27663. * Stores the blending speed of the animation
  27664. */
  27665. blendingSpeed: number;
  27666. /**
  27667. * Stores the animation ranges for the animation
  27668. */
  27669. private _ranges;
  27670. /**
  27671. * @hidden Internal use
  27672. */
  27673. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27674. /**
  27675. * Sets up an animation
  27676. * @param property The property to animate
  27677. * @param animationType The animation type to apply
  27678. * @param framePerSecond The frames per second of the animation
  27679. * @param easingFunction The easing function used in the animation
  27680. * @returns The created animation
  27681. */
  27682. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27683. /**
  27684. * Create and start an animation on a node
  27685. * @param name defines the name of the global animation that will be run on all nodes
  27686. * @param node defines the root node where the animation will take place
  27687. * @param targetProperty defines property to animate
  27688. * @param framePerSecond defines the number of frame per second yo use
  27689. * @param totalFrame defines the number of frames in total
  27690. * @param from defines the initial value
  27691. * @param to defines the final value
  27692. * @param loopMode defines which loop mode you want to use (off by default)
  27693. * @param easingFunction defines the easing function to use (linear by default)
  27694. * @param onAnimationEnd defines the callback to call when animation end
  27695. * @returns the animatable created for this animation
  27696. */
  27697. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27698. /**
  27699. * Create and start an animation on a node and its descendants
  27700. * @param name defines the name of the global animation that will be run on all nodes
  27701. * @param node defines the root node where the animation will take place
  27702. * @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
  27703. * @param targetProperty defines property to animate
  27704. * @param framePerSecond defines the number of frame per second to use
  27705. * @param totalFrame defines the number of frames in total
  27706. * @param from defines the initial value
  27707. * @param to defines the final value
  27708. * @param loopMode defines which loop mode you want to use (off by default)
  27709. * @param easingFunction defines the easing function to use (linear by default)
  27710. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27711. * @returns the list of animatables created for all nodes
  27712. * @example https://www.babylonjs-playground.com/#MH0VLI
  27713. */
  27714. 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[]>;
  27715. /**
  27716. * Creates a new animation, merges it with the existing animations and starts it
  27717. * @param name Name of the animation
  27718. * @param node Node which contains the scene that begins the animations
  27719. * @param targetProperty Specifies which property to animate
  27720. * @param framePerSecond The frames per second of the animation
  27721. * @param totalFrame The total number of frames
  27722. * @param from The frame at the beginning of the animation
  27723. * @param to The frame at the end of the animation
  27724. * @param loopMode Specifies the loop mode of the animation
  27725. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27726. * @param onAnimationEnd Callback to run once the animation is complete
  27727. * @returns Nullable animation
  27728. */
  27729. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27730. /**
  27731. * Transition property of an host to the target Value
  27732. * @param property The property to transition
  27733. * @param targetValue The target Value of the property
  27734. * @param host The object where the property to animate belongs
  27735. * @param scene Scene used to run the animation
  27736. * @param frameRate Framerate (in frame/s) to use
  27737. * @param transition The transition type we want to use
  27738. * @param duration The duration of the animation, in milliseconds
  27739. * @param onAnimationEnd Callback trigger at the end of the animation
  27740. * @returns Nullable animation
  27741. */
  27742. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27743. /**
  27744. * Return the array of runtime animations currently using this animation
  27745. */
  27746. readonly runtimeAnimations: RuntimeAnimation[];
  27747. /**
  27748. * Specifies if any of the runtime animations are currently running
  27749. */
  27750. readonly hasRunningRuntimeAnimations: boolean;
  27751. /**
  27752. * Initializes the animation
  27753. * @param name Name of the animation
  27754. * @param targetProperty Property to animate
  27755. * @param framePerSecond The frames per second of the animation
  27756. * @param dataType The data type of the animation
  27757. * @param loopMode The loop mode of the animation
  27758. * @param enableBlending Specifies if blending should be enabled
  27759. */
  27760. constructor(
  27761. /**Name of the animation */
  27762. name: string,
  27763. /**Property to animate */
  27764. targetProperty: string,
  27765. /**The frames per second of the animation */
  27766. framePerSecond: number,
  27767. /**The data type of the animation */
  27768. dataType: number,
  27769. /**The loop mode of the animation */
  27770. loopMode?: number | undefined,
  27771. /**Specifies if blending should be enabled */
  27772. enableBlending?: boolean | undefined);
  27773. /**
  27774. * Converts the animation to a string
  27775. * @param fullDetails support for multiple levels of logging within scene loading
  27776. * @returns String form of the animation
  27777. */
  27778. toString(fullDetails?: boolean): string;
  27779. /**
  27780. * Add an event to this animation
  27781. * @param event Event to add
  27782. */
  27783. addEvent(event: AnimationEvent): void;
  27784. /**
  27785. * Remove all events found at the given frame
  27786. * @param frame The frame to remove events from
  27787. */
  27788. removeEvents(frame: number): void;
  27789. /**
  27790. * Retrieves all the events from the animation
  27791. * @returns Events from the animation
  27792. */
  27793. getEvents(): AnimationEvent[];
  27794. /**
  27795. * Creates an animation range
  27796. * @param name Name of the animation range
  27797. * @param from Starting frame of the animation range
  27798. * @param to Ending frame of the animation
  27799. */
  27800. createRange(name: string, from: number, to: number): void;
  27801. /**
  27802. * Deletes an animation range by name
  27803. * @param name Name of the animation range to delete
  27804. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27805. */
  27806. deleteRange(name: string, deleteFrames?: boolean): void;
  27807. /**
  27808. * Gets the animation range by name, or null if not defined
  27809. * @param name Name of the animation range
  27810. * @returns Nullable animation range
  27811. */
  27812. getRange(name: string): Nullable<AnimationRange>;
  27813. /**
  27814. * Gets the key frames from the animation
  27815. * @returns The key frames of the animation
  27816. */
  27817. getKeys(): Array<IAnimationKey>;
  27818. /**
  27819. * Gets the highest frame rate of the animation
  27820. * @returns Highest frame rate of the animation
  27821. */
  27822. getHighestFrame(): number;
  27823. /**
  27824. * Gets the easing function of the animation
  27825. * @returns Easing function of the animation
  27826. */
  27827. getEasingFunction(): IEasingFunction;
  27828. /**
  27829. * Sets the easing function of the animation
  27830. * @param easingFunction A custom mathematical formula for animation
  27831. */
  27832. setEasingFunction(easingFunction: EasingFunction): void;
  27833. /**
  27834. * Interpolates a scalar linearly
  27835. * @param startValue Start value of the animation curve
  27836. * @param endValue End value of the animation curve
  27837. * @param gradient Scalar amount to interpolate
  27838. * @returns Interpolated scalar value
  27839. */
  27840. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27841. /**
  27842. * Interpolates a scalar cubically
  27843. * @param startValue Start value of the animation curve
  27844. * @param outTangent End tangent of the animation
  27845. * @param endValue End value of the animation curve
  27846. * @param inTangent Start tangent of the animation curve
  27847. * @param gradient Scalar amount to interpolate
  27848. * @returns Interpolated scalar value
  27849. */
  27850. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27851. /**
  27852. * Interpolates a quaternion using a spherical linear interpolation
  27853. * @param startValue Start value of the animation curve
  27854. * @param endValue End value of the animation curve
  27855. * @param gradient Scalar amount to interpolate
  27856. * @returns Interpolated quaternion value
  27857. */
  27858. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27859. /**
  27860. * Interpolates a quaternion cubically
  27861. * @param startValue Start value of the animation curve
  27862. * @param outTangent End tangent of the animation curve
  27863. * @param endValue End value of the animation curve
  27864. * @param inTangent Start tangent of the animation curve
  27865. * @param gradient Scalar amount to interpolate
  27866. * @returns Interpolated quaternion value
  27867. */
  27868. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27869. /**
  27870. * Interpolates a Vector3 linearl
  27871. * @param startValue Start value of the animation curve
  27872. * @param endValue End value of the animation curve
  27873. * @param gradient Scalar amount to interpolate
  27874. * @returns Interpolated scalar value
  27875. */
  27876. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27877. /**
  27878. * Interpolates a Vector3 cubically
  27879. * @param startValue Start value of the animation curve
  27880. * @param outTangent End tangent of the animation
  27881. * @param endValue End value of the animation curve
  27882. * @param inTangent Start tangent of the animation curve
  27883. * @param gradient Scalar amount to interpolate
  27884. * @returns InterpolatedVector3 value
  27885. */
  27886. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27887. /**
  27888. * Interpolates a Vector2 linearly
  27889. * @param startValue Start value of the animation curve
  27890. * @param endValue End value of the animation curve
  27891. * @param gradient Scalar amount to interpolate
  27892. * @returns Interpolated Vector2 value
  27893. */
  27894. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27895. /**
  27896. * Interpolates a Vector2 cubically
  27897. * @param startValue Start value of the animation curve
  27898. * @param outTangent End tangent of the animation
  27899. * @param endValue End value of the animation curve
  27900. * @param inTangent Start tangent of the animation curve
  27901. * @param gradient Scalar amount to interpolate
  27902. * @returns Interpolated Vector2 value
  27903. */
  27904. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27905. /**
  27906. * Interpolates a size linearly
  27907. * @param startValue Start value of the animation curve
  27908. * @param endValue End value of the animation curve
  27909. * @param gradient Scalar amount to interpolate
  27910. * @returns Interpolated Size value
  27911. */
  27912. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27913. /**
  27914. * Interpolates a Color3 linearly
  27915. * @param startValue Start value of the animation curve
  27916. * @param endValue End value of the animation curve
  27917. * @param gradient Scalar amount to interpolate
  27918. * @returns Interpolated Color3 value
  27919. */
  27920. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27921. /**
  27922. * @hidden Internal use only
  27923. */
  27924. _getKeyValue(value: any): any;
  27925. /**
  27926. * @hidden Internal use only
  27927. */
  27928. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27929. /**
  27930. * Defines the function to use to interpolate matrices
  27931. * @param startValue defines the start matrix
  27932. * @param endValue defines the end matrix
  27933. * @param gradient defines the gradient between both matrices
  27934. * @param result defines an optional target matrix where to store the interpolation
  27935. * @returns the interpolated matrix
  27936. */
  27937. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27938. /**
  27939. * Makes a copy of the animation
  27940. * @returns Cloned animation
  27941. */
  27942. clone(): Animation;
  27943. /**
  27944. * Sets the key frames of the animation
  27945. * @param values The animation key frames to set
  27946. */
  27947. setKeys(values: Array<IAnimationKey>): void;
  27948. /**
  27949. * Serializes the animation to an object
  27950. * @returns Serialized object
  27951. */
  27952. serialize(): any;
  27953. /**
  27954. * Float animation type
  27955. */
  27956. private static _ANIMATIONTYPE_FLOAT;
  27957. /**
  27958. * Vector3 animation type
  27959. */
  27960. private static _ANIMATIONTYPE_VECTOR3;
  27961. /**
  27962. * Quaternion animation type
  27963. */
  27964. private static _ANIMATIONTYPE_QUATERNION;
  27965. /**
  27966. * Matrix animation type
  27967. */
  27968. private static _ANIMATIONTYPE_MATRIX;
  27969. /**
  27970. * Color3 animation type
  27971. */
  27972. private static _ANIMATIONTYPE_COLOR3;
  27973. /**
  27974. * Vector2 animation type
  27975. */
  27976. private static _ANIMATIONTYPE_VECTOR2;
  27977. /**
  27978. * Size animation type
  27979. */
  27980. private static _ANIMATIONTYPE_SIZE;
  27981. /**
  27982. * Relative Loop Mode
  27983. */
  27984. private static _ANIMATIONLOOPMODE_RELATIVE;
  27985. /**
  27986. * Cycle Loop Mode
  27987. */
  27988. private static _ANIMATIONLOOPMODE_CYCLE;
  27989. /**
  27990. * Constant Loop Mode
  27991. */
  27992. private static _ANIMATIONLOOPMODE_CONSTANT;
  27993. /**
  27994. * Get the float animation type
  27995. */
  27996. static readonly ANIMATIONTYPE_FLOAT: number;
  27997. /**
  27998. * Get the Vector3 animation type
  27999. */
  28000. static readonly ANIMATIONTYPE_VECTOR3: number;
  28001. /**
  28002. * Get the Vector2 animation type
  28003. */
  28004. static readonly ANIMATIONTYPE_VECTOR2: number;
  28005. /**
  28006. * Get the Size animation type
  28007. */
  28008. static readonly ANIMATIONTYPE_SIZE: number;
  28009. /**
  28010. * Get the Quaternion animation type
  28011. */
  28012. static readonly ANIMATIONTYPE_QUATERNION: number;
  28013. /**
  28014. * Get the Matrix animation type
  28015. */
  28016. static readonly ANIMATIONTYPE_MATRIX: number;
  28017. /**
  28018. * Get the Color3 animation type
  28019. */
  28020. static readonly ANIMATIONTYPE_COLOR3: number;
  28021. /**
  28022. * Get the Relative Loop Mode
  28023. */
  28024. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28025. /**
  28026. * Get the Cycle Loop Mode
  28027. */
  28028. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28029. /**
  28030. * Get the Constant Loop Mode
  28031. */
  28032. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28033. /** @hidden */
  28034. static _UniversalLerp(left: any, right: any, amount: number): any;
  28035. /**
  28036. * Parses an animation object and creates an animation
  28037. * @param parsedAnimation Parsed animation object
  28038. * @returns Animation object
  28039. */
  28040. static Parse(parsedAnimation: any): Animation;
  28041. /**
  28042. * Appends the serialized animations from the source animations
  28043. * @param source Source containing the animations
  28044. * @param destination Target to store the animations
  28045. */
  28046. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28047. }
  28048. }
  28049. declare module "babylonjs/Animations/animatable.interface" {
  28050. import { Nullable } from "babylonjs/types";
  28051. import { Animation } from "babylonjs/Animations/animation";
  28052. /**
  28053. * Interface containing an array of animations
  28054. */
  28055. export interface IAnimatable {
  28056. /**
  28057. * Array of animations
  28058. */
  28059. animations: Nullable<Array<Animation>>;
  28060. }
  28061. }
  28062. declare module "babylonjs/Materials/fresnelParameters" {
  28063. import { Color3 } from "babylonjs/Maths/math.color";
  28064. /**
  28065. * This represents all the required information to add a fresnel effect on a material:
  28066. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28067. */
  28068. export class FresnelParameters {
  28069. private _isEnabled;
  28070. /**
  28071. * Define if the fresnel effect is enable or not.
  28072. */
  28073. isEnabled: boolean;
  28074. /**
  28075. * Define the color used on edges (grazing angle)
  28076. */
  28077. leftColor: Color3;
  28078. /**
  28079. * Define the color used on center
  28080. */
  28081. rightColor: Color3;
  28082. /**
  28083. * Define bias applied to computed fresnel term
  28084. */
  28085. bias: number;
  28086. /**
  28087. * Defined the power exponent applied to fresnel term
  28088. */
  28089. power: number;
  28090. /**
  28091. * Clones the current fresnel and its valuues
  28092. * @returns a clone fresnel configuration
  28093. */
  28094. clone(): FresnelParameters;
  28095. /**
  28096. * Serializes the current fresnel parameters to a JSON representation.
  28097. * @return the JSON serialization
  28098. */
  28099. serialize(): any;
  28100. /**
  28101. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28102. * @param parsedFresnelParameters Define the JSON representation
  28103. * @returns the parsed parameters
  28104. */
  28105. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28106. }
  28107. }
  28108. declare module "babylonjs/Misc/decorators" {
  28109. import { Nullable } from "babylonjs/types";
  28110. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28111. import { Scene } from "babylonjs/scene";
  28112. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28113. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28114. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28115. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28116. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28117. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28118. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28119. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28120. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28121. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28122. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28123. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28124. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28125. /**
  28126. * Decorator used to define property that can be serialized as reference to a camera
  28127. * @param sourceName defines the name of the property to decorate
  28128. */
  28129. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28130. /**
  28131. * Class used to help serialization objects
  28132. */
  28133. export class SerializationHelper {
  28134. /** @hidden */
  28135. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28136. /** @hidden */
  28137. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28138. /** @hidden */
  28139. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28140. /** @hidden */
  28141. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28142. /**
  28143. * Appends the serialized animations from the source animations
  28144. * @param source Source containing the animations
  28145. * @param destination Target to store the animations
  28146. */
  28147. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28148. /**
  28149. * Static function used to serialized a specific entity
  28150. * @param entity defines the entity to serialize
  28151. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28152. * @returns a JSON compatible object representing the serialization of the entity
  28153. */
  28154. static Serialize<T>(entity: T, serializationObject?: any): any;
  28155. /**
  28156. * Creates a new entity from a serialization data object
  28157. * @param creationFunction defines a function used to instanciated the new entity
  28158. * @param source defines the source serialization data
  28159. * @param scene defines the hosting scene
  28160. * @param rootUrl defines the root url for resources
  28161. * @returns a new entity
  28162. */
  28163. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28164. /**
  28165. * Clones an object
  28166. * @param creationFunction defines the function used to instanciate the new object
  28167. * @param source defines the source object
  28168. * @returns the cloned object
  28169. */
  28170. static Clone<T>(creationFunction: () => T, source: T): T;
  28171. /**
  28172. * Instanciates a new object based on a source one (some data will be shared between both object)
  28173. * @param creationFunction defines the function used to instanciate the new object
  28174. * @param source defines the source object
  28175. * @returns the new object
  28176. */
  28177. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28178. }
  28179. }
  28180. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28181. import { Nullable } from "babylonjs/types";
  28182. /**
  28183. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28184. */
  28185. export interface CubeMapInfo {
  28186. /**
  28187. * The pixel array for the front face.
  28188. * This is stored in format, left to right, up to down format.
  28189. */
  28190. front: Nullable<ArrayBufferView>;
  28191. /**
  28192. * The pixel array for the back face.
  28193. * This is stored in format, left to right, up to down format.
  28194. */
  28195. back: Nullable<ArrayBufferView>;
  28196. /**
  28197. * The pixel array for the left face.
  28198. * This is stored in format, left to right, up to down format.
  28199. */
  28200. left: Nullable<ArrayBufferView>;
  28201. /**
  28202. * The pixel array for the right face.
  28203. * This is stored in format, left to right, up to down format.
  28204. */
  28205. right: Nullable<ArrayBufferView>;
  28206. /**
  28207. * The pixel array for the up face.
  28208. * This is stored in format, left to right, up to down format.
  28209. */
  28210. up: Nullable<ArrayBufferView>;
  28211. /**
  28212. * The pixel array for the down face.
  28213. * This is stored in format, left to right, up to down format.
  28214. */
  28215. down: Nullable<ArrayBufferView>;
  28216. /**
  28217. * The size of the cubemap stored.
  28218. *
  28219. * Each faces will be size * size pixels.
  28220. */
  28221. size: number;
  28222. /**
  28223. * The format of the texture.
  28224. *
  28225. * RGBA, RGB.
  28226. */
  28227. format: number;
  28228. /**
  28229. * The type of the texture data.
  28230. *
  28231. * UNSIGNED_INT, FLOAT.
  28232. */
  28233. type: number;
  28234. /**
  28235. * Specifies whether the texture is in gamma space.
  28236. */
  28237. gammaSpace: boolean;
  28238. }
  28239. /**
  28240. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28241. */
  28242. export class PanoramaToCubeMapTools {
  28243. private static FACE_FRONT;
  28244. private static FACE_BACK;
  28245. private static FACE_RIGHT;
  28246. private static FACE_LEFT;
  28247. private static FACE_DOWN;
  28248. private static FACE_UP;
  28249. /**
  28250. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28251. *
  28252. * @param float32Array The source data.
  28253. * @param inputWidth The width of the input panorama.
  28254. * @param inputHeight The height of the input panorama.
  28255. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28256. * @return The cubemap data
  28257. */
  28258. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28259. private static CreateCubemapTexture;
  28260. private static CalcProjectionSpherical;
  28261. }
  28262. }
  28263. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28264. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28265. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28266. import { Nullable } from "babylonjs/types";
  28267. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28268. /**
  28269. * Helper class dealing with the extraction of spherical polynomial dataArray
  28270. * from a cube map.
  28271. */
  28272. export class CubeMapToSphericalPolynomialTools {
  28273. private static FileFaces;
  28274. /**
  28275. * Converts a texture to the according Spherical Polynomial data.
  28276. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28277. *
  28278. * @param texture The texture to extract the information from.
  28279. * @return The Spherical Polynomial data.
  28280. */
  28281. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28282. /**
  28283. * Converts a cubemap to the according Spherical Polynomial data.
  28284. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28285. *
  28286. * @param cubeInfo The Cube map to extract the information from.
  28287. * @return The Spherical Polynomial data.
  28288. */
  28289. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28290. }
  28291. }
  28292. declare module "babylonjs/Misc/guid" {
  28293. /**
  28294. * Class used to manipulate GUIDs
  28295. */
  28296. export class GUID {
  28297. /**
  28298. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28299. * Be aware Math.random() could cause collisions, but:
  28300. * "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"
  28301. * @returns a pseudo random id
  28302. */
  28303. static RandomId(): string;
  28304. }
  28305. }
  28306. declare module "babylonjs/Materials/Textures/baseTexture" {
  28307. import { Observable } from "babylonjs/Misc/observable";
  28308. import { Nullable } from "babylonjs/types";
  28309. import { Scene } from "babylonjs/scene";
  28310. import { Matrix } from "babylonjs/Maths/math.vector";
  28311. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28312. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28313. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28314. import { ISize } from "babylonjs/Maths/math.size";
  28315. /**
  28316. * Base class of all the textures in babylon.
  28317. * It groups all the common properties the materials, post process, lights... might need
  28318. * in order to make a correct use of the texture.
  28319. */
  28320. export class BaseTexture implements IAnimatable {
  28321. /**
  28322. * Default anisotropic filtering level for the application.
  28323. * It is set to 4 as a good tradeoff between perf and quality.
  28324. */
  28325. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28326. /**
  28327. * Gets or sets the unique id of the texture
  28328. */
  28329. uniqueId: number;
  28330. /**
  28331. * Define the name of the texture.
  28332. */
  28333. name: string;
  28334. /**
  28335. * Gets or sets an object used to store user defined information.
  28336. */
  28337. metadata: any;
  28338. /**
  28339. * For internal use only. Please do not use.
  28340. */
  28341. reservedDataStore: any;
  28342. private _hasAlpha;
  28343. /**
  28344. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28345. */
  28346. hasAlpha: boolean;
  28347. /**
  28348. * Defines if the alpha value should be determined via the rgb values.
  28349. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28350. */
  28351. getAlphaFromRGB: boolean;
  28352. /**
  28353. * Intensity or strength of the texture.
  28354. * It is commonly used by materials to fine tune the intensity of the texture
  28355. */
  28356. level: number;
  28357. /**
  28358. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28359. * This is part of the texture as textures usually maps to one uv set.
  28360. */
  28361. coordinatesIndex: number;
  28362. private _coordinatesMode;
  28363. /**
  28364. * How a texture is mapped.
  28365. *
  28366. * | Value | Type | Description |
  28367. * | ----- | ----------------------------------- | ----------- |
  28368. * | 0 | EXPLICIT_MODE | |
  28369. * | 1 | SPHERICAL_MODE | |
  28370. * | 2 | PLANAR_MODE | |
  28371. * | 3 | CUBIC_MODE | |
  28372. * | 4 | PROJECTION_MODE | |
  28373. * | 5 | SKYBOX_MODE | |
  28374. * | 6 | INVCUBIC_MODE | |
  28375. * | 7 | EQUIRECTANGULAR_MODE | |
  28376. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28377. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28378. */
  28379. coordinatesMode: number;
  28380. /**
  28381. * | Value | Type | Description |
  28382. * | ----- | ------------------ | ----------- |
  28383. * | 0 | CLAMP_ADDRESSMODE | |
  28384. * | 1 | WRAP_ADDRESSMODE | |
  28385. * | 2 | MIRROR_ADDRESSMODE | |
  28386. */
  28387. wrapU: number;
  28388. /**
  28389. * | Value | Type | Description |
  28390. * | ----- | ------------------ | ----------- |
  28391. * | 0 | CLAMP_ADDRESSMODE | |
  28392. * | 1 | WRAP_ADDRESSMODE | |
  28393. * | 2 | MIRROR_ADDRESSMODE | |
  28394. */
  28395. wrapV: number;
  28396. /**
  28397. * | Value | Type | Description |
  28398. * | ----- | ------------------ | ----------- |
  28399. * | 0 | CLAMP_ADDRESSMODE | |
  28400. * | 1 | WRAP_ADDRESSMODE | |
  28401. * | 2 | MIRROR_ADDRESSMODE | |
  28402. */
  28403. wrapR: number;
  28404. /**
  28405. * With compliant hardware and browser (supporting anisotropic filtering)
  28406. * this defines the level of anisotropic filtering in the texture.
  28407. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28408. */
  28409. anisotropicFilteringLevel: number;
  28410. /**
  28411. * Define if the texture is a cube texture or if false a 2d texture.
  28412. */
  28413. isCube: boolean;
  28414. /**
  28415. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28416. */
  28417. is3D: boolean;
  28418. /**
  28419. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28420. * HDR texture are usually stored in linear space.
  28421. * This only impacts the PBR and Background materials
  28422. */
  28423. gammaSpace: boolean;
  28424. /**
  28425. * Gets or sets whether or not the texture contains RGBD data.
  28426. */
  28427. isRGBD: boolean;
  28428. /**
  28429. * Is Z inverted in the texture (useful in a cube texture).
  28430. */
  28431. invertZ: boolean;
  28432. /**
  28433. * Are mip maps generated for this texture or not.
  28434. */
  28435. readonly noMipmap: boolean;
  28436. /**
  28437. * @hidden
  28438. */
  28439. lodLevelInAlpha: boolean;
  28440. /**
  28441. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28442. */
  28443. lodGenerationOffset: number;
  28444. /**
  28445. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28446. */
  28447. lodGenerationScale: number;
  28448. /**
  28449. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28450. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28451. * average roughness values.
  28452. */
  28453. linearSpecularLOD: boolean;
  28454. /**
  28455. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28456. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28457. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28458. */
  28459. irradianceTexture: Nullable<BaseTexture>;
  28460. /**
  28461. * Define if the texture is a render target.
  28462. */
  28463. isRenderTarget: boolean;
  28464. /**
  28465. * Define the unique id of the texture in the scene.
  28466. */
  28467. readonly uid: string;
  28468. /**
  28469. * Return a string representation of the texture.
  28470. * @returns the texture as a string
  28471. */
  28472. toString(): string;
  28473. /**
  28474. * Get the class name of the texture.
  28475. * @returns "BaseTexture"
  28476. */
  28477. getClassName(): string;
  28478. /**
  28479. * Define the list of animation attached to the texture.
  28480. */
  28481. animations: import("babylonjs/Animations/animation").Animation[];
  28482. /**
  28483. * An event triggered when the texture is disposed.
  28484. */
  28485. onDisposeObservable: Observable<BaseTexture>;
  28486. private _onDisposeObserver;
  28487. /**
  28488. * Callback triggered when the texture has been disposed.
  28489. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28490. */
  28491. onDispose: () => void;
  28492. /**
  28493. * Define the current state of the loading sequence when in delayed load mode.
  28494. */
  28495. delayLoadState: number;
  28496. private _scene;
  28497. /** @hidden */
  28498. _texture: Nullable<InternalTexture>;
  28499. private _uid;
  28500. /**
  28501. * Define if the texture is preventinga material to render or not.
  28502. * If not and the texture is not ready, the engine will use a default black texture instead.
  28503. */
  28504. readonly isBlocking: boolean;
  28505. /**
  28506. * Instantiates a new BaseTexture.
  28507. * Base class of all the textures in babylon.
  28508. * It groups all the common properties the materials, post process, lights... might need
  28509. * in order to make a correct use of the texture.
  28510. * @param scene Define the scene the texture blongs to
  28511. */
  28512. constructor(scene: Nullable<Scene>);
  28513. /**
  28514. * Get the scene the texture belongs to.
  28515. * @returns the scene or null if undefined
  28516. */
  28517. getScene(): Nullable<Scene>;
  28518. /**
  28519. * Get the texture transform matrix used to offset tile the texture for istance.
  28520. * @returns the transformation matrix
  28521. */
  28522. getTextureMatrix(): Matrix;
  28523. /**
  28524. * Get the texture reflection matrix used to rotate/transform the reflection.
  28525. * @returns the reflection matrix
  28526. */
  28527. getReflectionTextureMatrix(): Matrix;
  28528. /**
  28529. * Get the underlying lower level texture from Babylon.
  28530. * @returns the insternal texture
  28531. */
  28532. getInternalTexture(): Nullable<InternalTexture>;
  28533. /**
  28534. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28535. * @returns true if ready or not blocking
  28536. */
  28537. isReadyOrNotBlocking(): boolean;
  28538. /**
  28539. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28540. * @returns true if fully ready
  28541. */
  28542. isReady(): boolean;
  28543. private _cachedSize;
  28544. /**
  28545. * Get the size of the texture.
  28546. * @returns the texture size.
  28547. */
  28548. getSize(): ISize;
  28549. /**
  28550. * Get the base size of the texture.
  28551. * It can be different from the size if the texture has been resized for POT for instance
  28552. * @returns the base size
  28553. */
  28554. getBaseSize(): ISize;
  28555. /**
  28556. * Update the sampling mode of the texture.
  28557. * Default is Trilinear mode.
  28558. *
  28559. * | Value | Type | Description |
  28560. * | ----- | ------------------ | ----------- |
  28561. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28562. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28563. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28564. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28565. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28566. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28567. * | 7 | NEAREST_LINEAR | |
  28568. * | 8 | NEAREST_NEAREST | |
  28569. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28570. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28571. * | 11 | LINEAR_LINEAR | |
  28572. * | 12 | LINEAR_NEAREST | |
  28573. *
  28574. * > _mag_: magnification filter (close to the viewer)
  28575. * > _min_: minification filter (far from the viewer)
  28576. * > _mip_: filter used between mip map levels
  28577. *@param samplingMode Define the new sampling mode of the texture
  28578. */
  28579. updateSamplingMode(samplingMode: number): void;
  28580. /**
  28581. * Scales the texture if is `canRescale()`
  28582. * @param ratio the resize factor we want to use to rescale
  28583. */
  28584. scale(ratio: number): void;
  28585. /**
  28586. * Get if the texture can rescale.
  28587. */
  28588. readonly canRescale: boolean;
  28589. /** @hidden */
  28590. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28591. /** @hidden */
  28592. _rebuild(): void;
  28593. /**
  28594. * Triggers the load sequence in delayed load mode.
  28595. */
  28596. delayLoad(): void;
  28597. /**
  28598. * Clones the texture.
  28599. * @returns the cloned texture
  28600. */
  28601. clone(): Nullable<BaseTexture>;
  28602. /**
  28603. * Get the texture underlying type (INT, FLOAT...)
  28604. */
  28605. readonly textureType: number;
  28606. /**
  28607. * Get the texture underlying format (RGB, RGBA...)
  28608. */
  28609. readonly textureFormat: number;
  28610. /**
  28611. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28612. * This will returns an RGBA array buffer containing either in values (0-255) or
  28613. * float values (0-1) depending of the underlying buffer type.
  28614. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28615. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28616. * @param buffer defines a user defined buffer to fill with data (can be null)
  28617. * @returns The Array buffer containing the pixels data.
  28618. */
  28619. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28620. /**
  28621. * Release and destroy the underlying lower level texture aka internalTexture.
  28622. */
  28623. releaseInternalTexture(): void;
  28624. /**
  28625. * Get the polynomial representation of the texture data.
  28626. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28627. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28628. */
  28629. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28630. /** @hidden */
  28631. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28632. /** @hidden */
  28633. readonly _lodTextureMid: Nullable<BaseTexture>;
  28634. /** @hidden */
  28635. readonly _lodTextureLow: Nullable<BaseTexture>;
  28636. /**
  28637. * Dispose the texture and release its associated resources.
  28638. */
  28639. dispose(): void;
  28640. /**
  28641. * Serialize the texture into a JSON representation that can be parsed later on.
  28642. * @returns the JSON representation of the texture
  28643. */
  28644. serialize(): any;
  28645. /**
  28646. * Helper function to be called back once a list of texture contains only ready textures.
  28647. * @param textures Define the list of textures to wait for
  28648. * @param callback Define the callback triggered once the entire list will be ready
  28649. */
  28650. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28651. }
  28652. }
  28653. declare module "babylonjs/Materials/Textures/internalTexture" {
  28654. import { Observable } from "babylonjs/Misc/observable";
  28655. import { Nullable, int } from "babylonjs/types";
  28656. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28657. import { Engine } from "babylonjs/Engines/engine";
  28658. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28659. /**
  28660. * Class used to store data associated with WebGL texture data for the engine
  28661. * This class should not be used directly
  28662. */
  28663. export class InternalTexture {
  28664. /** @hidden */
  28665. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28666. /**
  28667. * The source of the texture data is unknown
  28668. */
  28669. static DATASOURCE_UNKNOWN: number;
  28670. /**
  28671. * Texture data comes from an URL
  28672. */
  28673. static DATASOURCE_URL: number;
  28674. /**
  28675. * Texture data is only used for temporary storage
  28676. */
  28677. static DATASOURCE_TEMP: number;
  28678. /**
  28679. * Texture data comes from raw data (ArrayBuffer)
  28680. */
  28681. static DATASOURCE_RAW: number;
  28682. /**
  28683. * Texture content is dynamic (video or dynamic texture)
  28684. */
  28685. static DATASOURCE_DYNAMIC: number;
  28686. /**
  28687. * Texture content is generated by rendering to it
  28688. */
  28689. static DATASOURCE_RENDERTARGET: number;
  28690. /**
  28691. * Texture content is part of a multi render target process
  28692. */
  28693. static DATASOURCE_MULTIRENDERTARGET: number;
  28694. /**
  28695. * Texture data comes from a cube data file
  28696. */
  28697. static DATASOURCE_CUBE: number;
  28698. /**
  28699. * Texture data comes from a raw cube data
  28700. */
  28701. static DATASOURCE_CUBERAW: number;
  28702. /**
  28703. * Texture data come from a prefiltered cube data file
  28704. */
  28705. static DATASOURCE_CUBEPREFILTERED: number;
  28706. /**
  28707. * Texture content is raw 3D data
  28708. */
  28709. static DATASOURCE_RAW3D: number;
  28710. /**
  28711. * Texture content is a depth texture
  28712. */
  28713. static DATASOURCE_DEPTHTEXTURE: number;
  28714. /**
  28715. * Texture data comes from a raw cube data encoded with RGBD
  28716. */
  28717. static DATASOURCE_CUBERAW_RGBD: number;
  28718. /**
  28719. * Defines if the texture is ready
  28720. */
  28721. isReady: boolean;
  28722. /**
  28723. * Defines if the texture is a cube texture
  28724. */
  28725. isCube: boolean;
  28726. /**
  28727. * Defines if the texture contains 3D data
  28728. */
  28729. is3D: boolean;
  28730. /**
  28731. * Defines if the texture contains multiview data
  28732. */
  28733. isMultiview: boolean;
  28734. /**
  28735. * Gets the URL used to load this texture
  28736. */
  28737. url: string;
  28738. /**
  28739. * Gets the sampling mode of the texture
  28740. */
  28741. samplingMode: number;
  28742. /**
  28743. * Gets a boolean indicating if the texture needs mipmaps generation
  28744. */
  28745. generateMipMaps: boolean;
  28746. /**
  28747. * Gets the number of samples used by the texture (WebGL2+ only)
  28748. */
  28749. samples: number;
  28750. /**
  28751. * Gets the type of the texture (int, float...)
  28752. */
  28753. type: number;
  28754. /**
  28755. * Gets the format of the texture (RGB, RGBA...)
  28756. */
  28757. format: number;
  28758. /**
  28759. * Observable called when the texture is loaded
  28760. */
  28761. onLoadedObservable: Observable<InternalTexture>;
  28762. /**
  28763. * Gets the width of the texture
  28764. */
  28765. width: number;
  28766. /**
  28767. * Gets the height of the texture
  28768. */
  28769. height: number;
  28770. /**
  28771. * Gets the depth of the texture
  28772. */
  28773. depth: number;
  28774. /**
  28775. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28776. */
  28777. baseWidth: number;
  28778. /**
  28779. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28780. */
  28781. baseHeight: number;
  28782. /**
  28783. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28784. */
  28785. baseDepth: number;
  28786. /**
  28787. * Gets a boolean indicating if the texture is inverted on Y axis
  28788. */
  28789. invertY: boolean;
  28790. /** @hidden */
  28791. _invertVScale: boolean;
  28792. /** @hidden */
  28793. _associatedChannel: number;
  28794. /** @hidden */
  28795. _dataSource: number;
  28796. /** @hidden */
  28797. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  28798. /** @hidden */
  28799. _bufferView: Nullable<ArrayBufferView>;
  28800. /** @hidden */
  28801. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28802. /** @hidden */
  28803. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28804. /** @hidden */
  28805. _size: number;
  28806. /** @hidden */
  28807. _extension: string;
  28808. /** @hidden */
  28809. _files: Nullable<string[]>;
  28810. /** @hidden */
  28811. _workingCanvas: Nullable<HTMLCanvasElement>;
  28812. /** @hidden */
  28813. _workingContext: Nullable<CanvasRenderingContext2D>;
  28814. /** @hidden */
  28815. _framebuffer: Nullable<WebGLFramebuffer>;
  28816. /** @hidden */
  28817. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28818. /** @hidden */
  28819. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28820. /** @hidden */
  28821. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28822. /** @hidden */
  28823. _attachments: Nullable<number[]>;
  28824. /** @hidden */
  28825. _cachedCoordinatesMode: Nullable<number>;
  28826. /** @hidden */
  28827. _cachedWrapU: Nullable<number>;
  28828. /** @hidden */
  28829. _cachedWrapV: Nullable<number>;
  28830. /** @hidden */
  28831. _cachedWrapR: Nullable<number>;
  28832. /** @hidden */
  28833. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28834. /** @hidden */
  28835. _isDisabled: boolean;
  28836. /** @hidden */
  28837. _compression: Nullable<string>;
  28838. /** @hidden */
  28839. _generateStencilBuffer: boolean;
  28840. /** @hidden */
  28841. _generateDepthBuffer: boolean;
  28842. /** @hidden */
  28843. _comparisonFunction: number;
  28844. /** @hidden */
  28845. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28846. /** @hidden */
  28847. _lodGenerationScale: number;
  28848. /** @hidden */
  28849. _lodGenerationOffset: number;
  28850. /** @hidden */
  28851. _colorTextureArray: Nullable<WebGLTexture>;
  28852. /** @hidden */
  28853. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28854. /** @hidden */
  28855. _lodTextureHigh: Nullable<BaseTexture>;
  28856. /** @hidden */
  28857. _lodTextureMid: Nullable<BaseTexture>;
  28858. /** @hidden */
  28859. _lodTextureLow: Nullable<BaseTexture>;
  28860. /** @hidden */
  28861. _isRGBD: boolean;
  28862. /** @hidden */
  28863. _linearSpecularLOD: boolean;
  28864. /** @hidden */
  28865. _irradianceTexture: Nullable<BaseTexture>;
  28866. /** @hidden */
  28867. _webGLTexture: Nullable<WebGLTexture>;
  28868. /** @hidden */
  28869. _references: number;
  28870. private _engine;
  28871. /**
  28872. * Gets the Engine the texture belongs to.
  28873. * @returns The babylon engine
  28874. */
  28875. getEngine(): Engine;
  28876. /**
  28877. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28878. */
  28879. readonly dataSource: number;
  28880. /**
  28881. * Creates a new InternalTexture
  28882. * @param engine defines the engine to use
  28883. * @param dataSource defines the type of data that will be used
  28884. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28885. */
  28886. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28887. /**
  28888. * Increments the number of references (ie. the number of Texture that point to it)
  28889. */
  28890. incrementReferences(): void;
  28891. /**
  28892. * Change the size of the texture (not the size of the content)
  28893. * @param width defines the new width
  28894. * @param height defines the new height
  28895. * @param depth defines the new depth (1 by default)
  28896. */
  28897. updateSize(width: int, height: int, depth?: int): void;
  28898. /** @hidden */
  28899. _rebuild(): void;
  28900. /** @hidden */
  28901. _swapAndDie(target: InternalTexture): void;
  28902. /**
  28903. * Dispose the current allocated resources
  28904. */
  28905. dispose(): void;
  28906. }
  28907. }
  28908. declare module "babylonjs/Materials/effect" {
  28909. import { Observable } from "babylonjs/Misc/observable";
  28910. import { Nullable } from "babylonjs/types";
  28911. import { IDisposable } from "babylonjs/scene";
  28912. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28913. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28914. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28915. import { Engine } from "babylonjs/Engines/engine";
  28916. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28917. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28918. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28919. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28920. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28921. /**
  28922. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28923. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28924. */
  28925. export class EffectFallbacks {
  28926. private _defines;
  28927. private _currentRank;
  28928. private _maxRank;
  28929. private _mesh;
  28930. /**
  28931. * Removes the fallback from the bound mesh.
  28932. */
  28933. unBindMesh(): void;
  28934. /**
  28935. * Adds a fallback on the specified property.
  28936. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28937. * @param define The name of the define in the shader
  28938. */
  28939. addFallback(rank: number, define: string): void;
  28940. /**
  28941. * Sets the mesh to use CPU skinning when needing to fallback.
  28942. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28943. * @param mesh The mesh to use the fallbacks.
  28944. */
  28945. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28946. /**
  28947. * Checks to see if more fallbacks are still availible.
  28948. */
  28949. readonly hasMoreFallbacks: boolean;
  28950. /**
  28951. * Removes the defines that should be removed when falling back.
  28952. * @param currentDefines defines the current define statements for the shader.
  28953. * @param effect defines the current effect we try to compile
  28954. * @returns The resulting defines with defines of the current rank removed.
  28955. */
  28956. reduce(currentDefines: string, effect: Effect): string;
  28957. }
  28958. /**
  28959. * Options to be used when creating an effect.
  28960. */
  28961. export class EffectCreationOptions {
  28962. /**
  28963. * Atrributes that will be used in the shader.
  28964. */
  28965. attributes: string[];
  28966. /**
  28967. * Uniform varible names that will be set in the shader.
  28968. */
  28969. uniformsNames: string[];
  28970. /**
  28971. * Uniform buffer varible names that will be set in the shader.
  28972. */
  28973. uniformBuffersNames: string[];
  28974. /**
  28975. * Sampler texture variable names that will be set in the shader.
  28976. */
  28977. samplers: string[];
  28978. /**
  28979. * Define statements that will be set in the shader.
  28980. */
  28981. defines: any;
  28982. /**
  28983. * Possible fallbacks for this effect to improve performance when needed.
  28984. */
  28985. fallbacks: Nullable<EffectFallbacks>;
  28986. /**
  28987. * Callback that will be called when the shader is compiled.
  28988. */
  28989. onCompiled: Nullable<(effect: Effect) => void>;
  28990. /**
  28991. * Callback that will be called if an error occurs during shader compilation.
  28992. */
  28993. onError: Nullable<(effect: Effect, errors: string) => void>;
  28994. /**
  28995. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28996. */
  28997. indexParameters: any;
  28998. /**
  28999. * Max number of lights that can be used in the shader.
  29000. */
  29001. maxSimultaneousLights: number;
  29002. /**
  29003. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29004. */
  29005. transformFeedbackVaryings: Nullable<string[]>;
  29006. }
  29007. /**
  29008. * Effect containing vertex and fragment shader that can be executed on an object.
  29009. */
  29010. export class Effect implements IDisposable {
  29011. /**
  29012. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29013. */
  29014. static ShadersRepository: string;
  29015. /**
  29016. * Name of the effect.
  29017. */
  29018. name: any;
  29019. /**
  29020. * String container all the define statements that should be set on the shader.
  29021. */
  29022. defines: string;
  29023. /**
  29024. * Callback that will be called when the shader is compiled.
  29025. */
  29026. onCompiled: Nullable<(effect: Effect) => void>;
  29027. /**
  29028. * Callback that will be called if an error occurs during shader compilation.
  29029. */
  29030. onError: Nullable<(effect: Effect, errors: string) => void>;
  29031. /**
  29032. * Callback that will be called when effect is bound.
  29033. */
  29034. onBind: Nullable<(effect: Effect) => void>;
  29035. /**
  29036. * Unique ID of the effect.
  29037. */
  29038. uniqueId: number;
  29039. /**
  29040. * Observable that will be called when the shader is compiled.
  29041. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29042. */
  29043. onCompileObservable: Observable<Effect>;
  29044. /**
  29045. * Observable that will be called if an error occurs during shader compilation.
  29046. */
  29047. onErrorObservable: Observable<Effect>;
  29048. /** @hidden */
  29049. _onBindObservable: Nullable<Observable<Effect>>;
  29050. /**
  29051. * Observable that will be called when effect is bound.
  29052. */
  29053. readonly onBindObservable: Observable<Effect>;
  29054. /** @hidden */
  29055. _bonesComputationForcedToCPU: boolean;
  29056. private static _uniqueIdSeed;
  29057. private _engine;
  29058. private _uniformBuffersNames;
  29059. private _uniformsNames;
  29060. private _samplerList;
  29061. private _samplers;
  29062. private _isReady;
  29063. private _compilationError;
  29064. private _attributesNames;
  29065. private _attributes;
  29066. private _uniforms;
  29067. /**
  29068. * Key for the effect.
  29069. * @hidden
  29070. */
  29071. _key: string;
  29072. private _indexParameters;
  29073. private _fallbacks;
  29074. private _vertexSourceCode;
  29075. private _fragmentSourceCode;
  29076. private _vertexSourceCodeOverride;
  29077. private _fragmentSourceCodeOverride;
  29078. private _transformFeedbackVaryings;
  29079. /**
  29080. * Compiled shader to webGL program.
  29081. * @hidden
  29082. */
  29083. _pipelineContext: Nullable<IPipelineContext>;
  29084. private _valueCache;
  29085. private static _baseCache;
  29086. /**
  29087. * Instantiates an effect.
  29088. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29089. * @param baseName Name of the effect.
  29090. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29091. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29092. * @param samplers List of sampler variables that will be passed to the shader.
  29093. * @param engine Engine to be used to render the effect
  29094. * @param defines Define statements to be added to the shader.
  29095. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29096. * @param onCompiled Callback that will be called when the shader is compiled.
  29097. * @param onError Callback that will be called if an error occurs during shader compilation.
  29098. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29099. */
  29100. 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);
  29101. private _useFinalCode;
  29102. /**
  29103. * Unique key for this effect
  29104. */
  29105. readonly key: string;
  29106. /**
  29107. * If the effect has been compiled and prepared.
  29108. * @returns if the effect is compiled and prepared.
  29109. */
  29110. isReady(): boolean;
  29111. private _isReadyInternal;
  29112. /**
  29113. * The engine the effect was initialized with.
  29114. * @returns the engine.
  29115. */
  29116. getEngine(): Engine;
  29117. /**
  29118. * The pipeline context for this effect
  29119. * @returns the associated pipeline context
  29120. */
  29121. getPipelineContext(): Nullable<IPipelineContext>;
  29122. /**
  29123. * The set of names of attribute variables for the shader.
  29124. * @returns An array of attribute names.
  29125. */
  29126. getAttributesNames(): string[];
  29127. /**
  29128. * Returns the attribute at the given index.
  29129. * @param index The index of the attribute.
  29130. * @returns The location of the attribute.
  29131. */
  29132. getAttributeLocation(index: number): number;
  29133. /**
  29134. * Returns the attribute based on the name of the variable.
  29135. * @param name of the attribute to look up.
  29136. * @returns the attribute location.
  29137. */
  29138. getAttributeLocationByName(name: string): number;
  29139. /**
  29140. * The number of attributes.
  29141. * @returns the numnber of attributes.
  29142. */
  29143. getAttributesCount(): number;
  29144. /**
  29145. * Gets the index of a uniform variable.
  29146. * @param uniformName of the uniform to look up.
  29147. * @returns the index.
  29148. */
  29149. getUniformIndex(uniformName: string): number;
  29150. /**
  29151. * Returns the attribute based on the name of the variable.
  29152. * @param uniformName of the uniform to look up.
  29153. * @returns the location of the uniform.
  29154. */
  29155. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29156. /**
  29157. * Returns an array of sampler variable names
  29158. * @returns The array of sampler variable neames.
  29159. */
  29160. getSamplers(): string[];
  29161. /**
  29162. * The error from the last compilation.
  29163. * @returns the error string.
  29164. */
  29165. getCompilationError(): string;
  29166. /**
  29167. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29168. * @param func The callback to be used.
  29169. */
  29170. executeWhenCompiled(func: (effect: Effect) => void): void;
  29171. private _checkIsReady;
  29172. /** @hidden */
  29173. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29174. /** @hidden */
  29175. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29176. /** @hidden */
  29177. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29178. /**
  29179. * Recompiles the webGL program
  29180. * @param vertexSourceCode The source code for the vertex shader.
  29181. * @param fragmentSourceCode The source code for the fragment shader.
  29182. * @param onCompiled Callback called when completed.
  29183. * @param onError Callback called on error.
  29184. * @hidden
  29185. */
  29186. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29187. /**
  29188. * Prepares the effect
  29189. * @hidden
  29190. */
  29191. _prepareEffect(): void;
  29192. private _processCompilationErrors;
  29193. /**
  29194. * Checks if the effect is supported. (Must be called after compilation)
  29195. */
  29196. readonly isSupported: boolean;
  29197. /**
  29198. * Binds a texture to the engine to be used as output of the shader.
  29199. * @param channel Name of the output variable.
  29200. * @param texture Texture to bind.
  29201. * @hidden
  29202. */
  29203. _bindTexture(channel: string, texture: InternalTexture): void;
  29204. /**
  29205. * Sets a texture on the engine to be used in the shader.
  29206. * @param channel Name of the sampler variable.
  29207. * @param texture Texture to set.
  29208. */
  29209. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29210. /**
  29211. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29212. * @param channel Name of the sampler variable.
  29213. * @param texture Texture to set.
  29214. */
  29215. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29216. /**
  29217. * Sets an array of textures on the engine to be used in the shader.
  29218. * @param channel Name of the variable.
  29219. * @param textures Textures to set.
  29220. */
  29221. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29222. /**
  29223. * 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)
  29224. * @param channel Name of the sampler variable.
  29225. * @param postProcess Post process to get the input texture from.
  29226. */
  29227. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29228. /**
  29229. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29230. * 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)
  29231. * @param channel Name of the sampler variable.
  29232. * @param postProcess Post process to get the output texture from.
  29233. */
  29234. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29235. /** @hidden */
  29236. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29237. /** @hidden */
  29238. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29239. /** @hidden */
  29240. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29241. /** @hidden */
  29242. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29243. /**
  29244. * Binds a buffer to a uniform.
  29245. * @param buffer Buffer to bind.
  29246. * @param name Name of the uniform variable to bind to.
  29247. */
  29248. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29249. /**
  29250. * Binds block to a uniform.
  29251. * @param blockName Name of the block to bind.
  29252. * @param index Index to bind.
  29253. */
  29254. bindUniformBlock(blockName: string, index: number): void;
  29255. /**
  29256. * Sets an interger value on a uniform variable.
  29257. * @param uniformName Name of the variable.
  29258. * @param value Value to be set.
  29259. * @returns this effect.
  29260. */
  29261. setInt(uniformName: string, value: number): Effect;
  29262. /**
  29263. * Sets an int array on a uniform variable.
  29264. * @param uniformName Name of the variable.
  29265. * @param array array to be set.
  29266. * @returns this effect.
  29267. */
  29268. setIntArray(uniformName: string, array: Int32Array): Effect;
  29269. /**
  29270. * 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)
  29271. * @param uniformName Name of the variable.
  29272. * @param array array to be set.
  29273. * @returns this effect.
  29274. */
  29275. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29276. /**
  29277. * 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)
  29278. * @param uniformName Name of the variable.
  29279. * @param array array to be set.
  29280. * @returns this effect.
  29281. */
  29282. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29283. /**
  29284. * 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)
  29285. * @param uniformName Name of the variable.
  29286. * @param array array to be set.
  29287. * @returns this effect.
  29288. */
  29289. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29290. /**
  29291. * Sets an float array on a uniform variable.
  29292. * @param uniformName Name of the variable.
  29293. * @param array array to be set.
  29294. * @returns this effect.
  29295. */
  29296. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29297. /**
  29298. * 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)
  29299. * @param uniformName Name of the variable.
  29300. * @param array array to be set.
  29301. * @returns this effect.
  29302. */
  29303. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29304. /**
  29305. * 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)
  29306. * @param uniformName Name of the variable.
  29307. * @param array array to be set.
  29308. * @returns this effect.
  29309. */
  29310. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29311. /**
  29312. * 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)
  29313. * @param uniformName Name of the variable.
  29314. * @param array array to be set.
  29315. * @returns this effect.
  29316. */
  29317. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29318. /**
  29319. * Sets an array on a uniform variable.
  29320. * @param uniformName Name of the variable.
  29321. * @param array array to be set.
  29322. * @returns this effect.
  29323. */
  29324. setArray(uniformName: string, array: number[]): Effect;
  29325. /**
  29326. * 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)
  29327. * @param uniformName Name of the variable.
  29328. * @param array array to be set.
  29329. * @returns this effect.
  29330. */
  29331. setArray2(uniformName: string, array: number[]): Effect;
  29332. /**
  29333. * 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)
  29334. * @param uniformName Name of the variable.
  29335. * @param array array to be set.
  29336. * @returns this effect.
  29337. */
  29338. setArray3(uniformName: string, array: number[]): Effect;
  29339. /**
  29340. * 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)
  29341. * @param uniformName Name of the variable.
  29342. * @param array array to be set.
  29343. * @returns this effect.
  29344. */
  29345. setArray4(uniformName: string, array: number[]): Effect;
  29346. /**
  29347. * Sets matrices on a uniform variable.
  29348. * @param uniformName Name of the variable.
  29349. * @param matrices matrices to be set.
  29350. * @returns this effect.
  29351. */
  29352. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29353. /**
  29354. * Sets matrix on a uniform variable.
  29355. * @param uniformName Name of the variable.
  29356. * @param matrix matrix to be set.
  29357. * @returns this effect.
  29358. */
  29359. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29360. /**
  29361. * 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)
  29362. * @param uniformName Name of the variable.
  29363. * @param matrix matrix to be set.
  29364. * @returns this effect.
  29365. */
  29366. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29367. /**
  29368. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29369. * @param uniformName Name of the variable.
  29370. * @param matrix matrix to be set.
  29371. * @returns this effect.
  29372. */
  29373. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29374. /**
  29375. * Sets a float on a uniform variable.
  29376. * @param uniformName Name of the variable.
  29377. * @param value value to be set.
  29378. * @returns this effect.
  29379. */
  29380. setFloat(uniformName: string, value: number): Effect;
  29381. /**
  29382. * Sets a boolean on a uniform variable.
  29383. * @param uniformName Name of the variable.
  29384. * @param bool value to be set.
  29385. * @returns this effect.
  29386. */
  29387. setBool(uniformName: string, bool: boolean): Effect;
  29388. /**
  29389. * Sets a Vector2 on a uniform variable.
  29390. * @param uniformName Name of the variable.
  29391. * @param vector2 vector2 to be set.
  29392. * @returns this effect.
  29393. */
  29394. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29395. /**
  29396. * Sets a float2 on a uniform variable.
  29397. * @param uniformName Name of the variable.
  29398. * @param x First float in float2.
  29399. * @param y Second float in float2.
  29400. * @returns this effect.
  29401. */
  29402. setFloat2(uniformName: string, x: number, y: number): Effect;
  29403. /**
  29404. * Sets a Vector3 on a uniform variable.
  29405. * @param uniformName Name of the variable.
  29406. * @param vector3 Value to be set.
  29407. * @returns this effect.
  29408. */
  29409. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29410. /**
  29411. * Sets a float3 on a uniform variable.
  29412. * @param uniformName Name of the variable.
  29413. * @param x First float in float3.
  29414. * @param y Second float in float3.
  29415. * @param z Third float in float3.
  29416. * @returns this effect.
  29417. */
  29418. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29419. /**
  29420. * Sets a Vector4 on a uniform variable.
  29421. * @param uniformName Name of the variable.
  29422. * @param vector4 Value to be set.
  29423. * @returns this effect.
  29424. */
  29425. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29426. /**
  29427. * Sets a float4 on a uniform variable.
  29428. * @param uniformName Name of the variable.
  29429. * @param x First float in float4.
  29430. * @param y Second float in float4.
  29431. * @param z Third float in float4.
  29432. * @param w Fourth float in float4.
  29433. * @returns this effect.
  29434. */
  29435. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29436. /**
  29437. * Sets a Color3 on a uniform variable.
  29438. * @param uniformName Name of the variable.
  29439. * @param color3 Value to be set.
  29440. * @returns this effect.
  29441. */
  29442. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29443. /**
  29444. * Sets a Color4 on a uniform variable.
  29445. * @param uniformName Name of the variable.
  29446. * @param color3 Value to be set.
  29447. * @param alpha Alpha value to be set.
  29448. * @returns this effect.
  29449. */
  29450. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29451. /**
  29452. * Sets a Color4 on a uniform variable
  29453. * @param uniformName defines the name of the variable
  29454. * @param color4 defines the value to be set
  29455. * @returns this effect.
  29456. */
  29457. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29458. /** Release all associated resources */
  29459. dispose(): void;
  29460. /**
  29461. * This function will add a new shader to the shader store
  29462. * @param name the name of the shader
  29463. * @param pixelShader optional pixel shader content
  29464. * @param vertexShader optional vertex shader content
  29465. */
  29466. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29467. /**
  29468. * Store of each shader (The can be looked up using effect.key)
  29469. */
  29470. static ShadersStore: {
  29471. [key: string]: string;
  29472. };
  29473. /**
  29474. * Store of each included file for a shader (The can be looked up using effect.key)
  29475. */
  29476. static IncludesShadersStore: {
  29477. [key: string]: string;
  29478. };
  29479. /**
  29480. * Resets the cache of effects.
  29481. */
  29482. static ResetCache(): void;
  29483. }
  29484. }
  29485. declare module "babylonjs/Materials/uniformBuffer" {
  29486. import { Nullable, FloatArray } from "babylonjs/types";
  29487. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29488. import { Engine } from "babylonjs/Engines/engine";
  29489. import { Effect } from "babylonjs/Materials/effect";
  29490. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29491. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29492. import { Color3 } from "babylonjs/Maths/math.color";
  29493. /**
  29494. * Uniform buffer objects.
  29495. *
  29496. * Handles blocks of uniform on the GPU.
  29497. *
  29498. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29499. *
  29500. * For more information, please refer to :
  29501. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29502. */
  29503. export class UniformBuffer {
  29504. private _engine;
  29505. private _buffer;
  29506. private _data;
  29507. private _bufferData;
  29508. private _dynamic?;
  29509. private _uniformLocations;
  29510. private _uniformSizes;
  29511. private _uniformLocationPointer;
  29512. private _needSync;
  29513. private _noUBO;
  29514. private _currentEffect;
  29515. private static _MAX_UNIFORM_SIZE;
  29516. private static _tempBuffer;
  29517. /**
  29518. * Lambda to Update a 3x3 Matrix 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. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29523. /**
  29524. * Lambda to Update a 2x2 Matrix 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. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29529. /**
  29530. * Lambda to Update a single float 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. updateFloat: (name: string, x: number) => void;
  29535. /**
  29536. * Lambda to Update a vec2 of float in a uniform buffer.
  29537. * This is dynamic to allow compat with webgl 1 and 2.
  29538. * You will need to pass the name of the uniform as well as the value.
  29539. */
  29540. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29541. /**
  29542. * Lambda to Update a vec3 of float in a uniform buffer.
  29543. * This is dynamic to allow compat with webgl 1 and 2.
  29544. * You will need to pass the name of the uniform as well as the value.
  29545. */
  29546. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29547. /**
  29548. * Lambda to Update a vec4 of float in a uniform buffer.
  29549. * This is dynamic to allow compat with webgl 1 and 2.
  29550. * You will need to pass the name of the uniform as well as the value.
  29551. */
  29552. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29553. /**
  29554. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29555. * This is dynamic to allow compat with webgl 1 and 2.
  29556. * You will need to pass the name of the uniform as well as the value.
  29557. */
  29558. updateMatrix: (name: string, mat: Matrix) => void;
  29559. /**
  29560. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29561. * This is dynamic to allow compat with webgl 1 and 2.
  29562. * You will need to pass the name of the uniform as well as the value.
  29563. */
  29564. updateVector3: (name: string, vector: Vector3) => void;
  29565. /**
  29566. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29567. * This is dynamic to allow compat with webgl 1 and 2.
  29568. * You will need to pass the name of the uniform as well as the value.
  29569. */
  29570. updateVector4: (name: string, vector: Vector4) => void;
  29571. /**
  29572. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29573. * This is dynamic to allow compat with webgl 1 and 2.
  29574. * You will need to pass the name of the uniform as well as the value.
  29575. */
  29576. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29577. /**
  29578. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29579. * This is dynamic to allow compat with webgl 1 and 2.
  29580. * You will need to pass the name of the uniform as well as the value.
  29581. */
  29582. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29583. /**
  29584. * Instantiates a new Uniform buffer objects.
  29585. *
  29586. * Handles blocks of uniform on the GPU.
  29587. *
  29588. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29589. *
  29590. * For more information, please refer to :
  29591. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29592. * @param engine Define the engine the buffer is associated with
  29593. * @param data Define the data contained in the buffer
  29594. * @param dynamic Define if the buffer is updatable
  29595. */
  29596. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29597. /**
  29598. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29599. * or just falling back on setUniformXXX calls.
  29600. */
  29601. readonly useUbo: boolean;
  29602. /**
  29603. * Indicates if the WebGL underlying uniform buffer is in sync
  29604. * with the javascript cache data.
  29605. */
  29606. readonly isSync: boolean;
  29607. /**
  29608. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29609. * Also, a dynamic UniformBuffer will disable cache verification and always
  29610. * update the underlying WebGL uniform buffer to the GPU.
  29611. * @returns if Dynamic, otherwise false
  29612. */
  29613. isDynamic(): boolean;
  29614. /**
  29615. * The data cache on JS side.
  29616. * @returns the underlying data as a float array
  29617. */
  29618. getData(): Float32Array;
  29619. /**
  29620. * The underlying WebGL Uniform buffer.
  29621. * @returns the webgl buffer
  29622. */
  29623. getBuffer(): Nullable<DataBuffer>;
  29624. /**
  29625. * std140 layout specifies how to align data within an UBO structure.
  29626. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29627. * for specs.
  29628. */
  29629. private _fillAlignment;
  29630. /**
  29631. * Adds an uniform in the buffer.
  29632. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29633. * for the layout to be correct !
  29634. * @param name Name of the uniform, as used in the uniform block in the shader.
  29635. * @param size Data size, or data directly.
  29636. */
  29637. addUniform(name: string, size: number | number[]): void;
  29638. /**
  29639. * Adds a Matrix 4x4 to the uniform buffer.
  29640. * @param name Name of the uniform, as used in the uniform block in the shader.
  29641. * @param mat A 4x4 matrix.
  29642. */
  29643. addMatrix(name: string, mat: Matrix): void;
  29644. /**
  29645. * Adds a vec2 to the uniform buffer.
  29646. * @param name Name of the uniform, as used in the uniform block in the shader.
  29647. * @param x Define the x component value of the vec2
  29648. * @param y Define the y component value of the vec2
  29649. */
  29650. addFloat2(name: string, x: number, y: number): void;
  29651. /**
  29652. * Adds a vec3 to the uniform buffer.
  29653. * @param name Name of the uniform, as used in the uniform block in the shader.
  29654. * @param x Define the x component value of the vec3
  29655. * @param y Define the y component value of the vec3
  29656. * @param z Define the z component value of the vec3
  29657. */
  29658. addFloat3(name: string, x: number, y: number, z: number): void;
  29659. /**
  29660. * Adds a vec3 to the uniform buffer.
  29661. * @param name Name of the uniform, as used in the uniform block in the shader.
  29662. * @param color Define the vec3 from a Color
  29663. */
  29664. addColor3(name: string, color: Color3): void;
  29665. /**
  29666. * Adds a vec4 to the uniform buffer.
  29667. * @param name Name of the uniform, as used in the uniform block in the shader.
  29668. * @param color Define the rgb components from a Color
  29669. * @param alpha Define the a component of the vec4
  29670. */
  29671. addColor4(name: string, color: Color3, alpha: number): void;
  29672. /**
  29673. * Adds a vec3 to the uniform buffer.
  29674. * @param name Name of the uniform, as used in the uniform block in the shader.
  29675. * @param vector Define the vec3 components from a Vector
  29676. */
  29677. addVector3(name: string, vector: Vector3): void;
  29678. /**
  29679. * Adds a Matrix 3x3 to the uniform buffer.
  29680. * @param name Name of the uniform, as used in the uniform block in the shader.
  29681. */
  29682. addMatrix3x3(name: string): void;
  29683. /**
  29684. * Adds a Matrix 2x2 to the uniform buffer.
  29685. * @param name Name of the uniform, as used in the uniform block in the shader.
  29686. */
  29687. addMatrix2x2(name: string): void;
  29688. /**
  29689. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29690. */
  29691. create(): void;
  29692. /** @hidden */
  29693. _rebuild(): void;
  29694. /**
  29695. * Updates the WebGL Uniform Buffer on the GPU.
  29696. * If the `dynamic` flag is set to true, no cache comparison is done.
  29697. * Otherwise, the buffer will be updated only if the cache differs.
  29698. */
  29699. update(): void;
  29700. /**
  29701. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29702. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29703. * @param data Define the flattened data
  29704. * @param size Define the size of the data.
  29705. */
  29706. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29707. private _valueCache;
  29708. private _cacheMatrix;
  29709. private _updateMatrix3x3ForUniform;
  29710. private _updateMatrix3x3ForEffect;
  29711. private _updateMatrix2x2ForEffect;
  29712. private _updateMatrix2x2ForUniform;
  29713. private _updateFloatForEffect;
  29714. private _updateFloatForUniform;
  29715. private _updateFloat2ForEffect;
  29716. private _updateFloat2ForUniform;
  29717. private _updateFloat3ForEffect;
  29718. private _updateFloat3ForUniform;
  29719. private _updateFloat4ForEffect;
  29720. private _updateFloat4ForUniform;
  29721. private _updateMatrixForEffect;
  29722. private _updateMatrixForUniform;
  29723. private _updateVector3ForEffect;
  29724. private _updateVector3ForUniform;
  29725. private _updateVector4ForEffect;
  29726. private _updateVector4ForUniform;
  29727. private _updateColor3ForEffect;
  29728. private _updateColor3ForUniform;
  29729. private _updateColor4ForEffect;
  29730. private _updateColor4ForUniform;
  29731. /**
  29732. * Sets a sampler uniform on the effect.
  29733. * @param name Define the name of the sampler.
  29734. * @param texture Define the texture to set in the sampler
  29735. */
  29736. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29737. /**
  29738. * Directly updates the value of the uniform in the cache AND on the GPU.
  29739. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29740. * @param data Define the flattened data
  29741. */
  29742. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29743. /**
  29744. * Binds this uniform buffer to an effect.
  29745. * @param effect Define the effect to bind the buffer to
  29746. * @param name Name of the uniform block in the shader.
  29747. */
  29748. bindToEffect(effect: Effect, name: string): void;
  29749. /**
  29750. * Disposes the uniform buffer.
  29751. */
  29752. dispose(): void;
  29753. }
  29754. }
  29755. declare module "babylonjs/Audio/analyser" {
  29756. import { Scene } from "babylonjs/scene";
  29757. /**
  29758. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29759. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29760. */
  29761. export class Analyser {
  29762. /**
  29763. * Gets or sets the smoothing
  29764. * @ignorenaming
  29765. */
  29766. SMOOTHING: number;
  29767. /**
  29768. * Gets or sets the FFT table size
  29769. * @ignorenaming
  29770. */
  29771. FFT_SIZE: number;
  29772. /**
  29773. * Gets or sets the bar graph amplitude
  29774. * @ignorenaming
  29775. */
  29776. BARGRAPHAMPLITUDE: number;
  29777. /**
  29778. * Gets or sets the position of the debug canvas
  29779. * @ignorenaming
  29780. */
  29781. DEBUGCANVASPOS: {
  29782. x: number;
  29783. y: number;
  29784. };
  29785. /**
  29786. * Gets or sets the debug canvas size
  29787. * @ignorenaming
  29788. */
  29789. DEBUGCANVASSIZE: {
  29790. width: number;
  29791. height: number;
  29792. };
  29793. private _byteFreqs;
  29794. private _byteTime;
  29795. private _floatFreqs;
  29796. private _webAudioAnalyser;
  29797. private _debugCanvas;
  29798. private _debugCanvasContext;
  29799. private _scene;
  29800. private _registerFunc;
  29801. private _audioEngine;
  29802. /**
  29803. * Creates a new analyser
  29804. * @param scene defines hosting scene
  29805. */
  29806. constructor(scene: Scene);
  29807. /**
  29808. * Get the number of data values you will have to play with for the visualization
  29809. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29810. * @returns a number
  29811. */
  29812. getFrequencyBinCount(): number;
  29813. /**
  29814. * Gets the current frequency data as a byte array
  29815. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29816. * @returns a Uint8Array
  29817. */
  29818. getByteFrequencyData(): Uint8Array;
  29819. /**
  29820. * Gets the current waveform as a byte array
  29821. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29822. * @returns a Uint8Array
  29823. */
  29824. getByteTimeDomainData(): Uint8Array;
  29825. /**
  29826. * Gets the current frequency data as a float array
  29827. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29828. * @returns a Float32Array
  29829. */
  29830. getFloatFrequencyData(): Float32Array;
  29831. /**
  29832. * Renders the debug canvas
  29833. */
  29834. drawDebugCanvas(): void;
  29835. /**
  29836. * Stops rendering the debug canvas and removes it
  29837. */
  29838. stopDebugCanvas(): void;
  29839. /**
  29840. * Connects two audio nodes
  29841. * @param inputAudioNode defines first node to connect
  29842. * @param outputAudioNode defines second node to connect
  29843. */
  29844. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29845. /**
  29846. * Releases all associated resources
  29847. */
  29848. dispose(): void;
  29849. }
  29850. }
  29851. declare module "babylonjs/Audio/audioEngine" {
  29852. import { IDisposable } from "babylonjs/scene";
  29853. import { Analyser } from "babylonjs/Audio/analyser";
  29854. import { Nullable } from "babylonjs/types";
  29855. import { Observable } from "babylonjs/Misc/observable";
  29856. /**
  29857. * This represents an audio engine and it is responsible
  29858. * to play, synchronize and analyse sounds throughout the application.
  29859. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29860. */
  29861. export interface IAudioEngine extends IDisposable {
  29862. /**
  29863. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29864. */
  29865. readonly canUseWebAudio: boolean;
  29866. /**
  29867. * Gets the current AudioContext if available.
  29868. */
  29869. readonly audioContext: Nullable<AudioContext>;
  29870. /**
  29871. * The master gain node defines the global audio volume of your audio engine.
  29872. */
  29873. readonly masterGain: GainNode;
  29874. /**
  29875. * Gets whether or not mp3 are supported by your browser.
  29876. */
  29877. readonly isMP3supported: boolean;
  29878. /**
  29879. * Gets whether or not ogg are supported by your browser.
  29880. */
  29881. readonly isOGGsupported: boolean;
  29882. /**
  29883. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29884. * @ignoreNaming
  29885. */
  29886. WarnedWebAudioUnsupported: boolean;
  29887. /**
  29888. * Defines if the audio engine relies on a custom unlocked button.
  29889. * In this case, the embedded button will not be displayed.
  29890. */
  29891. useCustomUnlockedButton: boolean;
  29892. /**
  29893. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29894. */
  29895. readonly unlocked: boolean;
  29896. /**
  29897. * Event raised when audio has been unlocked on the browser.
  29898. */
  29899. onAudioUnlockedObservable: Observable<AudioEngine>;
  29900. /**
  29901. * Event raised when audio has been locked on the browser.
  29902. */
  29903. onAudioLockedObservable: Observable<AudioEngine>;
  29904. /**
  29905. * Flags the audio engine in Locked state.
  29906. * This happens due to new browser policies preventing audio to autoplay.
  29907. */
  29908. lock(): void;
  29909. /**
  29910. * Unlocks the audio engine once a user action has been done on the dom.
  29911. * This is helpful to resume play once browser policies have been satisfied.
  29912. */
  29913. unlock(): void;
  29914. }
  29915. /**
  29916. * This represents the default audio engine used in babylon.
  29917. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29918. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29919. */
  29920. export class AudioEngine implements IAudioEngine {
  29921. private _audioContext;
  29922. private _audioContextInitialized;
  29923. private _muteButton;
  29924. private _hostElement;
  29925. /**
  29926. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29927. */
  29928. canUseWebAudio: boolean;
  29929. /**
  29930. * The master gain node defines the global audio volume of your audio engine.
  29931. */
  29932. masterGain: GainNode;
  29933. /**
  29934. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29935. * @ignoreNaming
  29936. */
  29937. WarnedWebAudioUnsupported: boolean;
  29938. /**
  29939. * Gets whether or not mp3 are supported by your browser.
  29940. */
  29941. isMP3supported: boolean;
  29942. /**
  29943. * Gets whether or not ogg are supported by your browser.
  29944. */
  29945. isOGGsupported: boolean;
  29946. /**
  29947. * Gets whether audio has been unlocked on the device.
  29948. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29949. * a user interaction has happened.
  29950. */
  29951. unlocked: boolean;
  29952. /**
  29953. * Defines if the audio engine relies on a custom unlocked button.
  29954. * In this case, the embedded button will not be displayed.
  29955. */
  29956. useCustomUnlockedButton: boolean;
  29957. /**
  29958. * Event raised when audio has been unlocked on the browser.
  29959. */
  29960. onAudioUnlockedObservable: Observable<AudioEngine>;
  29961. /**
  29962. * Event raised when audio has been locked on the browser.
  29963. */
  29964. onAudioLockedObservable: Observable<AudioEngine>;
  29965. /**
  29966. * Gets the current AudioContext if available.
  29967. */
  29968. readonly audioContext: Nullable<AudioContext>;
  29969. private _connectedAnalyser;
  29970. /**
  29971. * Instantiates a new audio engine.
  29972. *
  29973. * There should be only one per page as some browsers restrict the number
  29974. * of audio contexts you can create.
  29975. * @param hostElement defines the host element where to display the mute icon if necessary
  29976. */
  29977. constructor(hostElement?: Nullable<HTMLElement>);
  29978. /**
  29979. * Flags the audio engine in Locked state.
  29980. * This happens due to new browser policies preventing audio to autoplay.
  29981. */
  29982. lock(): void;
  29983. /**
  29984. * Unlocks the audio engine once a user action has been done on the dom.
  29985. * This is helpful to resume play once browser policies have been satisfied.
  29986. */
  29987. unlock(): void;
  29988. private _resumeAudioContext;
  29989. private _initializeAudioContext;
  29990. private _tryToRun;
  29991. private _triggerRunningState;
  29992. private _triggerSuspendedState;
  29993. private _displayMuteButton;
  29994. private _moveButtonToTopLeft;
  29995. private _onResize;
  29996. private _hideMuteButton;
  29997. /**
  29998. * Destroy and release the resources associated with the audio ccontext.
  29999. */
  30000. dispose(): void;
  30001. /**
  30002. * Gets the global volume sets on the master gain.
  30003. * @returns the global volume if set or -1 otherwise
  30004. */
  30005. getGlobalVolume(): number;
  30006. /**
  30007. * Sets the global volume of your experience (sets on the master gain).
  30008. * @param newVolume Defines the new global volume of the application
  30009. */
  30010. setGlobalVolume(newVolume: number): void;
  30011. /**
  30012. * Connect the audio engine to an audio analyser allowing some amazing
  30013. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30014. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30015. * @param analyser The analyser to connect to the engine
  30016. */
  30017. connectToAnalyser(analyser: Analyser): void;
  30018. }
  30019. }
  30020. declare module "babylonjs/Loading/loadingScreen" {
  30021. /**
  30022. * Interface used to present a loading screen while loading a scene
  30023. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30024. */
  30025. export interface ILoadingScreen {
  30026. /**
  30027. * Function called to display the loading screen
  30028. */
  30029. displayLoadingUI: () => void;
  30030. /**
  30031. * Function called to hide the loading screen
  30032. */
  30033. hideLoadingUI: () => void;
  30034. /**
  30035. * Gets or sets the color to use for the background
  30036. */
  30037. loadingUIBackgroundColor: string;
  30038. /**
  30039. * Gets or sets the text to display while loading
  30040. */
  30041. loadingUIText: string;
  30042. }
  30043. /**
  30044. * Class used for the default loading screen
  30045. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30046. */
  30047. export class DefaultLoadingScreen implements ILoadingScreen {
  30048. private _renderingCanvas;
  30049. private _loadingText;
  30050. private _loadingDivBackgroundColor;
  30051. private _loadingDiv;
  30052. private _loadingTextDiv;
  30053. /** Gets or sets the logo url to use for the default loading screen */
  30054. static DefaultLogoUrl: string;
  30055. /** Gets or sets the spinner url to use for the default loading screen */
  30056. static DefaultSpinnerUrl: string;
  30057. /**
  30058. * Creates a new default loading screen
  30059. * @param _renderingCanvas defines the canvas used to render the scene
  30060. * @param _loadingText defines the default text to display
  30061. * @param _loadingDivBackgroundColor defines the default background color
  30062. */
  30063. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30064. /**
  30065. * Function called to display the loading screen
  30066. */
  30067. displayLoadingUI(): void;
  30068. /**
  30069. * Function called to hide the loading screen
  30070. */
  30071. hideLoadingUI(): void;
  30072. /**
  30073. * Gets or sets the text to display while loading
  30074. */
  30075. loadingUIText: string;
  30076. /**
  30077. * Gets or sets the color to use for the background
  30078. */
  30079. loadingUIBackgroundColor: string;
  30080. private _resizeLoadingUI;
  30081. }
  30082. }
  30083. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30084. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30085. import { Engine } from "babylonjs/Engines/engine";
  30086. import { Nullable } from "babylonjs/types";
  30087. /** @hidden */
  30088. export class WebGLPipelineContext implements IPipelineContext {
  30089. engine: Engine;
  30090. program: Nullable<WebGLProgram>;
  30091. context?: WebGLRenderingContext;
  30092. vertexShader?: WebGLShader;
  30093. fragmentShader?: WebGLShader;
  30094. isParallelCompiled: boolean;
  30095. onCompiled?: () => void;
  30096. transformFeedback?: WebGLTransformFeedback | null;
  30097. readonly isAsync: boolean;
  30098. readonly isReady: boolean;
  30099. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30100. }
  30101. }
  30102. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30103. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30104. /** @hidden */
  30105. export class WebGLDataBuffer extends DataBuffer {
  30106. private _buffer;
  30107. constructor(resource: WebGLBuffer);
  30108. readonly underlyingResource: any;
  30109. }
  30110. }
  30111. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30112. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30113. /** @hidden */
  30114. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30115. attributeProcessor(attribute: string): string;
  30116. varyingProcessor(varying: string, isFragment: boolean): string;
  30117. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30118. }
  30119. }
  30120. declare module "babylonjs/Misc/perfCounter" {
  30121. /**
  30122. * This class is used to track a performance counter which is number based.
  30123. * The user has access to many properties which give statistics of different nature.
  30124. *
  30125. * The implementer can track two kinds of Performance Counter: time and count.
  30126. * 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.
  30127. * 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.
  30128. */
  30129. export class PerfCounter {
  30130. /**
  30131. * Gets or sets a global boolean to turn on and off all the counters
  30132. */
  30133. static Enabled: boolean;
  30134. /**
  30135. * Returns the smallest value ever
  30136. */
  30137. readonly min: number;
  30138. /**
  30139. * Returns the biggest value ever
  30140. */
  30141. readonly max: number;
  30142. /**
  30143. * Returns the average value since the performance counter is running
  30144. */
  30145. readonly average: number;
  30146. /**
  30147. * Returns the average value of the last second the counter was monitored
  30148. */
  30149. readonly lastSecAverage: number;
  30150. /**
  30151. * Returns the current value
  30152. */
  30153. readonly current: number;
  30154. /**
  30155. * Gets the accumulated total
  30156. */
  30157. readonly total: number;
  30158. /**
  30159. * Gets the total value count
  30160. */
  30161. readonly count: number;
  30162. /**
  30163. * Creates a new counter
  30164. */
  30165. constructor();
  30166. /**
  30167. * Call this method to start monitoring a new frame.
  30168. * 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.
  30169. */
  30170. fetchNewFrame(): void;
  30171. /**
  30172. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30173. * @param newCount the count value to add to the monitored count
  30174. * @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.
  30175. */
  30176. addCount(newCount: number, fetchResult: boolean): void;
  30177. /**
  30178. * Start monitoring this performance counter
  30179. */
  30180. beginMonitoring(): void;
  30181. /**
  30182. * Compute the time lapsed since the previous beginMonitoring() call.
  30183. * @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
  30184. */
  30185. endMonitoring(newFrame?: boolean): void;
  30186. private _fetchResult;
  30187. private _startMonitoringTime;
  30188. private _min;
  30189. private _max;
  30190. private _average;
  30191. private _current;
  30192. private _totalValueCount;
  30193. private _totalAccumulated;
  30194. private _lastSecAverage;
  30195. private _lastSecAccumulated;
  30196. private _lastSecTime;
  30197. private _lastSecValueCount;
  30198. }
  30199. }
  30200. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30201. /**
  30202. * Interface for any object that can request an animation frame
  30203. */
  30204. export interface ICustomAnimationFrameRequester {
  30205. /**
  30206. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30207. */
  30208. renderFunction?: Function;
  30209. /**
  30210. * Called to request the next frame to render to
  30211. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30212. */
  30213. requestAnimationFrame: Function;
  30214. /**
  30215. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30216. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30217. */
  30218. requestID?: number;
  30219. }
  30220. }
  30221. declare module "babylonjs/Misc/performanceMonitor" {
  30222. /**
  30223. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30224. */
  30225. export class PerformanceMonitor {
  30226. private _enabled;
  30227. private _rollingFrameTime;
  30228. private _lastFrameTimeMs;
  30229. /**
  30230. * constructor
  30231. * @param frameSampleSize The number of samples required to saturate the sliding window
  30232. */
  30233. constructor(frameSampleSize?: number);
  30234. /**
  30235. * Samples current frame
  30236. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30237. */
  30238. sampleFrame(timeMs?: number): void;
  30239. /**
  30240. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30241. */
  30242. readonly averageFrameTime: number;
  30243. /**
  30244. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30245. */
  30246. readonly averageFrameTimeVariance: number;
  30247. /**
  30248. * Returns the frame time of the most recent frame
  30249. */
  30250. readonly instantaneousFrameTime: number;
  30251. /**
  30252. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30253. */
  30254. readonly averageFPS: number;
  30255. /**
  30256. * Returns the average framerate in frames per second using the most recent frame time
  30257. */
  30258. readonly instantaneousFPS: number;
  30259. /**
  30260. * Returns true if enough samples have been taken to completely fill the sliding window
  30261. */
  30262. readonly isSaturated: boolean;
  30263. /**
  30264. * Enables contributions to the sliding window sample set
  30265. */
  30266. enable(): void;
  30267. /**
  30268. * Disables contributions to the sliding window sample set
  30269. * Samples will not be interpolated over the disabled period
  30270. */
  30271. disable(): void;
  30272. /**
  30273. * Returns true if sampling is enabled
  30274. */
  30275. readonly isEnabled: boolean;
  30276. /**
  30277. * Resets performance monitor
  30278. */
  30279. reset(): void;
  30280. }
  30281. /**
  30282. * RollingAverage
  30283. *
  30284. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30285. */
  30286. export class RollingAverage {
  30287. /**
  30288. * Current average
  30289. */
  30290. average: number;
  30291. /**
  30292. * Current variance
  30293. */
  30294. variance: number;
  30295. protected _samples: Array<number>;
  30296. protected _sampleCount: number;
  30297. protected _pos: number;
  30298. protected _m2: number;
  30299. /**
  30300. * constructor
  30301. * @param length The number of samples required to saturate the sliding window
  30302. */
  30303. constructor(length: number);
  30304. /**
  30305. * Adds a sample to the sample set
  30306. * @param v The sample value
  30307. */
  30308. add(v: number): void;
  30309. /**
  30310. * Returns previously added values or null if outside of history or outside the sliding window domain
  30311. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30312. * @return Value previously recorded with add() or null if outside of range
  30313. */
  30314. history(i: number): number;
  30315. /**
  30316. * Returns true if enough samples have been taken to completely fill the sliding window
  30317. * @return true if sample-set saturated
  30318. */
  30319. isSaturated(): boolean;
  30320. /**
  30321. * Resets the rolling average (equivalent to 0 samples taken so far)
  30322. */
  30323. reset(): void;
  30324. /**
  30325. * Wraps a value around the sample range boundaries
  30326. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30327. * @return Wrapped position in sample range
  30328. */
  30329. protected _wrapPosition(i: number): number;
  30330. }
  30331. }
  30332. declare module "babylonjs/Materials/Textures/videoTexture" {
  30333. import { Observable } from "babylonjs/Misc/observable";
  30334. import { Nullable } from "babylonjs/types";
  30335. import { Scene } from "babylonjs/scene";
  30336. import { Texture } from "babylonjs/Materials/Textures/texture";
  30337. /**
  30338. * Settings for finer control over video usage
  30339. */
  30340. export interface VideoTextureSettings {
  30341. /**
  30342. * Applies `autoplay` to video, if specified
  30343. */
  30344. autoPlay?: boolean;
  30345. /**
  30346. * Applies `loop` to video, if specified
  30347. */
  30348. loop?: boolean;
  30349. /**
  30350. * Automatically updates internal texture from video at every frame in the render loop
  30351. */
  30352. autoUpdateTexture: boolean;
  30353. /**
  30354. * Image src displayed during the video loading or until the user interacts with the video.
  30355. */
  30356. poster?: string;
  30357. }
  30358. /**
  30359. * If you want to display a video in your scene, this is the special texture for that.
  30360. * This special texture works similar to other textures, with the exception of a few parameters.
  30361. * @see https://doc.babylonjs.com/how_to/video_texture
  30362. */
  30363. export class VideoTexture extends Texture {
  30364. /**
  30365. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30366. */
  30367. readonly autoUpdateTexture: boolean;
  30368. /**
  30369. * The video instance used by the texture internally
  30370. */
  30371. readonly video: HTMLVideoElement;
  30372. private _onUserActionRequestedObservable;
  30373. /**
  30374. * Event triggerd when a dom action is required by the user to play the video.
  30375. * This happens due to recent changes in browser policies preventing video to auto start.
  30376. */
  30377. readonly onUserActionRequestedObservable: Observable<Texture>;
  30378. private _generateMipMaps;
  30379. private _engine;
  30380. private _stillImageCaptured;
  30381. private _displayingPosterTexture;
  30382. private _settings;
  30383. private _createInternalTextureOnEvent;
  30384. private _frameId;
  30385. /**
  30386. * Creates a video texture.
  30387. * If you want to display a video in your scene, this is the special texture for that.
  30388. * This special texture works similar to other textures, with the exception of a few parameters.
  30389. * @see https://doc.babylonjs.com/how_to/video_texture
  30390. * @param name optional name, will detect from video source, if not defined
  30391. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30392. * @param scene is obviously the current scene.
  30393. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30394. * @param invertY is false by default but can be used to invert video on Y axis
  30395. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30396. * @param settings allows finer control over video usage
  30397. */
  30398. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30399. private _getName;
  30400. private _getVideo;
  30401. private _createInternalTexture;
  30402. private reset;
  30403. /**
  30404. * @hidden Internal method to initiate `update`.
  30405. */
  30406. _rebuild(): void;
  30407. /**
  30408. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30409. */
  30410. update(): void;
  30411. /**
  30412. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30413. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30414. */
  30415. updateTexture(isVisible: boolean): void;
  30416. protected _updateInternalTexture: () => void;
  30417. /**
  30418. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30419. * @param url New url.
  30420. */
  30421. updateURL(url: string): void;
  30422. /**
  30423. * Dispose the texture and release its associated resources.
  30424. */
  30425. dispose(): void;
  30426. /**
  30427. * Creates a video texture straight from a stream.
  30428. * @param scene Define the scene the texture should be created in
  30429. * @param stream Define the stream the texture should be created from
  30430. * @returns The created video texture as a promise
  30431. */
  30432. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30433. /**
  30434. * Creates a video texture straight from your WebCam video feed.
  30435. * @param scene Define the scene the texture should be created in
  30436. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30437. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30438. * @returns The created video texture as a promise
  30439. */
  30440. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30441. minWidth: number;
  30442. maxWidth: number;
  30443. minHeight: number;
  30444. maxHeight: number;
  30445. deviceId: string;
  30446. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30447. /**
  30448. * Creates a video texture straight from your WebCam video feed.
  30449. * @param scene Define the scene the texture should be created in
  30450. * @param onReady Define a callback to triggered once the texture will be ready
  30451. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30452. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30453. */
  30454. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30455. minWidth: number;
  30456. maxWidth: number;
  30457. minHeight: number;
  30458. maxHeight: number;
  30459. deviceId: string;
  30460. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30461. }
  30462. }
  30463. declare module "babylonjs/Engines/engine" {
  30464. import { Observable } from "babylonjs/Misc/observable";
  30465. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30466. import { Scene } from "babylonjs/scene";
  30467. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30468. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30469. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30470. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30471. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30472. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30473. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30474. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30475. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30476. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30477. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30478. import { WebRequest } from "babylonjs/Misc/webRequest";
  30479. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30480. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30481. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30482. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30483. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30484. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30485. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30486. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30487. import { Material } from "babylonjs/Materials/material";
  30488. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30489. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30490. /**
  30491. * Defines the interface used by objects containing a viewport (like a camera)
  30492. */
  30493. interface IViewportOwnerLike {
  30494. /**
  30495. * Gets or sets the viewport
  30496. */
  30497. viewport: IViewportLike;
  30498. }
  30499. /**
  30500. * Interface for attribute information associated with buffer instanciation
  30501. */
  30502. export class InstancingAttributeInfo {
  30503. /**
  30504. * Index/offset of the attribute in the vertex shader
  30505. */
  30506. index: number;
  30507. /**
  30508. * size of the attribute, 1, 2, 3 or 4
  30509. */
  30510. attributeSize: number;
  30511. /**
  30512. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30513. * default is FLOAT
  30514. */
  30515. attribyteType: number;
  30516. /**
  30517. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30518. */
  30519. normalized: boolean;
  30520. /**
  30521. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30522. */
  30523. offset: number;
  30524. /**
  30525. * Name of the GLSL attribute, for debugging purpose only
  30526. */
  30527. attributeName: string;
  30528. }
  30529. /**
  30530. * Define options used to create a depth texture
  30531. */
  30532. export class DepthTextureCreationOptions {
  30533. /** Specifies whether or not a stencil should be allocated in the texture */
  30534. generateStencil?: boolean;
  30535. /** Specifies whether or not bilinear filtering is enable on the texture */
  30536. bilinearFiltering?: boolean;
  30537. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30538. comparisonFunction?: number;
  30539. /** Specifies if the created texture is a cube texture */
  30540. isCube?: boolean;
  30541. }
  30542. /**
  30543. * Class used to describe the capabilities of the engine relatively to the current browser
  30544. */
  30545. export class EngineCapabilities {
  30546. /** Maximum textures units per fragment shader */
  30547. maxTexturesImageUnits: number;
  30548. /** Maximum texture units per vertex shader */
  30549. maxVertexTextureImageUnits: number;
  30550. /** Maximum textures units in the entire pipeline */
  30551. maxCombinedTexturesImageUnits: number;
  30552. /** Maximum texture size */
  30553. maxTextureSize: number;
  30554. /** Maximum cube texture size */
  30555. maxCubemapTextureSize: number;
  30556. /** Maximum render texture size */
  30557. maxRenderTextureSize: number;
  30558. /** Maximum number of vertex attributes */
  30559. maxVertexAttribs: number;
  30560. /** Maximum number of varyings */
  30561. maxVaryingVectors: number;
  30562. /** Maximum number of uniforms per vertex shader */
  30563. maxVertexUniformVectors: number;
  30564. /** Maximum number of uniforms per fragment shader */
  30565. maxFragmentUniformVectors: number;
  30566. /** Defines if standard derivates (dx/dy) are supported */
  30567. standardDerivatives: boolean;
  30568. /** Defines if s3tc texture compression is supported */
  30569. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30570. /** Defines if pvrtc texture compression is supported */
  30571. pvrtc: any;
  30572. /** Defines if etc1 texture compression is supported */
  30573. etc1: any;
  30574. /** Defines if etc2 texture compression is supported */
  30575. etc2: any;
  30576. /** Defines if astc texture compression is supported */
  30577. astc: any;
  30578. /** Defines if float textures are supported */
  30579. textureFloat: boolean;
  30580. /** Defines if vertex array objects are supported */
  30581. vertexArrayObject: boolean;
  30582. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30583. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30584. /** Gets the maximum level of anisotropy supported */
  30585. maxAnisotropy: number;
  30586. /** Defines if instancing is supported */
  30587. instancedArrays: boolean;
  30588. /** Defines if 32 bits indices are supported */
  30589. uintIndices: boolean;
  30590. /** Defines if high precision shaders are supported */
  30591. highPrecisionShaderSupported: boolean;
  30592. /** Defines if depth reading in the fragment shader is supported */
  30593. fragmentDepthSupported: boolean;
  30594. /** Defines if float texture linear filtering is supported*/
  30595. textureFloatLinearFiltering: boolean;
  30596. /** Defines if rendering to float textures is supported */
  30597. textureFloatRender: boolean;
  30598. /** Defines if half float textures are supported*/
  30599. textureHalfFloat: boolean;
  30600. /** Defines if half float texture linear filtering is supported*/
  30601. textureHalfFloatLinearFiltering: boolean;
  30602. /** Defines if rendering to half float textures is supported */
  30603. textureHalfFloatRender: boolean;
  30604. /** Defines if textureLOD shader command is supported */
  30605. textureLOD: boolean;
  30606. /** Defines if draw buffers extension is supported */
  30607. drawBuffersExtension: boolean;
  30608. /** Defines if depth textures are supported */
  30609. depthTextureExtension: boolean;
  30610. /** Defines if float color buffer are supported */
  30611. colorBufferFloat: boolean;
  30612. /** Gets disjoint timer query extension (null if not supported) */
  30613. timerQuery: EXT_disjoint_timer_query;
  30614. /** Defines if timestamp can be used with timer query */
  30615. canUseTimestampForTimerQuery: boolean;
  30616. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30617. multiview: any;
  30618. /** Function used to let the system compiles shaders in background */
  30619. parallelShaderCompile: {
  30620. COMPLETION_STATUS_KHR: number;
  30621. };
  30622. /** Max number of texture samples for MSAA */
  30623. maxMSAASamples: number;
  30624. /** Defines if the blend min max extension is supported */
  30625. blendMinMax: boolean;
  30626. }
  30627. /** Interface defining initialization parameters for Engine class */
  30628. export interface EngineOptions extends WebGLContextAttributes {
  30629. /**
  30630. * Defines if the engine should no exceed a specified device ratio
  30631. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30632. */
  30633. limitDeviceRatio?: number;
  30634. /**
  30635. * Defines if webvr should be enabled automatically
  30636. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30637. */
  30638. autoEnableWebVR?: boolean;
  30639. /**
  30640. * Defines if webgl2 should be turned off even if supported
  30641. * @see http://doc.babylonjs.com/features/webgl2
  30642. */
  30643. disableWebGL2Support?: boolean;
  30644. /**
  30645. * Defines if webaudio should be initialized as well
  30646. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30647. */
  30648. audioEngine?: boolean;
  30649. /**
  30650. * Defines if animations should run using a deterministic lock step
  30651. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30652. */
  30653. deterministicLockstep?: boolean;
  30654. /** Defines the maximum steps to use with deterministic lock step mode */
  30655. lockstepMaxSteps?: number;
  30656. /**
  30657. * Defines that engine should ignore context lost events
  30658. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30659. */
  30660. doNotHandleContextLost?: boolean;
  30661. /**
  30662. * Defines that engine should ignore modifying touch action attribute and style
  30663. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30664. */
  30665. doNotHandleTouchAction?: boolean;
  30666. /**
  30667. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30668. */
  30669. useHighPrecisionFloats?: boolean;
  30670. }
  30671. /**
  30672. * Defines the interface used by display changed events
  30673. */
  30674. export interface IDisplayChangedEventArgs {
  30675. /** Gets the vrDisplay object (if any) */
  30676. vrDisplay: Nullable<any>;
  30677. /** Gets a boolean indicating if webVR is supported */
  30678. vrSupported: boolean;
  30679. }
  30680. /**
  30681. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30682. */
  30683. export class Engine {
  30684. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30685. static ExceptionList: ({
  30686. key: string;
  30687. capture: string;
  30688. captureConstraint: number;
  30689. targets: string[];
  30690. } | {
  30691. key: string;
  30692. capture: null;
  30693. captureConstraint: null;
  30694. targets: string[];
  30695. })[];
  30696. /** Gets the list of created engines */
  30697. static readonly Instances: Engine[];
  30698. /**
  30699. * Gets the latest created engine
  30700. */
  30701. static readonly LastCreatedEngine: Nullable<Engine>;
  30702. /**
  30703. * Gets the latest created scene
  30704. */
  30705. static readonly LastCreatedScene: Nullable<Scene>;
  30706. /**
  30707. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30708. * @param flag defines which part of the materials must be marked as dirty
  30709. * @param predicate defines a predicate used to filter which materials should be affected
  30710. */
  30711. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30712. /** Defines that alpha blending is disabled */
  30713. static readonly ALPHA_DISABLE: number;
  30714. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30715. static readonly ALPHA_ADD: number;
  30716. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30717. static readonly ALPHA_COMBINE: number;
  30718. /** Defines that alpha blending to DEST - SRC * DEST */
  30719. static readonly ALPHA_SUBTRACT: number;
  30720. /** Defines that alpha blending to SRC * DEST */
  30721. static readonly ALPHA_MULTIPLY: number;
  30722. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30723. static readonly ALPHA_MAXIMIZED: number;
  30724. /** Defines that alpha blending to SRC + DEST */
  30725. static readonly ALPHA_ONEONE: number;
  30726. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30727. static readonly ALPHA_PREMULTIPLIED: number;
  30728. /**
  30729. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30730. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30731. */
  30732. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30733. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30734. static readonly ALPHA_INTERPOLATE: number;
  30735. /**
  30736. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30737. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30738. */
  30739. static readonly ALPHA_SCREENMODE: number;
  30740. /** Defines that the ressource is not delayed*/
  30741. static readonly DELAYLOADSTATE_NONE: number;
  30742. /** Defines that the ressource was successfully delay loaded */
  30743. static readonly DELAYLOADSTATE_LOADED: number;
  30744. /** Defines that the ressource is currently delay loading */
  30745. static readonly DELAYLOADSTATE_LOADING: number;
  30746. /** Defines that the ressource is delayed and has not started loading */
  30747. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30748. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30749. static readonly NEVER: number;
  30750. /** 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 */
  30751. static readonly ALWAYS: number;
  30752. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30753. static readonly LESS: number;
  30754. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30755. static readonly EQUAL: number;
  30756. /** 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 */
  30757. static readonly LEQUAL: number;
  30758. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30759. static readonly GREATER: number;
  30760. /** 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 */
  30761. static readonly GEQUAL: number;
  30762. /** 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 */
  30763. static readonly NOTEQUAL: number;
  30764. /** Passed to stencilOperation to specify that stencil value must be kept */
  30765. static readonly KEEP: number;
  30766. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30767. static readonly REPLACE: number;
  30768. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30769. static readonly INCR: number;
  30770. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30771. static readonly DECR: number;
  30772. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30773. static readonly INVERT: number;
  30774. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30775. static readonly INCR_WRAP: number;
  30776. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30777. static readonly DECR_WRAP: number;
  30778. /** Texture is not repeating outside of 0..1 UVs */
  30779. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30780. /** Texture is repeating outside of 0..1 UVs */
  30781. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30782. /** Texture is repeating and mirrored */
  30783. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30784. /** ALPHA */
  30785. static readonly TEXTUREFORMAT_ALPHA: number;
  30786. /** LUMINANCE */
  30787. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30788. /** LUMINANCE_ALPHA */
  30789. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30790. /** RGB */
  30791. static readonly TEXTUREFORMAT_RGB: number;
  30792. /** RGBA */
  30793. static readonly TEXTUREFORMAT_RGBA: number;
  30794. /** RED */
  30795. static readonly TEXTUREFORMAT_RED: number;
  30796. /** RED (2nd reference) */
  30797. static readonly TEXTUREFORMAT_R: number;
  30798. /** RG */
  30799. static readonly TEXTUREFORMAT_RG: number;
  30800. /** RED_INTEGER */
  30801. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30802. /** RED_INTEGER (2nd reference) */
  30803. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30804. /** RG_INTEGER */
  30805. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30806. /** RGB_INTEGER */
  30807. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30808. /** RGBA_INTEGER */
  30809. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30810. /** UNSIGNED_BYTE */
  30811. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30812. /** UNSIGNED_BYTE (2nd reference) */
  30813. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30814. /** FLOAT */
  30815. static readonly TEXTURETYPE_FLOAT: number;
  30816. /** HALF_FLOAT */
  30817. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30818. /** BYTE */
  30819. static readonly TEXTURETYPE_BYTE: number;
  30820. /** SHORT */
  30821. static readonly TEXTURETYPE_SHORT: number;
  30822. /** UNSIGNED_SHORT */
  30823. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30824. /** INT */
  30825. static readonly TEXTURETYPE_INT: number;
  30826. /** UNSIGNED_INT */
  30827. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30828. /** UNSIGNED_SHORT_4_4_4_4 */
  30829. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30830. /** UNSIGNED_SHORT_5_5_5_1 */
  30831. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30832. /** UNSIGNED_SHORT_5_6_5 */
  30833. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30834. /** UNSIGNED_INT_2_10_10_10_REV */
  30835. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30836. /** UNSIGNED_INT_24_8 */
  30837. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30838. /** UNSIGNED_INT_10F_11F_11F_REV */
  30839. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30840. /** UNSIGNED_INT_5_9_9_9_REV */
  30841. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30842. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30843. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30844. /** nearest is mag = nearest and min = nearest and mip = linear */
  30845. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30846. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30847. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30848. /** Trilinear is mag = linear and min = linear and mip = linear */
  30849. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30850. /** nearest is mag = nearest and min = nearest and mip = linear */
  30851. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30852. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30853. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30854. /** Trilinear is mag = linear and min = linear and mip = linear */
  30855. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30856. /** mag = nearest and min = nearest and mip = nearest */
  30857. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30858. /** mag = nearest and min = linear and mip = nearest */
  30859. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30860. /** mag = nearest and min = linear and mip = linear */
  30861. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30862. /** mag = nearest and min = linear and mip = none */
  30863. static readonly TEXTURE_NEAREST_LINEAR: number;
  30864. /** mag = nearest and min = nearest and mip = none */
  30865. static readonly TEXTURE_NEAREST_NEAREST: number;
  30866. /** mag = linear and min = nearest and mip = nearest */
  30867. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30868. /** mag = linear and min = nearest and mip = linear */
  30869. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30870. /** mag = linear and min = linear and mip = none */
  30871. static readonly TEXTURE_LINEAR_LINEAR: number;
  30872. /** mag = linear and min = nearest and mip = none */
  30873. static readonly TEXTURE_LINEAR_NEAREST: number;
  30874. /** Explicit coordinates mode */
  30875. static readonly TEXTURE_EXPLICIT_MODE: number;
  30876. /** Spherical coordinates mode */
  30877. static readonly TEXTURE_SPHERICAL_MODE: number;
  30878. /** Planar coordinates mode */
  30879. static readonly TEXTURE_PLANAR_MODE: number;
  30880. /** Cubic coordinates mode */
  30881. static readonly TEXTURE_CUBIC_MODE: number;
  30882. /** Projection coordinates mode */
  30883. static readonly TEXTURE_PROJECTION_MODE: number;
  30884. /** Skybox coordinates mode */
  30885. static readonly TEXTURE_SKYBOX_MODE: number;
  30886. /** Inverse Cubic coordinates mode */
  30887. static readonly TEXTURE_INVCUBIC_MODE: number;
  30888. /** Equirectangular coordinates mode */
  30889. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30890. /** Equirectangular Fixed coordinates mode */
  30891. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30892. /** Equirectangular Fixed Mirrored coordinates mode */
  30893. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30894. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30895. static readonly SCALEMODE_FLOOR: number;
  30896. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30897. static readonly SCALEMODE_NEAREST: number;
  30898. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30899. static readonly SCALEMODE_CEILING: number;
  30900. /** @hidden */
  30901. static _TextureLoaders: IInternalTextureLoader[];
  30902. /**
  30903. * Returns the current npm package of the sdk
  30904. */
  30905. static readonly NpmPackage: string;
  30906. /**
  30907. * Returns the current version of the framework
  30908. */
  30909. static readonly Version: string;
  30910. /**
  30911. * Returns a string describing the current engine
  30912. */
  30913. readonly description: string;
  30914. /**
  30915. * Gets or sets the epsilon value used by collision engine
  30916. */
  30917. static CollisionsEpsilon: number;
  30918. /**
  30919. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30920. */
  30921. static ShadersRepository: string;
  30922. /**
  30923. * Method called to create the default loading screen.
  30924. * This can be overriden in your own app.
  30925. * @param canvas The rendering canvas element
  30926. * @returns The loading screen
  30927. */
  30928. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30929. /**
  30930. * Method called to create the default rescale post process on each engine.
  30931. */
  30932. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30933. /** @hidden */
  30934. _shaderProcessor: IShaderProcessor;
  30935. /**
  30936. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30937. */
  30938. forcePOTTextures: boolean;
  30939. /**
  30940. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30941. */
  30942. isFullscreen: boolean;
  30943. /**
  30944. * Gets a boolean indicating if the pointer is currently locked
  30945. */
  30946. isPointerLock: boolean;
  30947. /**
  30948. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30949. */
  30950. cullBackFaces: boolean;
  30951. /**
  30952. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30953. */
  30954. renderEvenInBackground: boolean;
  30955. /**
  30956. * Gets or sets a boolean indicating that cache can be kept between frames
  30957. */
  30958. preventCacheWipeBetweenFrames: boolean;
  30959. /**
  30960. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30961. **/
  30962. enableOfflineSupport: boolean;
  30963. /**
  30964. * 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)
  30965. **/
  30966. disableManifestCheck: boolean;
  30967. /**
  30968. * Gets the list of created scenes
  30969. */
  30970. scenes: Scene[];
  30971. /**
  30972. * Event raised when a new scene is created
  30973. */
  30974. onNewSceneAddedObservable: Observable<Scene>;
  30975. /**
  30976. * Gets the list of created postprocesses
  30977. */
  30978. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  30979. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30980. validateShaderPrograms: boolean;
  30981. /**
  30982. * Observable event triggered each time the rendering canvas is resized
  30983. */
  30984. onResizeObservable: Observable<Engine>;
  30985. /**
  30986. * Observable event triggered each time the canvas loses focus
  30987. */
  30988. onCanvasBlurObservable: Observable<Engine>;
  30989. /**
  30990. * Observable event triggered each time the canvas gains focus
  30991. */
  30992. onCanvasFocusObservable: Observable<Engine>;
  30993. /**
  30994. * Observable event triggered each time the canvas receives pointerout event
  30995. */
  30996. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30997. /**
  30998. * Observable event triggered before each texture is initialized
  30999. */
  31000. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31001. /**
  31002. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31003. */
  31004. disableUniformBuffers: boolean;
  31005. /** @hidden */
  31006. _uniformBuffers: UniformBuffer[];
  31007. /**
  31008. * Gets a boolean indicating that the engine supports uniform buffers
  31009. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31010. */
  31011. readonly supportsUniformBuffers: boolean;
  31012. /**
  31013. * Observable raised when the engine begins a new frame
  31014. */
  31015. onBeginFrameObservable: Observable<Engine>;
  31016. /**
  31017. * If set, will be used to request the next animation frame for the render loop
  31018. */
  31019. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31020. /**
  31021. * Observable raised when the engine ends the current frame
  31022. */
  31023. onEndFrameObservable: Observable<Engine>;
  31024. /**
  31025. * Observable raised when the engine is about to compile a shader
  31026. */
  31027. onBeforeShaderCompilationObservable: Observable<Engine>;
  31028. /**
  31029. * Observable raised when the engine has jsut compiled a shader
  31030. */
  31031. onAfterShaderCompilationObservable: Observable<Engine>;
  31032. /** @hidden */
  31033. _gl: WebGLRenderingContext;
  31034. private _renderingCanvas;
  31035. private _windowIsBackground;
  31036. protected _webGLVersion: number;
  31037. protected _highPrecisionShadersAllowed: boolean;
  31038. /** @hidden */
  31039. readonly _shouldUseHighPrecisionShader: boolean;
  31040. /**
  31041. * Gets a boolean indicating that only power of 2 textures are supported
  31042. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31043. */
  31044. readonly needPOTTextures: boolean;
  31045. /** @hidden */
  31046. _badOS: boolean;
  31047. /** @hidden */
  31048. _badDesktopOS: boolean;
  31049. /**
  31050. * Gets the audio engine
  31051. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31052. * @ignorenaming
  31053. */
  31054. static audioEngine: IAudioEngine;
  31055. /**
  31056. * Default AudioEngine factory responsible of creating the Audio Engine.
  31057. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31058. */
  31059. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31060. /**
  31061. * Default offline support factory responsible of creating a tool used to store data locally.
  31062. * By default, this will create a Database object if the workload has been embedded.
  31063. */
  31064. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31065. private _onFocus;
  31066. private _onBlur;
  31067. private _onCanvasPointerOut;
  31068. private _onCanvasBlur;
  31069. private _onCanvasFocus;
  31070. private _onFullscreenChange;
  31071. private _onPointerLockChange;
  31072. private _hardwareScalingLevel;
  31073. /** @hidden */
  31074. _caps: EngineCapabilities;
  31075. private _pointerLockRequested;
  31076. private _isStencilEnable;
  31077. protected _colorWrite: boolean;
  31078. private _loadingScreen;
  31079. /** @hidden */
  31080. _drawCalls: PerfCounter;
  31081. private _glVersion;
  31082. private _glRenderer;
  31083. private _glVendor;
  31084. private _videoTextureSupported;
  31085. private _renderingQueueLaunched;
  31086. private _activeRenderLoops;
  31087. private _deterministicLockstep;
  31088. private _lockstepMaxSteps;
  31089. /**
  31090. * Observable signaled when a context lost event is raised
  31091. */
  31092. onContextLostObservable: Observable<Engine>;
  31093. /**
  31094. * Observable signaled when a context restored event is raised
  31095. */
  31096. onContextRestoredObservable: Observable<Engine>;
  31097. private _onContextLost;
  31098. private _onContextRestored;
  31099. private _contextWasLost;
  31100. /** @hidden */
  31101. _doNotHandleContextLost: boolean;
  31102. /**
  31103. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31104. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31105. */
  31106. doNotHandleContextLost: boolean;
  31107. private _fps;
  31108. private _deltaTime;
  31109. /**
  31110. * Turn this value on if you want to pause FPS computation when in background
  31111. */
  31112. disablePerformanceMonitorInBackground: boolean;
  31113. private _performanceMonitor;
  31114. /**
  31115. * Gets the performance monitor attached to this engine
  31116. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31117. */
  31118. readonly performanceMonitor: PerformanceMonitor;
  31119. /**
  31120. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31121. */
  31122. disableVertexArrayObjects: boolean;
  31123. /** @hidden */
  31124. protected _depthCullingState: _DepthCullingState;
  31125. /** @hidden */
  31126. protected _stencilState: _StencilState;
  31127. /** @hidden */
  31128. protected _alphaState: _AlphaState;
  31129. /** @hidden */
  31130. protected _alphaMode: number;
  31131. /** @hidden */
  31132. protected _alphaEquation: number;
  31133. /** @hidden */
  31134. _internalTexturesCache: InternalTexture[];
  31135. /** @hidden */
  31136. protected _activeChannel: number;
  31137. private _currentTextureChannel;
  31138. /** @hidden */
  31139. protected _boundTexturesCache: {
  31140. [key: string]: Nullable<InternalTexture>;
  31141. };
  31142. /** @hidden */
  31143. protected _currentEffect: Nullable<Effect>;
  31144. /** @hidden */
  31145. protected _currentProgram: Nullable<WebGLProgram>;
  31146. private _compiledEffects;
  31147. private _vertexAttribArraysEnabled;
  31148. /** @hidden */
  31149. protected _cachedViewport: Nullable<IViewportLike>;
  31150. private _cachedVertexArrayObject;
  31151. /** @hidden */
  31152. protected _cachedVertexBuffers: any;
  31153. /** @hidden */
  31154. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31155. /** @hidden */
  31156. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31157. /** @hidden */
  31158. _currentRenderTarget: Nullable<InternalTexture>;
  31159. private _uintIndicesCurrentlySet;
  31160. private _currentBoundBuffer;
  31161. /** @hidden */
  31162. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31163. private _currentBufferPointers;
  31164. private _currentInstanceLocations;
  31165. private _currentInstanceBuffers;
  31166. private _textureUnits;
  31167. /** @hidden */
  31168. _workingCanvas: Nullable<HTMLCanvasElement>;
  31169. /** @hidden */
  31170. _workingContext: Nullable<CanvasRenderingContext2D>;
  31171. private _rescalePostProcess;
  31172. private _dummyFramebuffer;
  31173. /** @hidden */
  31174. _bindedRenderFunction: any;
  31175. private _vaoRecordInProgress;
  31176. private _mustWipeVertexAttributes;
  31177. private _emptyTexture;
  31178. private _emptyCubeTexture;
  31179. private _emptyTexture3D;
  31180. /** @hidden */
  31181. _frameHandler: number;
  31182. private _nextFreeTextureSlots;
  31183. private _maxSimultaneousTextures;
  31184. private _activeRequests;
  31185. private _texturesSupported;
  31186. /** @hidden */
  31187. _textureFormatInUse: Nullable<string>;
  31188. /**
  31189. * Gets the list of texture formats supported
  31190. */
  31191. readonly texturesSupported: Array<string>;
  31192. /**
  31193. * Gets the list of texture formats in use
  31194. */
  31195. readonly textureFormatInUse: Nullable<string>;
  31196. /**
  31197. * Gets the current viewport
  31198. */
  31199. readonly currentViewport: Nullable<IViewportLike>;
  31200. /**
  31201. * Gets the default empty texture
  31202. */
  31203. readonly emptyTexture: InternalTexture;
  31204. /**
  31205. * Gets the default empty 3D texture
  31206. */
  31207. readonly emptyTexture3D: InternalTexture;
  31208. /**
  31209. * Gets the default empty cube texture
  31210. */
  31211. readonly emptyCubeTexture: InternalTexture;
  31212. /**
  31213. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31214. */
  31215. readonly premultipliedAlpha: boolean;
  31216. /**
  31217. * Creates a new engine
  31218. * @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
  31219. * @param antialias defines enable antialiasing (default: false)
  31220. * @param options defines further options to be sent to the getContext() function
  31221. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31222. */
  31223. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31224. /**
  31225. * Initializes a webVR display and starts listening to display change events
  31226. * The onVRDisplayChangedObservable will be notified upon these changes
  31227. * @returns The onVRDisplayChangedObservable
  31228. */
  31229. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31230. /** @hidden */
  31231. _prepareVRComponent(): void;
  31232. /** @hidden */
  31233. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31234. /** @hidden */
  31235. _submitVRFrame(): void;
  31236. /**
  31237. * Call this function to leave webVR mode
  31238. * Will do nothing if webVR is not supported or if there is no webVR device
  31239. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31240. */
  31241. disableVR(): void;
  31242. /**
  31243. * Gets a boolean indicating that the system is in VR mode and is presenting
  31244. * @returns true if VR mode is engaged
  31245. */
  31246. isVRPresenting(): boolean;
  31247. /** @hidden */
  31248. _requestVRFrame(): void;
  31249. private _disableTouchAction;
  31250. private _rebuildInternalTextures;
  31251. private _rebuildEffects;
  31252. /**
  31253. * Gets a boolean indicating if all created effects are ready
  31254. * @returns true if all effects are ready
  31255. */
  31256. areAllEffectsReady(): boolean;
  31257. private _rebuildBuffers;
  31258. private _initGLContext;
  31259. /**
  31260. * Gets version of the current webGL context
  31261. */
  31262. readonly webGLVersion: number;
  31263. /**
  31264. * Gets a string idenfifying the name of the class
  31265. * @returns "Engine" string
  31266. */
  31267. getClassName(): string;
  31268. /**
  31269. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31270. */
  31271. readonly isStencilEnable: boolean;
  31272. /** @hidden */
  31273. _prepareWorkingCanvas(): void;
  31274. /**
  31275. * Reset the texture cache to empty state
  31276. */
  31277. resetTextureCache(): void;
  31278. /**
  31279. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31280. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31281. * @returns true if engine is in deterministic lock step mode
  31282. */
  31283. isDeterministicLockStep(): boolean;
  31284. /**
  31285. * Gets the max steps when engine is running in deterministic lock step
  31286. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31287. * @returns the max steps
  31288. */
  31289. getLockstepMaxSteps(): number;
  31290. /**
  31291. * Gets an object containing information about the current webGL context
  31292. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31293. */
  31294. getGlInfo(): {
  31295. vendor: string;
  31296. renderer: string;
  31297. version: string;
  31298. };
  31299. /**
  31300. * Gets current aspect ratio
  31301. * @param viewportOwner defines the camera to use to get the aspect ratio
  31302. * @param useScreen defines if screen size must be used (or the current render target if any)
  31303. * @returns a number defining the aspect ratio
  31304. */
  31305. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31306. /**
  31307. * Gets current screen aspect ratio
  31308. * @returns a number defining the aspect ratio
  31309. */
  31310. getScreenAspectRatio(): number;
  31311. /**
  31312. * Gets the current render width
  31313. * @param useScreen defines if screen size must be used (or the current render target if any)
  31314. * @returns a number defining the current render width
  31315. */
  31316. getRenderWidth(useScreen?: boolean): number;
  31317. /**
  31318. * Gets the current render height
  31319. * @param useScreen defines if screen size must be used (or the current render target if any)
  31320. * @returns a number defining the current render height
  31321. */
  31322. getRenderHeight(useScreen?: boolean): number;
  31323. /**
  31324. * Gets the HTML canvas attached with the current webGL context
  31325. * @returns a HTML canvas
  31326. */
  31327. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31328. /**
  31329. * Gets host window
  31330. * @returns the host window object
  31331. */
  31332. getHostWindow(): Window;
  31333. /**
  31334. * Gets host document
  31335. * @returns the host document object
  31336. */
  31337. getHostDocument(): Document;
  31338. /**
  31339. * Gets the client rect of the HTML canvas attached with the current webGL context
  31340. * @returns a client rectanglee
  31341. */
  31342. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31343. /**
  31344. * Defines the hardware scaling level.
  31345. * By default the hardware scaling level is computed from the window device ratio.
  31346. * 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.
  31347. * @param level defines the level to use
  31348. */
  31349. setHardwareScalingLevel(level: number): void;
  31350. /**
  31351. * Gets the current hardware scaling level.
  31352. * By default the hardware scaling level is computed from the window device ratio.
  31353. * 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.
  31354. * @returns a number indicating the current hardware scaling level
  31355. */
  31356. getHardwareScalingLevel(): number;
  31357. /**
  31358. * Gets the list of loaded textures
  31359. * @returns an array containing all loaded textures
  31360. */
  31361. getLoadedTexturesCache(): InternalTexture[];
  31362. /**
  31363. * Gets the object containing all engine capabilities
  31364. * @returns the EngineCapabilities object
  31365. */
  31366. getCaps(): EngineCapabilities;
  31367. /**
  31368. * Gets the current depth function
  31369. * @returns a number defining the depth function
  31370. */
  31371. getDepthFunction(): Nullable<number>;
  31372. /**
  31373. * Sets the current depth function
  31374. * @param depthFunc defines the function to use
  31375. */
  31376. setDepthFunction(depthFunc: number): void;
  31377. /**
  31378. * Sets the current depth function to GREATER
  31379. */
  31380. setDepthFunctionToGreater(): void;
  31381. /**
  31382. * Sets the current depth function to GEQUAL
  31383. */
  31384. setDepthFunctionToGreaterOrEqual(): void;
  31385. /**
  31386. * Sets the current depth function to LESS
  31387. */
  31388. setDepthFunctionToLess(): void;
  31389. private _cachedStencilBuffer;
  31390. private _cachedStencilFunction;
  31391. private _cachedStencilMask;
  31392. private _cachedStencilOperationPass;
  31393. private _cachedStencilOperationFail;
  31394. private _cachedStencilOperationDepthFail;
  31395. private _cachedStencilReference;
  31396. /**
  31397. * Caches the the state of the stencil buffer
  31398. */
  31399. cacheStencilState(): void;
  31400. /**
  31401. * Restores the state of the stencil buffer
  31402. */
  31403. restoreStencilState(): void;
  31404. /**
  31405. * Sets the current depth function to LEQUAL
  31406. */
  31407. setDepthFunctionToLessOrEqual(): void;
  31408. /**
  31409. * Gets a boolean indicating if stencil buffer is enabled
  31410. * @returns the current stencil buffer state
  31411. */
  31412. getStencilBuffer(): boolean;
  31413. /**
  31414. * Enable or disable the stencil buffer
  31415. * @param enable defines if the stencil buffer must be enabled or disabled
  31416. */
  31417. setStencilBuffer(enable: boolean): void;
  31418. /**
  31419. * Gets the current stencil mask
  31420. * @returns a number defining the new stencil mask to use
  31421. */
  31422. getStencilMask(): number;
  31423. /**
  31424. * Sets the current stencil mask
  31425. * @param mask defines the new stencil mask to use
  31426. */
  31427. setStencilMask(mask: number): void;
  31428. /**
  31429. * Gets the current stencil function
  31430. * @returns a number defining the stencil function to use
  31431. */
  31432. getStencilFunction(): number;
  31433. /**
  31434. * Gets the current stencil reference value
  31435. * @returns a number defining the stencil reference value to use
  31436. */
  31437. getStencilFunctionReference(): number;
  31438. /**
  31439. * Gets the current stencil mask
  31440. * @returns a number defining the stencil mask to use
  31441. */
  31442. getStencilFunctionMask(): number;
  31443. /**
  31444. * Sets the current stencil function
  31445. * @param stencilFunc defines the new stencil function to use
  31446. */
  31447. setStencilFunction(stencilFunc: number): void;
  31448. /**
  31449. * Sets the current stencil reference
  31450. * @param reference defines the new stencil reference to use
  31451. */
  31452. setStencilFunctionReference(reference: number): void;
  31453. /**
  31454. * Sets the current stencil mask
  31455. * @param mask defines the new stencil mask to use
  31456. */
  31457. setStencilFunctionMask(mask: number): void;
  31458. /**
  31459. * Gets the current stencil operation when stencil fails
  31460. * @returns a number defining stencil operation to use when stencil fails
  31461. */
  31462. getStencilOperationFail(): number;
  31463. /**
  31464. * Gets the current stencil operation when depth fails
  31465. * @returns a number defining stencil operation to use when depth fails
  31466. */
  31467. getStencilOperationDepthFail(): number;
  31468. /**
  31469. * Gets the current stencil operation when stencil passes
  31470. * @returns a number defining stencil operation to use when stencil passes
  31471. */
  31472. getStencilOperationPass(): number;
  31473. /**
  31474. * Sets the stencil operation to use when stencil fails
  31475. * @param operation defines the stencil operation to use when stencil fails
  31476. */
  31477. setStencilOperationFail(operation: number): void;
  31478. /**
  31479. * Sets the stencil operation to use when depth fails
  31480. * @param operation defines the stencil operation to use when depth fails
  31481. */
  31482. setStencilOperationDepthFail(operation: number): void;
  31483. /**
  31484. * Sets the stencil operation to use when stencil passes
  31485. * @param operation defines the stencil operation to use when stencil passes
  31486. */
  31487. setStencilOperationPass(operation: number): void;
  31488. /**
  31489. * Sets a boolean indicating if the dithering state is enabled or disabled
  31490. * @param value defines the dithering state
  31491. */
  31492. setDitheringState(value: boolean): void;
  31493. /**
  31494. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31495. * @param value defines the rasterizer state
  31496. */
  31497. setRasterizerState(value: boolean): void;
  31498. /**
  31499. * stop executing a render loop function and remove it from the execution array
  31500. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31501. */
  31502. stopRenderLoop(renderFunction?: () => void): void;
  31503. /** @hidden */
  31504. _renderLoop(): void;
  31505. /**
  31506. * Can be used to override the current requestAnimationFrame requester.
  31507. * @hidden
  31508. */
  31509. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31510. /**
  31511. * Register and execute a render loop. The engine can have more than one render function
  31512. * @param renderFunction defines the function to continuously execute
  31513. */
  31514. runRenderLoop(renderFunction: () => void): void;
  31515. /**
  31516. * Toggle full screen mode
  31517. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31518. */
  31519. switchFullscreen(requestPointerLock: boolean): void;
  31520. /**
  31521. * Enters full screen mode
  31522. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31523. */
  31524. enterFullscreen(requestPointerLock: boolean): void;
  31525. /**
  31526. * Exits full screen mode
  31527. */
  31528. exitFullscreen(): void;
  31529. /**
  31530. * Enters Pointerlock mode
  31531. */
  31532. enterPointerlock(): void;
  31533. /**
  31534. * Exits Pointerlock mode
  31535. */
  31536. exitPointerlock(): void;
  31537. /**
  31538. * Clear the current render buffer or the current render target (if any is set up)
  31539. * @param color defines the color to use
  31540. * @param backBuffer defines if the back buffer must be cleared
  31541. * @param depth defines if the depth buffer must be cleared
  31542. * @param stencil defines if the stencil buffer must be cleared
  31543. */
  31544. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31545. /**
  31546. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31547. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31548. * @param y defines the y-coordinate of the corner of the clear rectangle
  31549. * @param width defines the width of the clear rectangle
  31550. * @param height defines the height of the clear rectangle
  31551. * @param clearColor defines the clear color
  31552. */
  31553. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31554. /**
  31555. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31556. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31557. * @param y defines the y-coordinate of the corner of the clear rectangle
  31558. * @param width defines the width of the clear rectangle
  31559. * @param height defines the height of the clear rectangle
  31560. */
  31561. enableScissor(x: number, y: number, width: number, height: number): void;
  31562. /**
  31563. * Disable previously set scissor test rectangle
  31564. */
  31565. disableScissor(): void;
  31566. private _viewportCached;
  31567. /** @hidden */
  31568. _viewport(x: number, y: number, width: number, height: number): void;
  31569. /**
  31570. * Set the WebGL's viewport
  31571. * @param viewport defines the viewport element to be used
  31572. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31573. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31574. */
  31575. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31576. /**
  31577. * Directly set the WebGL Viewport
  31578. * @param x defines the x coordinate of the viewport (in screen space)
  31579. * @param y defines the y coordinate of the viewport (in screen space)
  31580. * @param width defines the width of the viewport (in screen space)
  31581. * @param height defines the height of the viewport (in screen space)
  31582. * @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
  31583. */
  31584. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31585. /**
  31586. * Begin a new frame
  31587. */
  31588. beginFrame(): void;
  31589. /**
  31590. * Enf the current frame
  31591. */
  31592. endFrame(): void;
  31593. /**
  31594. * Resize the view according to the canvas' size
  31595. */
  31596. resize(): void;
  31597. /**
  31598. * Force a specific size of the canvas
  31599. * @param width defines the new canvas' width
  31600. * @param height defines the new canvas' height
  31601. */
  31602. setSize(width: number, height: number): void;
  31603. /**
  31604. * Binds the frame buffer to the specified texture.
  31605. * @param texture The texture to render to or null for the default canvas
  31606. * @param faceIndex The face of the texture to render to in case of cube texture
  31607. * @param requiredWidth The width of the target to render to
  31608. * @param requiredHeight The height of the target to render to
  31609. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31610. * @param depthStencilTexture The depth stencil texture to use to render
  31611. * @param lodLevel defines le lod level to bind to the frame buffer
  31612. */
  31613. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31614. /** @hidden */
  31615. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31616. /**
  31617. * Unbind the current render target texture from the webGL context
  31618. * @param texture defines the render target texture to unbind
  31619. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31620. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31621. */
  31622. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31623. /**
  31624. * Force the mipmap generation for the given render target texture
  31625. * @param texture defines the render target texture to use
  31626. */
  31627. generateMipMapsForCubemap(texture: InternalTexture): void;
  31628. /**
  31629. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31630. */
  31631. flushFramebuffer(): void;
  31632. /**
  31633. * Unbind the current render target and bind the default framebuffer
  31634. */
  31635. restoreDefaultFramebuffer(): void;
  31636. /**
  31637. * Create an uniform buffer
  31638. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31639. * @param elements defines the content of the uniform buffer
  31640. * @returns the webGL uniform buffer
  31641. */
  31642. createUniformBuffer(elements: FloatArray): DataBuffer;
  31643. /**
  31644. * Create a dynamic uniform buffer
  31645. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31646. * @param elements defines the content of the uniform buffer
  31647. * @returns the webGL uniform buffer
  31648. */
  31649. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31650. /**
  31651. * Update an existing uniform buffer
  31652. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31653. * @param uniformBuffer defines the target uniform buffer
  31654. * @param elements defines the content to update
  31655. * @param offset defines the offset in the uniform buffer where update should start
  31656. * @param count defines the size of the data to update
  31657. */
  31658. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31659. private _resetVertexBufferBinding;
  31660. /**
  31661. * Creates a vertex buffer
  31662. * @param data the data for the vertex buffer
  31663. * @returns the new WebGL static buffer
  31664. */
  31665. createVertexBuffer(data: DataArray): DataBuffer;
  31666. private _createVertexBuffer;
  31667. /**
  31668. * Creates a dynamic vertex buffer
  31669. * @param data the data for the dynamic vertex buffer
  31670. * @returns the new WebGL dynamic buffer
  31671. */
  31672. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31673. /**
  31674. * Update a dynamic index buffer
  31675. * @param indexBuffer defines the target index buffer
  31676. * @param indices defines the data to update
  31677. * @param offset defines the offset in the target index buffer where update should start
  31678. */
  31679. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31680. /**
  31681. * Updates a dynamic vertex buffer.
  31682. * @param vertexBuffer the vertex buffer to update
  31683. * @param data the data used to update the vertex buffer
  31684. * @param byteOffset the byte offset of the data
  31685. * @param byteLength the byte length of the data
  31686. */
  31687. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31688. private _resetIndexBufferBinding;
  31689. /**
  31690. * Creates a new index buffer
  31691. * @param indices defines the content of the index buffer
  31692. * @param updatable defines if the index buffer must be updatable
  31693. * @returns a new webGL buffer
  31694. */
  31695. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31696. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31697. /**
  31698. * Bind a webGL buffer to the webGL context
  31699. * @param buffer defines the buffer to bind
  31700. */
  31701. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31702. /**
  31703. * Bind an uniform buffer to the current webGL context
  31704. * @param buffer defines the buffer to bind
  31705. */
  31706. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31707. /**
  31708. * Bind a buffer to the current webGL context at a given location
  31709. * @param buffer defines the buffer to bind
  31710. * @param location defines the index where to bind the buffer
  31711. */
  31712. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31713. /**
  31714. * Bind a specific block at a given index in a specific shader program
  31715. * @param pipelineContext defines the pipeline context to use
  31716. * @param blockName defines the block name
  31717. * @param index defines the index where to bind the block
  31718. */
  31719. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31720. private bindIndexBuffer;
  31721. private bindBuffer;
  31722. /**
  31723. * update the bound buffer with the given data
  31724. * @param data defines the data to update
  31725. */
  31726. updateArrayBuffer(data: Float32Array): void;
  31727. private _vertexAttribPointer;
  31728. private _bindIndexBufferWithCache;
  31729. private _bindVertexBuffersAttributes;
  31730. /**
  31731. * Records a vertex array object
  31732. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31733. * @param vertexBuffers defines the list of vertex buffers to store
  31734. * @param indexBuffer defines the index buffer to store
  31735. * @param effect defines the effect to store
  31736. * @returns the new vertex array object
  31737. */
  31738. recordVertexArrayObject(vertexBuffers: {
  31739. [key: string]: VertexBuffer;
  31740. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31741. /**
  31742. * Bind a specific vertex array object
  31743. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31744. * @param vertexArrayObject defines the vertex array object to bind
  31745. * @param indexBuffer defines the index buffer to bind
  31746. */
  31747. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31748. /**
  31749. * Bind webGl buffers directly to the webGL context
  31750. * @param vertexBuffer defines the vertex buffer to bind
  31751. * @param indexBuffer defines the index buffer to bind
  31752. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31753. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31754. * @param effect defines the effect associated with the vertex buffer
  31755. */
  31756. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31757. private _unbindVertexArrayObject;
  31758. /**
  31759. * Bind a list of vertex buffers to the webGL context
  31760. * @param vertexBuffers defines the list of vertex buffers to bind
  31761. * @param indexBuffer defines the index buffer to bind
  31762. * @param effect defines the effect associated with the vertex buffers
  31763. */
  31764. bindBuffers(vertexBuffers: {
  31765. [key: string]: Nullable<VertexBuffer>;
  31766. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31767. /**
  31768. * Unbind all instance attributes
  31769. */
  31770. unbindInstanceAttributes(): void;
  31771. /**
  31772. * Release and free the memory of a vertex array object
  31773. * @param vao defines the vertex array object to delete
  31774. */
  31775. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31776. /** @hidden */
  31777. _releaseBuffer(buffer: DataBuffer): boolean;
  31778. protected _deleteBuffer(buffer: DataBuffer): void;
  31779. /**
  31780. * Creates a webGL buffer to use with instanciation
  31781. * @param capacity defines the size of the buffer
  31782. * @returns the webGL buffer
  31783. */
  31784. createInstancesBuffer(capacity: number): DataBuffer;
  31785. /**
  31786. * Delete a webGL buffer used with instanciation
  31787. * @param buffer defines the webGL buffer to delete
  31788. */
  31789. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31790. /**
  31791. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31792. * @param instancesBuffer defines the webGL buffer to update and bind
  31793. * @param data defines the data to store in the buffer
  31794. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31795. */
  31796. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31797. /**
  31798. * Apply all cached states (depth, culling, stencil and alpha)
  31799. */
  31800. applyStates(): void;
  31801. /**
  31802. * Send a draw order
  31803. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31804. * @param indexStart defines the starting index
  31805. * @param indexCount defines the number of index to draw
  31806. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31807. */
  31808. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31809. /**
  31810. * Draw a list of points
  31811. * @param verticesStart defines the index of first vertex to draw
  31812. * @param verticesCount defines the count of vertices to draw
  31813. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31814. */
  31815. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31816. /**
  31817. * Draw a list of unindexed primitives
  31818. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31819. * @param verticesStart defines the index of first vertex to draw
  31820. * @param verticesCount defines the count of vertices to draw
  31821. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31822. */
  31823. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31824. /**
  31825. * Draw a list of indexed primitives
  31826. * @param fillMode defines the primitive to use
  31827. * @param indexStart defines the starting index
  31828. * @param indexCount defines the number of index to draw
  31829. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31830. */
  31831. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31832. /**
  31833. * Draw a list of unindexed primitives
  31834. * @param fillMode defines the primitive to use
  31835. * @param verticesStart defines the index of first vertex to draw
  31836. * @param verticesCount defines the count of vertices to draw
  31837. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31838. */
  31839. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31840. private _drawMode;
  31841. /** @hidden */
  31842. _releaseEffect(effect: Effect): void;
  31843. /** @hidden */
  31844. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31845. /**
  31846. * Create a new effect (used to store vertex/fragment shaders)
  31847. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31848. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31849. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31850. * @param samplers defines an array of string used to represent textures
  31851. * @param defines defines the string containing the defines to use to compile the shaders
  31852. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31853. * @param onCompiled defines a function to call when the effect creation is successful
  31854. * @param onError defines a function to call when the effect creation has failed
  31855. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31856. * @returns the new Effect
  31857. */
  31858. 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;
  31859. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31860. private _compileShader;
  31861. private _compileRawShader;
  31862. /**
  31863. * Directly creates a webGL program
  31864. * @param pipelineContext defines the pipeline context to attach to
  31865. * @param vertexCode defines the vertex shader code to use
  31866. * @param fragmentCode defines the fragment shader code to use
  31867. * @param context defines the webGL context to use (if not set, the current one will be used)
  31868. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31869. * @returns the new webGL program
  31870. */
  31871. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31872. /**
  31873. * Creates a webGL program
  31874. * @param pipelineContext defines the pipeline context to attach to
  31875. * @param vertexCode defines the vertex shader code to use
  31876. * @param fragmentCode defines the fragment shader code to use
  31877. * @param defines defines the string containing the defines to use to compile the shaders
  31878. * @param context defines the webGL context to use (if not set, the current one will be used)
  31879. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31880. * @returns the new webGL program
  31881. */
  31882. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31883. /**
  31884. * Creates a new pipeline context
  31885. * @returns the new pipeline
  31886. */
  31887. createPipelineContext(): IPipelineContext;
  31888. private _createShaderProgram;
  31889. private _finalizePipelineContext;
  31890. /** @hidden */
  31891. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31892. /** @hidden */
  31893. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31894. /** @hidden */
  31895. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31896. /**
  31897. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31898. * @param pipelineContext defines the pipeline context to use
  31899. * @param uniformsNames defines the list of uniform names
  31900. * @returns an array of webGL uniform locations
  31901. */
  31902. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31903. /**
  31904. * Gets the lsit of active attributes for a given webGL program
  31905. * @param pipelineContext defines the pipeline context to use
  31906. * @param attributesNames defines the list of attribute names to get
  31907. * @returns an array of indices indicating the offset of each attribute
  31908. */
  31909. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31910. /**
  31911. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31912. * @param effect defines the effect to activate
  31913. */
  31914. enableEffect(effect: Nullable<Effect>): void;
  31915. /**
  31916. * Set the value of an uniform to an array of int32
  31917. * @param uniform defines the webGL uniform location where to store the value
  31918. * @param array defines the array of int32 to store
  31919. */
  31920. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31921. /**
  31922. * Set the value of an uniform to an array of int32 (stored as vec2)
  31923. * @param uniform defines the webGL uniform location where to store the value
  31924. * @param array defines the array of int32 to store
  31925. */
  31926. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31927. /**
  31928. * Set the value of an uniform to an array of int32 (stored as vec3)
  31929. * @param uniform defines the webGL uniform location where to store the value
  31930. * @param array defines the array of int32 to store
  31931. */
  31932. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31933. /**
  31934. * Set the value of an uniform to an array of int32 (stored as vec4)
  31935. * @param uniform defines the webGL uniform location where to store the value
  31936. * @param array defines the array of int32 to store
  31937. */
  31938. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31939. /**
  31940. * Set the value of an uniform to an array of float32
  31941. * @param uniform defines the webGL uniform location where to store the value
  31942. * @param array defines the array of float32 to store
  31943. */
  31944. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31945. /**
  31946. * Set the value of an uniform to an array of float32 (stored as vec2)
  31947. * @param uniform defines the webGL uniform location where to store the value
  31948. * @param array defines the array of float32 to store
  31949. */
  31950. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31951. /**
  31952. * Set the value of an uniform to an array of float32 (stored as vec3)
  31953. * @param uniform defines the webGL uniform location where to store the value
  31954. * @param array defines the array of float32 to store
  31955. */
  31956. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31957. /**
  31958. * Set the value of an uniform to an array of float32 (stored as vec4)
  31959. * @param uniform defines the webGL uniform location where to store the value
  31960. * @param array defines the array of float32 to store
  31961. */
  31962. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31963. /**
  31964. * Set the value of an uniform to an array of number
  31965. * @param uniform defines the webGL uniform location where to store the value
  31966. * @param array defines the array of number to store
  31967. */
  31968. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31969. /**
  31970. * Set the value of an uniform to an array of number (stored as vec2)
  31971. * @param uniform defines the webGL uniform location where to store the value
  31972. * @param array defines the array of number to store
  31973. */
  31974. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31975. /**
  31976. * Set the value of an uniform to an array of number (stored as vec3)
  31977. * @param uniform defines the webGL uniform location where to store the value
  31978. * @param array defines the array of number to store
  31979. */
  31980. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31981. /**
  31982. * Set the value of an uniform to an array of number (stored as vec4)
  31983. * @param uniform defines the webGL uniform location where to store the value
  31984. * @param array defines the array of number to store
  31985. */
  31986. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31987. /**
  31988. * Set the value of an uniform to an array of float32 (stored as matrices)
  31989. * @param uniform defines the webGL uniform location where to store the value
  31990. * @param matrices defines the array of float32 to store
  31991. */
  31992. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31993. /**
  31994. * Set the value of an uniform to a matrix (3x3)
  31995. * @param uniform defines the webGL uniform location where to store the value
  31996. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31997. */
  31998. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31999. /**
  32000. * Set the value of an uniform to a matrix (2x2)
  32001. * @param uniform defines the webGL uniform location where to store the value
  32002. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32003. */
  32004. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32005. /**
  32006. * Set the value of an uniform to a number (int)
  32007. * @param uniform defines the webGL uniform location where to store the value
  32008. * @param value defines the int number to store
  32009. */
  32010. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32011. /**
  32012. * Set the value of an uniform to a number (float)
  32013. * @param uniform defines the webGL uniform location where to store the value
  32014. * @param value defines the float number to store
  32015. */
  32016. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32017. /**
  32018. * Set the value of an uniform to a vec2
  32019. * @param uniform defines the webGL uniform location where to store the value
  32020. * @param x defines the 1st component of the value
  32021. * @param y defines the 2nd component of the value
  32022. */
  32023. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32024. /**
  32025. * Set the value of an uniform to a vec3
  32026. * @param uniform defines the webGL uniform location where to store the value
  32027. * @param x defines the 1st component of the value
  32028. * @param y defines the 2nd component of the value
  32029. * @param z defines the 3rd component of the value
  32030. */
  32031. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32032. /**
  32033. * Set the value of an uniform to a boolean
  32034. * @param uniform defines the webGL uniform location where to store the value
  32035. * @param bool defines the boolean to store
  32036. */
  32037. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  32038. /**
  32039. * Set the value of an uniform to a vec4
  32040. * @param uniform defines the webGL uniform location where to store the value
  32041. * @param x defines the 1st component of the value
  32042. * @param y defines the 2nd component of the value
  32043. * @param z defines the 3rd component of the value
  32044. * @param w defines the 4th component of the value
  32045. */
  32046. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32047. /**
  32048. * Sets a Color4 on a uniform variable
  32049. * @param uniform defines the uniform location
  32050. * @param color4 defines the value to be set
  32051. */
  32052. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  32053. /**
  32054. * Set various states to the webGL context
  32055. * @param culling defines backface culling state
  32056. * @param zOffset defines the value to apply to zOffset (0 by default)
  32057. * @param force defines if states must be applied even if cache is up to date
  32058. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32059. */
  32060. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32061. /**
  32062. * Set the z offset to apply to current rendering
  32063. * @param value defines the offset to apply
  32064. */
  32065. setZOffset(value: number): void;
  32066. /**
  32067. * Gets the current value of the zOffset
  32068. * @returns the current zOffset state
  32069. */
  32070. getZOffset(): number;
  32071. /**
  32072. * Enable or disable depth buffering
  32073. * @param enable defines the state to set
  32074. */
  32075. setDepthBuffer(enable: boolean): void;
  32076. /**
  32077. * Gets a boolean indicating if depth writing is enabled
  32078. * @returns the current depth writing state
  32079. */
  32080. getDepthWrite(): boolean;
  32081. /**
  32082. * Enable or disable depth writing
  32083. * @param enable defines the state to set
  32084. */
  32085. setDepthWrite(enable: boolean): void;
  32086. /**
  32087. * Enable or disable color writing
  32088. * @param enable defines the state to set
  32089. */
  32090. setColorWrite(enable: boolean): void;
  32091. /**
  32092. * Gets a boolean indicating if color writing is enabled
  32093. * @returns the current color writing state
  32094. */
  32095. getColorWrite(): boolean;
  32096. /**
  32097. * Sets alpha constants used by some alpha blending modes
  32098. * @param r defines the red component
  32099. * @param g defines the green component
  32100. * @param b defines the blue component
  32101. * @param a defines the alpha component
  32102. */
  32103. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32104. /**
  32105. * Sets the current alpha mode
  32106. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32107. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32108. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32109. */
  32110. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32111. /**
  32112. * Gets the current alpha mode
  32113. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32114. * @returns the current alpha mode
  32115. */
  32116. getAlphaMode(): number;
  32117. /**
  32118. * Sets the current alpha equation
  32119. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32120. */
  32121. setAlphaEquation(equation: number): void;
  32122. /**
  32123. * Gets the current alpha equation.
  32124. * @returns the current alpha equation
  32125. */
  32126. getAlphaEquation(): number;
  32127. /**
  32128. * Clears the list of texture accessible through engine.
  32129. * This can help preventing texture load conflict due to name collision.
  32130. */
  32131. clearInternalTexturesCache(): void;
  32132. /**
  32133. * Force the entire cache to be cleared
  32134. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32135. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32136. */
  32137. wipeCaches(bruteForce?: boolean): void;
  32138. /**
  32139. * Set the compressed texture format to use, based on the formats you have, and the formats
  32140. * supported by the hardware / browser.
  32141. *
  32142. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32143. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32144. * to API arguments needed to compressed textures. This puts the burden on the container
  32145. * generator to house the arcane code for determining these for current & future formats.
  32146. *
  32147. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32148. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32149. *
  32150. * Note: The result of this call is not taken into account when a texture is base64.
  32151. *
  32152. * @param formatsAvailable defines the list of those format families you have created
  32153. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32154. *
  32155. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32156. * @returns The extension selected.
  32157. */
  32158. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32159. /** @hidden */
  32160. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32161. min: number;
  32162. mag: number;
  32163. };
  32164. /** @hidden */
  32165. _createTexture(): WebGLTexture;
  32166. /**
  32167. * Usually called from Texture.ts.
  32168. * Passed information to create a WebGLTexture
  32169. * @param urlArg defines a value which contains one of the following:
  32170. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32171. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32172. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32173. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32174. * @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)
  32175. * @param scene needed for loading to the correct scene
  32176. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32177. * @param onLoad optional callback to be called upon successful completion
  32178. * @param onError optional callback to be called upon failure
  32179. * @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
  32180. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32181. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32182. * @param forcedExtension defines the extension to use to pick the right loader
  32183. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32184. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32185. */
  32186. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  32187. /**
  32188. * @hidden
  32189. * Rescales a texture
  32190. * @param source input texutre
  32191. * @param destination destination texture
  32192. * @param scene scene to use to render the resize
  32193. * @param internalFormat format to use when resizing
  32194. * @param onComplete callback to be called when resize has completed
  32195. */
  32196. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32197. private _unpackFlipYCached;
  32198. /**
  32199. * In case you are sharing the context with other applications, it might
  32200. * be interested to not cache the unpack flip y state to ensure a consistent
  32201. * value would be set.
  32202. */
  32203. enableUnpackFlipYCached: boolean;
  32204. /** @hidden */
  32205. _unpackFlipY(value: boolean): void;
  32206. /** @hidden */
  32207. _getUnpackAlignement(): number;
  32208. /**
  32209. * Creates a dynamic texture
  32210. * @param width defines the width of the texture
  32211. * @param height defines the height of the texture
  32212. * @param generateMipMaps defines if the engine should generate the mip levels
  32213. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32214. * @returns the dynamic texture inside an InternalTexture
  32215. */
  32216. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32217. /**
  32218. * Update the sampling mode of a given texture
  32219. * @param samplingMode defines the required sampling mode
  32220. * @param texture defines the texture to update
  32221. */
  32222. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32223. /**
  32224. * Update the content of a dynamic texture
  32225. * @param texture defines the texture to update
  32226. * @param canvas defines the canvas containing the source
  32227. * @param invertY defines if data must be stored with Y axis inverted
  32228. * @param premulAlpha defines if alpha is stored as premultiplied
  32229. * @param format defines the format of the data
  32230. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32231. */
  32232. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32233. /**
  32234. * Update a video texture
  32235. * @param texture defines the texture to update
  32236. * @param video defines the video element to use
  32237. * @param invertY defines if data must be stored with Y axis inverted
  32238. */
  32239. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32240. /**
  32241. * Updates a depth texture Comparison Mode and Function.
  32242. * If the comparison Function is equal to 0, the mode will be set to none.
  32243. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32244. * @param texture The texture to set the comparison function for
  32245. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32246. */
  32247. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32248. /** @hidden */
  32249. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32250. width: number;
  32251. height: number;
  32252. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32253. /**
  32254. * Creates a depth stencil texture.
  32255. * This is only available in WebGL 2 or with the depth texture extension available.
  32256. * @param size The size of face edge in the texture.
  32257. * @param options The options defining the texture.
  32258. * @returns The texture
  32259. */
  32260. createDepthStencilTexture(size: number | {
  32261. width: number;
  32262. height: number;
  32263. }, options: DepthTextureCreationOptions): InternalTexture;
  32264. /**
  32265. * Creates a depth stencil texture.
  32266. * This is only available in WebGL 2 or with the depth texture extension available.
  32267. * @param size The size of face edge in the texture.
  32268. * @param options The options defining the texture.
  32269. * @returns The texture
  32270. */
  32271. private _createDepthStencilTexture;
  32272. /**
  32273. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32274. * @param renderTarget The render target to set the frame buffer for
  32275. */
  32276. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32277. /**
  32278. * Creates a new render target texture
  32279. * @param size defines the size of the texture
  32280. * @param options defines the options used to create the texture
  32281. * @returns a new render target texture stored in an InternalTexture
  32282. */
  32283. createRenderTargetTexture(size: number | {
  32284. width: number;
  32285. height: number;
  32286. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32287. /** @hidden */
  32288. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32289. /**
  32290. * Updates the sample count of a render target texture
  32291. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32292. * @param texture defines the texture to update
  32293. * @param samples defines the sample count to set
  32294. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32295. */
  32296. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32297. /** @hidden */
  32298. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32299. /** @hidden */
  32300. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32301. /** @hidden */
  32302. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32303. /** @hidden */
  32304. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32305. /**
  32306. * @hidden
  32307. */
  32308. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32309. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32310. private _prepareWebGLTexture;
  32311. /** @hidden */
  32312. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32313. /** @hidden */
  32314. _releaseFramebufferObjects(texture: InternalTexture): void;
  32315. /** @hidden */
  32316. _releaseTexture(texture: InternalTexture): void;
  32317. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32318. protected _setProgram(program: WebGLProgram): void;
  32319. protected _boundUniforms: {
  32320. [key: number]: WebGLUniformLocation;
  32321. };
  32322. /**
  32323. * Binds an effect to the webGL context
  32324. * @param effect defines the effect to bind
  32325. */
  32326. bindSamplers(effect: Effect): void;
  32327. private _activateCurrentTexture;
  32328. /** @hidden */
  32329. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32330. /** @hidden */
  32331. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32332. /**
  32333. * Sets a texture to the webGL context from a postprocess
  32334. * @param channel defines the channel to use
  32335. * @param postProcess defines the source postprocess
  32336. */
  32337. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32338. /**
  32339. * Binds the output of the passed in post process to the texture channel specified
  32340. * @param channel The channel the texture should be bound to
  32341. * @param postProcess The post process which's output should be bound
  32342. */
  32343. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32344. /**
  32345. * Unbind all textures from the webGL context
  32346. */
  32347. unbindAllTextures(): void;
  32348. /**
  32349. * Sets a texture to the according uniform.
  32350. * @param channel The texture channel
  32351. * @param uniform The uniform to set
  32352. * @param texture The texture to apply
  32353. */
  32354. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32355. /**
  32356. * Sets a depth stencil texture from a render target to the according uniform.
  32357. * @param channel The texture channel
  32358. * @param uniform The uniform to set
  32359. * @param texture The render target texture containing the depth stencil texture to apply
  32360. */
  32361. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32362. private _bindSamplerUniformToChannel;
  32363. private _getTextureWrapMode;
  32364. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32365. /**
  32366. * Sets an array of texture to the webGL context
  32367. * @param channel defines the channel where the texture array must be set
  32368. * @param uniform defines the associated uniform location
  32369. * @param textures defines the array of textures to bind
  32370. */
  32371. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32372. /** @hidden */
  32373. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32374. private _setTextureParameterFloat;
  32375. private _setTextureParameterInteger;
  32376. /**
  32377. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32378. * @param x defines the x coordinate of the rectangle where pixels must be read
  32379. * @param y defines the y coordinate of the rectangle where pixels must be read
  32380. * @param width defines the width of the rectangle where pixels must be read
  32381. * @param height defines the height of the rectangle where pixels must be read
  32382. * @returns a Uint8Array containing RGBA colors
  32383. */
  32384. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32385. /**
  32386. * Unbind all vertex attributes from the webGL context
  32387. */
  32388. unbindAllAttributes(): void;
  32389. /**
  32390. * 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
  32391. */
  32392. releaseEffects(): void;
  32393. /**
  32394. * Dispose and release all associated resources
  32395. */
  32396. dispose(): void;
  32397. /**
  32398. * Display the loading screen
  32399. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32400. */
  32401. displayLoadingUI(): void;
  32402. /**
  32403. * Hide the loading screen
  32404. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32405. */
  32406. hideLoadingUI(): void;
  32407. /**
  32408. * Gets the current loading screen object
  32409. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32410. */
  32411. /**
  32412. * Sets the current loading screen object
  32413. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32414. */
  32415. loadingScreen: ILoadingScreen;
  32416. /**
  32417. * Sets the current loading screen text
  32418. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32419. */
  32420. loadingUIText: string;
  32421. /**
  32422. * Sets the current loading screen background color
  32423. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32424. */
  32425. loadingUIBackgroundColor: string;
  32426. /**
  32427. * Attach a new callback raised when context lost event is fired
  32428. * @param callback defines the callback to call
  32429. */
  32430. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32431. /**
  32432. * Attach a new callback raised when context restored event is fired
  32433. * @param callback defines the callback to call
  32434. */
  32435. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32436. /**
  32437. * Gets the source code of the vertex shader associated with a specific webGL program
  32438. * @param program defines the program to use
  32439. * @returns a string containing the source code of the vertex shader associated with the program
  32440. */
  32441. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32442. /**
  32443. * Gets the source code of the fragment shader associated with a specific webGL program
  32444. * @param program defines the program to use
  32445. * @returns a string containing the source code of the fragment shader associated with the program
  32446. */
  32447. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32448. /**
  32449. * Get the current error code of the webGL context
  32450. * @returns the error code
  32451. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32452. */
  32453. getError(): number;
  32454. /**
  32455. * Gets the current framerate
  32456. * @returns a number representing the framerate
  32457. */
  32458. getFps(): number;
  32459. /**
  32460. * Gets the time spent between current and previous frame
  32461. * @returns a number representing the delta time in ms
  32462. */
  32463. getDeltaTime(): number;
  32464. private _measureFps;
  32465. /** @hidden */
  32466. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32467. private _canRenderToFloatFramebuffer;
  32468. private _canRenderToHalfFloatFramebuffer;
  32469. private _canRenderToFramebuffer;
  32470. /** @hidden */
  32471. _getWebGLTextureType(type: number): number;
  32472. /** @hidden */
  32473. _getInternalFormat(format: number): number;
  32474. /** @hidden */
  32475. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32476. /** @hidden */
  32477. _getRGBAMultiSampleBufferFormat(type: number): number;
  32478. /** @hidden */
  32479. _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;
  32480. /** @hidden */
  32481. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32482. /**
  32483. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32484. * @returns true if the engine can be created
  32485. * @ignorenaming
  32486. */
  32487. static isSupported(): boolean;
  32488. /**
  32489. * Find the next highest power of two.
  32490. * @param x Number to start search from.
  32491. * @return Next highest power of two.
  32492. */
  32493. static CeilingPOT(x: number): number;
  32494. /**
  32495. * Find the next lowest power of two.
  32496. * @param x Number to start search from.
  32497. * @return Next lowest power of two.
  32498. */
  32499. static FloorPOT(x: number): number;
  32500. /**
  32501. * Find the nearest power of two.
  32502. * @param x Number to start search from.
  32503. * @return Next nearest power of two.
  32504. */
  32505. static NearestPOT(x: number): number;
  32506. /**
  32507. * Get the closest exponent of two
  32508. * @param value defines the value to approximate
  32509. * @param max defines the maximum value to return
  32510. * @param mode defines how to define the closest value
  32511. * @returns closest exponent of two of the given value
  32512. */
  32513. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32514. /**
  32515. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32516. * @param func - the function to be called
  32517. * @param requester - the object that will request the next frame. Falls back to window.
  32518. * @returns frame number
  32519. */
  32520. static QueueNewFrame(func: () => void, requester?: any): number;
  32521. /**
  32522. * Ask the browser to promote the current element to pointerlock mode
  32523. * @param element defines the DOM element to promote
  32524. */
  32525. static _RequestPointerlock(element: HTMLElement): void;
  32526. /**
  32527. * Asks the browser to exit pointerlock mode
  32528. */
  32529. static _ExitPointerlock(): void;
  32530. /**
  32531. * Ask the browser to promote the current element to fullscreen rendering mode
  32532. * @param element defines the DOM element to promote
  32533. */
  32534. static _RequestFullscreen(element: HTMLElement): void;
  32535. /**
  32536. * Asks the browser to exit fullscreen mode
  32537. */
  32538. static _ExitFullscreen(): void;
  32539. }
  32540. }
  32541. declare module "babylonjs/Engines/engineStore" {
  32542. import { Nullable } from "babylonjs/types";
  32543. import { Engine } from "babylonjs/Engines/engine";
  32544. import { Scene } from "babylonjs/scene";
  32545. /**
  32546. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32547. * during the life time of the application.
  32548. */
  32549. export class EngineStore {
  32550. /** Gets the list of created engines */
  32551. static Instances: import("babylonjs/Engines/engine").Engine[];
  32552. /** @hidden */
  32553. static _LastCreatedScene: Nullable<Scene>;
  32554. /**
  32555. * Gets the latest created engine
  32556. */
  32557. static readonly LastCreatedEngine: Nullable<Engine>;
  32558. /**
  32559. * Gets the latest created scene
  32560. */
  32561. static readonly LastCreatedScene: Nullable<Scene>;
  32562. /**
  32563. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32564. * @ignorenaming
  32565. */
  32566. static UseFallbackTexture: boolean;
  32567. /**
  32568. * Texture content used if a texture cannot loaded
  32569. * @ignorenaming
  32570. */
  32571. static FallbackTexture: string;
  32572. }
  32573. }
  32574. declare module "babylonjs/Misc/promise" {
  32575. /**
  32576. * Helper class that provides a small promise polyfill
  32577. */
  32578. export class PromisePolyfill {
  32579. /**
  32580. * Static function used to check if the polyfill is required
  32581. * If this is the case then the function will inject the polyfill to window.Promise
  32582. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32583. */
  32584. static Apply(force?: boolean): void;
  32585. }
  32586. }
  32587. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32588. /**
  32589. * Interface for screenshot methods with describe argument called `size` as object with options
  32590. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32591. */
  32592. export interface IScreenshotSize {
  32593. /**
  32594. * number in pixels for canvas height
  32595. */
  32596. height?: number;
  32597. /**
  32598. * multiplier allowing render at a higher or lower resolution
  32599. * If value is defined then height and width will be ignored and taken from camera
  32600. */
  32601. precision?: number;
  32602. /**
  32603. * number in pixels for canvas width
  32604. */
  32605. width?: number;
  32606. }
  32607. }
  32608. declare module "babylonjs/Misc/tools" {
  32609. import { Nullable, float } from "babylonjs/types";
  32610. import { DomManagement } from "babylonjs/Misc/domManagement";
  32611. import { WebRequest } from "babylonjs/Misc/webRequest";
  32612. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32613. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32614. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32615. import { Camera } from "babylonjs/Cameras/camera";
  32616. import { Engine } from "babylonjs/Engines/engine";
  32617. interface IColor4Like {
  32618. r: float;
  32619. g: float;
  32620. b: float;
  32621. a: float;
  32622. }
  32623. /**
  32624. * Class containing a set of static utilities functions
  32625. */
  32626. export class Tools {
  32627. /**
  32628. * Gets or sets the base URL to use to load assets
  32629. */
  32630. static BaseUrl: string;
  32631. /**
  32632. * Enable/Disable Custom HTTP Request Headers globally.
  32633. * default = false
  32634. * @see CustomRequestHeaders
  32635. */
  32636. static UseCustomRequestHeaders: boolean;
  32637. /**
  32638. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32639. * i.e. when loading files, where the server/service expects an Authorization header
  32640. */
  32641. static CustomRequestHeaders: {
  32642. [key: string]: string;
  32643. };
  32644. /**
  32645. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32646. */
  32647. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32648. /**
  32649. * Default behaviour for cors in the application.
  32650. * It can be a string if the expected behavior is identical in the entire app.
  32651. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32652. */
  32653. static CorsBehavior: string | ((url: string | string[]) => string);
  32654. /**
  32655. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32656. * @ignorenaming
  32657. */
  32658. static UseFallbackTexture: boolean;
  32659. /**
  32660. * Use this object to register external classes like custom textures or material
  32661. * to allow the laoders to instantiate them
  32662. */
  32663. static RegisteredExternalClasses: {
  32664. [key: string]: Object;
  32665. };
  32666. /**
  32667. * Texture content used if a texture cannot loaded
  32668. * @ignorenaming
  32669. */
  32670. static fallbackTexture: string;
  32671. /**
  32672. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32673. * @param u defines the coordinate on X axis
  32674. * @param v defines the coordinate on Y axis
  32675. * @param width defines the width of the source data
  32676. * @param height defines the height of the source data
  32677. * @param pixels defines the source byte array
  32678. * @param color defines the output color
  32679. */
  32680. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32681. /**
  32682. * Interpolates between a and b via alpha
  32683. * @param a The lower value (returned when alpha = 0)
  32684. * @param b The upper value (returned when alpha = 1)
  32685. * @param alpha The interpolation-factor
  32686. * @return The mixed value
  32687. */
  32688. static Mix(a: number, b: number, alpha: number): number;
  32689. /**
  32690. * Tries to instantiate a new object from a given class name
  32691. * @param className defines the class name to instantiate
  32692. * @returns the new object or null if the system was not able to do the instantiation
  32693. */
  32694. static Instantiate(className: string): any;
  32695. /**
  32696. * Provides a slice function that will work even on IE
  32697. * @param data defines the array to slice
  32698. * @param start defines the start of the data (optional)
  32699. * @param end defines the end of the data (optional)
  32700. * @returns the new sliced array
  32701. */
  32702. static Slice<T>(data: T, start?: number, end?: number): T;
  32703. /**
  32704. * Polyfill for setImmediate
  32705. * @param action defines the action to execute after the current execution block
  32706. */
  32707. static SetImmediate(action: () => void): void;
  32708. /**
  32709. * Function indicating if a number is an exponent of 2
  32710. * @param value defines the value to test
  32711. * @returns true if the value is an exponent of 2
  32712. */
  32713. static IsExponentOfTwo(value: number): boolean;
  32714. private static _tmpFloatArray;
  32715. /**
  32716. * Returns the nearest 32-bit single precision float representation of a Number
  32717. * @param value A Number. If the parameter is of a different type, it will get converted
  32718. * to a number or to NaN if it cannot be converted
  32719. * @returns number
  32720. */
  32721. static FloatRound(value: number): number;
  32722. /**
  32723. * Extracts the filename from a path
  32724. * @param path defines the path to use
  32725. * @returns the filename
  32726. */
  32727. static GetFilename(path: string): string;
  32728. /**
  32729. * Extracts the "folder" part of a path (everything before the filename).
  32730. * @param uri The URI to extract the info from
  32731. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32732. * @returns The "folder" part of the path
  32733. */
  32734. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32735. /**
  32736. * Extracts text content from a DOM element hierarchy
  32737. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32738. */
  32739. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32740. /**
  32741. * Convert an angle in radians to degrees
  32742. * @param angle defines the angle to convert
  32743. * @returns the angle in degrees
  32744. */
  32745. static ToDegrees(angle: number): number;
  32746. /**
  32747. * Convert an angle in degrees to radians
  32748. * @param angle defines the angle to convert
  32749. * @returns the angle in radians
  32750. */
  32751. static ToRadians(angle: number): number;
  32752. /**
  32753. * Encode a buffer to a base64 string
  32754. * @param buffer defines the buffer to encode
  32755. * @returns the encoded string
  32756. */
  32757. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32758. /**
  32759. * Returns an array if obj is not an array
  32760. * @param obj defines the object to evaluate as an array
  32761. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32762. * @returns either obj directly if obj is an array or a new array containing obj
  32763. */
  32764. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32765. /**
  32766. * Gets the pointer prefix to use
  32767. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32768. */
  32769. static GetPointerPrefix(): string;
  32770. /**
  32771. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32772. * @param url define the url we are trying
  32773. * @param element define the dom element where to configure the cors policy
  32774. */
  32775. static SetCorsBehavior(url: string | string[], element: {
  32776. crossOrigin: string | null;
  32777. }): void;
  32778. /**
  32779. * Removes unwanted characters from an url
  32780. * @param url defines the url to clean
  32781. * @returns the cleaned url
  32782. */
  32783. static CleanUrl(url: string): string;
  32784. /**
  32785. * Gets or sets a function used to pre-process url before using them to load assets
  32786. */
  32787. static PreprocessUrl: (url: string) => string;
  32788. /**
  32789. * Loads an image as an HTMLImageElement.
  32790. * @param input url string, ArrayBuffer, or Blob to load
  32791. * @param onLoad callback called when the image successfully loads
  32792. * @param onError callback called when the image fails to load
  32793. * @param offlineProvider offline provider for caching
  32794. * @returns the HTMLImageElement of the loaded image
  32795. */
  32796. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32797. /**
  32798. * Loads a file
  32799. * @param url url string, ArrayBuffer, or Blob to load
  32800. * @param onSuccess callback called when the file successfully loads
  32801. * @param onProgress callback called while file is loading (if the server supports this mode)
  32802. * @param offlineProvider defines the offline provider for caching
  32803. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32804. * @param onError callback called when the file fails to load
  32805. * @returns a file request object
  32806. */
  32807. 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;
  32808. /**
  32809. * Loads a file from a url
  32810. * @param url the file url to load
  32811. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32812. */
  32813. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32814. /**
  32815. * Load a script (identified by an url). When the url returns, the
  32816. * content of this file is added into a new script element, attached to the DOM (body element)
  32817. * @param scriptUrl defines the url of the script to laod
  32818. * @param onSuccess defines the callback called when the script is loaded
  32819. * @param onError defines the callback to call if an error occurs
  32820. * @param scriptId defines the id of the script element
  32821. */
  32822. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32823. /**
  32824. * Load an asynchronous script (identified by an url). When the url returns, the
  32825. * content of this file is added into a new script element, attached to the DOM (body element)
  32826. * @param scriptUrl defines the url of the script to laod
  32827. * @param scriptId defines the id of the script element
  32828. * @returns a promise request object
  32829. */
  32830. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32831. /**
  32832. * Loads a file from a blob
  32833. * @param fileToLoad defines the blob to use
  32834. * @param callback defines the callback to call when data is loaded
  32835. * @param progressCallback defines the callback to call during loading process
  32836. * @returns a file request object
  32837. */
  32838. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32839. /**
  32840. * Loads a file
  32841. * @param fileToLoad defines the file to load
  32842. * @param callback defines the callback to call when data is loaded
  32843. * @param progressCallBack defines the callback to call during loading process
  32844. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32845. * @returns a file request object
  32846. */
  32847. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32848. /**
  32849. * Creates a data url from a given string content
  32850. * @param content defines the content to convert
  32851. * @returns the new data url link
  32852. */
  32853. static FileAsURL(content: string): string;
  32854. /**
  32855. * Format the given number to a specific decimal format
  32856. * @param value defines the number to format
  32857. * @param decimals defines the number of decimals to use
  32858. * @returns the formatted string
  32859. */
  32860. static Format(value: number, decimals?: number): string;
  32861. /**
  32862. * Tries to copy an object by duplicating every property
  32863. * @param source defines the source object
  32864. * @param destination defines the target object
  32865. * @param doNotCopyList defines a list of properties to avoid
  32866. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32867. */
  32868. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32869. /**
  32870. * Gets a boolean indicating if the given object has no own property
  32871. * @param obj defines the object to test
  32872. * @returns true if object has no own property
  32873. */
  32874. static IsEmpty(obj: any): boolean;
  32875. /**
  32876. * Function used to register events at window level
  32877. * @param windowElement defines the Window object to use
  32878. * @param events defines the events to register
  32879. */
  32880. static RegisterTopRootEvents(windowElement: Window, events: {
  32881. name: string;
  32882. handler: Nullable<(e: FocusEvent) => any>;
  32883. }[]): void;
  32884. /**
  32885. * Function used to unregister events from window level
  32886. * @param windowElement defines the Window object to use
  32887. * @param events defines the events to unregister
  32888. */
  32889. static UnregisterTopRootEvents(windowElement: Window, events: {
  32890. name: string;
  32891. handler: Nullable<(e: FocusEvent) => any>;
  32892. }[]): void;
  32893. /**
  32894. * @ignore
  32895. */
  32896. static _ScreenshotCanvas: HTMLCanvasElement;
  32897. /**
  32898. * Dumps the current bound framebuffer
  32899. * @param width defines the rendering width
  32900. * @param height defines the rendering height
  32901. * @param engine defines the hosting engine
  32902. * @param successCallback defines the callback triggered once the data are available
  32903. * @param mimeType defines the mime type of the result
  32904. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32905. */
  32906. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32907. /**
  32908. * Converts the canvas data to blob.
  32909. * This acts as a polyfill for browsers not supporting the to blob function.
  32910. * @param canvas Defines the canvas to extract the data from
  32911. * @param successCallback Defines the callback triggered once the data are available
  32912. * @param mimeType Defines the mime type of the result
  32913. */
  32914. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32915. /**
  32916. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32917. * @param successCallback defines the callback triggered once the data are available
  32918. * @param mimeType defines the mime type of the result
  32919. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32920. */
  32921. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32922. /**
  32923. * Downloads a blob in the browser
  32924. * @param blob defines the blob to download
  32925. * @param fileName defines the name of the downloaded file
  32926. */
  32927. static Download(blob: Blob, fileName: string): void;
  32928. /**
  32929. * Captures a screenshot of the current rendering
  32930. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32931. * @param engine defines the rendering engine
  32932. * @param camera defines the source camera
  32933. * @param size This parameter can be set to a single number or to an object with the
  32934. * following (optional) properties: precision, width, height. If a single number is passed,
  32935. * it will be used for both width and height. If an object is passed, the screenshot size
  32936. * will be derived from the parameters. The precision property is a multiplier allowing
  32937. * rendering at a higher or lower resolution
  32938. * @param successCallback defines the callback receives a single parameter which contains the
  32939. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32940. * src parameter of an <img> to display it
  32941. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32942. * Check your browser for supported MIME types
  32943. */
  32944. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32945. /**
  32946. * Captures a screenshot of the current rendering
  32947. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32948. * @param engine defines the rendering engine
  32949. * @param camera defines the source camera
  32950. * @param size This parameter can be set to a single number or to an object with the
  32951. * following (optional) properties: precision, width, height. If a single number is passed,
  32952. * it will be used for both width and height. If an object is passed, the screenshot size
  32953. * will be derived from the parameters. The precision property is a multiplier allowing
  32954. * rendering at a higher or lower resolution
  32955. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32956. * Check your browser for supported MIME types
  32957. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32958. * to the src parameter of an <img> to display it
  32959. */
  32960. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32961. /**
  32962. * Generates an image screenshot from the specified camera.
  32963. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32964. * @param engine The engine to use for rendering
  32965. * @param camera The camera to use for rendering
  32966. * @param size This parameter can be set to a single number or to an object with the
  32967. * following (optional) properties: precision, width, height. If a single number is passed,
  32968. * it will be used for both width and height. If an object is passed, the screenshot size
  32969. * will be derived from the parameters. The precision property is a multiplier allowing
  32970. * rendering at a higher or lower resolution
  32971. * @param successCallback The callback receives a single parameter which contains the
  32972. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32973. * src parameter of an <img> to display it
  32974. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32975. * Check your browser for supported MIME types
  32976. * @param samples Texture samples (default: 1)
  32977. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32978. * @param fileName A name for for the downloaded file.
  32979. */
  32980. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32981. /**
  32982. * Generates an image screenshot from the specified camera.
  32983. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32984. * @param engine The engine to use for rendering
  32985. * @param camera The camera to use for rendering
  32986. * @param size This parameter can be set to a single number or to an object with the
  32987. * following (optional) properties: precision, width, height. If a single number is passed,
  32988. * it will be used for both width and height. If an object is passed, the screenshot size
  32989. * will be derived from the parameters. The precision property is a multiplier allowing
  32990. * rendering at a higher or lower resolution
  32991. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32992. * Check your browser for supported MIME types
  32993. * @param samples Texture samples (default: 1)
  32994. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32995. * @param fileName A name for for the downloaded file.
  32996. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32997. * to the src parameter of an <img> to display it
  32998. */
  32999. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33000. /**
  33001. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33002. * Be aware Math.random() could cause collisions, but:
  33003. * "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"
  33004. * @returns a pseudo random id
  33005. */
  33006. static RandomId(): string;
  33007. /**
  33008. * Test if the given uri is a base64 string
  33009. * @param uri The uri to test
  33010. * @return True if the uri is a base64 string or false otherwise
  33011. */
  33012. static IsBase64(uri: string): boolean;
  33013. /**
  33014. * Decode the given base64 uri.
  33015. * @param uri The uri to decode
  33016. * @return The decoded base64 data.
  33017. */
  33018. static DecodeBase64(uri: string): ArrayBuffer;
  33019. /**
  33020. * Gets the absolute url.
  33021. * @param url the input url
  33022. * @return the absolute url
  33023. */
  33024. static GetAbsoluteUrl(url: string): string;
  33025. /**
  33026. * No log
  33027. */
  33028. static readonly NoneLogLevel: number;
  33029. /**
  33030. * Only message logs
  33031. */
  33032. static readonly MessageLogLevel: number;
  33033. /**
  33034. * Only warning logs
  33035. */
  33036. static readonly WarningLogLevel: number;
  33037. /**
  33038. * Only error logs
  33039. */
  33040. static readonly ErrorLogLevel: number;
  33041. /**
  33042. * All logs
  33043. */
  33044. static readonly AllLogLevel: number;
  33045. /**
  33046. * Gets a value indicating the number of loading errors
  33047. * @ignorenaming
  33048. */
  33049. static readonly errorsCount: number;
  33050. /**
  33051. * Callback called when a new log is added
  33052. */
  33053. static OnNewCacheEntry: (entry: string) => void;
  33054. /**
  33055. * Log a message to the console
  33056. * @param message defines the message to log
  33057. */
  33058. static Log(message: string): void;
  33059. /**
  33060. * Write a warning message to the console
  33061. * @param message defines the message to log
  33062. */
  33063. static Warn(message: string): void;
  33064. /**
  33065. * Write an error message to the console
  33066. * @param message defines the message to log
  33067. */
  33068. static Error(message: string): void;
  33069. /**
  33070. * Gets current log cache (list of logs)
  33071. */
  33072. static readonly LogCache: string;
  33073. /**
  33074. * Clears the log cache
  33075. */
  33076. static ClearLogCache(): void;
  33077. /**
  33078. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33079. */
  33080. static LogLevels: number;
  33081. /**
  33082. * Checks if the window object exists
  33083. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33084. */
  33085. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33086. /**
  33087. * No performance log
  33088. */
  33089. static readonly PerformanceNoneLogLevel: number;
  33090. /**
  33091. * Use user marks to log performance
  33092. */
  33093. static readonly PerformanceUserMarkLogLevel: number;
  33094. /**
  33095. * Log performance to the console
  33096. */
  33097. static readonly PerformanceConsoleLogLevel: number;
  33098. private static _performance;
  33099. /**
  33100. * Sets the current performance log level
  33101. */
  33102. static PerformanceLogLevel: number;
  33103. private static _StartPerformanceCounterDisabled;
  33104. private static _EndPerformanceCounterDisabled;
  33105. private static _StartUserMark;
  33106. private static _EndUserMark;
  33107. private static _StartPerformanceConsole;
  33108. private static _EndPerformanceConsole;
  33109. /**
  33110. * Starts a performance counter
  33111. */
  33112. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33113. /**
  33114. * Ends a specific performance coutner
  33115. */
  33116. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33117. /**
  33118. * Gets either window.performance.now() if supported or Date.now() else
  33119. */
  33120. static readonly Now: number;
  33121. /**
  33122. * This method will return the name of the class used to create the instance of the given object.
  33123. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33124. * @param object the object to get the class name from
  33125. * @param isType defines if the object is actually a type
  33126. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33127. */
  33128. static GetClassName(object: any, isType?: boolean): string;
  33129. /**
  33130. * Gets the first element of an array satisfying a given predicate
  33131. * @param array defines the array to browse
  33132. * @param predicate defines the predicate to use
  33133. * @returns null if not found or the element
  33134. */
  33135. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33136. /**
  33137. * This method will return the name of the full name of the class, including its owning module (if any).
  33138. * 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).
  33139. * @param object the object to get the class name from
  33140. * @param isType defines if the object is actually a type
  33141. * @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.
  33142. * @ignorenaming
  33143. */
  33144. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33145. /**
  33146. * Returns a promise that resolves after the given amount of time.
  33147. * @param delay Number of milliseconds to delay
  33148. * @returns Promise that resolves after the given amount of time
  33149. */
  33150. static DelayAsync(delay: number): Promise<void>;
  33151. }
  33152. /**
  33153. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33154. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33155. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33156. * @param name The name of the class, case should be preserved
  33157. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33158. */
  33159. export function className(name: string, module?: string): (target: Object) => void;
  33160. /**
  33161. * An implementation of a loop for asynchronous functions.
  33162. */
  33163. export class AsyncLoop {
  33164. /**
  33165. * Defines the number of iterations for the loop
  33166. */
  33167. iterations: number;
  33168. /**
  33169. * Defines the current index of the loop.
  33170. */
  33171. index: number;
  33172. private _done;
  33173. private _fn;
  33174. private _successCallback;
  33175. /**
  33176. * Constructor.
  33177. * @param iterations the number of iterations.
  33178. * @param func the function to run each iteration
  33179. * @param successCallback the callback that will be called upon succesful execution
  33180. * @param offset starting offset.
  33181. */
  33182. constructor(
  33183. /**
  33184. * Defines the number of iterations for the loop
  33185. */
  33186. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33187. /**
  33188. * Execute the next iteration. Must be called after the last iteration was finished.
  33189. */
  33190. executeNext(): void;
  33191. /**
  33192. * Break the loop and run the success callback.
  33193. */
  33194. breakLoop(): void;
  33195. /**
  33196. * Create and run an async loop.
  33197. * @param iterations the number of iterations.
  33198. * @param fn the function to run each iteration
  33199. * @param successCallback the callback that will be called upon succesful execution
  33200. * @param offset starting offset.
  33201. * @returns the created async loop object
  33202. */
  33203. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33204. /**
  33205. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33206. * @param iterations total number of iterations
  33207. * @param syncedIterations number of synchronous iterations in each async iteration.
  33208. * @param fn the function to call each iteration.
  33209. * @param callback a success call back that will be called when iterating stops.
  33210. * @param breakFunction a break condition (optional)
  33211. * @param timeout timeout settings for the setTimeout function. default - 0.
  33212. * @returns the created async loop object
  33213. */
  33214. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33215. }
  33216. }
  33217. declare module "babylonjs/Misc/stringDictionary" {
  33218. import { Nullable } from "babylonjs/types";
  33219. /**
  33220. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33221. * The underlying implementation relies on an associative array to ensure the best performances.
  33222. * The value can be anything including 'null' but except 'undefined'
  33223. */
  33224. export class StringDictionary<T> {
  33225. /**
  33226. * This will clear this dictionary and copy the content from the 'source' one.
  33227. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33228. * @param source the dictionary to take the content from and copy to this dictionary
  33229. */
  33230. copyFrom(source: StringDictionary<T>): void;
  33231. /**
  33232. * Get a value based from its key
  33233. * @param key the given key to get the matching value from
  33234. * @return the value if found, otherwise undefined is returned
  33235. */
  33236. get(key: string): T | undefined;
  33237. /**
  33238. * Get a value from its key or add it if it doesn't exist.
  33239. * This method will ensure you that a given key/data will be present in the dictionary.
  33240. * @param key the given key to get the matching value from
  33241. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33242. * The factory will only be invoked if there's no data for the given key.
  33243. * @return the value corresponding to the key.
  33244. */
  33245. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33246. /**
  33247. * Get a value from its key if present in the dictionary otherwise add it
  33248. * @param key the key to get the value from
  33249. * @param val if there's no such key/value pair in the dictionary add it with this value
  33250. * @return the value corresponding to the key
  33251. */
  33252. getOrAdd(key: string, val: T): T;
  33253. /**
  33254. * Check if there's a given key in the dictionary
  33255. * @param key the key to check for
  33256. * @return true if the key is present, false otherwise
  33257. */
  33258. contains(key: string): boolean;
  33259. /**
  33260. * Add a new key and its corresponding value
  33261. * @param key the key to add
  33262. * @param value the value corresponding to the key
  33263. * @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
  33264. */
  33265. add(key: string, value: T): boolean;
  33266. /**
  33267. * Update a specific value associated to a key
  33268. * @param key defines the key to use
  33269. * @param value defines the value to store
  33270. * @returns true if the value was updated (or false if the key was not found)
  33271. */
  33272. set(key: string, value: T): boolean;
  33273. /**
  33274. * Get the element of the given key and remove it from the dictionary
  33275. * @param key defines the key to search
  33276. * @returns the value associated with the key or null if not found
  33277. */
  33278. getAndRemove(key: string): Nullable<T>;
  33279. /**
  33280. * Remove a key/value from the dictionary.
  33281. * @param key the key to remove
  33282. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33283. */
  33284. remove(key: string): boolean;
  33285. /**
  33286. * Clear the whole content of the dictionary
  33287. */
  33288. clear(): void;
  33289. /**
  33290. * Gets the current count
  33291. */
  33292. readonly count: number;
  33293. /**
  33294. * Execute a callback on each key/val of the dictionary.
  33295. * Note that you can remove any element in this dictionary in the callback implementation
  33296. * @param callback the callback to execute on a given key/value pair
  33297. */
  33298. forEach(callback: (key: string, val: T) => void): void;
  33299. /**
  33300. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33301. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33302. * Note that you can remove any element in this dictionary in the callback implementation
  33303. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33304. * @returns the first item
  33305. */
  33306. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33307. private _count;
  33308. private _data;
  33309. }
  33310. }
  33311. declare module "babylonjs/Collisions/collisionCoordinator" {
  33312. import { Nullable } from "babylonjs/types";
  33313. import { Scene } from "babylonjs/scene";
  33314. import { Vector3 } from "babylonjs/Maths/math.vector";
  33315. import { Collider } from "babylonjs/Collisions/collider";
  33316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33317. /** @hidden */
  33318. export interface ICollisionCoordinator {
  33319. createCollider(): Collider;
  33320. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33321. init(scene: Scene): void;
  33322. }
  33323. /** @hidden */
  33324. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33325. private _scene;
  33326. private _scaledPosition;
  33327. private _scaledVelocity;
  33328. private _finalPosition;
  33329. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33330. createCollider(): Collider;
  33331. init(scene: Scene): void;
  33332. private _collideWithWorld;
  33333. }
  33334. }
  33335. declare module "babylonjs/Inputs/scene.inputManager" {
  33336. import { Nullable } from "babylonjs/types";
  33337. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33338. import { Vector2 } from "babylonjs/Maths/math.vector";
  33339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33340. import { Scene } from "babylonjs/scene";
  33341. /**
  33342. * Class used to manage all inputs for the scene.
  33343. */
  33344. export class InputManager {
  33345. /** The distance in pixel that you have to move to prevent some events */
  33346. static DragMovementThreshold: number;
  33347. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33348. static LongPressDelay: number;
  33349. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33350. static DoubleClickDelay: number;
  33351. /** If you need to check double click without raising a single click at first click, enable this flag */
  33352. static ExclusiveDoubleClickMode: boolean;
  33353. private _wheelEventName;
  33354. private _onPointerMove;
  33355. private _onPointerDown;
  33356. private _onPointerUp;
  33357. private _initClickEvent;
  33358. private _initActionManager;
  33359. private _delayedSimpleClick;
  33360. private _delayedSimpleClickTimeout;
  33361. private _previousDelayedSimpleClickTimeout;
  33362. private _meshPickProceed;
  33363. private _previousButtonPressed;
  33364. private _currentPickResult;
  33365. private _previousPickResult;
  33366. private _totalPointersPressed;
  33367. private _doubleClickOccured;
  33368. private _pointerOverMesh;
  33369. private _pickedDownMesh;
  33370. private _pickedUpMesh;
  33371. private _pointerX;
  33372. private _pointerY;
  33373. private _unTranslatedPointerX;
  33374. private _unTranslatedPointerY;
  33375. private _startingPointerPosition;
  33376. private _previousStartingPointerPosition;
  33377. private _startingPointerTime;
  33378. private _previousStartingPointerTime;
  33379. private _pointerCaptures;
  33380. private _onKeyDown;
  33381. private _onKeyUp;
  33382. private _onCanvasFocusObserver;
  33383. private _onCanvasBlurObserver;
  33384. private _scene;
  33385. /**
  33386. * Creates a new InputManager
  33387. * @param scene defines the hosting scene
  33388. */
  33389. constructor(scene: Scene);
  33390. /**
  33391. * Gets the mesh that is currently under the pointer
  33392. */
  33393. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33394. /**
  33395. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33396. */
  33397. readonly unTranslatedPointer: Vector2;
  33398. /**
  33399. * Gets or sets the current on-screen X position of the pointer
  33400. */
  33401. pointerX: number;
  33402. /**
  33403. * Gets or sets the current on-screen Y position of the pointer
  33404. */
  33405. pointerY: number;
  33406. private _updatePointerPosition;
  33407. private _processPointerMove;
  33408. private _setRayOnPointerInfo;
  33409. private _checkPrePointerObservable;
  33410. /**
  33411. * Use this method to simulate a pointer move on a mesh
  33412. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33413. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33414. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33415. */
  33416. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33417. /**
  33418. * Use this method to simulate a pointer down on a mesh
  33419. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33420. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33421. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33422. */
  33423. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33424. private _processPointerDown;
  33425. /** @hidden */
  33426. _isPointerSwiping(): boolean;
  33427. /**
  33428. * Use this method to simulate a pointer up on a mesh
  33429. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33430. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33431. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33432. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33433. */
  33434. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33435. private _processPointerUp;
  33436. /**
  33437. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33438. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33439. * @returns true if the pointer was captured
  33440. */
  33441. isPointerCaptured(pointerId?: number): boolean;
  33442. /**
  33443. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33444. * @param attachUp defines if you want to attach events to pointerup
  33445. * @param attachDown defines if you want to attach events to pointerdown
  33446. * @param attachMove defines if you want to attach events to pointermove
  33447. */
  33448. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33449. /**
  33450. * Detaches all event handlers
  33451. */
  33452. detachControl(): void;
  33453. /**
  33454. * Force the value of meshUnderPointer
  33455. * @param mesh defines the mesh to use
  33456. */
  33457. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33458. /**
  33459. * Gets the mesh under the pointer
  33460. * @returns a Mesh or null if no mesh is under the pointer
  33461. */
  33462. getPointerOverMesh(): Nullable<AbstractMesh>;
  33463. }
  33464. }
  33465. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33466. /**
  33467. * Helper class used to generate session unique ID
  33468. */
  33469. export class UniqueIdGenerator {
  33470. private static _UniqueIdCounter;
  33471. /**
  33472. * Gets an unique (relatively to the current scene) Id
  33473. */
  33474. static readonly UniqueId: number;
  33475. }
  33476. }
  33477. declare module "babylonjs/Animations/animationGroup" {
  33478. import { Animatable } from "babylonjs/Animations/animatable";
  33479. import { Animation } from "babylonjs/Animations/animation";
  33480. import { Scene, IDisposable } from "babylonjs/scene";
  33481. import { Observable } from "babylonjs/Misc/observable";
  33482. import { Nullable } from "babylonjs/types";
  33483. import "babylonjs/Animations/animatable";
  33484. /**
  33485. * This class defines the direct association between an animation and a target
  33486. */
  33487. export class TargetedAnimation {
  33488. /**
  33489. * Animation to perform
  33490. */
  33491. animation: Animation;
  33492. /**
  33493. * Target to animate
  33494. */
  33495. target: any;
  33496. /**
  33497. * Serialize the object
  33498. * @returns the JSON object representing the current entity
  33499. */
  33500. serialize(): any;
  33501. }
  33502. /**
  33503. * Use this class to create coordinated animations on multiple targets
  33504. */
  33505. export class AnimationGroup implements IDisposable {
  33506. /** The name of the animation group */
  33507. name: string;
  33508. private _scene;
  33509. private _targetedAnimations;
  33510. private _animatables;
  33511. private _from;
  33512. private _to;
  33513. private _isStarted;
  33514. private _isPaused;
  33515. private _speedRatio;
  33516. private _loopAnimation;
  33517. /**
  33518. * Gets or sets the unique id of the node
  33519. */
  33520. uniqueId: number;
  33521. /**
  33522. * This observable will notify when one animation have ended
  33523. */
  33524. onAnimationEndObservable: Observable<TargetedAnimation>;
  33525. /**
  33526. * Observer raised when one animation loops
  33527. */
  33528. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33529. /**
  33530. * This observable will notify when all animations have ended.
  33531. */
  33532. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33533. /**
  33534. * This observable will notify when all animations have paused.
  33535. */
  33536. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33537. /**
  33538. * This observable will notify when all animations are playing.
  33539. */
  33540. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33541. /**
  33542. * Gets the first frame
  33543. */
  33544. readonly from: number;
  33545. /**
  33546. * Gets the last frame
  33547. */
  33548. readonly to: number;
  33549. /**
  33550. * Define if the animations are started
  33551. */
  33552. readonly isStarted: boolean;
  33553. /**
  33554. * Gets a value indicating that the current group is playing
  33555. */
  33556. readonly isPlaying: boolean;
  33557. /**
  33558. * Gets or sets the speed ratio to use for all animations
  33559. */
  33560. /**
  33561. * Gets or sets the speed ratio to use for all animations
  33562. */
  33563. speedRatio: number;
  33564. /**
  33565. * Gets or sets if all animations should loop or not
  33566. */
  33567. loopAnimation: boolean;
  33568. /**
  33569. * Gets the targeted animations for this animation group
  33570. */
  33571. readonly targetedAnimations: Array<TargetedAnimation>;
  33572. /**
  33573. * returning the list of animatables controlled by this animation group.
  33574. */
  33575. readonly animatables: Array<Animatable>;
  33576. /**
  33577. * Instantiates a new Animation Group.
  33578. * This helps managing several animations at once.
  33579. * @see http://doc.babylonjs.com/how_to/group
  33580. * @param name Defines the name of the group
  33581. * @param scene Defines the scene the group belongs to
  33582. */
  33583. constructor(
  33584. /** The name of the animation group */
  33585. name: string, scene?: Nullable<Scene>);
  33586. /**
  33587. * Add an animation (with its target) in the group
  33588. * @param animation defines the animation we want to add
  33589. * @param target defines the target of the animation
  33590. * @returns the TargetedAnimation object
  33591. */
  33592. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33593. /**
  33594. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33595. * It can add constant keys at begin or end
  33596. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33597. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33598. * @returns the animation group
  33599. */
  33600. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33601. /**
  33602. * Start all animations on given targets
  33603. * @param loop defines if animations must loop
  33604. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33605. * @param from defines the from key (optional)
  33606. * @param to defines the to key (optional)
  33607. * @returns the current animation group
  33608. */
  33609. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33610. /**
  33611. * Pause all animations
  33612. * @returns the animation group
  33613. */
  33614. pause(): AnimationGroup;
  33615. /**
  33616. * Play all animations to initial state
  33617. * This function will start() the animations if they were not started or will restart() them if they were paused
  33618. * @param loop defines if animations must loop
  33619. * @returns the animation group
  33620. */
  33621. play(loop?: boolean): AnimationGroup;
  33622. /**
  33623. * Reset all animations to initial state
  33624. * @returns the animation group
  33625. */
  33626. reset(): AnimationGroup;
  33627. /**
  33628. * Restart animations from key 0
  33629. * @returns the animation group
  33630. */
  33631. restart(): AnimationGroup;
  33632. /**
  33633. * Stop all animations
  33634. * @returns the animation group
  33635. */
  33636. stop(): AnimationGroup;
  33637. /**
  33638. * Set animation weight for all animatables
  33639. * @param weight defines the weight to use
  33640. * @return the animationGroup
  33641. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33642. */
  33643. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33644. /**
  33645. * Synchronize and normalize all animatables with a source animatable
  33646. * @param root defines the root animatable to synchronize with
  33647. * @return the animationGroup
  33648. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33649. */
  33650. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33651. /**
  33652. * Goes to a specific frame in this animation group
  33653. * @param frame the frame number to go to
  33654. * @return the animationGroup
  33655. */
  33656. goToFrame(frame: number): AnimationGroup;
  33657. /**
  33658. * Dispose all associated resources
  33659. */
  33660. dispose(): void;
  33661. private _checkAnimationGroupEnded;
  33662. /**
  33663. * Clone the current animation group and returns a copy
  33664. * @param newName defines the name of the new group
  33665. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33666. * @returns the new aniamtion group
  33667. */
  33668. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33669. /**
  33670. * Serializes the animationGroup to an object
  33671. * @returns Serialized object
  33672. */
  33673. serialize(): any;
  33674. /**
  33675. * Returns a new AnimationGroup object parsed from the source provided.
  33676. * @param parsedAnimationGroup defines the source
  33677. * @param scene defines the scene that will receive the animationGroup
  33678. * @returns a new AnimationGroup
  33679. */
  33680. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33681. /**
  33682. * Returns the string "AnimationGroup"
  33683. * @returns "AnimationGroup"
  33684. */
  33685. getClassName(): string;
  33686. /**
  33687. * Creates a detailled string about the object
  33688. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33689. * @returns a string representing the object
  33690. */
  33691. toString(fullDetails?: boolean): string;
  33692. }
  33693. }
  33694. declare module "babylonjs/scene" {
  33695. import { Nullable } from "babylonjs/types";
  33696. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33697. import { Observable } from "babylonjs/Misc/observable";
  33698. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33699. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33700. import { Geometry } from "babylonjs/Meshes/geometry";
  33701. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33702. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33704. import { Mesh } from "babylonjs/Meshes/mesh";
  33705. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33706. import { Bone } from "babylonjs/Bones/bone";
  33707. import { Skeleton } from "babylonjs/Bones/skeleton";
  33708. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33709. import { Camera } from "babylonjs/Cameras/camera";
  33710. import { AbstractScene } from "babylonjs/abstractScene";
  33711. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33712. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33713. import { Material } from "babylonjs/Materials/material";
  33714. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33715. import { Effect } from "babylonjs/Materials/effect";
  33716. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33717. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33718. import { Light } from "babylonjs/Lights/light";
  33719. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33720. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33721. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33722. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33723. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33724. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33725. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33726. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33727. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33728. import { Engine } from "babylonjs/Engines/engine";
  33729. import { Node } from "babylonjs/node";
  33730. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33731. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33732. import { WebRequest } from "babylonjs/Misc/webRequest";
  33733. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33734. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33735. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33736. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33737. import { Plane } from "babylonjs/Maths/math.plane";
  33738. import { Ray } from "babylonjs/Culling/ray";
  33739. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33740. import { Animation } from "babylonjs/Animations/animation";
  33741. import { Animatable } from "babylonjs/Animations/animatable";
  33742. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33743. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33744. import { Collider } from "babylonjs/Collisions/collider";
  33745. /**
  33746. * Define an interface for all classes that will hold resources
  33747. */
  33748. export interface IDisposable {
  33749. /**
  33750. * Releases all held resources
  33751. */
  33752. dispose(): void;
  33753. }
  33754. /** Interface defining initialization parameters for Scene class */
  33755. export interface SceneOptions {
  33756. /**
  33757. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33758. * It will improve performance when the number of geometries becomes important.
  33759. */
  33760. useGeometryUniqueIdsMap?: boolean;
  33761. /**
  33762. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33763. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33764. */
  33765. useMaterialMeshMap?: boolean;
  33766. /**
  33767. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33768. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33769. */
  33770. useClonedMeshhMap?: boolean;
  33771. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33772. virtual?: boolean;
  33773. }
  33774. /**
  33775. * Represents a scene to be rendered by the engine.
  33776. * @see http://doc.babylonjs.com/features/scene
  33777. */
  33778. export class Scene extends AbstractScene implements IAnimatable {
  33779. /** The fog is deactivated */
  33780. static readonly FOGMODE_NONE: number;
  33781. /** The fog density is following an exponential function */
  33782. static readonly FOGMODE_EXP: number;
  33783. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33784. static readonly FOGMODE_EXP2: number;
  33785. /** The fog density is following a linear function. */
  33786. static readonly FOGMODE_LINEAR: number;
  33787. /**
  33788. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33789. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33790. */
  33791. static MinDeltaTime: number;
  33792. /**
  33793. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33794. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33795. */
  33796. static MaxDeltaTime: number;
  33797. /**
  33798. * Factory used to create the default material.
  33799. * @param name The name of the material to create
  33800. * @param scene The scene to create the material for
  33801. * @returns The default material
  33802. */
  33803. static DefaultMaterialFactory(scene: Scene): Material;
  33804. /**
  33805. * Factory used to create the a collision coordinator.
  33806. * @returns The collision coordinator
  33807. */
  33808. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33809. /** @hidden */
  33810. _inputManager: InputManager;
  33811. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33812. cameraToUseForPointers: Nullable<Camera>;
  33813. /** @hidden */
  33814. readonly _isScene: boolean;
  33815. /**
  33816. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33817. */
  33818. autoClear: boolean;
  33819. /**
  33820. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33821. */
  33822. autoClearDepthAndStencil: boolean;
  33823. /**
  33824. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33825. */
  33826. clearColor: Color4;
  33827. /**
  33828. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33829. */
  33830. ambientColor: Color3;
  33831. /**
  33832. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33833. * It should only be one of the following (if not the default embedded one):
  33834. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33835. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33836. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33837. * The material properties need to be setup according to the type of texture in use.
  33838. */
  33839. environmentBRDFTexture: BaseTexture;
  33840. /** @hidden */
  33841. protected _environmentTexture: Nullable<BaseTexture>;
  33842. /**
  33843. * Texture used in all pbr material as the reflection texture.
  33844. * As in the majority of the scene they are the same (exception for multi room and so on),
  33845. * this is easier to reference from here than from all the materials.
  33846. */
  33847. /**
  33848. * Texture used in all pbr material as the reflection texture.
  33849. * As in the majority of the scene they are the same (exception for multi room and so on),
  33850. * this is easier to set here than in all the materials.
  33851. */
  33852. environmentTexture: Nullable<BaseTexture>;
  33853. /** @hidden */
  33854. protected _environmentIntensity: number;
  33855. /**
  33856. * Intensity of the environment in all pbr material.
  33857. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33858. * As in the majority of the scene they are the same (exception for multi room and so on),
  33859. * this is easier to reference from here than from all the materials.
  33860. */
  33861. /**
  33862. * Intensity of the environment in all pbr material.
  33863. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33864. * As in the majority of the scene they are the same (exception for multi room and so on),
  33865. * this is easier to set here than in all the materials.
  33866. */
  33867. environmentIntensity: number;
  33868. /** @hidden */
  33869. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33870. /**
  33871. * Default image processing configuration used either in the rendering
  33872. * Forward main pass or through the imageProcessingPostProcess if present.
  33873. * As in the majority of the scene they are the same (exception for multi camera),
  33874. * this is easier to reference from here than from all the materials and post process.
  33875. *
  33876. * No setter as we it is a shared configuration, you can set the values instead.
  33877. */
  33878. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33879. private _forceWireframe;
  33880. /**
  33881. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33882. */
  33883. forceWireframe: boolean;
  33884. private _forcePointsCloud;
  33885. /**
  33886. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33887. */
  33888. forcePointsCloud: boolean;
  33889. /**
  33890. * Gets or sets the active clipplane 1
  33891. */
  33892. clipPlane: Nullable<Plane>;
  33893. /**
  33894. * Gets or sets the active clipplane 2
  33895. */
  33896. clipPlane2: Nullable<Plane>;
  33897. /**
  33898. * Gets or sets the active clipplane 3
  33899. */
  33900. clipPlane3: Nullable<Plane>;
  33901. /**
  33902. * Gets or sets the active clipplane 4
  33903. */
  33904. clipPlane4: Nullable<Plane>;
  33905. /**
  33906. * Gets or sets a boolean indicating if animations are enabled
  33907. */
  33908. animationsEnabled: boolean;
  33909. private _animationPropertiesOverride;
  33910. /**
  33911. * Gets or sets the animation properties override
  33912. */
  33913. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33914. /**
  33915. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33916. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33917. */
  33918. useConstantAnimationDeltaTime: boolean;
  33919. /**
  33920. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33921. * Please note that it requires to run a ray cast through the scene on every frame
  33922. */
  33923. constantlyUpdateMeshUnderPointer: boolean;
  33924. /**
  33925. * Defines the HTML cursor to use when hovering over interactive elements
  33926. */
  33927. hoverCursor: string;
  33928. /**
  33929. * Defines the HTML default cursor to use (empty by default)
  33930. */
  33931. defaultCursor: string;
  33932. /**
  33933. * This is used to call preventDefault() on pointer down
  33934. * in order to block unwanted artifacts like system double clicks
  33935. */
  33936. preventDefaultOnPointerDown: boolean;
  33937. /**
  33938. * This is used to call preventDefault() on pointer up
  33939. * in order to block unwanted artifacts like system double clicks
  33940. */
  33941. preventDefaultOnPointerUp: boolean;
  33942. /**
  33943. * Gets or sets user defined metadata
  33944. */
  33945. metadata: any;
  33946. /**
  33947. * For internal use only. Please do not use.
  33948. */
  33949. reservedDataStore: any;
  33950. /**
  33951. * Gets the name of the plugin used to load this scene (null by default)
  33952. */
  33953. loadingPluginName: string;
  33954. /**
  33955. * Use this array to add regular expressions used to disable offline support for specific urls
  33956. */
  33957. disableOfflineSupportExceptionRules: RegExp[];
  33958. /**
  33959. * An event triggered when the scene is disposed.
  33960. */
  33961. onDisposeObservable: Observable<Scene>;
  33962. private _onDisposeObserver;
  33963. /** Sets a function to be executed when this scene is disposed. */
  33964. onDispose: () => void;
  33965. /**
  33966. * An event triggered before rendering the scene (right after animations and physics)
  33967. */
  33968. onBeforeRenderObservable: Observable<Scene>;
  33969. private _onBeforeRenderObserver;
  33970. /** Sets a function to be executed before rendering this scene */
  33971. beforeRender: Nullable<() => void>;
  33972. /**
  33973. * An event triggered after rendering the scene
  33974. */
  33975. onAfterRenderObservable: Observable<Scene>;
  33976. /**
  33977. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33978. */
  33979. onAfterRenderCameraObservable: Observable<Camera>;
  33980. private _onAfterRenderObserver;
  33981. /** Sets a function to be executed after rendering this scene */
  33982. afterRender: Nullable<() => void>;
  33983. /**
  33984. * An event triggered before animating the scene
  33985. */
  33986. onBeforeAnimationsObservable: Observable<Scene>;
  33987. /**
  33988. * An event triggered after animations processing
  33989. */
  33990. onAfterAnimationsObservable: Observable<Scene>;
  33991. /**
  33992. * An event triggered before draw calls are ready to be sent
  33993. */
  33994. onBeforeDrawPhaseObservable: Observable<Scene>;
  33995. /**
  33996. * An event triggered after draw calls have been sent
  33997. */
  33998. onAfterDrawPhaseObservable: Observable<Scene>;
  33999. /**
  34000. * An event triggered when the scene is ready
  34001. */
  34002. onReadyObservable: Observable<Scene>;
  34003. /**
  34004. * An event triggered before rendering a camera
  34005. */
  34006. onBeforeCameraRenderObservable: Observable<Camera>;
  34007. private _onBeforeCameraRenderObserver;
  34008. /** Sets a function to be executed before rendering a camera*/
  34009. beforeCameraRender: () => void;
  34010. /**
  34011. * An event triggered after rendering a camera
  34012. */
  34013. onAfterCameraRenderObservable: Observable<Camera>;
  34014. private _onAfterCameraRenderObserver;
  34015. /** Sets a function to be executed after rendering a camera*/
  34016. afterCameraRender: () => void;
  34017. /**
  34018. * An event triggered when active meshes evaluation is about to start
  34019. */
  34020. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34021. /**
  34022. * An event triggered when active meshes evaluation is done
  34023. */
  34024. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34025. /**
  34026. * An event triggered when particles rendering is about to start
  34027. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34028. */
  34029. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34030. /**
  34031. * An event triggered when particles rendering is done
  34032. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34033. */
  34034. onAfterParticlesRenderingObservable: Observable<Scene>;
  34035. /**
  34036. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34037. */
  34038. onDataLoadedObservable: Observable<Scene>;
  34039. /**
  34040. * An event triggered when a camera is created
  34041. */
  34042. onNewCameraAddedObservable: Observable<Camera>;
  34043. /**
  34044. * An event triggered when a camera is removed
  34045. */
  34046. onCameraRemovedObservable: Observable<Camera>;
  34047. /**
  34048. * An event triggered when a light is created
  34049. */
  34050. onNewLightAddedObservable: Observable<Light>;
  34051. /**
  34052. * An event triggered when a light is removed
  34053. */
  34054. onLightRemovedObservable: Observable<Light>;
  34055. /**
  34056. * An event triggered when a geometry is created
  34057. */
  34058. onNewGeometryAddedObservable: Observable<Geometry>;
  34059. /**
  34060. * An event triggered when a geometry is removed
  34061. */
  34062. onGeometryRemovedObservable: Observable<Geometry>;
  34063. /**
  34064. * An event triggered when a transform node is created
  34065. */
  34066. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34067. /**
  34068. * An event triggered when a transform node is removed
  34069. */
  34070. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34071. /**
  34072. * An event triggered when a mesh is created
  34073. */
  34074. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34075. /**
  34076. * An event triggered when a mesh is removed
  34077. */
  34078. onMeshRemovedObservable: Observable<AbstractMesh>;
  34079. /**
  34080. * An event triggered when a skeleton is created
  34081. */
  34082. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34083. /**
  34084. * An event triggered when a skeleton is removed
  34085. */
  34086. onSkeletonRemovedObservable: Observable<Skeleton>;
  34087. /**
  34088. * An event triggered when a material is created
  34089. */
  34090. onNewMaterialAddedObservable: Observable<Material>;
  34091. /**
  34092. * An event triggered when a material is removed
  34093. */
  34094. onMaterialRemovedObservable: Observable<Material>;
  34095. /**
  34096. * An event triggered when a texture is created
  34097. */
  34098. onNewTextureAddedObservable: Observable<BaseTexture>;
  34099. /**
  34100. * An event triggered when a texture is removed
  34101. */
  34102. onTextureRemovedObservable: Observable<BaseTexture>;
  34103. /**
  34104. * An event triggered when render targets are about to be rendered
  34105. * Can happen multiple times per frame.
  34106. */
  34107. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34108. /**
  34109. * An event triggered when render targets were rendered.
  34110. * Can happen multiple times per frame.
  34111. */
  34112. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34113. /**
  34114. * An event triggered before calculating deterministic simulation step
  34115. */
  34116. onBeforeStepObservable: Observable<Scene>;
  34117. /**
  34118. * An event triggered after calculating deterministic simulation step
  34119. */
  34120. onAfterStepObservable: Observable<Scene>;
  34121. /**
  34122. * An event triggered when the activeCamera property is updated
  34123. */
  34124. onActiveCameraChanged: Observable<Scene>;
  34125. /**
  34126. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34127. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34128. * 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)
  34129. */
  34130. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34131. /**
  34132. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34133. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34134. * 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)
  34135. */
  34136. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34137. /**
  34138. * This Observable will when a mesh has been imported into the scene.
  34139. */
  34140. onMeshImportedObservable: Observable<AbstractMesh>;
  34141. /**
  34142. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34143. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34144. */
  34145. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34146. /** @hidden */
  34147. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34148. /**
  34149. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34150. */
  34151. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34152. /**
  34153. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34154. */
  34155. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34156. /**
  34157. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34158. */
  34159. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34160. /** Callback called when a pointer move is detected */
  34161. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34162. /** Callback called when a pointer down is detected */
  34163. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34164. /** Callback called when a pointer up is detected */
  34165. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34166. /** Callback called when a pointer pick is detected */
  34167. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34168. /**
  34169. * 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).
  34170. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34171. */
  34172. onPrePointerObservable: Observable<PointerInfoPre>;
  34173. /**
  34174. * Observable event triggered each time an input event is received from the rendering canvas
  34175. */
  34176. onPointerObservable: Observable<PointerInfo>;
  34177. /**
  34178. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34179. */
  34180. readonly unTranslatedPointer: Vector2;
  34181. /**
  34182. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34183. */
  34184. static DragMovementThreshold: number;
  34185. /**
  34186. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34187. */
  34188. static LongPressDelay: number;
  34189. /**
  34190. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34191. */
  34192. static DoubleClickDelay: number;
  34193. /** If you need to check double click without raising a single click at first click, enable this flag */
  34194. static ExclusiveDoubleClickMode: boolean;
  34195. /** @hidden */
  34196. _mirroredCameraPosition: Nullable<Vector3>;
  34197. /**
  34198. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34199. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34200. */
  34201. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34202. /**
  34203. * Observable event triggered each time an keyboard event is received from the hosting window
  34204. */
  34205. onKeyboardObservable: Observable<KeyboardInfo>;
  34206. private _useRightHandedSystem;
  34207. /**
  34208. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34209. */
  34210. useRightHandedSystem: boolean;
  34211. private _timeAccumulator;
  34212. private _currentStepId;
  34213. private _currentInternalStep;
  34214. /**
  34215. * Sets the step Id used by deterministic lock step
  34216. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34217. * @param newStepId defines the step Id
  34218. */
  34219. setStepId(newStepId: number): void;
  34220. /**
  34221. * Gets the step Id used by deterministic lock step
  34222. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34223. * @returns the step Id
  34224. */
  34225. getStepId(): number;
  34226. /**
  34227. * Gets the internal step used by deterministic lock step
  34228. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34229. * @returns the internal step
  34230. */
  34231. getInternalStep(): number;
  34232. private _fogEnabled;
  34233. /**
  34234. * Gets or sets a boolean indicating if fog is enabled on this scene
  34235. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34236. * (Default is true)
  34237. */
  34238. fogEnabled: boolean;
  34239. private _fogMode;
  34240. /**
  34241. * Gets or sets the fog mode to use
  34242. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34243. * | mode | value |
  34244. * | --- | --- |
  34245. * | FOGMODE_NONE | 0 |
  34246. * | FOGMODE_EXP | 1 |
  34247. * | FOGMODE_EXP2 | 2 |
  34248. * | FOGMODE_LINEAR | 3 |
  34249. */
  34250. fogMode: number;
  34251. /**
  34252. * Gets or sets the fog color to use
  34253. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34254. * (Default is Color3(0.2, 0.2, 0.3))
  34255. */
  34256. fogColor: Color3;
  34257. /**
  34258. * Gets or sets the fog density to use
  34259. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34260. * (Default is 0.1)
  34261. */
  34262. fogDensity: number;
  34263. /**
  34264. * Gets or sets the fog start distance to use
  34265. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34266. * (Default is 0)
  34267. */
  34268. fogStart: number;
  34269. /**
  34270. * Gets or sets the fog end distance to use
  34271. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34272. * (Default is 1000)
  34273. */
  34274. fogEnd: number;
  34275. private _shadowsEnabled;
  34276. /**
  34277. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34278. */
  34279. shadowsEnabled: boolean;
  34280. private _lightsEnabled;
  34281. /**
  34282. * Gets or sets a boolean indicating if lights are enabled on this scene
  34283. */
  34284. lightsEnabled: boolean;
  34285. /** All of the active cameras added to this scene. */
  34286. activeCameras: Camera[];
  34287. /** @hidden */
  34288. _activeCamera: Nullable<Camera>;
  34289. /** Gets or sets the current active camera */
  34290. activeCamera: Nullable<Camera>;
  34291. private _defaultMaterial;
  34292. /** The default material used on meshes when no material is affected */
  34293. /** The default material used on meshes when no material is affected */
  34294. defaultMaterial: Material;
  34295. private _texturesEnabled;
  34296. /**
  34297. * Gets or sets a boolean indicating if textures are enabled on this scene
  34298. */
  34299. texturesEnabled: boolean;
  34300. /**
  34301. * Gets or sets a boolean indicating if particles are enabled on this scene
  34302. */
  34303. particlesEnabled: boolean;
  34304. /**
  34305. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34306. */
  34307. spritesEnabled: boolean;
  34308. private _skeletonsEnabled;
  34309. /**
  34310. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34311. */
  34312. skeletonsEnabled: boolean;
  34313. /**
  34314. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34315. */
  34316. lensFlaresEnabled: boolean;
  34317. /**
  34318. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34319. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34320. */
  34321. collisionsEnabled: boolean;
  34322. private _collisionCoordinator;
  34323. /** @hidden */
  34324. readonly collisionCoordinator: ICollisionCoordinator;
  34325. /**
  34326. * Defines the gravity applied to this scene (used only for collisions)
  34327. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34328. */
  34329. gravity: Vector3;
  34330. /**
  34331. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34332. */
  34333. postProcessesEnabled: boolean;
  34334. /**
  34335. * The list of postprocesses added to the scene
  34336. */
  34337. postProcesses: PostProcess[];
  34338. /**
  34339. * Gets the current postprocess manager
  34340. */
  34341. postProcessManager: PostProcessManager;
  34342. /**
  34343. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34344. */
  34345. renderTargetsEnabled: boolean;
  34346. /**
  34347. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34348. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34349. */
  34350. dumpNextRenderTargets: boolean;
  34351. /**
  34352. * The list of user defined render targets added to the scene
  34353. */
  34354. customRenderTargets: RenderTargetTexture[];
  34355. /**
  34356. * Defines if texture loading must be delayed
  34357. * If true, textures will only be loaded when they need to be rendered
  34358. */
  34359. useDelayedTextureLoading: boolean;
  34360. /**
  34361. * Gets the list of meshes imported to the scene through SceneLoader
  34362. */
  34363. importedMeshesFiles: String[];
  34364. /**
  34365. * Gets or sets a boolean indicating if probes are enabled on this scene
  34366. */
  34367. probesEnabled: boolean;
  34368. /**
  34369. * Gets or sets the current offline provider to use to store scene data
  34370. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34371. */
  34372. offlineProvider: IOfflineProvider;
  34373. /**
  34374. * Gets or sets the action manager associated with the scene
  34375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34376. */
  34377. actionManager: AbstractActionManager;
  34378. private _meshesForIntersections;
  34379. /**
  34380. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34381. */
  34382. proceduralTexturesEnabled: boolean;
  34383. private _engine;
  34384. private _totalVertices;
  34385. /** @hidden */
  34386. _activeIndices: PerfCounter;
  34387. /** @hidden */
  34388. _activeParticles: PerfCounter;
  34389. /** @hidden */
  34390. _activeBones: PerfCounter;
  34391. private _animationRatio;
  34392. /** @hidden */
  34393. _animationTimeLast: number;
  34394. /** @hidden */
  34395. _animationTime: number;
  34396. /**
  34397. * Gets or sets a general scale for animation speed
  34398. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34399. */
  34400. animationTimeScale: number;
  34401. /** @hidden */
  34402. _cachedMaterial: Nullable<Material>;
  34403. /** @hidden */
  34404. _cachedEffect: Nullable<Effect>;
  34405. /** @hidden */
  34406. _cachedVisibility: Nullable<number>;
  34407. private _renderId;
  34408. private _frameId;
  34409. private _executeWhenReadyTimeoutId;
  34410. private _intermediateRendering;
  34411. private _viewUpdateFlag;
  34412. private _projectionUpdateFlag;
  34413. /** @hidden */
  34414. _toBeDisposed: Nullable<IDisposable>[];
  34415. private _activeRequests;
  34416. /** @hidden */
  34417. _pendingData: any[];
  34418. private _isDisposed;
  34419. /**
  34420. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34421. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34422. */
  34423. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34424. private _activeMeshes;
  34425. private _processedMaterials;
  34426. private _renderTargets;
  34427. /** @hidden */
  34428. _activeParticleSystems: SmartArray<IParticleSystem>;
  34429. private _activeSkeletons;
  34430. private _softwareSkinnedMeshes;
  34431. private _renderingManager;
  34432. /** @hidden */
  34433. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34434. private _transformMatrix;
  34435. private _sceneUbo;
  34436. /** @hidden */
  34437. _viewMatrix: Matrix;
  34438. private _projectionMatrix;
  34439. /** @hidden */
  34440. _forcedViewPosition: Nullable<Vector3>;
  34441. /** @hidden */
  34442. _frustumPlanes: Plane[];
  34443. /**
  34444. * Gets the list of frustum planes (built from the active camera)
  34445. */
  34446. readonly frustumPlanes: Plane[];
  34447. /**
  34448. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34449. * This is useful if there are more lights that the maximum simulteanous authorized
  34450. */
  34451. requireLightSorting: boolean;
  34452. /** @hidden */
  34453. readonly useMaterialMeshMap: boolean;
  34454. /** @hidden */
  34455. readonly useClonedMeshhMap: boolean;
  34456. private _externalData;
  34457. private _uid;
  34458. /**
  34459. * @hidden
  34460. * Backing store of defined scene components.
  34461. */
  34462. _components: ISceneComponent[];
  34463. /**
  34464. * @hidden
  34465. * Backing store of defined scene components.
  34466. */
  34467. _serializableComponents: ISceneSerializableComponent[];
  34468. /**
  34469. * List of components to register on the next registration step.
  34470. */
  34471. private _transientComponents;
  34472. /**
  34473. * Registers the transient components if needed.
  34474. */
  34475. private _registerTransientComponents;
  34476. /**
  34477. * @hidden
  34478. * Add a component to the scene.
  34479. * Note that the ccomponent could be registered on th next frame if this is called after
  34480. * the register component stage.
  34481. * @param component Defines the component to add to the scene
  34482. */
  34483. _addComponent(component: ISceneComponent): void;
  34484. /**
  34485. * @hidden
  34486. * Gets a component from the scene.
  34487. * @param name defines the name of the component to retrieve
  34488. * @returns the component or null if not present
  34489. */
  34490. _getComponent(name: string): Nullable<ISceneComponent>;
  34491. /**
  34492. * @hidden
  34493. * Defines the actions happening before camera updates.
  34494. */
  34495. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34496. /**
  34497. * @hidden
  34498. * Defines the actions happening before clear the canvas.
  34499. */
  34500. _beforeClearStage: Stage<SimpleStageAction>;
  34501. /**
  34502. * @hidden
  34503. * Defines the actions when collecting render targets for the frame.
  34504. */
  34505. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34506. /**
  34507. * @hidden
  34508. * Defines the actions happening for one camera in the frame.
  34509. */
  34510. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34511. /**
  34512. * @hidden
  34513. * Defines the actions happening during the per mesh ready checks.
  34514. */
  34515. _isReadyForMeshStage: Stage<MeshStageAction>;
  34516. /**
  34517. * @hidden
  34518. * Defines the actions happening before evaluate active mesh checks.
  34519. */
  34520. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34521. /**
  34522. * @hidden
  34523. * Defines the actions happening during the evaluate sub mesh checks.
  34524. */
  34525. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34526. /**
  34527. * @hidden
  34528. * Defines the actions happening during the active mesh stage.
  34529. */
  34530. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34531. /**
  34532. * @hidden
  34533. * Defines the actions happening during the per camera render target step.
  34534. */
  34535. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34536. /**
  34537. * @hidden
  34538. * Defines the actions happening just before the active camera is drawing.
  34539. */
  34540. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34541. /**
  34542. * @hidden
  34543. * Defines the actions happening just before a render target is drawing.
  34544. */
  34545. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34546. /**
  34547. * @hidden
  34548. * Defines the actions happening just before a rendering group is drawing.
  34549. */
  34550. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34551. /**
  34552. * @hidden
  34553. * Defines the actions happening just before a mesh is drawing.
  34554. */
  34555. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34556. /**
  34557. * @hidden
  34558. * Defines the actions happening just after a mesh has been drawn.
  34559. */
  34560. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34561. /**
  34562. * @hidden
  34563. * Defines the actions happening just after a rendering group has been drawn.
  34564. */
  34565. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34566. /**
  34567. * @hidden
  34568. * Defines the actions happening just after the active camera has been drawn.
  34569. */
  34570. _afterCameraDrawStage: Stage<CameraStageAction>;
  34571. /**
  34572. * @hidden
  34573. * Defines the actions happening just after a render target has been drawn.
  34574. */
  34575. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34576. /**
  34577. * @hidden
  34578. * Defines the actions happening just after rendering all cameras and computing intersections.
  34579. */
  34580. _afterRenderStage: Stage<SimpleStageAction>;
  34581. /**
  34582. * @hidden
  34583. * Defines the actions happening when a pointer move event happens.
  34584. */
  34585. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34586. /**
  34587. * @hidden
  34588. * Defines the actions happening when a pointer down event happens.
  34589. */
  34590. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34591. /**
  34592. * @hidden
  34593. * Defines the actions happening when a pointer up event happens.
  34594. */
  34595. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34596. /**
  34597. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34598. */
  34599. private geometriesByUniqueId;
  34600. /**
  34601. * Creates a new Scene
  34602. * @param engine defines the engine to use to render this scene
  34603. * @param options defines the scene options
  34604. */
  34605. constructor(engine: Engine, options?: SceneOptions);
  34606. /**
  34607. * Gets a string idenfifying the name of the class
  34608. * @returns "Scene" string
  34609. */
  34610. getClassName(): string;
  34611. private _defaultMeshCandidates;
  34612. /**
  34613. * @hidden
  34614. */
  34615. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34616. private _defaultSubMeshCandidates;
  34617. /**
  34618. * @hidden
  34619. */
  34620. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34621. /**
  34622. * Sets the default candidate providers for the scene.
  34623. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34624. * and getCollidingSubMeshCandidates to their default function
  34625. */
  34626. setDefaultCandidateProviders(): void;
  34627. /**
  34628. * Gets the mesh that is currently under the pointer
  34629. */
  34630. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34631. /**
  34632. * Gets or sets the current on-screen X position of the pointer
  34633. */
  34634. pointerX: number;
  34635. /**
  34636. * Gets or sets the current on-screen Y position of the pointer
  34637. */
  34638. pointerY: number;
  34639. /**
  34640. * Gets the cached material (ie. the latest rendered one)
  34641. * @returns the cached material
  34642. */
  34643. getCachedMaterial(): Nullable<Material>;
  34644. /**
  34645. * Gets the cached effect (ie. the latest rendered one)
  34646. * @returns the cached effect
  34647. */
  34648. getCachedEffect(): Nullable<Effect>;
  34649. /**
  34650. * Gets the cached visibility state (ie. the latest rendered one)
  34651. * @returns the cached visibility state
  34652. */
  34653. getCachedVisibility(): Nullable<number>;
  34654. /**
  34655. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34656. * @param material defines the current material
  34657. * @param effect defines the current effect
  34658. * @param visibility defines the current visibility state
  34659. * @returns true if one parameter is not cached
  34660. */
  34661. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34662. /**
  34663. * Gets the engine associated with the scene
  34664. * @returns an Engine
  34665. */
  34666. getEngine(): Engine;
  34667. /**
  34668. * Gets the total number of vertices rendered per frame
  34669. * @returns the total number of vertices rendered per frame
  34670. */
  34671. getTotalVertices(): number;
  34672. /**
  34673. * Gets the performance counter for total vertices
  34674. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34675. */
  34676. readonly totalVerticesPerfCounter: PerfCounter;
  34677. /**
  34678. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34679. * @returns the total number of active indices rendered per frame
  34680. */
  34681. getActiveIndices(): number;
  34682. /**
  34683. * Gets the performance counter for active indices
  34684. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34685. */
  34686. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34687. /**
  34688. * Gets the total number of active particles rendered per frame
  34689. * @returns the total number of active particles rendered per frame
  34690. */
  34691. getActiveParticles(): number;
  34692. /**
  34693. * Gets the performance counter for active particles
  34694. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34695. */
  34696. readonly activeParticlesPerfCounter: PerfCounter;
  34697. /**
  34698. * Gets the total number of active bones rendered per frame
  34699. * @returns the total number of active bones rendered per frame
  34700. */
  34701. getActiveBones(): number;
  34702. /**
  34703. * Gets the performance counter for active bones
  34704. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34705. */
  34706. readonly activeBonesPerfCounter: PerfCounter;
  34707. /**
  34708. * Gets the array of active meshes
  34709. * @returns an array of AbstractMesh
  34710. */
  34711. getActiveMeshes(): SmartArray<AbstractMesh>;
  34712. /**
  34713. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34714. * @returns a number
  34715. */
  34716. getAnimationRatio(): number;
  34717. /**
  34718. * Gets an unique Id for the current render phase
  34719. * @returns a number
  34720. */
  34721. getRenderId(): number;
  34722. /**
  34723. * Gets an unique Id for the current frame
  34724. * @returns a number
  34725. */
  34726. getFrameId(): number;
  34727. /** Call this function if you want to manually increment the render Id*/
  34728. incrementRenderId(): void;
  34729. private _createUbo;
  34730. /**
  34731. * Use this method to simulate a pointer move on a mesh
  34732. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34733. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34734. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34735. * @returns the current scene
  34736. */
  34737. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34738. /**
  34739. * Use this method to simulate a pointer down on a mesh
  34740. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34741. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34742. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34743. * @returns the current scene
  34744. */
  34745. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34746. /**
  34747. * Use this method to simulate a pointer up on a mesh
  34748. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34749. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34750. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34751. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34752. * @returns the current scene
  34753. */
  34754. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34755. /**
  34756. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34757. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34758. * @returns true if the pointer was captured
  34759. */
  34760. isPointerCaptured(pointerId?: number): boolean;
  34761. /**
  34762. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34763. * @param attachUp defines if you want to attach events to pointerup
  34764. * @param attachDown defines if you want to attach events to pointerdown
  34765. * @param attachMove defines if you want to attach events to pointermove
  34766. */
  34767. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34768. /** Detaches all event handlers*/
  34769. detachControl(): void;
  34770. /**
  34771. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34772. * Delay loaded resources are not taking in account
  34773. * @return true if all required resources are ready
  34774. */
  34775. isReady(): boolean;
  34776. /** Resets all cached information relative to material (including effect and visibility) */
  34777. resetCachedMaterial(): void;
  34778. /**
  34779. * Registers a function to be called before every frame render
  34780. * @param func defines the function to register
  34781. */
  34782. registerBeforeRender(func: () => void): void;
  34783. /**
  34784. * Unregisters a function called before every frame render
  34785. * @param func defines the function to unregister
  34786. */
  34787. unregisterBeforeRender(func: () => void): void;
  34788. /**
  34789. * Registers a function to be called after every frame render
  34790. * @param func defines the function to register
  34791. */
  34792. registerAfterRender(func: () => void): void;
  34793. /**
  34794. * Unregisters a function called after every frame render
  34795. * @param func defines the function to unregister
  34796. */
  34797. unregisterAfterRender(func: () => void): void;
  34798. private _executeOnceBeforeRender;
  34799. /**
  34800. * The provided function will run before render once and will be disposed afterwards.
  34801. * A timeout delay can be provided so that the function will be executed in N ms.
  34802. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34803. * @param func The function to be executed.
  34804. * @param timeout optional delay in ms
  34805. */
  34806. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34807. /** @hidden */
  34808. _addPendingData(data: any): void;
  34809. /** @hidden */
  34810. _removePendingData(data: any): void;
  34811. /**
  34812. * Returns the number of items waiting to be loaded
  34813. * @returns the number of items waiting to be loaded
  34814. */
  34815. getWaitingItemsCount(): number;
  34816. /**
  34817. * Returns a boolean indicating if the scene is still loading data
  34818. */
  34819. readonly isLoading: boolean;
  34820. /**
  34821. * Registers a function to be executed when the scene is ready
  34822. * @param {Function} func - the function to be executed
  34823. */
  34824. executeWhenReady(func: () => void): void;
  34825. /**
  34826. * Returns a promise that resolves when the scene is ready
  34827. * @returns A promise that resolves when the scene is ready
  34828. */
  34829. whenReadyAsync(): Promise<void>;
  34830. /** @hidden */
  34831. _checkIsReady(): void;
  34832. /**
  34833. * Gets all animatable attached to the scene
  34834. */
  34835. readonly animatables: Animatable[];
  34836. /**
  34837. * Resets the last animation time frame.
  34838. * Useful to override when animations start running when loading a scene for the first time.
  34839. */
  34840. resetLastAnimationTimeFrame(): void;
  34841. /**
  34842. * Gets the current view matrix
  34843. * @returns a Matrix
  34844. */
  34845. getViewMatrix(): Matrix;
  34846. /**
  34847. * Gets the current projection matrix
  34848. * @returns a Matrix
  34849. */
  34850. getProjectionMatrix(): Matrix;
  34851. /**
  34852. * Gets the current transform matrix
  34853. * @returns a Matrix made of View * Projection
  34854. */
  34855. getTransformMatrix(): Matrix;
  34856. /**
  34857. * Sets the current transform matrix
  34858. * @param viewL defines the View matrix to use
  34859. * @param projectionL defines the Projection matrix to use
  34860. * @param viewR defines the right View matrix to use (if provided)
  34861. * @param projectionR defines the right Projection matrix to use (if provided)
  34862. */
  34863. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34864. /**
  34865. * Gets the uniform buffer used to store scene data
  34866. * @returns a UniformBuffer
  34867. */
  34868. getSceneUniformBuffer(): UniformBuffer;
  34869. /**
  34870. * Gets an unique (relatively to the current scene) Id
  34871. * @returns an unique number for the scene
  34872. */
  34873. getUniqueId(): number;
  34874. /**
  34875. * Add a mesh to the list of scene's meshes
  34876. * @param newMesh defines the mesh to add
  34877. * @param recursive if all child meshes should also be added to the scene
  34878. */
  34879. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34880. /**
  34881. * Remove a mesh for the list of scene's meshes
  34882. * @param toRemove defines the mesh to remove
  34883. * @param recursive if all child meshes should also be removed from the scene
  34884. * @returns the index where the mesh was in the mesh list
  34885. */
  34886. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34887. /**
  34888. * Add a transform node to the list of scene's transform nodes
  34889. * @param newTransformNode defines the transform node to add
  34890. */
  34891. addTransformNode(newTransformNode: TransformNode): void;
  34892. /**
  34893. * Remove a transform node for the list of scene's transform nodes
  34894. * @param toRemove defines the transform node to remove
  34895. * @returns the index where the transform node was in the transform node list
  34896. */
  34897. removeTransformNode(toRemove: TransformNode): number;
  34898. /**
  34899. * Remove a skeleton for the list of scene's skeletons
  34900. * @param toRemove defines the skeleton to remove
  34901. * @returns the index where the skeleton was in the skeleton list
  34902. */
  34903. removeSkeleton(toRemove: Skeleton): number;
  34904. /**
  34905. * Remove a morph target for the list of scene's morph targets
  34906. * @param toRemove defines the morph target to remove
  34907. * @returns the index where the morph target was in the morph target list
  34908. */
  34909. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34910. /**
  34911. * Remove a light for the list of scene's lights
  34912. * @param toRemove defines the light to remove
  34913. * @returns the index where the light was in the light list
  34914. */
  34915. removeLight(toRemove: Light): number;
  34916. /**
  34917. * Remove a camera for the list of scene's cameras
  34918. * @param toRemove defines the camera to remove
  34919. * @returns the index where the camera was in the camera list
  34920. */
  34921. removeCamera(toRemove: Camera): number;
  34922. /**
  34923. * Remove a particle system for the list of scene's particle systems
  34924. * @param toRemove defines the particle system to remove
  34925. * @returns the index where the particle system was in the particle system list
  34926. */
  34927. removeParticleSystem(toRemove: IParticleSystem): number;
  34928. /**
  34929. * Remove a animation for the list of scene's animations
  34930. * @param toRemove defines the animation to remove
  34931. * @returns the index where the animation was in the animation list
  34932. */
  34933. removeAnimation(toRemove: Animation): number;
  34934. /**
  34935. * Will stop the animation of the given target
  34936. * @param target - the target
  34937. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34938. * @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)
  34939. */
  34940. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34941. /**
  34942. * Removes the given animation group from this scene.
  34943. * @param toRemove The animation group to remove
  34944. * @returns The index of the removed animation group
  34945. */
  34946. removeAnimationGroup(toRemove: AnimationGroup): number;
  34947. /**
  34948. * Removes the given multi-material from this scene.
  34949. * @param toRemove The multi-material to remove
  34950. * @returns The index of the removed multi-material
  34951. */
  34952. removeMultiMaterial(toRemove: MultiMaterial): number;
  34953. /**
  34954. * Removes the given material from this scene.
  34955. * @param toRemove The material to remove
  34956. * @returns The index of the removed material
  34957. */
  34958. removeMaterial(toRemove: Material): number;
  34959. /**
  34960. * Removes the given action manager from this scene.
  34961. * @param toRemove The action manager to remove
  34962. * @returns The index of the removed action manager
  34963. */
  34964. removeActionManager(toRemove: AbstractActionManager): number;
  34965. /**
  34966. * Removes the given texture from this scene.
  34967. * @param toRemove The texture to remove
  34968. * @returns The index of the removed texture
  34969. */
  34970. removeTexture(toRemove: BaseTexture): number;
  34971. /**
  34972. * Adds the given light to this scene
  34973. * @param newLight The light to add
  34974. */
  34975. addLight(newLight: Light): void;
  34976. /**
  34977. * Sorts the list list based on light priorities
  34978. */
  34979. sortLightsByPriority(): void;
  34980. /**
  34981. * Adds the given camera to this scene
  34982. * @param newCamera The camera to add
  34983. */
  34984. addCamera(newCamera: Camera): void;
  34985. /**
  34986. * Adds the given skeleton to this scene
  34987. * @param newSkeleton The skeleton to add
  34988. */
  34989. addSkeleton(newSkeleton: Skeleton): void;
  34990. /**
  34991. * Adds the given particle system to this scene
  34992. * @param newParticleSystem The particle system to add
  34993. */
  34994. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34995. /**
  34996. * Adds the given animation to this scene
  34997. * @param newAnimation The animation to add
  34998. */
  34999. addAnimation(newAnimation: Animation): void;
  35000. /**
  35001. * Adds the given animation group to this scene.
  35002. * @param newAnimationGroup The animation group to add
  35003. */
  35004. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35005. /**
  35006. * Adds the given multi-material to this scene
  35007. * @param newMultiMaterial The multi-material to add
  35008. */
  35009. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35010. /**
  35011. * Adds the given material to this scene
  35012. * @param newMaterial The material to add
  35013. */
  35014. addMaterial(newMaterial: Material): void;
  35015. /**
  35016. * Adds the given morph target to this scene
  35017. * @param newMorphTargetManager The morph target to add
  35018. */
  35019. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35020. /**
  35021. * Adds the given geometry to this scene
  35022. * @param newGeometry The geometry to add
  35023. */
  35024. addGeometry(newGeometry: Geometry): void;
  35025. /**
  35026. * Adds the given action manager to this scene
  35027. * @param newActionManager The action manager to add
  35028. */
  35029. addActionManager(newActionManager: AbstractActionManager): void;
  35030. /**
  35031. * Adds the given texture to this scene.
  35032. * @param newTexture The texture to add
  35033. */
  35034. addTexture(newTexture: BaseTexture): void;
  35035. /**
  35036. * Switch active camera
  35037. * @param newCamera defines the new active camera
  35038. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35039. */
  35040. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35041. /**
  35042. * sets the active camera of the scene using its ID
  35043. * @param id defines the camera's ID
  35044. * @return the new active camera or null if none found.
  35045. */
  35046. setActiveCameraByID(id: string): Nullable<Camera>;
  35047. /**
  35048. * sets the active camera of the scene using its name
  35049. * @param name defines the camera's name
  35050. * @returns the new active camera or null if none found.
  35051. */
  35052. setActiveCameraByName(name: string): Nullable<Camera>;
  35053. /**
  35054. * get an animation group using its name
  35055. * @param name defines the material's name
  35056. * @return the animation group or null if none found.
  35057. */
  35058. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35059. /**
  35060. * Get a material using its unique id
  35061. * @param uniqueId defines the material's unique id
  35062. * @return the material or null if none found.
  35063. */
  35064. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35065. /**
  35066. * get a material using its id
  35067. * @param id defines the material's ID
  35068. * @return the material or null if none found.
  35069. */
  35070. getMaterialByID(id: string): Nullable<Material>;
  35071. /**
  35072. * Gets a the last added material using a given id
  35073. * @param id defines the material's ID
  35074. * @return the last material with the given id or null if none found.
  35075. */
  35076. getLastMaterialByID(id: string): Nullable<Material>;
  35077. /**
  35078. * Gets a material using its name
  35079. * @param name defines the material's name
  35080. * @return the material or null if none found.
  35081. */
  35082. getMaterialByName(name: string): Nullable<Material>;
  35083. /**
  35084. * Get a texture using its unique id
  35085. * @param uniqueId defines the texture's unique id
  35086. * @return the texture or null if none found.
  35087. */
  35088. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35089. /**
  35090. * Gets a camera using its id
  35091. * @param id defines the id to look for
  35092. * @returns the camera or null if not found
  35093. */
  35094. getCameraByID(id: string): Nullable<Camera>;
  35095. /**
  35096. * Gets a camera using its unique id
  35097. * @param uniqueId defines the unique id to look for
  35098. * @returns the camera or null if not found
  35099. */
  35100. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35101. /**
  35102. * Gets a camera using its name
  35103. * @param name defines the camera's name
  35104. * @return the camera or null if none found.
  35105. */
  35106. getCameraByName(name: string): Nullable<Camera>;
  35107. /**
  35108. * Gets a bone using its id
  35109. * @param id defines the bone's id
  35110. * @return the bone or null if not found
  35111. */
  35112. getBoneByID(id: string): Nullable<Bone>;
  35113. /**
  35114. * Gets a bone using its id
  35115. * @param name defines the bone's name
  35116. * @return the bone or null if not found
  35117. */
  35118. getBoneByName(name: string): Nullable<Bone>;
  35119. /**
  35120. * Gets a light node using its name
  35121. * @param name defines the the light's name
  35122. * @return the light or null if none found.
  35123. */
  35124. getLightByName(name: string): Nullable<Light>;
  35125. /**
  35126. * Gets a light node using its id
  35127. * @param id defines the light's id
  35128. * @return the light or null if none found.
  35129. */
  35130. getLightByID(id: string): Nullable<Light>;
  35131. /**
  35132. * Gets a light node using its scene-generated unique ID
  35133. * @param uniqueId defines the light's unique id
  35134. * @return the light or null if none found.
  35135. */
  35136. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35137. /**
  35138. * Gets a particle system by id
  35139. * @param id defines the particle system id
  35140. * @return the corresponding system or null if none found
  35141. */
  35142. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35143. /**
  35144. * Gets a geometry using its ID
  35145. * @param id defines the geometry's id
  35146. * @return the geometry or null if none found.
  35147. */
  35148. getGeometryByID(id: string): Nullable<Geometry>;
  35149. private _getGeometryByUniqueID;
  35150. /**
  35151. * Add a new geometry to this scene
  35152. * @param geometry defines the geometry to be added to the scene.
  35153. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35154. * @return a boolean defining if the geometry was added or not
  35155. */
  35156. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35157. /**
  35158. * Removes an existing geometry
  35159. * @param geometry defines the geometry to be removed from the scene
  35160. * @return a boolean defining if the geometry was removed or not
  35161. */
  35162. removeGeometry(geometry: Geometry): boolean;
  35163. /**
  35164. * Gets the list of geometries attached to the scene
  35165. * @returns an array of Geometry
  35166. */
  35167. getGeometries(): Geometry[];
  35168. /**
  35169. * Gets the first added mesh found of a given ID
  35170. * @param id defines the id to search for
  35171. * @return the mesh found or null if not found at all
  35172. */
  35173. getMeshByID(id: string): Nullable<AbstractMesh>;
  35174. /**
  35175. * Gets a list of meshes using their id
  35176. * @param id defines the id to search for
  35177. * @returns a list of meshes
  35178. */
  35179. getMeshesByID(id: string): Array<AbstractMesh>;
  35180. /**
  35181. * Gets the first added transform node found of a given ID
  35182. * @param id defines the id to search for
  35183. * @return the found transform node or null if not found at all.
  35184. */
  35185. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35186. /**
  35187. * Gets a transform node with its auto-generated unique id
  35188. * @param uniqueId efines the unique id to search for
  35189. * @return the found transform node or null if not found at all.
  35190. */
  35191. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35192. /**
  35193. * Gets a list of transform nodes using their id
  35194. * @param id defines the id to search for
  35195. * @returns a list of transform nodes
  35196. */
  35197. getTransformNodesByID(id: string): Array<TransformNode>;
  35198. /**
  35199. * Gets a mesh with its auto-generated unique id
  35200. * @param uniqueId defines the unique id to search for
  35201. * @return the found mesh or null if not found at all.
  35202. */
  35203. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35204. /**
  35205. * Gets a the last added mesh using a given id
  35206. * @param id defines the id to search for
  35207. * @return the found mesh or null if not found at all.
  35208. */
  35209. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35210. /**
  35211. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35212. * @param id defines the id to search for
  35213. * @return the found node or null if not found at all
  35214. */
  35215. getLastEntryByID(id: string): Nullable<Node>;
  35216. /**
  35217. * Gets a node (Mesh, Camera, Light) using a given id
  35218. * @param id defines the id to search for
  35219. * @return the found node or null if not found at all
  35220. */
  35221. getNodeByID(id: string): Nullable<Node>;
  35222. /**
  35223. * Gets a node (Mesh, Camera, Light) using a given name
  35224. * @param name defines the name to search for
  35225. * @return the found node or null if not found at all.
  35226. */
  35227. getNodeByName(name: string): Nullable<Node>;
  35228. /**
  35229. * Gets a mesh using a given name
  35230. * @param name defines the name to search for
  35231. * @return the found mesh or null if not found at all.
  35232. */
  35233. getMeshByName(name: string): Nullable<AbstractMesh>;
  35234. /**
  35235. * Gets a transform node using a given name
  35236. * @param name defines the name to search for
  35237. * @return the found transform node or null if not found at all.
  35238. */
  35239. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35240. /**
  35241. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35242. * @param id defines the id to search for
  35243. * @return the found skeleton or null if not found at all.
  35244. */
  35245. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35246. /**
  35247. * Gets a skeleton using a given auto generated unique id
  35248. * @param uniqueId defines the unique id to search for
  35249. * @return the found skeleton or null if not found at all.
  35250. */
  35251. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35252. /**
  35253. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35254. * @param id defines the id to search for
  35255. * @return the found skeleton or null if not found at all.
  35256. */
  35257. getSkeletonById(id: string): Nullable<Skeleton>;
  35258. /**
  35259. * Gets a skeleton using a given name
  35260. * @param name defines the name to search for
  35261. * @return the found skeleton or null if not found at all.
  35262. */
  35263. getSkeletonByName(name: string): Nullable<Skeleton>;
  35264. /**
  35265. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35266. * @param id defines the id to search for
  35267. * @return the found morph target manager or null if not found at all.
  35268. */
  35269. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35270. /**
  35271. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35272. * @param id defines the id to search for
  35273. * @return the found morph target or null if not found at all.
  35274. */
  35275. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35276. /**
  35277. * Gets a boolean indicating if the given mesh is active
  35278. * @param mesh defines the mesh to look for
  35279. * @returns true if the mesh is in the active list
  35280. */
  35281. isActiveMesh(mesh: AbstractMesh): boolean;
  35282. /**
  35283. * Return a unique id as a string which can serve as an identifier for the scene
  35284. */
  35285. readonly uid: string;
  35286. /**
  35287. * Add an externaly attached data from its key.
  35288. * This method call will fail and return false, if such key already exists.
  35289. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35290. * @param key the unique key that identifies the data
  35291. * @param data the data object to associate to the key for this Engine instance
  35292. * @return true if no such key were already present and the data was added successfully, false otherwise
  35293. */
  35294. addExternalData<T>(key: string, data: T): boolean;
  35295. /**
  35296. * Get an externaly attached data from its key
  35297. * @param key the unique key that identifies the data
  35298. * @return the associated data, if present (can be null), or undefined if not present
  35299. */
  35300. getExternalData<T>(key: string): Nullable<T>;
  35301. /**
  35302. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35303. * @param key the unique key that identifies the data
  35304. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35305. * @return the associated data, can be null if the factory returned null.
  35306. */
  35307. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35308. /**
  35309. * Remove an externaly attached data from the Engine instance
  35310. * @param key the unique key that identifies the data
  35311. * @return true if the data was successfully removed, false if it doesn't exist
  35312. */
  35313. removeExternalData(key: string): boolean;
  35314. private _evaluateSubMesh;
  35315. /**
  35316. * Clear the processed materials smart array preventing retention point in material dispose.
  35317. */
  35318. freeProcessedMaterials(): void;
  35319. private _preventFreeActiveMeshesAndRenderingGroups;
  35320. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35321. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35322. * when disposing several meshes in a row or a hierarchy of meshes.
  35323. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35324. */
  35325. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35326. /**
  35327. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35328. */
  35329. freeActiveMeshes(): void;
  35330. /**
  35331. * Clear the info related to rendering groups preventing retention points during dispose.
  35332. */
  35333. freeRenderingGroups(): void;
  35334. /** @hidden */
  35335. _isInIntermediateRendering(): boolean;
  35336. /**
  35337. * Lambda returning the list of potentially active meshes.
  35338. */
  35339. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35340. /**
  35341. * Lambda returning the list of potentially active sub meshes.
  35342. */
  35343. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35344. /**
  35345. * Lambda returning the list of potentially intersecting sub meshes.
  35346. */
  35347. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35348. /**
  35349. * Lambda returning the list of potentially colliding sub meshes.
  35350. */
  35351. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35352. private _activeMeshesFrozen;
  35353. /**
  35354. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35355. * @returns the current scene
  35356. */
  35357. freezeActiveMeshes(): Scene;
  35358. /**
  35359. * Use this function to restart evaluating active meshes on every frame
  35360. * @returns the current scene
  35361. */
  35362. unfreezeActiveMeshes(): Scene;
  35363. private _evaluateActiveMeshes;
  35364. private _activeMesh;
  35365. /**
  35366. * Update the transform matrix to update from the current active camera
  35367. * @param force defines a boolean used to force the update even if cache is up to date
  35368. */
  35369. updateTransformMatrix(force?: boolean): void;
  35370. private _bindFrameBuffer;
  35371. /** @hidden */
  35372. _allowPostProcessClearColor: boolean;
  35373. /** @hidden */
  35374. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35375. private _processSubCameras;
  35376. private _checkIntersections;
  35377. /** @hidden */
  35378. _advancePhysicsEngineStep(step: number): void;
  35379. /**
  35380. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35381. */
  35382. getDeterministicFrameTime: () => number;
  35383. /** @hidden */
  35384. _animate(): void;
  35385. /** Execute all animations (for a frame) */
  35386. animate(): void;
  35387. /**
  35388. * Render the scene
  35389. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35390. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35391. */
  35392. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35393. /**
  35394. * Freeze all materials
  35395. * A frozen material will not be updatable but should be faster to render
  35396. */
  35397. freezeMaterials(): void;
  35398. /**
  35399. * Unfreeze all materials
  35400. * A frozen material will not be updatable but should be faster to render
  35401. */
  35402. unfreezeMaterials(): void;
  35403. /**
  35404. * Releases all held ressources
  35405. */
  35406. dispose(): void;
  35407. /**
  35408. * Gets if the scene is already disposed
  35409. */
  35410. readonly isDisposed: boolean;
  35411. /**
  35412. * Call this function to reduce memory footprint of the scene.
  35413. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35414. */
  35415. clearCachedVertexData(): void;
  35416. /**
  35417. * This function will remove the local cached buffer data from texture.
  35418. * It will save memory but will prevent the texture from being rebuilt
  35419. */
  35420. cleanCachedTextureBuffer(): void;
  35421. /**
  35422. * Get the world extend vectors with an optional filter
  35423. *
  35424. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35425. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35426. */
  35427. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35428. min: Vector3;
  35429. max: Vector3;
  35430. };
  35431. /**
  35432. * Creates a ray that can be used to pick in the scene
  35433. * @param x defines the x coordinate of the origin (on-screen)
  35434. * @param y defines the y coordinate of the origin (on-screen)
  35435. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35436. * @param camera defines the camera to use for the picking
  35437. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35438. * @returns a Ray
  35439. */
  35440. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35441. /**
  35442. * Creates a ray that can be used to pick in the scene
  35443. * @param x defines the x coordinate of the origin (on-screen)
  35444. * @param y defines the y coordinate of the origin (on-screen)
  35445. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35446. * @param result defines the ray where to store the picking ray
  35447. * @param camera defines the camera to use for the picking
  35448. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35449. * @returns the current scene
  35450. */
  35451. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35452. /**
  35453. * Creates a ray that can be used to pick in the scene
  35454. * @param x defines the x coordinate of the origin (on-screen)
  35455. * @param y defines the y coordinate of the origin (on-screen)
  35456. * @param camera defines the camera to use for the picking
  35457. * @returns a Ray
  35458. */
  35459. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35460. /**
  35461. * Creates a ray that can be used to pick in the scene
  35462. * @param x defines the x coordinate of the origin (on-screen)
  35463. * @param y defines the y coordinate of the origin (on-screen)
  35464. * @param result defines the ray where to store the picking ray
  35465. * @param camera defines the camera to use for the picking
  35466. * @returns the current scene
  35467. */
  35468. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35469. /** Launch a ray to try to pick a mesh in the scene
  35470. * @param x position on screen
  35471. * @param y position on screen
  35472. * @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
  35473. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35474. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35475. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35476. * @returns a PickingInfo
  35477. */
  35478. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35479. /** Use the given ray to pick a mesh in the scene
  35480. * @param ray The ray to use to pick meshes
  35481. * @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
  35482. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35483. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35484. * @returns a PickingInfo
  35485. */
  35486. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35487. /**
  35488. * Launch a ray to try to pick a mesh in the scene
  35489. * @param x X position on screen
  35490. * @param y Y position on screen
  35491. * @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
  35492. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35493. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35494. * @returns an array of PickingInfo
  35495. */
  35496. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35497. /**
  35498. * Launch a ray to try to pick a mesh in the scene
  35499. * @param ray Ray to use
  35500. * @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
  35501. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35502. * @returns an array of PickingInfo
  35503. */
  35504. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35505. /**
  35506. * Force the value of meshUnderPointer
  35507. * @param mesh defines the mesh to use
  35508. */
  35509. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35510. /**
  35511. * Gets the mesh under the pointer
  35512. * @returns a Mesh or null if no mesh is under the pointer
  35513. */
  35514. getPointerOverMesh(): Nullable<AbstractMesh>;
  35515. /** @hidden */
  35516. _rebuildGeometries(): void;
  35517. /** @hidden */
  35518. _rebuildTextures(): void;
  35519. private _getByTags;
  35520. /**
  35521. * Get a list of meshes by tags
  35522. * @param tagsQuery defines the tags query to use
  35523. * @param forEach defines a predicate used to filter results
  35524. * @returns an array of Mesh
  35525. */
  35526. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35527. /**
  35528. * Get a list of cameras by tags
  35529. * @param tagsQuery defines the tags query to use
  35530. * @param forEach defines a predicate used to filter results
  35531. * @returns an array of Camera
  35532. */
  35533. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35534. /**
  35535. * Get a list of lights by tags
  35536. * @param tagsQuery defines the tags query to use
  35537. * @param forEach defines a predicate used to filter results
  35538. * @returns an array of Light
  35539. */
  35540. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35541. /**
  35542. * Get a list of materials by tags
  35543. * @param tagsQuery defines the tags query to use
  35544. * @param forEach defines a predicate used to filter results
  35545. * @returns an array of Material
  35546. */
  35547. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35548. /**
  35549. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35550. * This allowed control for front to back rendering or reversly depending of the special needs.
  35551. *
  35552. * @param renderingGroupId The rendering group id corresponding to its index
  35553. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35554. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35555. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35556. */
  35557. 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;
  35558. /**
  35559. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35560. *
  35561. * @param renderingGroupId The rendering group id corresponding to its index
  35562. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35563. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35564. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35565. */
  35566. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35567. /**
  35568. * Gets the current auto clear configuration for one rendering group of the rendering
  35569. * manager.
  35570. * @param index the rendering group index to get the information for
  35571. * @returns The auto clear setup for the requested rendering group
  35572. */
  35573. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35574. private _blockMaterialDirtyMechanism;
  35575. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35576. blockMaterialDirtyMechanism: boolean;
  35577. /**
  35578. * Will flag all materials as dirty to trigger new shader compilation
  35579. * @param flag defines the flag used to specify which material part must be marked as dirty
  35580. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35581. */
  35582. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35583. /** @hidden */
  35584. _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;
  35585. /** @hidden */
  35586. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35587. }
  35588. }
  35589. declare module "babylonjs/assetContainer" {
  35590. import { AbstractScene } from "babylonjs/abstractScene";
  35591. import { Scene } from "babylonjs/scene";
  35592. import { Mesh } from "babylonjs/Meshes/mesh";
  35593. /**
  35594. * Set of assets to keep when moving a scene into an asset container.
  35595. */
  35596. export class KeepAssets extends AbstractScene {
  35597. }
  35598. /**
  35599. * Container with a set of assets that can be added or removed from a scene.
  35600. */
  35601. export class AssetContainer extends AbstractScene {
  35602. /**
  35603. * The scene the AssetContainer belongs to.
  35604. */
  35605. scene: Scene;
  35606. /**
  35607. * Instantiates an AssetContainer.
  35608. * @param scene The scene the AssetContainer belongs to.
  35609. */
  35610. constructor(scene: Scene);
  35611. /**
  35612. * Adds all the assets from the container to the scene.
  35613. */
  35614. addAllToScene(): void;
  35615. /**
  35616. * Removes all the assets in the container from the scene
  35617. */
  35618. removeAllFromScene(): void;
  35619. /**
  35620. * Disposes all the assets in the container
  35621. */
  35622. dispose(): void;
  35623. private _moveAssets;
  35624. /**
  35625. * Removes all the assets contained in the scene and adds them to the container.
  35626. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35627. */
  35628. moveAllFromScene(keepAssets?: KeepAssets): void;
  35629. /**
  35630. * 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.
  35631. * @returns the root mesh
  35632. */
  35633. createRootMesh(): Mesh;
  35634. }
  35635. }
  35636. declare module "babylonjs/abstractScene" {
  35637. import { Scene } from "babylonjs/scene";
  35638. import { Nullable } from "babylonjs/types";
  35639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35640. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35641. import { Geometry } from "babylonjs/Meshes/geometry";
  35642. import { Skeleton } from "babylonjs/Bones/skeleton";
  35643. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35644. import { AssetContainer } from "babylonjs/assetContainer";
  35645. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35646. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35647. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35648. import { Material } from "babylonjs/Materials/material";
  35649. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35650. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35651. import { Camera } from "babylonjs/Cameras/camera";
  35652. import { Light } from "babylonjs/Lights/light";
  35653. import { Node } from "babylonjs/node";
  35654. import { Animation } from "babylonjs/Animations/animation";
  35655. /**
  35656. * Defines how the parser contract is defined.
  35657. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35658. */
  35659. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35660. /**
  35661. * Defines how the individual parser contract is defined.
  35662. * These parser can parse an individual asset
  35663. */
  35664. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35665. /**
  35666. * Base class of the scene acting as a container for the different elements composing a scene.
  35667. * This class is dynamically extended by the different components of the scene increasing
  35668. * flexibility and reducing coupling
  35669. */
  35670. export abstract class AbstractScene {
  35671. /**
  35672. * Stores the list of available parsers in the application.
  35673. */
  35674. private static _BabylonFileParsers;
  35675. /**
  35676. * Stores the list of available individual parsers in the application.
  35677. */
  35678. private static _IndividualBabylonFileParsers;
  35679. /**
  35680. * Adds a parser in the list of available ones
  35681. * @param name Defines the name of the parser
  35682. * @param parser Defines the parser to add
  35683. */
  35684. static AddParser(name: string, parser: BabylonFileParser): void;
  35685. /**
  35686. * Gets a general parser from the list of avaialble ones
  35687. * @param name Defines the name of the parser
  35688. * @returns the requested parser or null
  35689. */
  35690. static GetParser(name: string): Nullable<BabylonFileParser>;
  35691. /**
  35692. * Adds n individual parser in the list of available ones
  35693. * @param name Defines the name of the parser
  35694. * @param parser Defines the parser to add
  35695. */
  35696. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35697. /**
  35698. * Gets an individual parser from the list of avaialble ones
  35699. * @param name Defines the name of the parser
  35700. * @returns the requested parser or null
  35701. */
  35702. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35703. /**
  35704. * Parser json data and populate both a scene and its associated container object
  35705. * @param jsonData Defines the data to parse
  35706. * @param scene Defines the scene to parse the data for
  35707. * @param container Defines the container attached to the parsing sequence
  35708. * @param rootUrl Defines the root url of the data
  35709. */
  35710. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35711. /**
  35712. * Gets the list of root nodes (ie. nodes with no parent)
  35713. */
  35714. rootNodes: Node[];
  35715. /** All of the cameras added to this scene
  35716. * @see http://doc.babylonjs.com/babylon101/cameras
  35717. */
  35718. cameras: Camera[];
  35719. /**
  35720. * All of the lights added to this scene
  35721. * @see http://doc.babylonjs.com/babylon101/lights
  35722. */
  35723. lights: Light[];
  35724. /**
  35725. * All of the (abstract) meshes added to this scene
  35726. */
  35727. meshes: AbstractMesh[];
  35728. /**
  35729. * The list of skeletons added to the scene
  35730. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35731. */
  35732. skeletons: Skeleton[];
  35733. /**
  35734. * All of the particle systems added to this scene
  35735. * @see http://doc.babylonjs.com/babylon101/particles
  35736. */
  35737. particleSystems: IParticleSystem[];
  35738. /**
  35739. * Gets a list of Animations associated with the scene
  35740. */
  35741. animations: Animation[];
  35742. /**
  35743. * All of the animation groups added to this scene
  35744. * @see http://doc.babylonjs.com/how_to/group
  35745. */
  35746. animationGroups: AnimationGroup[];
  35747. /**
  35748. * All of the multi-materials added to this scene
  35749. * @see http://doc.babylonjs.com/how_to/multi_materials
  35750. */
  35751. multiMaterials: MultiMaterial[];
  35752. /**
  35753. * All of the materials added to this scene
  35754. * In the context of a Scene, it is not supposed to be modified manually.
  35755. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35756. * Note also that the order of the Material wihin the array is not significant and might change.
  35757. * @see http://doc.babylonjs.com/babylon101/materials
  35758. */
  35759. materials: Material[];
  35760. /**
  35761. * The list of morph target managers added to the scene
  35762. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35763. */
  35764. morphTargetManagers: MorphTargetManager[];
  35765. /**
  35766. * The list of geometries used in the scene.
  35767. */
  35768. geometries: Geometry[];
  35769. /**
  35770. * All of the tranform nodes added to this scene
  35771. * In the context of a Scene, it is not supposed to be modified manually.
  35772. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35773. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35774. * @see http://doc.babylonjs.com/how_to/transformnode
  35775. */
  35776. transformNodes: TransformNode[];
  35777. /**
  35778. * ActionManagers available on the scene.
  35779. */
  35780. actionManagers: AbstractActionManager[];
  35781. /**
  35782. * Textures to keep.
  35783. */
  35784. textures: BaseTexture[];
  35785. /**
  35786. * Environment texture for the scene
  35787. */
  35788. environmentTexture: Nullable<BaseTexture>;
  35789. }
  35790. }
  35791. declare module "babylonjs/Audio/sound" {
  35792. import { Observable } from "babylonjs/Misc/observable";
  35793. import { Vector3 } from "babylonjs/Maths/math.vector";
  35794. import { Nullable } from "babylonjs/types";
  35795. import { Scene } from "babylonjs/scene";
  35796. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35797. /**
  35798. * Interface used to define options for Sound class
  35799. */
  35800. export interface ISoundOptions {
  35801. /**
  35802. * Does the sound autoplay once loaded.
  35803. */
  35804. autoplay?: boolean;
  35805. /**
  35806. * Does the sound loop after it finishes playing once.
  35807. */
  35808. loop?: boolean;
  35809. /**
  35810. * Sound's volume
  35811. */
  35812. volume?: number;
  35813. /**
  35814. * Is it a spatial sound?
  35815. */
  35816. spatialSound?: boolean;
  35817. /**
  35818. * Maximum distance to hear that sound
  35819. */
  35820. maxDistance?: number;
  35821. /**
  35822. * Uses user defined attenuation function
  35823. */
  35824. useCustomAttenuation?: boolean;
  35825. /**
  35826. * Define the roll off factor of spatial sounds.
  35827. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35828. */
  35829. rolloffFactor?: number;
  35830. /**
  35831. * Define the reference distance the sound should be heard perfectly.
  35832. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35833. */
  35834. refDistance?: number;
  35835. /**
  35836. * Define the distance attenuation model the sound will follow.
  35837. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35838. */
  35839. distanceModel?: string;
  35840. /**
  35841. * Defines the playback speed (1 by default)
  35842. */
  35843. playbackRate?: number;
  35844. /**
  35845. * Defines if the sound is from a streaming source
  35846. */
  35847. streaming?: boolean;
  35848. /**
  35849. * Defines an optional length (in seconds) inside the sound file
  35850. */
  35851. length?: number;
  35852. /**
  35853. * Defines an optional offset (in seconds) inside the sound file
  35854. */
  35855. offset?: number;
  35856. /**
  35857. * If true, URLs will not be required to state the audio file codec to use.
  35858. */
  35859. skipCodecCheck?: boolean;
  35860. }
  35861. /**
  35862. * Defines a sound that can be played in the application.
  35863. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35864. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35865. */
  35866. export class Sound {
  35867. /**
  35868. * The name of the sound in the scene.
  35869. */
  35870. name: string;
  35871. /**
  35872. * Does the sound autoplay once loaded.
  35873. */
  35874. autoplay: boolean;
  35875. /**
  35876. * Does the sound loop after it finishes playing once.
  35877. */
  35878. loop: boolean;
  35879. /**
  35880. * Does the sound use a custom attenuation curve to simulate the falloff
  35881. * happening when the source gets further away from the camera.
  35882. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35883. */
  35884. useCustomAttenuation: boolean;
  35885. /**
  35886. * The sound track id this sound belongs to.
  35887. */
  35888. soundTrackId: number;
  35889. /**
  35890. * Is this sound currently played.
  35891. */
  35892. isPlaying: boolean;
  35893. /**
  35894. * Is this sound currently paused.
  35895. */
  35896. isPaused: boolean;
  35897. /**
  35898. * Does this sound enables spatial sound.
  35899. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35900. */
  35901. spatialSound: boolean;
  35902. /**
  35903. * Define the reference distance the sound should be heard perfectly.
  35904. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35905. */
  35906. refDistance: number;
  35907. /**
  35908. * Define the roll off factor of spatial sounds.
  35909. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35910. */
  35911. rolloffFactor: number;
  35912. /**
  35913. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35914. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35915. */
  35916. maxDistance: number;
  35917. /**
  35918. * Define the distance attenuation model the sound will follow.
  35919. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35920. */
  35921. distanceModel: string;
  35922. /**
  35923. * @hidden
  35924. * Back Compat
  35925. **/
  35926. onended: () => any;
  35927. /**
  35928. * Observable event when the current playing sound finishes.
  35929. */
  35930. onEndedObservable: Observable<Sound>;
  35931. private _panningModel;
  35932. private _playbackRate;
  35933. private _streaming;
  35934. private _startTime;
  35935. private _startOffset;
  35936. private _position;
  35937. /** @hidden */
  35938. _positionInEmitterSpace: boolean;
  35939. private _localDirection;
  35940. private _volume;
  35941. private _isReadyToPlay;
  35942. private _isDirectional;
  35943. private _readyToPlayCallback;
  35944. private _audioBuffer;
  35945. private _soundSource;
  35946. private _streamingSource;
  35947. private _soundPanner;
  35948. private _soundGain;
  35949. private _inputAudioNode;
  35950. private _outputAudioNode;
  35951. private _coneInnerAngle;
  35952. private _coneOuterAngle;
  35953. private _coneOuterGain;
  35954. private _scene;
  35955. private _connectedTransformNode;
  35956. private _customAttenuationFunction;
  35957. private _registerFunc;
  35958. private _isOutputConnected;
  35959. private _htmlAudioElement;
  35960. private _urlType;
  35961. private _length?;
  35962. private _offset?;
  35963. /** @hidden */
  35964. static _SceneComponentInitialization: (scene: Scene) => void;
  35965. /**
  35966. * Create a sound and attach it to a scene
  35967. * @param name Name of your sound
  35968. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35969. * @param scene defines the scene the sound belongs to
  35970. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35971. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35972. */
  35973. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35974. /**
  35975. * Release the sound and its associated resources
  35976. */
  35977. dispose(): void;
  35978. /**
  35979. * Gets if the sounds is ready to be played or not.
  35980. * @returns true if ready, otherwise false
  35981. */
  35982. isReady(): boolean;
  35983. private _soundLoaded;
  35984. /**
  35985. * Sets the data of the sound from an audiobuffer
  35986. * @param audioBuffer The audioBuffer containing the data
  35987. */
  35988. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35989. /**
  35990. * Updates the current sounds options such as maxdistance, loop...
  35991. * @param options A JSON object containing values named as the object properties
  35992. */
  35993. updateOptions(options: ISoundOptions): void;
  35994. private _createSpatialParameters;
  35995. private _updateSpatialParameters;
  35996. /**
  35997. * Switch the panning model to HRTF:
  35998. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36000. */
  36001. switchPanningModelToHRTF(): void;
  36002. /**
  36003. * Switch the panning model to Equal Power:
  36004. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36006. */
  36007. switchPanningModelToEqualPower(): void;
  36008. private _switchPanningModel;
  36009. /**
  36010. * Connect this sound to a sound track audio node like gain...
  36011. * @param soundTrackAudioNode the sound track audio node to connect to
  36012. */
  36013. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36014. /**
  36015. * Transform this sound into a directional source
  36016. * @param coneInnerAngle Size of the inner cone in degree
  36017. * @param coneOuterAngle Size of the outer cone in degree
  36018. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36019. */
  36020. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36021. /**
  36022. * Gets or sets the inner angle for the directional cone.
  36023. */
  36024. /**
  36025. * Gets or sets the inner angle for the directional cone.
  36026. */
  36027. directionalConeInnerAngle: number;
  36028. /**
  36029. * Gets or sets the outer angle for the directional cone.
  36030. */
  36031. /**
  36032. * Gets or sets the outer angle for the directional cone.
  36033. */
  36034. directionalConeOuterAngle: number;
  36035. /**
  36036. * Sets the position of the emitter if spatial sound is enabled
  36037. * @param newPosition Defines the new posisiton
  36038. */
  36039. setPosition(newPosition: Vector3): void;
  36040. /**
  36041. * Sets the local direction of the emitter if spatial sound is enabled
  36042. * @param newLocalDirection Defines the new local direction
  36043. */
  36044. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36045. private _updateDirection;
  36046. /** @hidden */
  36047. updateDistanceFromListener(): void;
  36048. /**
  36049. * Sets a new custom attenuation function for the sound.
  36050. * @param callback Defines the function used for the attenuation
  36051. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36052. */
  36053. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36054. /**
  36055. * Play the sound
  36056. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36057. * @param offset (optional) Start the sound at a specific time in seconds
  36058. * @param length (optional) Sound duration (in seconds)
  36059. */
  36060. play(time?: number, offset?: number, length?: number): void;
  36061. private _onended;
  36062. /**
  36063. * Stop the sound
  36064. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36065. */
  36066. stop(time?: number): void;
  36067. /**
  36068. * Put the sound in pause
  36069. */
  36070. pause(): void;
  36071. /**
  36072. * Sets a dedicated volume for this sounds
  36073. * @param newVolume Define the new volume of the sound
  36074. * @param time Define time for gradual change to new volume
  36075. */
  36076. setVolume(newVolume: number, time?: number): void;
  36077. /**
  36078. * Set the sound play back rate
  36079. * @param newPlaybackRate Define the playback rate the sound should be played at
  36080. */
  36081. setPlaybackRate(newPlaybackRate: number): void;
  36082. /**
  36083. * Gets the volume of the sound.
  36084. * @returns the volume of the sound
  36085. */
  36086. getVolume(): number;
  36087. /**
  36088. * Attach the sound to a dedicated mesh
  36089. * @param transformNode The transform node to connect the sound with
  36090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36091. */
  36092. attachToMesh(transformNode: TransformNode): void;
  36093. /**
  36094. * Detach the sound from the previously attached mesh
  36095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36096. */
  36097. detachFromMesh(): void;
  36098. private _onRegisterAfterWorldMatrixUpdate;
  36099. /**
  36100. * Clone the current sound in the scene.
  36101. * @returns the new sound clone
  36102. */
  36103. clone(): Nullable<Sound>;
  36104. /**
  36105. * Gets the current underlying audio buffer containing the data
  36106. * @returns the audio buffer
  36107. */
  36108. getAudioBuffer(): Nullable<AudioBuffer>;
  36109. /**
  36110. * Serializes the Sound in a JSON representation
  36111. * @returns the JSON representation of the sound
  36112. */
  36113. serialize(): any;
  36114. /**
  36115. * Parse a JSON representation of a sound to innstantiate in a given scene
  36116. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36117. * @param scene Define the scene the new parsed sound should be created in
  36118. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36119. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36120. * @returns the newly parsed sound
  36121. */
  36122. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36123. }
  36124. }
  36125. declare module "babylonjs/Actions/directAudioActions" {
  36126. import { Action } from "babylonjs/Actions/action";
  36127. import { Condition } from "babylonjs/Actions/condition";
  36128. import { Sound } from "babylonjs/Audio/sound";
  36129. /**
  36130. * This defines an action helpful to play a defined sound on a triggered action.
  36131. */
  36132. export class PlaySoundAction extends Action {
  36133. private _sound;
  36134. /**
  36135. * Instantiate the action
  36136. * @param triggerOptions defines the trigger options
  36137. * @param sound defines the sound to play
  36138. * @param condition defines the trigger related conditions
  36139. */
  36140. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36141. /** @hidden */
  36142. _prepare(): void;
  36143. /**
  36144. * Execute the action and play the sound.
  36145. */
  36146. execute(): void;
  36147. /**
  36148. * Serializes the actions and its related information.
  36149. * @param parent defines the object to serialize in
  36150. * @returns the serialized object
  36151. */
  36152. serialize(parent: any): any;
  36153. }
  36154. /**
  36155. * This defines an action helpful to stop a defined sound on a triggered action.
  36156. */
  36157. export class StopSoundAction extends Action {
  36158. private _sound;
  36159. /**
  36160. * Instantiate the action
  36161. * @param triggerOptions defines the trigger options
  36162. * @param sound defines the sound to stop
  36163. * @param condition defines the trigger related conditions
  36164. */
  36165. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36166. /** @hidden */
  36167. _prepare(): void;
  36168. /**
  36169. * Execute the action and stop the sound.
  36170. */
  36171. execute(): void;
  36172. /**
  36173. * Serializes the actions and its related information.
  36174. * @param parent defines the object to serialize in
  36175. * @returns the serialized object
  36176. */
  36177. serialize(parent: any): any;
  36178. }
  36179. }
  36180. declare module "babylonjs/Actions/interpolateValueAction" {
  36181. import { Action } from "babylonjs/Actions/action";
  36182. import { Condition } from "babylonjs/Actions/condition";
  36183. import { Observable } from "babylonjs/Misc/observable";
  36184. /**
  36185. * This defines an action responsible to change the value of a property
  36186. * by interpolating between its current value and the newly set one once triggered.
  36187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36188. */
  36189. export class InterpolateValueAction extends Action {
  36190. /**
  36191. * Defines the path of the property where the value should be interpolated
  36192. */
  36193. propertyPath: string;
  36194. /**
  36195. * Defines the target value at the end of the interpolation.
  36196. */
  36197. value: any;
  36198. /**
  36199. * Defines the time it will take for the property to interpolate to the value.
  36200. */
  36201. duration: number;
  36202. /**
  36203. * Defines if the other scene animations should be stopped when the action has been triggered
  36204. */
  36205. stopOtherAnimations?: boolean;
  36206. /**
  36207. * Defines a callback raised once the interpolation animation has been done.
  36208. */
  36209. onInterpolationDone?: () => void;
  36210. /**
  36211. * Observable triggered once the interpolation animation has been done.
  36212. */
  36213. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36214. private _target;
  36215. private _effectiveTarget;
  36216. private _property;
  36217. /**
  36218. * Instantiate the action
  36219. * @param triggerOptions defines the trigger options
  36220. * @param target defines the object containing the value to interpolate
  36221. * @param propertyPath defines the path to the property in the target object
  36222. * @param value defines the target value at the end of the interpolation
  36223. * @param duration deines the time it will take for the property to interpolate to the value.
  36224. * @param condition defines the trigger related conditions
  36225. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36226. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36227. */
  36228. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36229. /** @hidden */
  36230. _prepare(): void;
  36231. /**
  36232. * Execute the action starts the value interpolation.
  36233. */
  36234. execute(): void;
  36235. /**
  36236. * Serializes the actions and its related information.
  36237. * @param parent defines the object to serialize in
  36238. * @returns the serialized object
  36239. */
  36240. serialize(parent: any): any;
  36241. }
  36242. }
  36243. declare module "babylonjs/Actions/index" {
  36244. export * from "babylonjs/Actions/abstractActionManager";
  36245. export * from "babylonjs/Actions/action";
  36246. export * from "babylonjs/Actions/actionEvent";
  36247. export * from "babylonjs/Actions/actionManager";
  36248. export * from "babylonjs/Actions/condition";
  36249. export * from "babylonjs/Actions/directActions";
  36250. export * from "babylonjs/Actions/directAudioActions";
  36251. export * from "babylonjs/Actions/interpolateValueAction";
  36252. }
  36253. declare module "babylonjs/Animations/index" {
  36254. export * from "babylonjs/Animations/animatable";
  36255. export * from "babylonjs/Animations/animation";
  36256. export * from "babylonjs/Animations/animationGroup";
  36257. export * from "babylonjs/Animations/animationPropertiesOverride";
  36258. export * from "babylonjs/Animations/easing";
  36259. export * from "babylonjs/Animations/runtimeAnimation";
  36260. export * from "babylonjs/Animations/animationEvent";
  36261. export * from "babylonjs/Animations/animationGroup";
  36262. export * from "babylonjs/Animations/animationKey";
  36263. export * from "babylonjs/Animations/animationRange";
  36264. export * from "babylonjs/Animations/animatable.interface";
  36265. }
  36266. declare module "babylonjs/Audio/soundTrack" {
  36267. import { Sound } from "babylonjs/Audio/sound";
  36268. import { Analyser } from "babylonjs/Audio/analyser";
  36269. import { Scene } from "babylonjs/scene";
  36270. /**
  36271. * Options allowed during the creation of a sound track.
  36272. */
  36273. export interface ISoundTrackOptions {
  36274. /**
  36275. * The volume the sound track should take during creation
  36276. */
  36277. volume?: number;
  36278. /**
  36279. * Define if the sound track is the main sound track of the scene
  36280. */
  36281. mainTrack?: boolean;
  36282. }
  36283. /**
  36284. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36285. * It will be also used in a future release to apply effects on a specific track.
  36286. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36287. */
  36288. export class SoundTrack {
  36289. /**
  36290. * The unique identifier of the sound track in the scene.
  36291. */
  36292. id: number;
  36293. /**
  36294. * The list of sounds included in the sound track.
  36295. */
  36296. soundCollection: Array<Sound>;
  36297. private _outputAudioNode;
  36298. private _scene;
  36299. private _isMainTrack;
  36300. private _connectedAnalyser;
  36301. private _options;
  36302. private _isInitialized;
  36303. /**
  36304. * Creates a new sound track.
  36305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36306. * @param scene Define the scene the sound track belongs to
  36307. * @param options
  36308. */
  36309. constructor(scene: Scene, options?: ISoundTrackOptions);
  36310. private _initializeSoundTrackAudioGraph;
  36311. /**
  36312. * Release the sound track and its associated resources
  36313. */
  36314. dispose(): void;
  36315. /**
  36316. * Adds a sound to this sound track
  36317. * @param sound define the cound to add
  36318. * @ignoreNaming
  36319. */
  36320. AddSound(sound: Sound): void;
  36321. /**
  36322. * Removes a sound to this sound track
  36323. * @param sound define the cound to remove
  36324. * @ignoreNaming
  36325. */
  36326. RemoveSound(sound: Sound): void;
  36327. /**
  36328. * Set a global volume for the full sound track.
  36329. * @param newVolume Define the new volume of the sound track
  36330. */
  36331. setVolume(newVolume: number): void;
  36332. /**
  36333. * Switch the panning model to HRTF:
  36334. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36335. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36336. */
  36337. switchPanningModelToHRTF(): void;
  36338. /**
  36339. * Switch the panning model to Equal Power:
  36340. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36341. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36342. */
  36343. switchPanningModelToEqualPower(): void;
  36344. /**
  36345. * Connect the sound track to an audio analyser allowing some amazing
  36346. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36347. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36348. * @param analyser The analyser to connect to the engine
  36349. */
  36350. connectToAnalyser(analyser: Analyser): void;
  36351. }
  36352. }
  36353. declare module "babylonjs/Audio/audioSceneComponent" {
  36354. import { Sound } from "babylonjs/Audio/sound";
  36355. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36356. import { Nullable } from "babylonjs/types";
  36357. import { Vector3 } from "babylonjs/Maths/math.vector";
  36358. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36359. import { Scene } from "babylonjs/scene";
  36360. import { AbstractScene } from "babylonjs/abstractScene";
  36361. import "babylonjs/Audio/audioEngine";
  36362. module "babylonjs/abstractScene" {
  36363. interface AbstractScene {
  36364. /**
  36365. * The list of sounds used in the scene.
  36366. */
  36367. sounds: Nullable<Array<Sound>>;
  36368. }
  36369. }
  36370. module "babylonjs/scene" {
  36371. interface Scene {
  36372. /**
  36373. * @hidden
  36374. * Backing field
  36375. */
  36376. _mainSoundTrack: SoundTrack;
  36377. /**
  36378. * The main sound track played by the scene.
  36379. * It cotains your primary collection of sounds.
  36380. */
  36381. mainSoundTrack: SoundTrack;
  36382. /**
  36383. * The list of sound tracks added to the scene
  36384. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36385. */
  36386. soundTracks: Nullable<Array<SoundTrack>>;
  36387. /**
  36388. * Gets a sound using a given name
  36389. * @param name defines the name to search for
  36390. * @return the found sound or null if not found at all.
  36391. */
  36392. getSoundByName(name: string): Nullable<Sound>;
  36393. /**
  36394. * Gets or sets if audio support is enabled
  36395. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36396. */
  36397. audioEnabled: boolean;
  36398. /**
  36399. * Gets or sets if audio will be output to headphones
  36400. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36401. */
  36402. headphone: boolean;
  36403. /**
  36404. * Gets or sets custom audio listener position provider
  36405. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36406. */
  36407. audioListenerPositionProvider: Nullable<() => Vector3>;
  36408. }
  36409. }
  36410. /**
  36411. * Defines the sound scene component responsible to manage any sounds
  36412. * in a given scene.
  36413. */
  36414. export class AudioSceneComponent implements ISceneSerializableComponent {
  36415. /**
  36416. * The component name helpfull to identify the component in the list of scene components.
  36417. */
  36418. readonly name: string;
  36419. /**
  36420. * The scene the component belongs to.
  36421. */
  36422. scene: Scene;
  36423. private _audioEnabled;
  36424. /**
  36425. * Gets whether audio is enabled or not.
  36426. * Please use related enable/disable method to switch state.
  36427. */
  36428. readonly audioEnabled: boolean;
  36429. private _headphone;
  36430. /**
  36431. * Gets whether audio is outputing to headphone or not.
  36432. * Please use the according Switch methods to change output.
  36433. */
  36434. readonly headphone: boolean;
  36435. private _audioListenerPositionProvider;
  36436. /**
  36437. * Gets the current audio listener position provider
  36438. */
  36439. /**
  36440. * Sets a custom listener position for all sounds in the scene
  36441. * By default, this is the position of the first active camera
  36442. */
  36443. audioListenerPositionProvider: Nullable<() => Vector3>;
  36444. /**
  36445. * Creates a new instance of the component for the given scene
  36446. * @param scene Defines the scene to register the component in
  36447. */
  36448. constructor(scene: Scene);
  36449. /**
  36450. * Registers the component in a given scene
  36451. */
  36452. register(): void;
  36453. /**
  36454. * Rebuilds the elements related to this component in case of
  36455. * context lost for instance.
  36456. */
  36457. rebuild(): void;
  36458. /**
  36459. * Serializes the component data to the specified json object
  36460. * @param serializationObject The object to serialize to
  36461. */
  36462. serialize(serializationObject: any): void;
  36463. /**
  36464. * Adds all the elements from the container to the scene
  36465. * @param container the container holding the elements
  36466. */
  36467. addFromContainer(container: AbstractScene): void;
  36468. /**
  36469. * Removes all the elements in the container from the scene
  36470. * @param container contains the elements to remove
  36471. * @param dispose if the removed element should be disposed (default: false)
  36472. */
  36473. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36474. /**
  36475. * Disposes the component and the associated ressources.
  36476. */
  36477. dispose(): void;
  36478. /**
  36479. * Disables audio in the associated scene.
  36480. */
  36481. disableAudio(): void;
  36482. /**
  36483. * Enables audio in the associated scene.
  36484. */
  36485. enableAudio(): void;
  36486. /**
  36487. * Switch audio to headphone output.
  36488. */
  36489. switchAudioModeForHeadphones(): void;
  36490. /**
  36491. * Switch audio to normal speakers.
  36492. */
  36493. switchAudioModeForNormalSpeakers(): void;
  36494. private _afterRender;
  36495. }
  36496. }
  36497. declare module "babylonjs/Audio/weightedsound" {
  36498. import { Sound } from "babylonjs/Audio/sound";
  36499. /**
  36500. * Wraps one or more Sound objects and selects one with random weight for playback.
  36501. */
  36502. export class WeightedSound {
  36503. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36504. loop: boolean;
  36505. private _coneInnerAngle;
  36506. private _coneOuterAngle;
  36507. private _volume;
  36508. /** A Sound is currently playing. */
  36509. isPlaying: boolean;
  36510. /** A Sound is currently paused. */
  36511. isPaused: boolean;
  36512. private _sounds;
  36513. private _weights;
  36514. private _currentIndex?;
  36515. /**
  36516. * Creates a new WeightedSound from the list of sounds given.
  36517. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36518. * @param sounds Array of Sounds that will be selected from.
  36519. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36520. */
  36521. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36522. /**
  36523. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36524. */
  36525. /**
  36526. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36527. */
  36528. directionalConeInnerAngle: number;
  36529. /**
  36530. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36531. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36532. */
  36533. /**
  36534. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36535. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36536. */
  36537. directionalConeOuterAngle: number;
  36538. /**
  36539. * Playback volume.
  36540. */
  36541. /**
  36542. * Playback volume.
  36543. */
  36544. volume: number;
  36545. private _onended;
  36546. /**
  36547. * Suspend playback
  36548. */
  36549. pause(): void;
  36550. /**
  36551. * Stop playback
  36552. */
  36553. stop(): void;
  36554. /**
  36555. * Start playback.
  36556. * @param startOffset Position the clip head at a specific time in seconds.
  36557. */
  36558. play(startOffset?: number): void;
  36559. }
  36560. }
  36561. declare module "babylonjs/Audio/index" {
  36562. export * from "babylonjs/Audio/analyser";
  36563. export * from "babylonjs/Audio/audioEngine";
  36564. export * from "babylonjs/Audio/audioSceneComponent";
  36565. export * from "babylonjs/Audio/sound";
  36566. export * from "babylonjs/Audio/soundTrack";
  36567. export * from "babylonjs/Audio/weightedsound";
  36568. }
  36569. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36570. import { Behavior } from "babylonjs/Behaviors/behavior";
  36571. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36572. import { BackEase } from "babylonjs/Animations/easing";
  36573. /**
  36574. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36575. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36576. */
  36577. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36578. /**
  36579. * Gets the name of the behavior.
  36580. */
  36581. readonly name: string;
  36582. /**
  36583. * The easing function used by animations
  36584. */
  36585. static EasingFunction: BackEase;
  36586. /**
  36587. * The easing mode used by animations
  36588. */
  36589. static EasingMode: number;
  36590. /**
  36591. * The duration of the animation, in milliseconds
  36592. */
  36593. transitionDuration: number;
  36594. /**
  36595. * Length of the distance animated by the transition when lower radius is reached
  36596. */
  36597. lowerRadiusTransitionRange: number;
  36598. /**
  36599. * Length of the distance animated by the transition when upper radius is reached
  36600. */
  36601. upperRadiusTransitionRange: number;
  36602. private _autoTransitionRange;
  36603. /**
  36604. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36605. */
  36606. /**
  36607. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36608. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36609. */
  36610. autoTransitionRange: boolean;
  36611. private _attachedCamera;
  36612. private _onAfterCheckInputsObserver;
  36613. private _onMeshTargetChangedObserver;
  36614. /**
  36615. * Initializes the behavior.
  36616. */
  36617. init(): void;
  36618. /**
  36619. * Attaches the behavior to its arc rotate camera.
  36620. * @param camera Defines the camera to attach the behavior to
  36621. */
  36622. attach(camera: ArcRotateCamera): void;
  36623. /**
  36624. * Detaches the behavior from its current arc rotate camera.
  36625. */
  36626. detach(): void;
  36627. private _radiusIsAnimating;
  36628. private _radiusBounceTransition;
  36629. private _animatables;
  36630. private _cachedWheelPrecision;
  36631. /**
  36632. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36633. * @param radiusLimit The limit to check against.
  36634. * @return Bool to indicate if at limit.
  36635. */
  36636. private _isRadiusAtLimit;
  36637. /**
  36638. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36639. * @param radiusDelta The delta by which to animate to. Can be negative.
  36640. */
  36641. private _applyBoundRadiusAnimation;
  36642. /**
  36643. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36644. */
  36645. protected _clearAnimationLocks(): void;
  36646. /**
  36647. * Stops and removes all animations that have been applied to the camera
  36648. */
  36649. stopAllAnimations(): void;
  36650. }
  36651. }
  36652. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36653. import { Behavior } from "babylonjs/Behaviors/behavior";
  36654. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36655. import { ExponentialEase } from "babylonjs/Animations/easing";
  36656. import { Nullable } from "babylonjs/types";
  36657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36658. import { Vector3 } from "babylonjs/Maths/math.vector";
  36659. /**
  36660. * 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.
  36661. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36662. */
  36663. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36664. /**
  36665. * Gets the name of the behavior.
  36666. */
  36667. readonly name: string;
  36668. private _mode;
  36669. private _radiusScale;
  36670. private _positionScale;
  36671. private _defaultElevation;
  36672. private _elevationReturnTime;
  36673. private _elevationReturnWaitTime;
  36674. private _zoomStopsAnimation;
  36675. private _framingTime;
  36676. /**
  36677. * The easing function used by animations
  36678. */
  36679. static EasingFunction: ExponentialEase;
  36680. /**
  36681. * The easing mode used by animations
  36682. */
  36683. static EasingMode: number;
  36684. /**
  36685. * Sets the current mode used by the behavior
  36686. */
  36687. /**
  36688. * Gets current mode used by the behavior.
  36689. */
  36690. mode: number;
  36691. /**
  36692. * Sets the scale applied to the radius (1 by default)
  36693. */
  36694. /**
  36695. * Gets the scale applied to the radius
  36696. */
  36697. radiusScale: number;
  36698. /**
  36699. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36700. */
  36701. /**
  36702. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36703. */
  36704. positionScale: number;
  36705. /**
  36706. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36707. * behaviour is triggered, in radians.
  36708. */
  36709. /**
  36710. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36711. * behaviour is triggered, in radians.
  36712. */
  36713. defaultElevation: number;
  36714. /**
  36715. * Sets the time (in milliseconds) taken to return to the default beta position.
  36716. * Negative value indicates camera should not return to default.
  36717. */
  36718. /**
  36719. * Gets the time (in milliseconds) taken to return to the default beta position.
  36720. * Negative value indicates camera should not return to default.
  36721. */
  36722. elevationReturnTime: number;
  36723. /**
  36724. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36725. */
  36726. /**
  36727. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36728. */
  36729. elevationReturnWaitTime: number;
  36730. /**
  36731. * Sets the flag that indicates if user zooming should stop animation.
  36732. */
  36733. /**
  36734. * Gets the flag that indicates if user zooming should stop animation.
  36735. */
  36736. zoomStopsAnimation: boolean;
  36737. /**
  36738. * Sets the transition time when framing the mesh, in milliseconds
  36739. */
  36740. /**
  36741. * Gets the transition time when framing the mesh, in milliseconds
  36742. */
  36743. framingTime: number;
  36744. /**
  36745. * Define if the behavior should automatically change the configured
  36746. * camera limits and sensibilities.
  36747. */
  36748. autoCorrectCameraLimitsAndSensibility: boolean;
  36749. private _onPrePointerObservableObserver;
  36750. private _onAfterCheckInputsObserver;
  36751. private _onMeshTargetChangedObserver;
  36752. private _attachedCamera;
  36753. private _isPointerDown;
  36754. private _lastInteractionTime;
  36755. /**
  36756. * Initializes the behavior.
  36757. */
  36758. init(): void;
  36759. /**
  36760. * Attaches the behavior to its arc rotate camera.
  36761. * @param camera Defines the camera to attach the behavior to
  36762. */
  36763. attach(camera: ArcRotateCamera): void;
  36764. /**
  36765. * Detaches the behavior from its current arc rotate camera.
  36766. */
  36767. detach(): void;
  36768. private _animatables;
  36769. private _betaIsAnimating;
  36770. private _betaTransition;
  36771. private _radiusTransition;
  36772. private _vectorTransition;
  36773. /**
  36774. * Targets the given mesh and updates zoom level accordingly.
  36775. * @param mesh The mesh to target.
  36776. * @param radius Optional. If a cached radius position already exists, overrides default.
  36777. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36778. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36779. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36780. */
  36781. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36782. /**
  36783. * Targets the given mesh with its children and updates zoom level accordingly.
  36784. * @param mesh The mesh to target.
  36785. * @param radius Optional. If a cached radius position already exists, overrides default.
  36786. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36787. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36788. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36789. */
  36790. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36791. /**
  36792. * Targets the given meshes with their children and updates zoom level accordingly.
  36793. * @param meshes The mesh to target.
  36794. * @param radius Optional. If a cached radius position already exists, overrides default.
  36795. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36796. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36797. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36798. */
  36799. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36800. /**
  36801. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36802. * @param minimumWorld Determines the smaller position of the bounding box extend
  36803. * @param maximumWorld Determines the bigger position of the bounding box extend
  36804. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36805. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36806. */
  36807. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36808. /**
  36809. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36810. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36811. * frustum width.
  36812. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36813. * to fully enclose the mesh in the viewing frustum.
  36814. */
  36815. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36816. /**
  36817. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36818. * is automatically returned to its default position (expected to be above ground plane).
  36819. */
  36820. private _maintainCameraAboveGround;
  36821. /**
  36822. * Returns the frustum slope based on the canvas ratio and camera FOV
  36823. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36824. */
  36825. private _getFrustumSlope;
  36826. /**
  36827. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36828. */
  36829. private _clearAnimationLocks;
  36830. /**
  36831. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36832. */
  36833. private _applyUserInteraction;
  36834. /**
  36835. * Stops and removes all animations that have been applied to the camera
  36836. */
  36837. stopAllAnimations(): void;
  36838. /**
  36839. * Gets a value indicating if the user is moving the camera
  36840. */
  36841. readonly isUserIsMoving: boolean;
  36842. /**
  36843. * The camera can move all the way towards the mesh.
  36844. */
  36845. static IgnoreBoundsSizeMode: number;
  36846. /**
  36847. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36848. */
  36849. static FitFrustumSidesMode: number;
  36850. }
  36851. }
  36852. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36853. import { Nullable } from "babylonjs/types";
  36854. import { Camera } from "babylonjs/Cameras/camera";
  36855. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36856. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36857. /**
  36858. * Base class for Camera Pointer Inputs.
  36859. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36860. * for example usage.
  36861. */
  36862. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36863. /**
  36864. * Defines the camera the input is attached to.
  36865. */
  36866. abstract camera: Camera;
  36867. /**
  36868. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36869. */
  36870. protected _altKey: boolean;
  36871. protected _ctrlKey: boolean;
  36872. protected _metaKey: boolean;
  36873. protected _shiftKey: boolean;
  36874. /**
  36875. * Which mouse buttons were pressed at time of last mouse event.
  36876. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36877. */
  36878. protected _buttonsPressed: number;
  36879. /**
  36880. * Defines the buttons associated with the input to handle camera move.
  36881. */
  36882. buttons: number[];
  36883. /**
  36884. * Attach the input controls to a specific dom element to get the input from.
  36885. * @param element Defines the element the controls should be listened from
  36886. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36887. */
  36888. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36889. /**
  36890. * Detach the current controls from the specified dom element.
  36891. * @param element Defines the element to stop listening the inputs from
  36892. */
  36893. detachControl(element: Nullable<HTMLElement>): void;
  36894. /**
  36895. * Gets the class name of the current input.
  36896. * @returns the class name
  36897. */
  36898. getClassName(): string;
  36899. /**
  36900. * Get the friendly name associated with the input class.
  36901. * @returns the input friendly name
  36902. */
  36903. getSimpleName(): string;
  36904. /**
  36905. * Called on pointer POINTERDOUBLETAP event.
  36906. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36907. */
  36908. protected onDoubleTap(type: string): void;
  36909. /**
  36910. * Called on pointer POINTERMOVE event if only a single touch is active.
  36911. * Override this method to provide functionality.
  36912. */
  36913. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36914. /**
  36915. * Called on pointer POINTERMOVE event if multiple touches are active.
  36916. * Override this method to provide functionality.
  36917. */
  36918. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36919. /**
  36920. * Called on JS contextmenu event.
  36921. * Override this method to provide functionality.
  36922. */
  36923. protected onContextMenu(evt: PointerEvent): void;
  36924. /**
  36925. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36926. * press.
  36927. * Override this method to provide functionality.
  36928. */
  36929. protected onButtonDown(evt: PointerEvent): void;
  36930. /**
  36931. * Called each time a new POINTERUP event occurs. Ie, for each button
  36932. * release.
  36933. * Override this method to provide functionality.
  36934. */
  36935. protected onButtonUp(evt: PointerEvent): void;
  36936. /**
  36937. * Called when window becomes inactive.
  36938. * Override this method to provide functionality.
  36939. */
  36940. protected onLostFocus(): void;
  36941. private _pointerInput;
  36942. private _observer;
  36943. private _onLostFocus;
  36944. private pointA;
  36945. private pointB;
  36946. }
  36947. }
  36948. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36949. import { Nullable } from "babylonjs/types";
  36950. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36951. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36952. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36953. /**
  36954. * Manage the pointers inputs to control an arc rotate camera.
  36955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36956. */
  36957. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36958. /**
  36959. * Defines the camera the input is attached to.
  36960. */
  36961. camera: ArcRotateCamera;
  36962. /**
  36963. * Gets the class name of the current input.
  36964. * @returns the class name
  36965. */
  36966. getClassName(): string;
  36967. /**
  36968. * Defines the buttons associated with the input to handle camera move.
  36969. */
  36970. buttons: number[];
  36971. /**
  36972. * Defines the pointer angular sensibility along the X axis or how fast is
  36973. * the camera rotating.
  36974. */
  36975. angularSensibilityX: number;
  36976. /**
  36977. * Defines the pointer angular sensibility along the Y axis or how fast is
  36978. * the camera rotating.
  36979. */
  36980. angularSensibilityY: number;
  36981. /**
  36982. * Defines the pointer pinch precision or how fast is the camera zooming.
  36983. */
  36984. pinchPrecision: number;
  36985. /**
  36986. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36987. * from 0.
  36988. * It defines the percentage of current camera.radius to use as delta when
  36989. * pinch zoom is used.
  36990. */
  36991. pinchDeltaPercentage: number;
  36992. /**
  36993. * Defines the pointer panning sensibility or how fast is the camera moving.
  36994. */
  36995. panningSensibility: number;
  36996. /**
  36997. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36998. */
  36999. multiTouchPanning: boolean;
  37000. /**
  37001. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37002. * zoom (pinch) through multitouch.
  37003. */
  37004. multiTouchPanAndZoom: boolean;
  37005. /**
  37006. * Revers pinch action direction.
  37007. */
  37008. pinchInwards: boolean;
  37009. private _isPanClick;
  37010. private _twoFingerActivityCount;
  37011. private _isPinching;
  37012. /**
  37013. * Called on pointer POINTERMOVE event if only a single touch is active.
  37014. */
  37015. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37016. /**
  37017. * Called on pointer POINTERDOUBLETAP event.
  37018. */
  37019. protected onDoubleTap(type: string): void;
  37020. /**
  37021. * Called on pointer POINTERMOVE event if multiple touches are active.
  37022. */
  37023. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37024. /**
  37025. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37026. * press.
  37027. */
  37028. protected onButtonDown(evt: PointerEvent): void;
  37029. /**
  37030. * Called each time a new POINTERUP event occurs. Ie, for each button
  37031. * release.
  37032. */
  37033. protected onButtonUp(evt: PointerEvent): void;
  37034. /**
  37035. * Called when window becomes inactive.
  37036. */
  37037. protected onLostFocus(): void;
  37038. }
  37039. }
  37040. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37041. import { Nullable } from "babylonjs/types";
  37042. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37043. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37044. /**
  37045. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37046. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37047. */
  37048. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37049. /**
  37050. * Defines the camera the input is attached to.
  37051. */
  37052. camera: ArcRotateCamera;
  37053. /**
  37054. * Defines the list of key codes associated with the up action (increase alpha)
  37055. */
  37056. keysUp: number[];
  37057. /**
  37058. * Defines the list of key codes associated with the down action (decrease alpha)
  37059. */
  37060. keysDown: number[];
  37061. /**
  37062. * Defines the list of key codes associated with the left action (increase beta)
  37063. */
  37064. keysLeft: number[];
  37065. /**
  37066. * Defines the list of key codes associated with the right action (decrease beta)
  37067. */
  37068. keysRight: number[];
  37069. /**
  37070. * Defines the list of key codes associated with the reset action.
  37071. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37072. */
  37073. keysReset: number[];
  37074. /**
  37075. * Defines the panning sensibility of the inputs.
  37076. * (How fast is the camera paning)
  37077. */
  37078. panningSensibility: number;
  37079. /**
  37080. * Defines the zooming sensibility of the inputs.
  37081. * (How fast is the camera zooming)
  37082. */
  37083. zoomingSensibility: number;
  37084. /**
  37085. * Defines wether maintaining the alt key down switch the movement mode from
  37086. * orientation to zoom.
  37087. */
  37088. useAltToZoom: boolean;
  37089. /**
  37090. * Rotation speed of the camera
  37091. */
  37092. angularSpeed: number;
  37093. private _keys;
  37094. private _ctrlPressed;
  37095. private _altPressed;
  37096. private _onCanvasBlurObserver;
  37097. private _onKeyboardObserver;
  37098. private _engine;
  37099. private _scene;
  37100. /**
  37101. * Attach the input controls to a specific dom element to get the input from.
  37102. * @param element Defines the element the controls should be listened from
  37103. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37104. */
  37105. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37106. /**
  37107. * Detach the current controls from the specified dom element.
  37108. * @param element Defines the element to stop listening the inputs from
  37109. */
  37110. detachControl(element: Nullable<HTMLElement>): void;
  37111. /**
  37112. * Update the current camera state depending on the inputs that have been used this frame.
  37113. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37114. */
  37115. checkInputs(): void;
  37116. /**
  37117. * Gets the class name of the current intput.
  37118. * @returns the class name
  37119. */
  37120. getClassName(): string;
  37121. /**
  37122. * Get the friendly name associated with the input class.
  37123. * @returns the input friendly name
  37124. */
  37125. getSimpleName(): string;
  37126. }
  37127. }
  37128. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37129. import { Nullable } from "babylonjs/types";
  37130. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37131. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37132. /**
  37133. * Manage the mouse wheel inputs to control an arc rotate camera.
  37134. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37135. */
  37136. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37137. /**
  37138. * Defines the camera the input is attached to.
  37139. */
  37140. camera: ArcRotateCamera;
  37141. /**
  37142. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37143. */
  37144. wheelPrecision: number;
  37145. /**
  37146. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37147. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37148. */
  37149. wheelDeltaPercentage: number;
  37150. private _wheel;
  37151. private _observer;
  37152. private computeDeltaFromMouseWheelLegacyEvent;
  37153. /**
  37154. * Attach the input controls to a specific dom element to get the input from.
  37155. * @param element Defines the element the controls should be listened from
  37156. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37157. */
  37158. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37159. /**
  37160. * Detach the current controls from the specified dom element.
  37161. * @param element Defines the element to stop listening the inputs from
  37162. */
  37163. detachControl(element: Nullable<HTMLElement>): void;
  37164. /**
  37165. * Gets the class name of the current intput.
  37166. * @returns the class name
  37167. */
  37168. getClassName(): string;
  37169. /**
  37170. * Get the friendly name associated with the input class.
  37171. * @returns the input friendly name
  37172. */
  37173. getSimpleName(): string;
  37174. }
  37175. }
  37176. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37177. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37178. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37179. /**
  37180. * Default Inputs manager for the ArcRotateCamera.
  37181. * It groups all the default supported inputs for ease of use.
  37182. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37183. */
  37184. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37185. /**
  37186. * Instantiates a new ArcRotateCameraInputsManager.
  37187. * @param camera Defines the camera the inputs belong to
  37188. */
  37189. constructor(camera: ArcRotateCamera);
  37190. /**
  37191. * Add mouse wheel input support to the input manager.
  37192. * @returns the current input manager
  37193. */
  37194. addMouseWheel(): ArcRotateCameraInputsManager;
  37195. /**
  37196. * Add pointers input support to the input manager.
  37197. * @returns the current input manager
  37198. */
  37199. addPointers(): ArcRotateCameraInputsManager;
  37200. /**
  37201. * Add keyboard input support to the input manager.
  37202. * @returns the current input manager
  37203. */
  37204. addKeyboard(): ArcRotateCameraInputsManager;
  37205. }
  37206. }
  37207. declare module "babylonjs/Cameras/arcRotateCamera" {
  37208. import { Observable } from "babylonjs/Misc/observable";
  37209. import { Nullable } from "babylonjs/types";
  37210. import { Scene } from "babylonjs/scene";
  37211. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37213. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37214. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37215. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37216. import { Camera } from "babylonjs/Cameras/camera";
  37217. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37218. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37219. import { Collider } from "babylonjs/Collisions/collider";
  37220. /**
  37221. * This represents an orbital type of camera.
  37222. *
  37223. * 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.
  37224. * 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.
  37225. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37226. */
  37227. export class ArcRotateCamera extends TargetCamera {
  37228. /**
  37229. * Defines the rotation angle of the camera along the longitudinal axis.
  37230. */
  37231. alpha: number;
  37232. /**
  37233. * Defines the rotation angle of the camera along the latitudinal axis.
  37234. */
  37235. beta: number;
  37236. /**
  37237. * Defines the radius of the camera from it s target point.
  37238. */
  37239. radius: number;
  37240. protected _target: Vector3;
  37241. protected _targetHost: Nullable<AbstractMesh>;
  37242. /**
  37243. * Defines the target point of the camera.
  37244. * The camera looks towards it form the radius distance.
  37245. */
  37246. target: Vector3;
  37247. /**
  37248. * Define the current local position of the camera in the scene
  37249. */
  37250. position: Vector3;
  37251. protected _upVector: Vector3;
  37252. protected _upToYMatrix: Matrix;
  37253. protected _YToUpMatrix: Matrix;
  37254. /**
  37255. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37256. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37257. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37258. */
  37259. upVector: Vector3;
  37260. /**
  37261. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37262. */
  37263. setMatUp(): void;
  37264. /**
  37265. * Current inertia value on the longitudinal axis.
  37266. * The bigger this number the longer it will take for the camera to stop.
  37267. */
  37268. inertialAlphaOffset: number;
  37269. /**
  37270. * Current inertia value on the latitudinal axis.
  37271. * The bigger this number the longer it will take for the camera to stop.
  37272. */
  37273. inertialBetaOffset: number;
  37274. /**
  37275. * Current inertia value on the radius axis.
  37276. * The bigger this number the longer it will take for the camera to stop.
  37277. */
  37278. inertialRadiusOffset: number;
  37279. /**
  37280. * Minimum allowed angle on the longitudinal axis.
  37281. * This can help limiting how the Camera is able to move in the scene.
  37282. */
  37283. lowerAlphaLimit: Nullable<number>;
  37284. /**
  37285. * Maximum allowed angle on the longitudinal axis.
  37286. * This can help limiting how the Camera is able to move in the scene.
  37287. */
  37288. upperAlphaLimit: Nullable<number>;
  37289. /**
  37290. * Minimum allowed angle on the latitudinal axis.
  37291. * This can help limiting how the Camera is able to move in the scene.
  37292. */
  37293. lowerBetaLimit: number;
  37294. /**
  37295. * Maximum allowed angle on the latitudinal axis.
  37296. * This can help limiting how the Camera is able to move in the scene.
  37297. */
  37298. upperBetaLimit: number;
  37299. /**
  37300. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37301. * This can help limiting how the Camera is able to move in the scene.
  37302. */
  37303. lowerRadiusLimit: Nullable<number>;
  37304. /**
  37305. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37306. * This can help limiting how the Camera is able to move in the scene.
  37307. */
  37308. upperRadiusLimit: Nullable<number>;
  37309. /**
  37310. * Defines the current inertia value used during panning of the camera along the X axis.
  37311. */
  37312. inertialPanningX: number;
  37313. /**
  37314. * Defines the current inertia value used during panning of the camera along the Y axis.
  37315. */
  37316. inertialPanningY: number;
  37317. /**
  37318. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37319. * Basically if your fingers moves away from more than this distance you will be considered
  37320. * in pinch mode.
  37321. */
  37322. pinchToPanMaxDistance: number;
  37323. /**
  37324. * Defines the maximum distance the camera can pan.
  37325. * This could help keeping the cammera always in your scene.
  37326. */
  37327. panningDistanceLimit: Nullable<number>;
  37328. /**
  37329. * Defines the target of the camera before paning.
  37330. */
  37331. panningOriginTarget: Vector3;
  37332. /**
  37333. * Defines the value of the inertia used during panning.
  37334. * 0 would mean stop inertia and one would mean no decelleration at all.
  37335. */
  37336. panningInertia: number;
  37337. /**
  37338. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37339. */
  37340. angularSensibilityX: number;
  37341. /**
  37342. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37343. */
  37344. angularSensibilityY: number;
  37345. /**
  37346. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37347. */
  37348. pinchPrecision: number;
  37349. /**
  37350. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37351. * It will be used instead of pinchDeltaPrecision if different from 0.
  37352. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37353. */
  37354. pinchDeltaPercentage: number;
  37355. /**
  37356. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37357. */
  37358. panningSensibility: number;
  37359. /**
  37360. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37361. */
  37362. keysUp: number[];
  37363. /**
  37364. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37365. */
  37366. keysDown: number[];
  37367. /**
  37368. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37369. */
  37370. keysLeft: number[];
  37371. /**
  37372. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37373. */
  37374. keysRight: number[];
  37375. /**
  37376. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37377. */
  37378. wheelPrecision: number;
  37379. /**
  37380. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37381. * It will be used instead of pinchDeltaPrecision if different from 0.
  37382. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37383. */
  37384. wheelDeltaPercentage: number;
  37385. /**
  37386. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37387. */
  37388. zoomOnFactor: number;
  37389. /**
  37390. * Defines a screen offset for the camera position.
  37391. */
  37392. targetScreenOffset: Vector2;
  37393. /**
  37394. * Allows the camera to be completely reversed.
  37395. * If false the camera can not arrive upside down.
  37396. */
  37397. allowUpsideDown: boolean;
  37398. /**
  37399. * Define if double tap/click is used to restore the previously saved state of the camera.
  37400. */
  37401. useInputToRestoreState: boolean;
  37402. /** @hidden */
  37403. _viewMatrix: Matrix;
  37404. /** @hidden */
  37405. _useCtrlForPanning: boolean;
  37406. /** @hidden */
  37407. _panningMouseButton: number;
  37408. /**
  37409. * Defines the input associated to the camera.
  37410. */
  37411. inputs: ArcRotateCameraInputsManager;
  37412. /** @hidden */
  37413. _reset: () => void;
  37414. /**
  37415. * Defines the allowed panning axis.
  37416. */
  37417. panningAxis: Vector3;
  37418. protected _localDirection: Vector3;
  37419. protected _transformedDirection: Vector3;
  37420. private _bouncingBehavior;
  37421. /**
  37422. * Gets the bouncing behavior of the camera if it has been enabled.
  37423. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37424. */
  37425. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37426. /**
  37427. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37428. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37429. */
  37430. useBouncingBehavior: boolean;
  37431. private _framingBehavior;
  37432. /**
  37433. * Gets the framing behavior of the camera if it has been enabled.
  37434. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37435. */
  37436. readonly framingBehavior: Nullable<FramingBehavior>;
  37437. /**
  37438. * Defines if the framing behavior of the camera is enabled on the camera.
  37439. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37440. */
  37441. useFramingBehavior: boolean;
  37442. private _autoRotationBehavior;
  37443. /**
  37444. * Gets the auto rotation behavior of the camera if it has been enabled.
  37445. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37446. */
  37447. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37448. /**
  37449. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37450. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37451. */
  37452. useAutoRotationBehavior: boolean;
  37453. /**
  37454. * Observable triggered when the mesh target has been changed on the camera.
  37455. */
  37456. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37457. /**
  37458. * Event raised when the camera is colliding with a mesh.
  37459. */
  37460. onCollide: (collidedMesh: AbstractMesh) => void;
  37461. /**
  37462. * Defines whether the camera should check collision with the objects oh the scene.
  37463. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37464. */
  37465. checkCollisions: boolean;
  37466. /**
  37467. * Defines the collision radius of the camera.
  37468. * This simulates a sphere around the camera.
  37469. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37470. */
  37471. collisionRadius: Vector3;
  37472. protected _collider: Collider;
  37473. protected _previousPosition: Vector3;
  37474. protected _collisionVelocity: Vector3;
  37475. protected _newPosition: Vector3;
  37476. protected _previousAlpha: number;
  37477. protected _previousBeta: number;
  37478. protected _previousRadius: number;
  37479. protected _collisionTriggered: boolean;
  37480. protected _targetBoundingCenter: Nullable<Vector3>;
  37481. private _computationVector;
  37482. /**
  37483. * Instantiates a new ArcRotateCamera in a given scene
  37484. * @param name Defines the name of the camera
  37485. * @param alpha Defines the camera rotation along the logitudinal axis
  37486. * @param beta Defines the camera rotation along the latitudinal axis
  37487. * @param radius Defines the camera distance from its target
  37488. * @param target Defines the camera target
  37489. * @param scene Defines the scene the camera belongs to
  37490. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37491. */
  37492. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37493. /** @hidden */
  37494. _initCache(): void;
  37495. /** @hidden */
  37496. _updateCache(ignoreParentClass?: boolean): void;
  37497. protected _getTargetPosition(): Vector3;
  37498. private _storedAlpha;
  37499. private _storedBeta;
  37500. private _storedRadius;
  37501. private _storedTarget;
  37502. private _storedTargetScreenOffset;
  37503. /**
  37504. * Stores the current state of the camera (alpha, beta, radius and target)
  37505. * @returns the camera itself
  37506. */
  37507. storeState(): Camera;
  37508. /**
  37509. * @hidden
  37510. * Restored camera state. You must call storeState() first
  37511. */
  37512. _restoreStateValues(): boolean;
  37513. /** @hidden */
  37514. _isSynchronizedViewMatrix(): boolean;
  37515. /**
  37516. * Attached controls to the current camera.
  37517. * @param element Defines the element the controls should be listened from
  37518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37519. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37520. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37521. */
  37522. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37523. /**
  37524. * Detach the current controls from the camera.
  37525. * The camera will stop reacting to inputs.
  37526. * @param element Defines the element to stop listening the inputs from
  37527. */
  37528. detachControl(element: HTMLElement): void;
  37529. /** @hidden */
  37530. _checkInputs(): void;
  37531. protected _checkLimits(): void;
  37532. /**
  37533. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37534. */
  37535. rebuildAnglesAndRadius(): void;
  37536. /**
  37537. * Use a position to define the current camera related information like aplha, beta and radius
  37538. * @param position Defines the position to set the camera at
  37539. */
  37540. setPosition(position: Vector3): void;
  37541. /**
  37542. * Defines the target the camera should look at.
  37543. * This will automatically adapt alpha beta and radius to fit within the new target.
  37544. * @param target Defines the new target as a Vector or a mesh
  37545. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37546. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37547. */
  37548. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37549. /** @hidden */
  37550. _getViewMatrix(): Matrix;
  37551. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37552. /**
  37553. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37554. * @param meshes Defines the mesh to zoom on
  37555. * @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)
  37556. */
  37557. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37558. /**
  37559. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37560. * The target will be changed but the radius
  37561. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37562. * @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)
  37563. */
  37564. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37565. min: Vector3;
  37566. max: Vector3;
  37567. distance: number;
  37568. }, doNotUpdateMaxZ?: boolean): void;
  37569. /**
  37570. * @override
  37571. * Override Camera.createRigCamera
  37572. */
  37573. createRigCamera(name: string, cameraIndex: number): Camera;
  37574. /**
  37575. * @hidden
  37576. * @override
  37577. * Override Camera._updateRigCameras
  37578. */
  37579. _updateRigCameras(): void;
  37580. /**
  37581. * Destroy the camera and release the current resources hold by it.
  37582. */
  37583. dispose(): void;
  37584. /**
  37585. * Gets the current object class name.
  37586. * @return the class name
  37587. */
  37588. getClassName(): string;
  37589. }
  37590. }
  37591. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37592. import { Behavior } from "babylonjs/Behaviors/behavior";
  37593. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37594. /**
  37595. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37596. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37597. */
  37598. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37599. /**
  37600. * Gets the name of the behavior.
  37601. */
  37602. readonly name: string;
  37603. private _zoomStopsAnimation;
  37604. private _idleRotationSpeed;
  37605. private _idleRotationWaitTime;
  37606. private _idleRotationSpinupTime;
  37607. /**
  37608. * Sets the flag that indicates if user zooming should stop animation.
  37609. */
  37610. /**
  37611. * Gets the flag that indicates if user zooming should stop animation.
  37612. */
  37613. zoomStopsAnimation: boolean;
  37614. /**
  37615. * Sets the default speed at which the camera rotates around the model.
  37616. */
  37617. /**
  37618. * Gets the default speed at which the camera rotates around the model.
  37619. */
  37620. idleRotationSpeed: number;
  37621. /**
  37622. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37623. */
  37624. /**
  37625. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37626. */
  37627. idleRotationWaitTime: number;
  37628. /**
  37629. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37630. */
  37631. /**
  37632. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37633. */
  37634. idleRotationSpinupTime: number;
  37635. /**
  37636. * Gets a value indicating if the camera is currently rotating because of this behavior
  37637. */
  37638. readonly rotationInProgress: boolean;
  37639. private _onPrePointerObservableObserver;
  37640. private _onAfterCheckInputsObserver;
  37641. private _attachedCamera;
  37642. private _isPointerDown;
  37643. private _lastFrameTime;
  37644. private _lastInteractionTime;
  37645. private _cameraRotationSpeed;
  37646. /**
  37647. * Initializes the behavior.
  37648. */
  37649. init(): void;
  37650. /**
  37651. * Attaches the behavior to its arc rotate camera.
  37652. * @param camera Defines the camera to attach the behavior to
  37653. */
  37654. attach(camera: ArcRotateCamera): void;
  37655. /**
  37656. * Detaches the behavior from its current arc rotate camera.
  37657. */
  37658. detach(): void;
  37659. /**
  37660. * Returns true if user is scrolling.
  37661. * @return true if user is scrolling.
  37662. */
  37663. private _userIsZooming;
  37664. private _lastFrameRadius;
  37665. private _shouldAnimationStopForInteraction;
  37666. /**
  37667. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37668. */
  37669. private _applyUserInteraction;
  37670. private _userIsMoving;
  37671. }
  37672. }
  37673. declare module "babylonjs/Behaviors/Cameras/index" {
  37674. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37675. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37676. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37677. }
  37678. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37679. import { Mesh } from "babylonjs/Meshes/mesh";
  37680. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37681. import { Behavior } from "babylonjs/Behaviors/behavior";
  37682. /**
  37683. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37684. */
  37685. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37686. private ui;
  37687. /**
  37688. * The name of the behavior
  37689. */
  37690. name: string;
  37691. /**
  37692. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37693. */
  37694. distanceAwayFromFace: number;
  37695. /**
  37696. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37697. */
  37698. distanceAwayFromBottomOfFace: number;
  37699. private _faceVectors;
  37700. private _target;
  37701. private _scene;
  37702. private _onRenderObserver;
  37703. private _tmpMatrix;
  37704. private _tmpVector;
  37705. /**
  37706. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37707. * @param ui The transform node that should be attched to the mesh
  37708. */
  37709. constructor(ui: TransformNode);
  37710. /**
  37711. * Initializes the behavior
  37712. */
  37713. init(): void;
  37714. private _closestFace;
  37715. private _zeroVector;
  37716. private _lookAtTmpMatrix;
  37717. private _lookAtToRef;
  37718. /**
  37719. * Attaches the AttachToBoxBehavior to the passed in mesh
  37720. * @param target The mesh that the specified node will be attached to
  37721. */
  37722. attach(target: Mesh): void;
  37723. /**
  37724. * Detaches the behavior from the mesh
  37725. */
  37726. detach(): void;
  37727. }
  37728. }
  37729. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37730. import { Behavior } from "babylonjs/Behaviors/behavior";
  37731. import { Mesh } from "babylonjs/Meshes/mesh";
  37732. /**
  37733. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37734. */
  37735. export class FadeInOutBehavior implements Behavior<Mesh> {
  37736. /**
  37737. * Time in milliseconds to delay before fading in (Default: 0)
  37738. */
  37739. delay: number;
  37740. /**
  37741. * Time in milliseconds for the mesh to fade in (Default: 300)
  37742. */
  37743. fadeInTime: number;
  37744. private _millisecondsPerFrame;
  37745. private _hovered;
  37746. private _hoverValue;
  37747. private _ownerNode;
  37748. /**
  37749. * Instatiates the FadeInOutBehavior
  37750. */
  37751. constructor();
  37752. /**
  37753. * The name of the behavior
  37754. */
  37755. readonly name: string;
  37756. /**
  37757. * Initializes the behavior
  37758. */
  37759. init(): void;
  37760. /**
  37761. * Attaches the fade behavior on the passed in mesh
  37762. * @param ownerNode The mesh that will be faded in/out once attached
  37763. */
  37764. attach(ownerNode: Mesh): void;
  37765. /**
  37766. * Detaches the behavior from the mesh
  37767. */
  37768. detach(): void;
  37769. /**
  37770. * Triggers the mesh to begin fading in or out
  37771. * @param value if the object should fade in or out (true to fade in)
  37772. */
  37773. fadeIn(value: boolean): void;
  37774. private _update;
  37775. private _setAllVisibility;
  37776. }
  37777. }
  37778. declare module "babylonjs/Misc/pivotTools" {
  37779. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37780. /**
  37781. * Class containing a set of static utilities functions for managing Pivots
  37782. * @hidden
  37783. */
  37784. export class PivotTools {
  37785. private static _PivotCached;
  37786. private static _OldPivotPoint;
  37787. private static _PivotTranslation;
  37788. private static _PivotTmpVector;
  37789. /** @hidden */
  37790. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37791. /** @hidden */
  37792. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37793. }
  37794. }
  37795. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37796. import { Scene } from "babylonjs/scene";
  37797. import { Vector4 } from "babylonjs/Maths/math.vector";
  37798. import { Mesh } from "babylonjs/Meshes/mesh";
  37799. import { Nullable } from "babylonjs/types";
  37800. import { Plane } from "babylonjs/Maths/math.plane";
  37801. /**
  37802. * Class containing static functions to help procedurally build meshes
  37803. */
  37804. export class PlaneBuilder {
  37805. /**
  37806. * Creates a plane mesh
  37807. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37808. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37809. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37811. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37813. * @param name defines the name of the mesh
  37814. * @param options defines the options used to create the mesh
  37815. * @param scene defines the hosting scene
  37816. * @returns the plane mesh
  37817. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37818. */
  37819. static CreatePlane(name: string, options: {
  37820. size?: number;
  37821. width?: number;
  37822. height?: number;
  37823. sideOrientation?: number;
  37824. frontUVs?: Vector4;
  37825. backUVs?: Vector4;
  37826. updatable?: boolean;
  37827. sourcePlane?: Plane;
  37828. }, scene?: Nullable<Scene>): Mesh;
  37829. }
  37830. }
  37831. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37832. import { Behavior } from "babylonjs/Behaviors/behavior";
  37833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37834. import { Observable } from "babylonjs/Misc/observable";
  37835. import { Vector3 } from "babylonjs/Maths/math.vector";
  37836. import { Ray } from "babylonjs/Culling/ray";
  37837. import "babylonjs/Meshes/Builders/planeBuilder";
  37838. /**
  37839. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37840. */
  37841. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37842. private static _AnyMouseID;
  37843. /**
  37844. * Abstract mesh the behavior is set on
  37845. */
  37846. attachedNode: AbstractMesh;
  37847. private _dragPlane;
  37848. private _scene;
  37849. private _pointerObserver;
  37850. private _beforeRenderObserver;
  37851. private static _planeScene;
  37852. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37853. /**
  37854. * 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)
  37855. */
  37856. maxDragAngle: number;
  37857. /**
  37858. * @hidden
  37859. */
  37860. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37861. /**
  37862. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37863. */
  37864. currentDraggingPointerID: number;
  37865. /**
  37866. * The last position where the pointer hit the drag plane in world space
  37867. */
  37868. lastDragPosition: Vector3;
  37869. /**
  37870. * If the behavior is currently in a dragging state
  37871. */
  37872. dragging: boolean;
  37873. /**
  37874. * 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)
  37875. */
  37876. dragDeltaRatio: number;
  37877. /**
  37878. * If the drag plane orientation should be updated during the dragging (Default: true)
  37879. */
  37880. updateDragPlane: boolean;
  37881. private _debugMode;
  37882. private _moving;
  37883. /**
  37884. * Fires each time the attached mesh is dragged with the pointer
  37885. * * delta between last drag position and current drag position in world space
  37886. * * dragDistance along the drag axis
  37887. * * dragPlaneNormal normal of the current drag plane used during the drag
  37888. * * dragPlanePoint in world space where the drag intersects the drag plane
  37889. */
  37890. onDragObservable: Observable<{
  37891. delta: Vector3;
  37892. dragPlanePoint: Vector3;
  37893. dragPlaneNormal: Vector3;
  37894. dragDistance: number;
  37895. pointerId: number;
  37896. }>;
  37897. /**
  37898. * Fires each time a drag begins (eg. mouse down on mesh)
  37899. */
  37900. onDragStartObservable: Observable<{
  37901. dragPlanePoint: Vector3;
  37902. pointerId: number;
  37903. }>;
  37904. /**
  37905. * Fires each time a drag ends (eg. mouse release after drag)
  37906. */
  37907. onDragEndObservable: Observable<{
  37908. dragPlanePoint: Vector3;
  37909. pointerId: number;
  37910. }>;
  37911. /**
  37912. * If the attached mesh should be moved when dragged
  37913. */
  37914. moveAttached: boolean;
  37915. /**
  37916. * If the drag behavior will react to drag events (Default: true)
  37917. */
  37918. enabled: boolean;
  37919. /**
  37920. * If pointer events should start and release the drag (Default: true)
  37921. */
  37922. startAndReleaseDragOnPointerEvents: boolean;
  37923. /**
  37924. * If camera controls should be detached during the drag
  37925. */
  37926. detachCameraControls: boolean;
  37927. /**
  37928. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37929. */
  37930. useObjectOrienationForDragging: boolean;
  37931. private _options;
  37932. /**
  37933. * Creates a pointer drag behavior that can be attached to a mesh
  37934. * @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)
  37935. */
  37936. constructor(options?: {
  37937. dragAxis?: Vector3;
  37938. dragPlaneNormal?: Vector3;
  37939. });
  37940. /**
  37941. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37942. */
  37943. validateDrag: (targetPosition: Vector3) => boolean;
  37944. /**
  37945. * The name of the behavior
  37946. */
  37947. readonly name: string;
  37948. /**
  37949. * Initializes the behavior
  37950. */
  37951. init(): void;
  37952. private _tmpVector;
  37953. private _alternatePickedPoint;
  37954. private _worldDragAxis;
  37955. private _targetPosition;
  37956. private _attachedElement;
  37957. /**
  37958. * Attaches the drag behavior the passed in mesh
  37959. * @param ownerNode The mesh that will be dragged around once attached
  37960. * @param predicate Predicate to use for pick filtering
  37961. */
  37962. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37963. /**
  37964. * Force relase the drag action by code.
  37965. */
  37966. releaseDrag(): void;
  37967. private _startDragRay;
  37968. private _lastPointerRay;
  37969. /**
  37970. * Simulates the start of a pointer drag event on the behavior
  37971. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37972. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37973. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37974. */
  37975. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37976. private _startDrag;
  37977. private _dragDelta;
  37978. private _moveDrag;
  37979. private _pickWithRayOnDragPlane;
  37980. private _pointA;
  37981. private _pointB;
  37982. private _pointC;
  37983. private _lineA;
  37984. private _lineB;
  37985. private _localAxis;
  37986. private _lookAt;
  37987. private _updateDragPlanePosition;
  37988. /**
  37989. * Detaches the behavior from the mesh
  37990. */
  37991. detach(): void;
  37992. }
  37993. }
  37994. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37995. import { Mesh } from "babylonjs/Meshes/mesh";
  37996. import { Behavior } from "babylonjs/Behaviors/behavior";
  37997. /**
  37998. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37999. */
  38000. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38001. private _dragBehaviorA;
  38002. private _dragBehaviorB;
  38003. private _startDistance;
  38004. private _initialScale;
  38005. private _targetScale;
  38006. private _ownerNode;
  38007. private _sceneRenderObserver;
  38008. /**
  38009. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38010. */
  38011. constructor();
  38012. /**
  38013. * The name of the behavior
  38014. */
  38015. readonly name: string;
  38016. /**
  38017. * Initializes the behavior
  38018. */
  38019. init(): void;
  38020. private _getCurrentDistance;
  38021. /**
  38022. * Attaches the scale behavior the passed in mesh
  38023. * @param ownerNode The mesh that will be scaled around once attached
  38024. */
  38025. attach(ownerNode: Mesh): void;
  38026. /**
  38027. * Detaches the behavior from the mesh
  38028. */
  38029. detach(): void;
  38030. }
  38031. }
  38032. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38033. import { Behavior } from "babylonjs/Behaviors/behavior";
  38034. import { Mesh } from "babylonjs/Meshes/mesh";
  38035. import { Observable } from "babylonjs/Misc/observable";
  38036. /**
  38037. * 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
  38038. */
  38039. export class SixDofDragBehavior implements Behavior<Mesh> {
  38040. private static _virtualScene;
  38041. private _ownerNode;
  38042. private _sceneRenderObserver;
  38043. private _scene;
  38044. private _targetPosition;
  38045. private _virtualOriginMesh;
  38046. private _virtualDragMesh;
  38047. private _pointerObserver;
  38048. private _moving;
  38049. private _startingOrientation;
  38050. /**
  38051. * 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)
  38052. */
  38053. private zDragFactor;
  38054. /**
  38055. * If the object should rotate to face the drag origin
  38056. */
  38057. rotateDraggedObject: boolean;
  38058. /**
  38059. * If the behavior is currently in a dragging state
  38060. */
  38061. dragging: boolean;
  38062. /**
  38063. * 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)
  38064. */
  38065. dragDeltaRatio: number;
  38066. /**
  38067. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38068. */
  38069. currentDraggingPointerID: number;
  38070. /**
  38071. * If camera controls should be detached during the drag
  38072. */
  38073. detachCameraControls: boolean;
  38074. /**
  38075. * Fires each time a drag starts
  38076. */
  38077. onDragStartObservable: Observable<{}>;
  38078. /**
  38079. * Fires each time a drag ends (eg. mouse release after drag)
  38080. */
  38081. onDragEndObservable: Observable<{}>;
  38082. /**
  38083. * 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
  38084. */
  38085. constructor();
  38086. /**
  38087. * The name of the behavior
  38088. */
  38089. readonly name: string;
  38090. /**
  38091. * Initializes the behavior
  38092. */
  38093. init(): void;
  38094. /**
  38095. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38096. */
  38097. private readonly _pointerCamera;
  38098. /**
  38099. * Attaches the scale behavior the passed in mesh
  38100. * @param ownerNode The mesh that will be scaled around once attached
  38101. */
  38102. attach(ownerNode: Mesh): void;
  38103. /**
  38104. * Detaches the behavior from the mesh
  38105. */
  38106. detach(): void;
  38107. }
  38108. }
  38109. declare module "babylonjs/Behaviors/Meshes/index" {
  38110. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38111. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38112. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38113. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38114. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38115. }
  38116. declare module "babylonjs/Behaviors/index" {
  38117. export * from "babylonjs/Behaviors/behavior";
  38118. export * from "babylonjs/Behaviors/Cameras/index";
  38119. export * from "babylonjs/Behaviors/Meshes/index";
  38120. }
  38121. declare module "babylonjs/Bones/boneIKController" {
  38122. import { Bone } from "babylonjs/Bones/bone";
  38123. import { Vector3 } from "babylonjs/Maths/math.vector";
  38124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38125. import { Nullable } from "babylonjs/types";
  38126. /**
  38127. * Class used to apply inverse kinematics to bones
  38128. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38129. */
  38130. export class BoneIKController {
  38131. private static _tmpVecs;
  38132. private static _tmpQuat;
  38133. private static _tmpMats;
  38134. /**
  38135. * Gets or sets the target mesh
  38136. */
  38137. targetMesh: AbstractMesh;
  38138. /** Gets or sets the mesh used as pole */
  38139. poleTargetMesh: AbstractMesh;
  38140. /**
  38141. * Gets or sets the bone used as pole
  38142. */
  38143. poleTargetBone: Nullable<Bone>;
  38144. /**
  38145. * Gets or sets the target position
  38146. */
  38147. targetPosition: Vector3;
  38148. /**
  38149. * Gets or sets the pole target position
  38150. */
  38151. poleTargetPosition: Vector3;
  38152. /**
  38153. * Gets or sets the pole target local offset
  38154. */
  38155. poleTargetLocalOffset: Vector3;
  38156. /**
  38157. * Gets or sets the pole angle
  38158. */
  38159. poleAngle: number;
  38160. /**
  38161. * Gets or sets the mesh associated with the controller
  38162. */
  38163. mesh: AbstractMesh;
  38164. /**
  38165. * 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)
  38166. */
  38167. slerpAmount: number;
  38168. private _bone1Quat;
  38169. private _bone1Mat;
  38170. private _bone2Ang;
  38171. private _bone1;
  38172. private _bone2;
  38173. private _bone1Length;
  38174. private _bone2Length;
  38175. private _maxAngle;
  38176. private _maxReach;
  38177. private _rightHandedSystem;
  38178. private _bendAxis;
  38179. private _slerping;
  38180. private _adjustRoll;
  38181. /**
  38182. * Gets or sets maximum allowed angle
  38183. */
  38184. maxAngle: number;
  38185. /**
  38186. * Creates a new BoneIKController
  38187. * @param mesh defines the mesh to control
  38188. * @param bone defines the bone to control
  38189. * @param options defines options to set up the controller
  38190. */
  38191. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38192. targetMesh?: AbstractMesh;
  38193. poleTargetMesh?: AbstractMesh;
  38194. poleTargetBone?: Bone;
  38195. poleTargetLocalOffset?: Vector3;
  38196. poleAngle?: number;
  38197. bendAxis?: Vector3;
  38198. maxAngle?: number;
  38199. slerpAmount?: number;
  38200. });
  38201. private _setMaxAngle;
  38202. /**
  38203. * Force the controller to update the bones
  38204. */
  38205. update(): void;
  38206. }
  38207. }
  38208. declare module "babylonjs/Bones/boneLookController" {
  38209. import { Vector3 } from "babylonjs/Maths/math.vector";
  38210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38211. import { Bone } from "babylonjs/Bones/bone";
  38212. import { Space } from "babylonjs/Maths/math.axis";
  38213. /**
  38214. * Class used to make a bone look toward a point in space
  38215. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38216. */
  38217. export class BoneLookController {
  38218. private static _tmpVecs;
  38219. private static _tmpQuat;
  38220. private static _tmpMats;
  38221. /**
  38222. * The target Vector3 that the bone will look at
  38223. */
  38224. target: Vector3;
  38225. /**
  38226. * The mesh that the bone is attached to
  38227. */
  38228. mesh: AbstractMesh;
  38229. /**
  38230. * The bone that will be looking to the target
  38231. */
  38232. bone: Bone;
  38233. /**
  38234. * The up axis of the coordinate system that is used when the bone is rotated
  38235. */
  38236. upAxis: Vector3;
  38237. /**
  38238. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38239. */
  38240. upAxisSpace: Space;
  38241. /**
  38242. * Used to make an adjustment to the yaw of the bone
  38243. */
  38244. adjustYaw: number;
  38245. /**
  38246. * Used to make an adjustment to the pitch of the bone
  38247. */
  38248. adjustPitch: number;
  38249. /**
  38250. * Used to make an adjustment to the roll of the bone
  38251. */
  38252. adjustRoll: number;
  38253. /**
  38254. * 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)
  38255. */
  38256. slerpAmount: number;
  38257. private _minYaw;
  38258. private _maxYaw;
  38259. private _minPitch;
  38260. private _maxPitch;
  38261. private _minYawSin;
  38262. private _minYawCos;
  38263. private _maxYawSin;
  38264. private _maxYawCos;
  38265. private _midYawConstraint;
  38266. private _minPitchTan;
  38267. private _maxPitchTan;
  38268. private _boneQuat;
  38269. private _slerping;
  38270. private _transformYawPitch;
  38271. private _transformYawPitchInv;
  38272. private _firstFrameSkipped;
  38273. private _yawRange;
  38274. private _fowardAxis;
  38275. /**
  38276. * Gets or sets the minimum yaw angle that the bone can look to
  38277. */
  38278. minYaw: number;
  38279. /**
  38280. * Gets or sets the maximum yaw angle that the bone can look to
  38281. */
  38282. maxYaw: number;
  38283. /**
  38284. * Gets or sets the minimum pitch angle that the bone can look to
  38285. */
  38286. minPitch: number;
  38287. /**
  38288. * Gets or sets the maximum pitch angle that the bone can look to
  38289. */
  38290. maxPitch: number;
  38291. /**
  38292. * Create a BoneLookController
  38293. * @param mesh the mesh that the bone belongs to
  38294. * @param bone the bone that will be looking to the target
  38295. * @param target the target Vector3 to look at
  38296. * @param options optional settings:
  38297. * * maxYaw: the maximum angle the bone will yaw to
  38298. * * minYaw: the minimum angle the bone will yaw to
  38299. * * maxPitch: the maximum angle the bone will pitch to
  38300. * * minPitch: the minimum angle the bone will yaw to
  38301. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38302. * * upAxis: the up axis of the coordinate system
  38303. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38304. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38305. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38306. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38307. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38308. * * adjustRoll: used to make an adjustment to the roll of the bone
  38309. **/
  38310. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38311. maxYaw?: number;
  38312. minYaw?: number;
  38313. maxPitch?: number;
  38314. minPitch?: number;
  38315. slerpAmount?: number;
  38316. upAxis?: Vector3;
  38317. upAxisSpace?: Space;
  38318. yawAxis?: Vector3;
  38319. pitchAxis?: Vector3;
  38320. adjustYaw?: number;
  38321. adjustPitch?: number;
  38322. adjustRoll?: number;
  38323. });
  38324. /**
  38325. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38326. */
  38327. update(): void;
  38328. private _getAngleDiff;
  38329. private _getAngleBetween;
  38330. private _isAngleBetween;
  38331. }
  38332. }
  38333. declare module "babylonjs/Bones/index" {
  38334. export * from "babylonjs/Bones/bone";
  38335. export * from "babylonjs/Bones/boneIKController";
  38336. export * from "babylonjs/Bones/boneLookController";
  38337. export * from "babylonjs/Bones/skeleton";
  38338. }
  38339. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38340. import { Nullable } from "babylonjs/types";
  38341. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38342. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38343. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38344. /**
  38345. * Manage the gamepad inputs to control an arc rotate camera.
  38346. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38347. */
  38348. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38349. /**
  38350. * Defines the camera the input is attached to.
  38351. */
  38352. camera: ArcRotateCamera;
  38353. /**
  38354. * Defines the gamepad the input is gathering event from.
  38355. */
  38356. gamepad: Nullable<Gamepad>;
  38357. /**
  38358. * Defines the gamepad rotation sensiblity.
  38359. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38360. */
  38361. gamepadRotationSensibility: number;
  38362. /**
  38363. * Defines the gamepad move sensiblity.
  38364. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38365. */
  38366. gamepadMoveSensibility: number;
  38367. private _onGamepadConnectedObserver;
  38368. private _onGamepadDisconnectedObserver;
  38369. /**
  38370. * Attach the input controls to a specific dom element to get the input from.
  38371. * @param element Defines the element the controls should be listened from
  38372. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38373. */
  38374. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38375. /**
  38376. * Detach the current controls from the specified dom element.
  38377. * @param element Defines the element to stop listening the inputs from
  38378. */
  38379. detachControl(element: Nullable<HTMLElement>): void;
  38380. /**
  38381. * Update the current camera state depending on the inputs that have been used this frame.
  38382. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38383. */
  38384. checkInputs(): void;
  38385. /**
  38386. * Gets the class name of the current intput.
  38387. * @returns the class name
  38388. */
  38389. getClassName(): string;
  38390. /**
  38391. * Get the friendly name associated with the input class.
  38392. * @returns the input friendly name
  38393. */
  38394. getSimpleName(): string;
  38395. }
  38396. }
  38397. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38398. import { Nullable } from "babylonjs/types";
  38399. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38400. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38401. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38402. interface ArcRotateCameraInputsManager {
  38403. /**
  38404. * Add orientation input support to the input manager.
  38405. * @returns the current input manager
  38406. */
  38407. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38408. }
  38409. }
  38410. /**
  38411. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38412. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38413. */
  38414. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38415. /**
  38416. * Defines the camera the input is attached to.
  38417. */
  38418. camera: ArcRotateCamera;
  38419. /**
  38420. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38421. */
  38422. alphaCorrection: number;
  38423. /**
  38424. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38425. */
  38426. gammaCorrection: number;
  38427. private _alpha;
  38428. private _gamma;
  38429. private _dirty;
  38430. private _deviceOrientationHandler;
  38431. /**
  38432. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38433. */
  38434. constructor();
  38435. /**
  38436. * Attach the input controls to a specific dom element to get the input from.
  38437. * @param element Defines the element the controls should be listened from
  38438. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38439. */
  38440. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38441. /** @hidden */
  38442. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38443. /**
  38444. * Update the current camera state depending on the inputs that have been used this frame.
  38445. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38446. */
  38447. checkInputs(): void;
  38448. /**
  38449. * Detach the current controls from the specified dom element.
  38450. * @param element Defines the element to stop listening the inputs from
  38451. */
  38452. detachControl(element: Nullable<HTMLElement>): void;
  38453. /**
  38454. * Gets the class name of the current intput.
  38455. * @returns the class name
  38456. */
  38457. getClassName(): string;
  38458. /**
  38459. * Get the friendly name associated with the input class.
  38460. * @returns the input friendly name
  38461. */
  38462. getSimpleName(): string;
  38463. }
  38464. }
  38465. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38466. import { Nullable } from "babylonjs/types";
  38467. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38468. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38469. /**
  38470. * Listen to mouse events to control the camera.
  38471. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38472. */
  38473. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38474. /**
  38475. * Defines the camera the input is attached to.
  38476. */
  38477. camera: FlyCamera;
  38478. /**
  38479. * Defines if touch is enabled. (Default is true.)
  38480. */
  38481. touchEnabled: boolean;
  38482. /**
  38483. * Defines the buttons associated with the input to handle camera rotation.
  38484. */
  38485. buttons: number[];
  38486. /**
  38487. * Assign buttons for Yaw control.
  38488. */
  38489. buttonsYaw: number[];
  38490. /**
  38491. * Assign buttons for Pitch control.
  38492. */
  38493. buttonsPitch: number[];
  38494. /**
  38495. * Assign buttons for Roll control.
  38496. */
  38497. buttonsRoll: number[];
  38498. /**
  38499. * Detect if any button is being pressed while mouse is moved.
  38500. * -1 = Mouse locked.
  38501. * 0 = Left button.
  38502. * 1 = Middle Button.
  38503. * 2 = Right Button.
  38504. */
  38505. activeButton: number;
  38506. /**
  38507. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38508. * Higher values reduce its sensitivity.
  38509. */
  38510. angularSensibility: number;
  38511. private _mousemoveCallback;
  38512. private _observer;
  38513. private _rollObserver;
  38514. private previousPosition;
  38515. private noPreventDefault;
  38516. private element;
  38517. /**
  38518. * Listen to mouse events to control the camera.
  38519. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38520. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38521. */
  38522. constructor(touchEnabled?: boolean);
  38523. /**
  38524. * Attach the mouse control to the HTML DOM element.
  38525. * @param element Defines the element that listens to the input events.
  38526. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38527. */
  38528. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38529. /**
  38530. * Detach the current controls from the specified dom element.
  38531. * @param element Defines the element to stop listening the inputs from
  38532. */
  38533. detachControl(element: Nullable<HTMLElement>): void;
  38534. /**
  38535. * Gets the class name of the current input.
  38536. * @returns the class name.
  38537. */
  38538. getClassName(): string;
  38539. /**
  38540. * Get the friendly name associated with the input class.
  38541. * @returns the input's friendly name.
  38542. */
  38543. getSimpleName(): string;
  38544. private _pointerInput;
  38545. private _onMouseMove;
  38546. /**
  38547. * Rotate camera by mouse offset.
  38548. */
  38549. private rotateCamera;
  38550. }
  38551. }
  38552. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38553. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38554. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38555. /**
  38556. * Default Inputs manager for the FlyCamera.
  38557. * It groups all the default supported inputs for ease of use.
  38558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38559. */
  38560. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38561. /**
  38562. * Instantiates a new FlyCameraInputsManager.
  38563. * @param camera Defines the camera the inputs belong to.
  38564. */
  38565. constructor(camera: FlyCamera);
  38566. /**
  38567. * Add keyboard input support to the input manager.
  38568. * @returns the new FlyCameraKeyboardMoveInput().
  38569. */
  38570. addKeyboard(): FlyCameraInputsManager;
  38571. /**
  38572. * Add mouse input support to the input manager.
  38573. * @param touchEnabled Enable touch screen support.
  38574. * @returns the new FlyCameraMouseInput().
  38575. */
  38576. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38577. }
  38578. }
  38579. declare module "babylonjs/Cameras/flyCamera" {
  38580. import { Scene } from "babylonjs/scene";
  38581. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38583. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38584. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38585. /**
  38586. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38587. * such as in a 3D Space Shooter or a Flight Simulator.
  38588. */
  38589. export class FlyCamera extends TargetCamera {
  38590. /**
  38591. * Define the collision ellipsoid of the camera.
  38592. * This is helpful for simulating a camera body, like a player's body.
  38593. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38594. */
  38595. ellipsoid: Vector3;
  38596. /**
  38597. * Define an offset for the position of the ellipsoid around the camera.
  38598. * This can be helpful if the camera is attached away from the player's body center,
  38599. * such as at its head.
  38600. */
  38601. ellipsoidOffset: Vector3;
  38602. /**
  38603. * Enable or disable collisions of the camera with the rest of the scene objects.
  38604. */
  38605. checkCollisions: boolean;
  38606. /**
  38607. * Enable or disable gravity on the camera.
  38608. */
  38609. applyGravity: boolean;
  38610. /**
  38611. * Define the current direction the camera is moving to.
  38612. */
  38613. cameraDirection: Vector3;
  38614. /**
  38615. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38616. * This overrides and empties cameraRotation.
  38617. */
  38618. rotationQuaternion: Quaternion;
  38619. /**
  38620. * Track Roll to maintain the wanted Rolling when looking around.
  38621. */
  38622. _trackRoll: number;
  38623. /**
  38624. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38625. */
  38626. rollCorrect: number;
  38627. /**
  38628. * Mimic a banked turn, Rolling the camera when Yawing.
  38629. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38630. */
  38631. bankedTurn: boolean;
  38632. /**
  38633. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38634. */
  38635. bankedTurnLimit: number;
  38636. /**
  38637. * Value of 0 disables the banked Roll.
  38638. * Value of 1 is equal to the Yaw angle in radians.
  38639. */
  38640. bankedTurnMultiplier: number;
  38641. /**
  38642. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38643. */
  38644. inputs: FlyCameraInputsManager;
  38645. /**
  38646. * Gets the input sensibility for mouse input.
  38647. * Higher values reduce sensitivity.
  38648. */
  38649. /**
  38650. * Sets the input sensibility for a mouse input.
  38651. * Higher values reduce sensitivity.
  38652. */
  38653. angularSensibility: number;
  38654. /**
  38655. * Get the keys for camera movement forward.
  38656. */
  38657. /**
  38658. * Set the keys for camera movement forward.
  38659. */
  38660. keysForward: number[];
  38661. /**
  38662. * Get the keys for camera movement backward.
  38663. */
  38664. keysBackward: number[];
  38665. /**
  38666. * Get the keys for camera movement up.
  38667. */
  38668. /**
  38669. * Set the keys for camera movement up.
  38670. */
  38671. keysUp: number[];
  38672. /**
  38673. * Get the keys for camera movement down.
  38674. */
  38675. /**
  38676. * Set the keys for camera movement down.
  38677. */
  38678. keysDown: number[];
  38679. /**
  38680. * Get the keys for camera movement left.
  38681. */
  38682. /**
  38683. * Set the keys for camera movement left.
  38684. */
  38685. keysLeft: number[];
  38686. /**
  38687. * Set the keys for camera movement right.
  38688. */
  38689. /**
  38690. * Set the keys for camera movement right.
  38691. */
  38692. keysRight: number[];
  38693. /**
  38694. * Event raised when the camera collides with a mesh in the scene.
  38695. */
  38696. onCollide: (collidedMesh: AbstractMesh) => void;
  38697. private _collider;
  38698. private _needMoveForGravity;
  38699. private _oldPosition;
  38700. private _diffPosition;
  38701. private _newPosition;
  38702. /** @hidden */
  38703. _localDirection: Vector3;
  38704. /** @hidden */
  38705. _transformedDirection: Vector3;
  38706. /**
  38707. * Instantiates a FlyCamera.
  38708. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38709. * such as in a 3D Space Shooter or a Flight Simulator.
  38710. * @param name Define the name of the camera in the scene.
  38711. * @param position Define the starting position of the camera in the scene.
  38712. * @param scene Define the scene the camera belongs to.
  38713. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38714. */
  38715. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38716. /**
  38717. * Attach a control to the HTML DOM element.
  38718. * @param element Defines the element that listens to the input events.
  38719. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38720. */
  38721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38722. /**
  38723. * Detach a control from the HTML DOM element.
  38724. * The camera will stop reacting to that input.
  38725. * @param element Defines the element that listens to the input events.
  38726. */
  38727. detachControl(element: HTMLElement): void;
  38728. private _collisionMask;
  38729. /**
  38730. * Get the mask that the camera ignores in collision events.
  38731. */
  38732. /**
  38733. * Set the mask that the camera ignores in collision events.
  38734. */
  38735. collisionMask: number;
  38736. /** @hidden */
  38737. _collideWithWorld(displacement: Vector3): void;
  38738. /** @hidden */
  38739. private _onCollisionPositionChange;
  38740. /** @hidden */
  38741. _checkInputs(): void;
  38742. /** @hidden */
  38743. _decideIfNeedsToMove(): boolean;
  38744. /** @hidden */
  38745. _updatePosition(): void;
  38746. /**
  38747. * Restore the Roll to its target value at the rate specified.
  38748. * @param rate - Higher means slower restoring.
  38749. * @hidden
  38750. */
  38751. restoreRoll(rate: number): void;
  38752. /**
  38753. * Destroy the camera and release the current resources held by it.
  38754. */
  38755. dispose(): void;
  38756. /**
  38757. * Get the current object class name.
  38758. * @returns the class name.
  38759. */
  38760. getClassName(): string;
  38761. }
  38762. }
  38763. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38764. import { Nullable } from "babylonjs/types";
  38765. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38766. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38767. /**
  38768. * Listen to keyboard events to control the camera.
  38769. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38770. */
  38771. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38772. /**
  38773. * Defines the camera the input is attached to.
  38774. */
  38775. camera: FlyCamera;
  38776. /**
  38777. * The list of keyboard keys used to control the forward move of the camera.
  38778. */
  38779. keysForward: number[];
  38780. /**
  38781. * The list of keyboard keys used to control the backward move of the camera.
  38782. */
  38783. keysBackward: number[];
  38784. /**
  38785. * The list of keyboard keys used to control the forward move of the camera.
  38786. */
  38787. keysUp: number[];
  38788. /**
  38789. * The list of keyboard keys used to control the backward move of the camera.
  38790. */
  38791. keysDown: number[];
  38792. /**
  38793. * The list of keyboard keys used to control the right strafe move of the camera.
  38794. */
  38795. keysRight: number[];
  38796. /**
  38797. * The list of keyboard keys used to control the left strafe move of the camera.
  38798. */
  38799. keysLeft: number[];
  38800. private _keys;
  38801. private _onCanvasBlurObserver;
  38802. private _onKeyboardObserver;
  38803. private _engine;
  38804. private _scene;
  38805. /**
  38806. * Attach the input controls to a specific dom element to get the input from.
  38807. * @param element Defines the element the controls should be listened from
  38808. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38809. */
  38810. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38811. /**
  38812. * Detach the current controls from the specified dom element.
  38813. * @param element Defines the element to stop listening the inputs from
  38814. */
  38815. detachControl(element: Nullable<HTMLElement>): void;
  38816. /**
  38817. * Gets the class name of the current intput.
  38818. * @returns the class name
  38819. */
  38820. getClassName(): string;
  38821. /** @hidden */
  38822. _onLostFocus(e: FocusEvent): void;
  38823. /**
  38824. * Get the friendly name associated with the input class.
  38825. * @returns the input friendly name
  38826. */
  38827. getSimpleName(): string;
  38828. /**
  38829. * Update the current camera state depending on the inputs that have been used this frame.
  38830. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38831. */
  38832. checkInputs(): void;
  38833. }
  38834. }
  38835. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38836. import { Nullable } from "babylonjs/types";
  38837. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38838. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38839. /**
  38840. * Manage the mouse wheel inputs to control a follow camera.
  38841. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38842. */
  38843. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38844. /**
  38845. * Defines the camera the input is attached to.
  38846. */
  38847. camera: FollowCamera;
  38848. /**
  38849. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38850. */
  38851. axisControlRadius: boolean;
  38852. /**
  38853. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38854. */
  38855. axisControlHeight: boolean;
  38856. /**
  38857. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38858. */
  38859. axisControlRotation: boolean;
  38860. /**
  38861. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38862. * relation to mouseWheel events.
  38863. */
  38864. wheelPrecision: number;
  38865. /**
  38866. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38867. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38868. */
  38869. wheelDeltaPercentage: number;
  38870. private _wheel;
  38871. private _observer;
  38872. /**
  38873. * Attach the input controls to a specific dom element to get the input from.
  38874. * @param element Defines the element the controls should be listened from
  38875. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38876. */
  38877. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38878. /**
  38879. * Detach the current controls from the specified dom element.
  38880. * @param element Defines the element to stop listening the inputs from
  38881. */
  38882. detachControl(element: Nullable<HTMLElement>): void;
  38883. /**
  38884. * Gets the class name of the current intput.
  38885. * @returns the class name
  38886. */
  38887. getClassName(): string;
  38888. /**
  38889. * Get the friendly name associated with the input class.
  38890. * @returns the input friendly name
  38891. */
  38892. getSimpleName(): string;
  38893. }
  38894. }
  38895. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38896. import { Nullable } from "babylonjs/types";
  38897. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38898. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38899. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38900. /**
  38901. * Manage the pointers inputs to control an follow camera.
  38902. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38903. */
  38904. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38905. /**
  38906. * Defines the camera the input is attached to.
  38907. */
  38908. camera: FollowCamera;
  38909. /**
  38910. * Gets the class name of the current input.
  38911. * @returns the class name
  38912. */
  38913. getClassName(): string;
  38914. /**
  38915. * Defines the pointer angular sensibility along the X axis or how fast is
  38916. * the camera rotating.
  38917. * A negative number will reverse the axis direction.
  38918. */
  38919. angularSensibilityX: number;
  38920. /**
  38921. * Defines the pointer angular sensibility along the Y axis or how fast is
  38922. * the camera rotating.
  38923. * A negative number will reverse the axis direction.
  38924. */
  38925. angularSensibilityY: number;
  38926. /**
  38927. * Defines the pointer pinch precision or how fast is the camera zooming.
  38928. * A negative number will reverse the axis direction.
  38929. */
  38930. pinchPrecision: number;
  38931. /**
  38932. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38933. * from 0.
  38934. * It defines the percentage of current camera.radius to use as delta when
  38935. * pinch zoom is used.
  38936. */
  38937. pinchDeltaPercentage: number;
  38938. /**
  38939. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38940. */
  38941. axisXControlRadius: boolean;
  38942. /**
  38943. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38944. */
  38945. axisXControlHeight: boolean;
  38946. /**
  38947. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38948. */
  38949. axisXControlRotation: boolean;
  38950. /**
  38951. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38952. */
  38953. axisYControlRadius: boolean;
  38954. /**
  38955. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38956. */
  38957. axisYControlHeight: boolean;
  38958. /**
  38959. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38960. */
  38961. axisYControlRotation: boolean;
  38962. /**
  38963. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38964. */
  38965. axisPinchControlRadius: boolean;
  38966. /**
  38967. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38968. */
  38969. axisPinchControlHeight: boolean;
  38970. /**
  38971. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38972. */
  38973. axisPinchControlRotation: boolean;
  38974. /**
  38975. * Log error messages if basic misconfiguration has occurred.
  38976. */
  38977. warningEnable: boolean;
  38978. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38979. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38980. private _warningCounter;
  38981. private _warning;
  38982. }
  38983. }
  38984. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38985. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38986. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38987. /**
  38988. * Default Inputs manager for the FollowCamera.
  38989. * It groups all the default supported inputs for ease of use.
  38990. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38991. */
  38992. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38993. /**
  38994. * Instantiates a new FollowCameraInputsManager.
  38995. * @param camera Defines the camera the inputs belong to
  38996. */
  38997. constructor(camera: FollowCamera);
  38998. /**
  38999. * Add keyboard input support to the input manager.
  39000. * @returns the current input manager
  39001. */
  39002. addKeyboard(): FollowCameraInputsManager;
  39003. /**
  39004. * Add mouse wheel input support to the input manager.
  39005. * @returns the current input manager
  39006. */
  39007. addMouseWheel(): FollowCameraInputsManager;
  39008. /**
  39009. * Add pointers input support to the input manager.
  39010. * @returns the current input manager
  39011. */
  39012. addPointers(): FollowCameraInputsManager;
  39013. /**
  39014. * Add orientation input support to the input manager.
  39015. * @returns the current input manager
  39016. */
  39017. addVRDeviceOrientation(): FollowCameraInputsManager;
  39018. }
  39019. }
  39020. declare module "babylonjs/Cameras/followCamera" {
  39021. import { Nullable } from "babylonjs/types";
  39022. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39023. import { Scene } from "babylonjs/scene";
  39024. import { Vector3 } from "babylonjs/Maths/math.vector";
  39025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39026. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39027. /**
  39028. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39029. * an arc rotate version arcFollowCamera are available.
  39030. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39031. */
  39032. export class FollowCamera extends TargetCamera {
  39033. /**
  39034. * Distance the follow camera should follow an object at
  39035. */
  39036. radius: number;
  39037. /**
  39038. * Minimum allowed distance of the camera to the axis of rotation
  39039. * (The camera can not get closer).
  39040. * This can help limiting how the Camera is able to move in the scene.
  39041. */
  39042. lowerRadiusLimit: Nullable<number>;
  39043. /**
  39044. * Maximum allowed distance of the camera to the axis of rotation
  39045. * (The camera can not get further).
  39046. * This can help limiting how the Camera is able to move in the scene.
  39047. */
  39048. upperRadiusLimit: Nullable<number>;
  39049. /**
  39050. * Define a rotation offset between the camera and the object it follows
  39051. */
  39052. rotationOffset: number;
  39053. /**
  39054. * Minimum allowed angle to camera position relative to target object.
  39055. * This can help limiting how the Camera is able to move in the scene.
  39056. */
  39057. lowerRotationOffsetLimit: Nullable<number>;
  39058. /**
  39059. * Maximum allowed angle to camera position relative to target object.
  39060. * This can help limiting how the Camera is able to move in the scene.
  39061. */
  39062. upperRotationOffsetLimit: Nullable<number>;
  39063. /**
  39064. * Define a height offset between the camera and the object it follows.
  39065. * It can help following an object from the top (like a car chaing a plane)
  39066. */
  39067. heightOffset: number;
  39068. /**
  39069. * Minimum allowed height of camera position relative to target object.
  39070. * This can help limiting how the Camera is able to move in the scene.
  39071. */
  39072. lowerHeightOffsetLimit: Nullable<number>;
  39073. /**
  39074. * Maximum allowed height of camera position relative to target object.
  39075. * This can help limiting how the Camera is able to move in the scene.
  39076. */
  39077. upperHeightOffsetLimit: Nullable<number>;
  39078. /**
  39079. * Define how fast the camera can accelerate to follow it s target.
  39080. */
  39081. cameraAcceleration: number;
  39082. /**
  39083. * Define the speed limit of the camera following an object.
  39084. */
  39085. maxCameraSpeed: number;
  39086. /**
  39087. * Define the target of the camera.
  39088. */
  39089. lockedTarget: Nullable<AbstractMesh>;
  39090. /**
  39091. * Defines the input associated with the camera.
  39092. */
  39093. inputs: FollowCameraInputsManager;
  39094. /**
  39095. * Instantiates the follow camera.
  39096. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39097. * @param name Define the name of the camera in the scene
  39098. * @param position Define the position of the camera
  39099. * @param scene Define the scene the camera belong to
  39100. * @param lockedTarget Define the target of the camera
  39101. */
  39102. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39103. private _follow;
  39104. /**
  39105. * Attached controls to the current camera.
  39106. * @param element Defines the element the controls should be listened from
  39107. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39108. */
  39109. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39110. /**
  39111. * Detach the current controls from the camera.
  39112. * The camera will stop reacting to inputs.
  39113. * @param element Defines the element to stop listening the inputs from
  39114. */
  39115. detachControl(element: HTMLElement): void;
  39116. /** @hidden */
  39117. _checkInputs(): void;
  39118. private _checkLimits;
  39119. /**
  39120. * Gets the camera class name.
  39121. * @returns the class name
  39122. */
  39123. getClassName(): string;
  39124. }
  39125. /**
  39126. * Arc Rotate version of the follow camera.
  39127. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39128. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39129. */
  39130. export class ArcFollowCamera extends TargetCamera {
  39131. /** The longitudinal angle of the camera */
  39132. alpha: number;
  39133. /** The latitudinal angle of the camera */
  39134. beta: number;
  39135. /** The radius of the camera from its target */
  39136. radius: number;
  39137. /** Define the camera target (the messh it should follow) */
  39138. target: Nullable<AbstractMesh>;
  39139. private _cartesianCoordinates;
  39140. /**
  39141. * Instantiates a new ArcFollowCamera
  39142. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39143. * @param name Define the name of the camera
  39144. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39145. * @param beta Define the rotation angle of the camera around the elevation axis
  39146. * @param radius Define the radius of the camera from its target point
  39147. * @param target Define the target of the camera
  39148. * @param scene Define the scene the camera belongs to
  39149. */
  39150. constructor(name: string,
  39151. /** The longitudinal angle of the camera */
  39152. alpha: number,
  39153. /** The latitudinal angle of the camera */
  39154. beta: number,
  39155. /** The radius of the camera from its target */
  39156. radius: number,
  39157. /** Define the camera target (the messh it should follow) */
  39158. target: Nullable<AbstractMesh>, scene: Scene);
  39159. private _follow;
  39160. /** @hidden */
  39161. _checkInputs(): void;
  39162. /**
  39163. * Returns the class name of the object.
  39164. * It is mostly used internally for serialization purposes.
  39165. */
  39166. getClassName(): string;
  39167. }
  39168. }
  39169. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39170. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39171. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39172. import { Nullable } from "babylonjs/types";
  39173. /**
  39174. * Manage the keyboard inputs to control the movement of a follow camera.
  39175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39176. */
  39177. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39178. /**
  39179. * Defines the camera the input is attached to.
  39180. */
  39181. camera: FollowCamera;
  39182. /**
  39183. * Defines the list of key codes associated with the up action (increase heightOffset)
  39184. */
  39185. keysHeightOffsetIncr: number[];
  39186. /**
  39187. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39188. */
  39189. keysHeightOffsetDecr: number[];
  39190. /**
  39191. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39192. */
  39193. keysHeightOffsetModifierAlt: boolean;
  39194. /**
  39195. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39196. */
  39197. keysHeightOffsetModifierCtrl: boolean;
  39198. /**
  39199. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39200. */
  39201. keysHeightOffsetModifierShift: boolean;
  39202. /**
  39203. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39204. */
  39205. keysRotationOffsetIncr: number[];
  39206. /**
  39207. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39208. */
  39209. keysRotationOffsetDecr: number[];
  39210. /**
  39211. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39212. */
  39213. keysRotationOffsetModifierAlt: boolean;
  39214. /**
  39215. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39216. */
  39217. keysRotationOffsetModifierCtrl: boolean;
  39218. /**
  39219. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39220. */
  39221. keysRotationOffsetModifierShift: boolean;
  39222. /**
  39223. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39224. */
  39225. keysRadiusIncr: number[];
  39226. /**
  39227. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39228. */
  39229. keysRadiusDecr: number[];
  39230. /**
  39231. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39232. */
  39233. keysRadiusModifierAlt: boolean;
  39234. /**
  39235. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39236. */
  39237. keysRadiusModifierCtrl: boolean;
  39238. /**
  39239. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39240. */
  39241. keysRadiusModifierShift: boolean;
  39242. /**
  39243. * Defines the rate of change of heightOffset.
  39244. */
  39245. heightSensibility: number;
  39246. /**
  39247. * Defines the rate of change of rotationOffset.
  39248. */
  39249. rotationSensibility: number;
  39250. /**
  39251. * Defines the rate of change of radius.
  39252. */
  39253. radiusSensibility: number;
  39254. private _keys;
  39255. private _ctrlPressed;
  39256. private _altPressed;
  39257. private _shiftPressed;
  39258. private _onCanvasBlurObserver;
  39259. private _onKeyboardObserver;
  39260. private _engine;
  39261. private _scene;
  39262. /**
  39263. * Attach the input controls to a specific dom element to get the input from.
  39264. * @param element Defines the element the controls should be listened from
  39265. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39266. */
  39267. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39268. /**
  39269. * Detach the current controls from the specified dom element.
  39270. * @param element Defines the element to stop listening the inputs from
  39271. */
  39272. detachControl(element: Nullable<HTMLElement>): void;
  39273. /**
  39274. * Update the current camera state depending on the inputs that have been used this frame.
  39275. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39276. */
  39277. checkInputs(): void;
  39278. /**
  39279. * Gets the class name of the current input.
  39280. * @returns the class name
  39281. */
  39282. getClassName(): string;
  39283. /**
  39284. * Get the friendly name associated with the input class.
  39285. * @returns the input friendly name
  39286. */
  39287. getSimpleName(): string;
  39288. /**
  39289. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39290. * allow modification of the heightOffset value.
  39291. */
  39292. private _modifierHeightOffset;
  39293. /**
  39294. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39295. * allow modification of the rotationOffset value.
  39296. */
  39297. private _modifierRotationOffset;
  39298. /**
  39299. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39300. * allow modification of the radius value.
  39301. */
  39302. private _modifierRadius;
  39303. }
  39304. }
  39305. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39306. import { Nullable } from "babylonjs/types";
  39307. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39308. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39309. import { Observable } from "babylonjs/Misc/observable";
  39310. module "babylonjs/Cameras/freeCameraInputsManager" {
  39311. interface FreeCameraInputsManager {
  39312. /**
  39313. * @hidden
  39314. */
  39315. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39316. /**
  39317. * Add orientation input support to the input manager.
  39318. * @returns the current input manager
  39319. */
  39320. addDeviceOrientation(): FreeCameraInputsManager;
  39321. }
  39322. }
  39323. /**
  39324. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39325. * Screen rotation is taken into account.
  39326. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39327. */
  39328. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39329. private _camera;
  39330. private _screenOrientationAngle;
  39331. private _constantTranform;
  39332. private _screenQuaternion;
  39333. private _alpha;
  39334. private _beta;
  39335. private _gamma;
  39336. /**
  39337. * Can be used to detect if a device orientation sensor is availible on a device
  39338. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39339. * @returns a promise that will resolve on orientation change
  39340. */
  39341. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39342. /**
  39343. * @hidden
  39344. */
  39345. _onDeviceOrientationChangedObservable: Observable<void>;
  39346. /**
  39347. * Instantiates a new input
  39348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39349. */
  39350. constructor();
  39351. /**
  39352. * Define the camera controlled by the input.
  39353. */
  39354. camera: FreeCamera;
  39355. /**
  39356. * Attach the input controls to a specific dom element to get the input from.
  39357. * @param element Defines the element the controls should be listened from
  39358. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39359. */
  39360. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39361. private _orientationChanged;
  39362. private _deviceOrientation;
  39363. /**
  39364. * Detach the current controls from the specified dom element.
  39365. * @param element Defines the element to stop listening the inputs from
  39366. */
  39367. detachControl(element: Nullable<HTMLElement>): void;
  39368. /**
  39369. * Update the current camera state depending on the inputs that have been used this frame.
  39370. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39371. */
  39372. checkInputs(): void;
  39373. /**
  39374. * Gets the class name of the current intput.
  39375. * @returns the class name
  39376. */
  39377. getClassName(): string;
  39378. /**
  39379. * Get the friendly name associated with the input class.
  39380. * @returns the input friendly name
  39381. */
  39382. getSimpleName(): string;
  39383. }
  39384. }
  39385. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39386. import { Nullable } from "babylonjs/types";
  39387. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39388. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39389. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39390. /**
  39391. * Manage the gamepad inputs to control a free camera.
  39392. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39393. */
  39394. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39395. /**
  39396. * Define the camera the input is attached to.
  39397. */
  39398. camera: FreeCamera;
  39399. /**
  39400. * Define the Gamepad controlling the input
  39401. */
  39402. gamepad: Nullable<Gamepad>;
  39403. /**
  39404. * Defines the gamepad rotation sensiblity.
  39405. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39406. */
  39407. gamepadAngularSensibility: number;
  39408. /**
  39409. * Defines the gamepad move sensiblity.
  39410. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39411. */
  39412. gamepadMoveSensibility: number;
  39413. private _onGamepadConnectedObserver;
  39414. private _onGamepadDisconnectedObserver;
  39415. private _cameraTransform;
  39416. private _deltaTransform;
  39417. private _vector3;
  39418. private _vector2;
  39419. /**
  39420. * Attach the input controls to a specific dom element to get the input from.
  39421. * @param element Defines the element the controls should be listened from
  39422. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39423. */
  39424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39425. /**
  39426. * Detach the current controls from the specified dom element.
  39427. * @param element Defines the element to stop listening the inputs from
  39428. */
  39429. detachControl(element: Nullable<HTMLElement>): void;
  39430. /**
  39431. * Update the current camera state depending on the inputs that have been used this frame.
  39432. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39433. */
  39434. checkInputs(): void;
  39435. /**
  39436. * Gets the class name of the current intput.
  39437. * @returns the class name
  39438. */
  39439. getClassName(): string;
  39440. /**
  39441. * Get the friendly name associated with the input class.
  39442. * @returns the input friendly name
  39443. */
  39444. getSimpleName(): string;
  39445. }
  39446. }
  39447. declare module "babylonjs/Misc/virtualJoystick" {
  39448. import { Nullable } from "babylonjs/types";
  39449. import { Vector3 } from "babylonjs/Maths/math.vector";
  39450. /**
  39451. * Defines the potential axis of a Joystick
  39452. */
  39453. export enum JoystickAxis {
  39454. /** X axis */
  39455. X = 0,
  39456. /** Y axis */
  39457. Y = 1,
  39458. /** Z axis */
  39459. Z = 2
  39460. }
  39461. /**
  39462. * Class used to define virtual joystick (used in touch mode)
  39463. */
  39464. export class VirtualJoystick {
  39465. /**
  39466. * Gets or sets a boolean indicating that left and right values must be inverted
  39467. */
  39468. reverseLeftRight: boolean;
  39469. /**
  39470. * Gets or sets a boolean indicating that up and down values must be inverted
  39471. */
  39472. reverseUpDown: boolean;
  39473. /**
  39474. * Gets the offset value for the position (ie. the change of the position value)
  39475. */
  39476. deltaPosition: Vector3;
  39477. /**
  39478. * Gets a boolean indicating if the virtual joystick was pressed
  39479. */
  39480. pressed: boolean;
  39481. /**
  39482. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39483. */
  39484. static Canvas: Nullable<HTMLCanvasElement>;
  39485. private static _globalJoystickIndex;
  39486. private static vjCanvasContext;
  39487. private static vjCanvasWidth;
  39488. private static vjCanvasHeight;
  39489. private static halfWidth;
  39490. private _action;
  39491. private _axisTargetedByLeftAndRight;
  39492. private _axisTargetedByUpAndDown;
  39493. private _joystickSensibility;
  39494. private _inversedSensibility;
  39495. private _joystickPointerID;
  39496. private _joystickColor;
  39497. private _joystickPointerPos;
  39498. private _joystickPreviousPointerPos;
  39499. private _joystickPointerStartPos;
  39500. private _deltaJoystickVector;
  39501. private _leftJoystick;
  39502. private _touches;
  39503. private _onPointerDownHandlerRef;
  39504. private _onPointerMoveHandlerRef;
  39505. private _onPointerUpHandlerRef;
  39506. private _onResize;
  39507. /**
  39508. * Creates a new virtual joystick
  39509. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39510. */
  39511. constructor(leftJoystick?: boolean);
  39512. /**
  39513. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39514. * @param newJoystickSensibility defines the new sensibility
  39515. */
  39516. setJoystickSensibility(newJoystickSensibility: number): void;
  39517. private _onPointerDown;
  39518. private _onPointerMove;
  39519. private _onPointerUp;
  39520. /**
  39521. * Change the color of the virtual joystick
  39522. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39523. */
  39524. setJoystickColor(newColor: string): void;
  39525. /**
  39526. * Defines a callback to call when the joystick is touched
  39527. * @param action defines the callback
  39528. */
  39529. setActionOnTouch(action: () => any): void;
  39530. /**
  39531. * Defines which axis you'd like to control for left & right
  39532. * @param axis defines the axis to use
  39533. */
  39534. setAxisForLeftRight(axis: JoystickAxis): void;
  39535. /**
  39536. * Defines which axis you'd like to control for up & down
  39537. * @param axis defines the axis to use
  39538. */
  39539. setAxisForUpDown(axis: JoystickAxis): void;
  39540. private _drawVirtualJoystick;
  39541. /**
  39542. * Release internal HTML canvas
  39543. */
  39544. releaseCanvas(): void;
  39545. }
  39546. }
  39547. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39548. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39549. import { Nullable } from "babylonjs/types";
  39550. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39551. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39552. module "babylonjs/Cameras/freeCameraInputsManager" {
  39553. interface FreeCameraInputsManager {
  39554. /**
  39555. * Add virtual joystick input support to the input manager.
  39556. * @returns the current input manager
  39557. */
  39558. addVirtualJoystick(): FreeCameraInputsManager;
  39559. }
  39560. }
  39561. /**
  39562. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39563. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39564. */
  39565. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39566. /**
  39567. * Defines the camera the input is attached to.
  39568. */
  39569. camera: FreeCamera;
  39570. private _leftjoystick;
  39571. private _rightjoystick;
  39572. /**
  39573. * Gets the left stick of the virtual joystick.
  39574. * @returns The virtual Joystick
  39575. */
  39576. getLeftJoystick(): VirtualJoystick;
  39577. /**
  39578. * Gets the right stick of the virtual joystick.
  39579. * @returns The virtual Joystick
  39580. */
  39581. getRightJoystick(): VirtualJoystick;
  39582. /**
  39583. * Update the current camera state depending on the inputs that have been used this frame.
  39584. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39585. */
  39586. checkInputs(): void;
  39587. /**
  39588. * Attach the input controls to a specific dom element to get the input from.
  39589. * @param element Defines the element the controls should be listened from
  39590. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39591. */
  39592. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39593. /**
  39594. * Detach the current controls from the specified dom element.
  39595. * @param element Defines the element to stop listening the inputs from
  39596. */
  39597. detachControl(element: Nullable<HTMLElement>): void;
  39598. /**
  39599. * Gets the class name of the current intput.
  39600. * @returns the class name
  39601. */
  39602. getClassName(): string;
  39603. /**
  39604. * Get the friendly name associated with the input class.
  39605. * @returns the input friendly name
  39606. */
  39607. getSimpleName(): string;
  39608. }
  39609. }
  39610. declare module "babylonjs/Cameras/Inputs/index" {
  39611. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39612. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39613. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39614. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39615. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39616. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39617. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39618. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39619. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39620. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39621. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39622. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39623. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39624. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39625. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39626. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39627. }
  39628. declare module "babylonjs/Cameras/touchCamera" {
  39629. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39630. import { Scene } from "babylonjs/scene";
  39631. import { Vector3 } from "babylonjs/Maths/math.vector";
  39632. /**
  39633. * This represents a FPS type of camera controlled by touch.
  39634. * This is like a universal camera minus the Gamepad controls.
  39635. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39636. */
  39637. export class TouchCamera extends FreeCamera {
  39638. /**
  39639. * Defines the touch sensibility for rotation.
  39640. * The higher the faster.
  39641. */
  39642. touchAngularSensibility: number;
  39643. /**
  39644. * Defines the touch sensibility for move.
  39645. * The higher the faster.
  39646. */
  39647. touchMoveSensibility: number;
  39648. /**
  39649. * Instantiates a new touch camera.
  39650. * This represents a FPS type of camera controlled by touch.
  39651. * This is like a universal camera minus the Gamepad controls.
  39652. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39653. * @param name Define the name of the camera in the scene
  39654. * @param position Define the start position of the camera in the scene
  39655. * @param scene Define the scene the camera belongs to
  39656. */
  39657. constructor(name: string, position: Vector3, scene: Scene);
  39658. /**
  39659. * Gets the current object class name.
  39660. * @return the class name
  39661. */
  39662. getClassName(): string;
  39663. /** @hidden */
  39664. _setupInputs(): void;
  39665. }
  39666. }
  39667. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39668. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39669. import { Scene } from "babylonjs/scene";
  39670. import { Vector3 } from "babylonjs/Maths/math.vector";
  39671. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39672. import { Axis } from "babylonjs/Maths/math.axis";
  39673. /**
  39674. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39675. * being tilted forward or back and left or right.
  39676. */
  39677. export class DeviceOrientationCamera extends FreeCamera {
  39678. private _initialQuaternion;
  39679. private _quaternionCache;
  39680. private _tmpDragQuaternion;
  39681. private _disablePointerInputWhenUsingDeviceOrientation;
  39682. /**
  39683. * Creates a new device orientation camera
  39684. * @param name The name of the camera
  39685. * @param position The start position camera
  39686. * @param scene The scene the camera belongs to
  39687. */
  39688. constructor(name: string, position: Vector3, scene: Scene);
  39689. /**
  39690. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39691. */
  39692. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39693. private _dragFactor;
  39694. /**
  39695. * Enabled turning on the y axis when the orientation sensor is active
  39696. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39697. */
  39698. enableHorizontalDragging(dragFactor?: number): void;
  39699. /**
  39700. * Gets the current instance class name ("DeviceOrientationCamera").
  39701. * This helps avoiding instanceof at run time.
  39702. * @returns the class name
  39703. */
  39704. getClassName(): string;
  39705. /**
  39706. * @hidden
  39707. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39708. */
  39709. _checkInputs(): void;
  39710. /**
  39711. * Reset the camera to its default orientation on the specified axis only.
  39712. * @param axis The axis to reset
  39713. */
  39714. resetToCurrentRotation(axis?: Axis): void;
  39715. }
  39716. }
  39717. declare module "babylonjs/Gamepads/xboxGamepad" {
  39718. import { Observable } from "babylonjs/Misc/observable";
  39719. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39720. /**
  39721. * Defines supported buttons for XBox360 compatible gamepads
  39722. */
  39723. export enum Xbox360Button {
  39724. /** A */
  39725. A = 0,
  39726. /** B */
  39727. B = 1,
  39728. /** X */
  39729. X = 2,
  39730. /** Y */
  39731. Y = 3,
  39732. /** Start */
  39733. Start = 4,
  39734. /** Back */
  39735. Back = 5,
  39736. /** Left button */
  39737. LB = 6,
  39738. /** Right button */
  39739. RB = 7,
  39740. /** Left stick */
  39741. LeftStick = 8,
  39742. /** Right stick */
  39743. RightStick = 9
  39744. }
  39745. /** Defines values for XBox360 DPad */
  39746. export enum Xbox360Dpad {
  39747. /** Up */
  39748. Up = 0,
  39749. /** Down */
  39750. Down = 1,
  39751. /** Left */
  39752. Left = 2,
  39753. /** Right */
  39754. Right = 3
  39755. }
  39756. /**
  39757. * Defines a XBox360 gamepad
  39758. */
  39759. export class Xbox360Pad extends Gamepad {
  39760. private _leftTrigger;
  39761. private _rightTrigger;
  39762. private _onlefttriggerchanged;
  39763. private _onrighttriggerchanged;
  39764. private _onbuttondown;
  39765. private _onbuttonup;
  39766. private _ondpaddown;
  39767. private _ondpadup;
  39768. /** Observable raised when a button is pressed */
  39769. onButtonDownObservable: Observable<Xbox360Button>;
  39770. /** Observable raised when a button is released */
  39771. onButtonUpObservable: Observable<Xbox360Button>;
  39772. /** Observable raised when a pad is pressed */
  39773. onPadDownObservable: Observable<Xbox360Dpad>;
  39774. /** Observable raised when a pad is released */
  39775. onPadUpObservable: Observable<Xbox360Dpad>;
  39776. private _buttonA;
  39777. private _buttonB;
  39778. private _buttonX;
  39779. private _buttonY;
  39780. private _buttonBack;
  39781. private _buttonStart;
  39782. private _buttonLB;
  39783. private _buttonRB;
  39784. private _buttonLeftStick;
  39785. private _buttonRightStick;
  39786. private _dPadUp;
  39787. private _dPadDown;
  39788. private _dPadLeft;
  39789. private _dPadRight;
  39790. private _isXboxOnePad;
  39791. /**
  39792. * Creates a new XBox360 gamepad object
  39793. * @param id defines the id of this gamepad
  39794. * @param index defines its index
  39795. * @param gamepad defines the internal HTML gamepad object
  39796. * @param xboxOne defines if it is a XBox One gamepad
  39797. */
  39798. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39799. /**
  39800. * Defines the callback to call when left trigger is pressed
  39801. * @param callback defines the callback to use
  39802. */
  39803. onlefttriggerchanged(callback: (value: number) => void): void;
  39804. /**
  39805. * Defines the callback to call when right trigger is pressed
  39806. * @param callback defines the callback to use
  39807. */
  39808. onrighttriggerchanged(callback: (value: number) => void): void;
  39809. /**
  39810. * Gets the left trigger value
  39811. */
  39812. /**
  39813. * Sets the left trigger value
  39814. */
  39815. leftTrigger: number;
  39816. /**
  39817. * Gets the right trigger value
  39818. */
  39819. /**
  39820. * Sets the right trigger value
  39821. */
  39822. rightTrigger: number;
  39823. /**
  39824. * Defines the callback to call when a button is pressed
  39825. * @param callback defines the callback to use
  39826. */
  39827. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39828. /**
  39829. * Defines the callback to call when a button is released
  39830. * @param callback defines the callback to use
  39831. */
  39832. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39833. /**
  39834. * Defines the callback to call when a pad is pressed
  39835. * @param callback defines the callback to use
  39836. */
  39837. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39838. /**
  39839. * Defines the callback to call when a pad is released
  39840. * @param callback defines the callback to use
  39841. */
  39842. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39843. private _setButtonValue;
  39844. private _setDPadValue;
  39845. /**
  39846. * Gets the value of the `A` button
  39847. */
  39848. /**
  39849. * Sets the value of the `A` button
  39850. */
  39851. buttonA: number;
  39852. /**
  39853. * Gets the value of the `B` button
  39854. */
  39855. /**
  39856. * Sets the value of the `B` button
  39857. */
  39858. buttonB: number;
  39859. /**
  39860. * Gets the value of the `X` button
  39861. */
  39862. /**
  39863. * Sets the value of the `X` button
  39864. */
  39865. buttonX: number;
  39866. /**
  39867. * Gets the value of the `Y` button
  39868. */
  39869. /**
  39870. * Sets the value of the `Y` button
  39871. */
  39872. buttonY: number;
  39873. /**
  39874. * Gets the value of the `Start` button
  39875. */
  39876. /**
  39877. * Sets the value of the `Start` button
  39878. */
  39879. buttonStart: number;
  39880. /**
  39881. * Gets the value of the `Back` button
  39882. */
  39883. /**
  39884. * Sets the value of the `Back` button
  39885. */
  39886. buttonBack: number;
  39887. /**
  39888. * Gets the value of the `Left` button
  39889. */
  39890. /**
  39891. * Sets the value of the `Left` button
  39892. */
  39893. buttonLB: number;
  39894. /**
  39895. * Gets the value of the `Right` button
  39896. */
  39897. /**
  39898. * Sets the value of the `Right` button
  39899. */
  39900. buttonRB: number;
  39901. /**
  39902. * Gets the value of the Left joystick
  39903. */
  39904. /**
  39905. * Sets the value of the Left joystick
  39906. */
  39907. buttonLeftStick: number;
  39908. /**
  39909. * Gets the value of the Right joystick
  39910. */
  39911. /**
  39912. * Sets the value of the Right joystick
  39913. */
  39914. buttonRightStick: number;
  39915. /**
  39916. * Gets the value of D-pad up
  39917. */
  39918. /**
  39919. * Sets the value of D-pad up
  39920. */
  39921. dPadUp: number;
  39922. /**
  39923. * Gets the value of D-pad down
  39924. */
  39925. /**
  39926. * Sets the value of D-pad down
  39927. */
  39928. dPadDown: number;
  39929. /**
  39930. * Gets the value of D-pad left
  39931. */
  39932. /**
  39933. * Sets the value of D-pad left
  39934. */
  39935. dPadLeft: number;
  39936. /**
  39937. * Gets the value of D-pad right
  39938. */
  39939. /**
  39940. * Sets the value of D-pad right
  39941. */
  39942. dPadRight: number;
  39943. /**
  39944. * Force the gamepad to synchronize with device values
  39945. */
  39946. update(): void;
  39947. /**
  39948. * Disposes the gamepad
  39949. */
  39950. dispose(): void;
  39951. }
  39952. }
  39953. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39954. import { Observable } from "babylonjs/Misc/observable";
  39955. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39956. /**
  39957. * Defines supported buttons for DualShock compatible gamepads
  39958. */
  39959. export enum DualShockButton {
  39960. /** Cross */
  39961. Cross = 0,
  39962. /** Circle */
  39963. Circle = 1,
  39964. /** Square */
  39965. Square = 2,
  39966. /** Triangle */
  39967. Triangle = 3,
  39968. /** Options */
  39969. Options = 4,
  39970. /** Share */
  39971. Share = 5,
  39972. /** L1 */
  39973. L1 = 6,
  39974. /** R1 */
  39975. R1 = 7,
  39976. /** Left stick */
  39977. LeftStick = 8,
  39978. /** Right stick */
  39979. RightStick = 9
  39980. }
  39981. /** Defines values for DualShock DPad */
  39982. export enum DualShockDpad {
  39983. /** Up */
  39984. Up = 0,
  39985. /** Down */
  39986. Down = 1,
  39987. /** Left */
  39988. Left = 2,
  39989. /** Right */
  39990. Right = 3
  39991. }
  39992. /**
  39993. * Defines a DualShock gamepad
  39994. */
  39995. export class DualShockPad extends Gamepad {
  39996. private _leftTrigger;
  39997. private _rightTrigger;
  39998. private _onlefttriggerchanged;
  39999. private _onrighttriggerchanged;
  40000. private _onbuttondown;
  40001. private _onbuttonup;
  40002. private _ondpaddown;
  40003. private _ondpadup;
  40004. /** Observable raised when a button is pressed */
  40005. onButtonDownObservable: Observable<DualShockButton>;
  40006. /** Observable raised when a button is released */
  40007. onButtonUpObservable: Observable<DualShockButton>;
  40008. /** Observable raised when a pad is pressed */
  40009. onPadDownObservable: Observable<DualShockDpad>;
  40010. /** Observable raised when a pad is released */
  40011. onPadUpObservable: Observable<DualShockDpad>;
  40012. private _buttonCross;
  40013. private _buttonCircle;
  40014. private _buttonSquare;
  40015. private _buttonTriangle;
  40016. private _buttonShare;
  40017. private _buttonOptions;
  40018. private _buttonL1;
  40019. private _buttonR1;
  40020. private _buttonLeftStick;
  40021. private _buttonRightStick;
  40022. private _dPadUp;
  40023. private _dPadDown;
  40024. private _dPadLeft;
  40025. private _dPadRight;
  40026. /**
  40027. * Creates a new DualShock gamepad object
  40028. * @param id defines the id of this gamepad
  40029. * @param index defines its index
  40030. * @param gamepad defines the internal HTML gamepad object
  40031. */
  40032. constructor(id: string, index: number, gamepad: any);
  40033. /**
  40034. * Defines the callback to call when left trigger is pressed
  40035. * @param callback defines the callback to use
  40036. */
  40037. onlefttriggerchanged(callback: (value: number) => void): void;
  40038. /**
  40039. * Defines the callback to call when right trigger is pressed
  40040. * @param callback defines the callback to use
  40041. */
  40042. onrighttriggerchanged(callback: (value: number) => void): void;
  40043. /**
  40044. * Gets the left trigger value
  40045. */
  40046. /**
  40047. * Sets the left trigger value
  40048. */
  40049. leftTrigger: number;
  40050. /**
  40051. * Gets the right trigger value
  40052. */
  40053. /**
  40054. * Sets the right trigger value
  40055. */
  40056. rightTrigger: number;
  40057. /**
  40058. * Defines the callback to call when a button is pressed
  40059. * @param callback defines the callback to use
  40060. */
  40061. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40062. /**
  40063. * Defines the callback to call when a button is released
  40064. * @param callback defines the callback to use
  40065. */
  40066. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40067. /**
  40068. * Defines the callback to call when a pad is pressed
  40069. * @param callback defines the callback to use
  40070. */
  40071. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40072. /**
  40073. * Defines the callback to call when a pad is released
  40074. * @param callback defines the callback to use
  40075. */
  40076. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40077. private _setButtonValue;
  40078. private _setDPadValue;
  40079. /**
  40080. * Gets the value of the `Cross` button
  40081. */
  40082. /**
  40083. * Sets the value of the `Cross` button
  40084. */
  40085. buttonCross: number;
  40086. /**
  40087. * Gets the value of the `Circle` button
  40088. */
  40089. /**
  40090. * Sets the value of the `Circle` button
  40091. */
  40092. buttonCircle: number;
  40093. /**
  40094. * Gets the value of the `Square` button
  40095. */
  40096. /**
  40097. * Sets the value of the `Square` button
  40098. */
  40099. buttonSquare: number;
  40100. /**
  40101. * Gets the value of the `Triangle` button
  40102. */
  40103. /**
  40104. * Sets the value of the `Triangle` button
  40105. */
  40106. buttonTriangle: number;
  40107. /**
  40108. * Gets the value of the `Options` button
  40109. */
  40110. /**
  40111. * Sets the value of the `Options` button
  40112. */
  40113. buttonOptions: number;
  40114. /**
  40115. * Gets the value of the `Share` button
  40116. */
  40117. /**
  40118. * Sets the value of the `Share` button
  40119. */
  40120. buttonShare: number;
  40121. /**
  40122. * Gets the value of the `L1` button
  40123. */
  40124. /**
  40125. * Sets the value of the `L1` button
  40126. */
  40127. buttonL1: number;
  40128. /**
  40129. * Gets the value of the `R1` button
  40130. */
  40131. /**
  40132. * Sets the value of the `R1` button
  40133. */
  40134. buttonR1: number;
  40135. /**
  40136. * Gets the value of the Left joystick
  40137. */
  40138. /**
  40139. * Sets the value of the Left joystick
  40140. */
  40141. buttonLeftStick: number;
  40142. /**
  40143. * Gets the value of the Right joystick
  40144. */
  40145. /**
  40146. * Sets the value of the Right joystick
  40147. */
  40148. buttonRightStick: number;
  40149. /**
  40150. * Gets the value of D-pad up
  40151. */
  40152. /**
  40153. * Sets the value of D-pad up
  40154. */
  40155. dPadUp: number;
  40156. /**
  40157. * Gets the value of D-pad down
  40158. */
  40159. /**
  40160. * Sets the value of D-pad down
  40161. */
  40162. dPadDown: number;
  40163. /**
  40164. * Gets the value of D-pad left
  40165. */
  40166. /**
  40167. * Sets the value of D-pad left
  40168. */
  40169. dPadLeft: number;
  40170. /**
  40171. * Gets the value of D-pad right
  40172. */
  40173. /**
  40174. * Sets the value of D-pad right
  40175. */
  40176. dPadRight: number;
  40177. /**
  40178. * Force the gamepad to synchronize with device values
  40179. */
  40180. update(): void;
  40181. /**
  40182. * Disposes the gamepad
  40183. */
  40184. dispose(): void;
  40185. }
  40186. }
  40187. declare module "babylonjs/Gamepads/gamepadManager" {
  40188. import { Observable } from "babylonjs/Misc/observable";
  40189. import { Nullable } from "babylonjs/types";
  40190. import { Scene } from "babylonjs/scene";
  40191. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40192. /**
  40193. * Manager for handling gamepads
  40194. */
  40195. export class GamepadManager {
  40196. private _scene?;
  40197. private _babylonGamepads;
  40198. private _oneGamepadConnected;
  40199. /** @hidden */
  40200. _isMonitoring: boolean;
  40201. private _gamepadEventSupported;
  40202. private _gamepadSupport;
  40203. /**
  40204. * observable to be triggered when the gamepad controller has been connected
  40205. */
  40206. onGamepadConnectedObservable: Observable<Gamepad>;
  40207. /**
  40208. * observable to be triggered when the gamepad controller has been disconnected
  40209. */
  40210. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40211. private _onGamepadConnectedEvent;
  40212. private _onGamepadDisconnectedEvent;
  40213. /**
  40214. * Initializes the gamepad manager
  40215. * @param _scene BabylonJS scene
  40216. */
  40217. constructor(_scene?: Scene | undefined);
  40218. /**
  40219. * The gamepads in the game pad manager
  40220. */
  40221. readonly gamepads: Gamepad[];
  40222. /**
  40223. * Get the gamepad controllers based on type
  40224. * @param type The type of gamepad controller
  40225. * @returns Nullable gamepad
  40226. */
  40227. getGamepadByType(type?: number): Nullable<Gamepad>;
  40228. /**
  40229. * Disposes the gamepad manager
  40230. */
  40231. dispose(): void;
  40232. private _addNewGamepad;
  40233. private _startMonitoringGamepads;
  40234. private _stopMonitoringGamepads;
  40235. /** @hidden */
  40236. _checkGamepadsStatus(): void;
  40237. private _updateGamepadObjects;
  40238. }
  40239. }
  40240. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40241. import { Nullable } from "babylonjs/types";
  40242. import { Scene } from "babylonjs/scene";
  40243. import { ISceneComponent } from "babylonjs/sceneComponent";
  40244. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40245. module "babylonjs/scene" {
  40246. interface Scene {
  40247. /** @hidden */
  40248. _gamepadManager: Nullable<GamepadManager>;
  40249. /**
  40250. * Gets the gamepad manager associated with the scene
  40251. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40252. */
  40253. gamepadManager: GamepadManager;
  40254. }
  40255. }
  40256. module "babylonjs/Cameras/freeCameraInputsManager" {
  40257. /**
  40258. * Interface representing a free camera inputs manager
  40259. */
  40260. interface FreeCameraInputsManager {
  40261. /**
  40262. * Adds gamepad input support to the FreeCameraInputsManager.
  40263. * @returns the FreeCameraInputsManager
  40264. */
  40265. addGamepad(): FreeCameraInputsManager;
  40266. }
  40267. }
  40268. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40269. /**
  40270. * Interface representing an arc rotate camera inputs manager
  40271. */
  40272. interface ArcRotateCameraInputsManager {
  40273. /**
  40274. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40275. * @returns the camera inputs manager
  40276. */
  40277. addGamepad(): ArcRotateCameraInputsManager;
  40278. }
  40279. }
  40280. /**
  40281. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40282. */
  40283. export class GamepadSystemSceneComponent implements ISceneComponent {
  40284. /**
  40285. * The component name helpfull to identify the component in the list of scene components.
  40286. */
  40287. readonly name: string;
  40288. /**
  40289. * The scene the component belongs to.
  40290. */
  40291. scene: Scene;
  40292. /**
  40293. * Creates a new instance of the component for the given scene
  40294. * @param scene Defines the scene to register the component in
  40295. */
  40296. constructor(scene: Scene);
  40297. /**
  40298. * Registers the component in a given scene
  40299. */
  40300. register(): void;
  40301. /**
  40302. * Rebuilds the elements related to this component in case of
  40303. * context lost for instance.
  40304. */
  40305. rebuild(): void;
  40306. /**
  40307. * Disposes the component and the associated ressources
  40308. */
  40309. dispose(): void;
  40310. private _beforeCameraUpdate;
  40311. }
  40312. }
  40313. declare module "babylonjs/Cameras/universalCamera" {
  40314. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40315. import { Scene } from "babylonjs/scene";
  40316. import { Vector3 } from "babylonjs/Maths/math.vector";
  40317. import "babylonjs/Gamepads/gamepadSceneComponent";
  40318. /**
  40319. * 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,
  40320. * which still works and will still be found in many Playgrounds.
  40321. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40322. */
  40323. export class UniversalCamera extends TouchCamera {
  40324. /**
  40325. * Defines the gamepad rotation sensiblity.
  40326. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40327. */
  40328. gamepadAngularSensibility: number;
  40329. /**
  40330. * Defines the gamepad move sensiblity.
  40331. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40332. */
  40333. gamepadMoveSensibility: number;
  40334. /**
  40335. * 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,
  40336. * which still works and will still be found in many Playgrounds.
  40337. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40338. * @param name Define the name of the camera in the scene
  40339. * @param position Define the start position of the camera in the scene
  40340. * @param scene Define the scene the camera belongs to
  40341. */
  40342. constructor(name: string, position: Vector3, scene: Scene);
  40343. /**
  40344. * Gets the current object class name.
  40345. * @return the class name
  40346. */
  40347. getClassName(): string;
  40348. }
  40349. }
  40350. declare module "babylonjs/Cameras/gamepadCamera" {
  40351. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40352. import { Scene } from "babylonjs/scene";
  40353. import { Vector3 } from "babylonjs/Maths/math.vector";
  40354. /**
  40355. * This represents a FPS type of camera. This is only here for back compat purpose.
  40356. * Please use the UniversalCamera instead as both are identical.
  40357. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40358. */
  40359. export class GamepadCamera extends UniversalCamera {
  40360. /**
  40361. * Instantiates a new Gamepad Camera
  40362. * This represents a FPS type of camera. This is only here for back compat purpose.
  40363. * Please use the UniversalCamera instead as both are identical.
  40364. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40365. * @param name Define the name of the camera in the scene
  40366. * @param position Define the start position of the camera in the scene
  40367. * @param scene Define the scene the camera belongs to
  40368. */
  40369. constructor(name: string, position: Vector3, scene: Scene);
  40370. /**
  40371. * Gets the current object class name.
  40372. * @return the class name
  40373. */
  40374. getClassName(): string;
  40375. }
  40376. }
  40377. declare module "babylonjs/Shaders/pass.fragment" {
  40378. /** @hidden */
  40379. export var passPixelShader: {
  40380. name: string;
  40381. shader: string;
  40382. };
  40383. }
  40384. declare module "babylonjs/Shaders/passCube.fragment" {
  40385. /** @hidden */
  40386. export var passCubePixelShader: {
  40387. name: string;
  40388. shader: string;
  40389. };
  40390. }
  40391. declare module "babylonjs/PostProcesses/passPostProcess" {
  40392. import { Nullable } from "babylonjs/types";
  40393. import { Camera } from "babylonjs/Cameras/camera";
  40394. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40395. import { Engine } from "babylonjs/Engines/engine";
  40396. import "babylonjs/Shaders/pass.fragment";
  40397. import "babylonjs/Shaders/passCube.fragment";
  40398. /**
  40399. * PassPostProcess which produces an output the same as it's input
  40400. */
  40401. export class PassPostProcess extends PostProcess {
  40402. /**
  40403. * Creates the PassPostProcess
  40404. * @param name The name of the effect.
  40405. * @param options The required width/height ratio to downsize to before computing the render pass.
  40406. * @param camera The camera to apply the render pass to.
  40407. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40408. * @param engine The engine which the post process will be applied. (default: current engine)
  40409. * @param reusable If the post process can be reused on the same frame. (default: false)
  40410. * @param textureType The type of texture to be used when performing the post processing.
  40411. * @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)
  40412. */
  40413. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40414. }
  40415. /**
  40416. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40417. */
  40418. export class PassCubePostProcess extends PostProcess {
  40419. private _face;
  40420. /**
  40421. * Gets or sets the cube face to display.
  40422. * * 0 is +X
  40423. * * 1 is -X
  40424. * * 2 is +Y
  40425. * * 3 is -Y
  40426. * * 4 is +Z
  40427. * * 5 is -Z
  40428. */
  40429. face: number;
  40430. /**
  40431. * Creates the PassCubePostProcess
  40432. * @param name The name of the effect.
  40433. * @param options The required width/height ratio to downsize to before computing the render pass.
  40434. * @param camera The camera to apply the render pass to.
  40435. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40436. * @param engine The engine which the post process will be applied. (default: current engine)
  40437. * @param reusable If the post process can be reused on the same frame. (default: false)
  40438. * @param textureType The type of texture to be used when performing the post processing.
  40439. * @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)
  40440. */
  40441. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40442. }
  40443. }
  40444. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40445. /** @hidden */
  40446. export var anaglyphPixelShader: {
  40447. name: string;
  40448. shader: string;
  40449. };
  40450. }
  40451. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40452. import { Engine } from "babylonjs/Engines/engine";
  40453. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40454. import { Camera } from "babylonjs/Cameras/camera";
  40455. import "babylonjs/Shaders/anaglyph.fragment";
  40456. /**
  40457. * Postprocess used to generate anaglyphic rendering
  40458. */
  40459. export class AnaglyphPostProcess extends PostProcess {
  40460. private _passedProcess;
  40461. /**
  40462. * Creates a new AnaglyphPostProcess
  40463. * @param name defines postprocess name
  40464. * @param options defines creation options or target ratio scale
  40465. * @param rigCameras defines cameras using this postprocess
  40466. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40467. * @param engine defines hosting engine
  40468. * @param reusable defines if the postprocess will be reused multiple times per frame
  40469. */
  40470. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40471. }
  40472. }
  40473. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40474. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40475. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40476. import { Scene } from "babylonjs/scene";
  40477. import { Vector3 } from "babylonjs/Maths/math.vector";
  40478. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40479. /**
  40480. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40481. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40482. */
  40483. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40484. /**
  40485. * Creates a new AnaglyphArcRotateCamera
  40486. * @param name defines camera name
  40487. * @param alpha defines alpha angle (in radians)
  40488. * @param beta defines beta angle (in radians)
  40489. * @param radius defines radius
  40490. * @param target defines camera target
  40491. * @param interaxialDistance defines distance between each color axis
  40492. * @param scene defines the hosting scene
  40493. */
  40494. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40495. /**
  40496. * Gets camera class name
  40497. * @returns AnaglyphArcRotateCamera
  40498. */
  40499. getClassName(): string;
  40500. }
  40501. }
  40502. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40503. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40504. import { Scene } from "babylonjs/scene";
  40505. import { Vector3 } from "babylonjs/Maths/math.vector";
  40506. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40507. /**
  40508. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40509. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40510. */
  40511. export class AnaglyphFreeCamera extends FreeCamera {
  40512. /**
  40513. * Creates a new AnaglyphFreeCamera
  40514. * @param name defines camera name
  40515. * @param position defines initial position
  40516. * @param interaxialDistance defines distance between each color axis
  40517. * @param scene defines the hosting scene
  40518. */
  40519. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40520. /**
  40521. * Gets camera class name
  40522. * @returns AnaglyphFreeCamera
  40523. */
  40524. getClassName(): string;
  40525. }
  40526. }
  40527. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40528. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40529. import { Scene } from "babylonjs/scene";
  40530. import { Vector3 } from "babylonjs/Maths/math.vector";
  40531. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40532. /**
  40533. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40534. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40535. */
  40536. export class AnaglyphGamepadCamera extends GamepadCamera {
  40537. /**
  40538. * Creates a new AnaglyphGamepadCamera
  40539. * @param name defines camera name
  40540. * @param position defines initial position
  40541. * @param interaxialDistance defines distance between each color axis
  40542. * @param scene defines the hosting scene
  40543. */
  40544. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40545. /**
  40546. * Gets camera class name
  40547. * @returns AnaglyphGamepadCamera
  40548. */
  40549. getClassName(): string;
  40550. }
  40551. }
  40552. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40553. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40554. import { Scene } from "babylonjs/scene";
  40555. import { Vector3 } from "babylonjs/Maths/math.vector";
  40556. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40557. /**
  40558. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40559. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40560. */
  40561. export class AnaglyphUniversalCamera extends UniversalCamera {
  40562. /**
  40563. * Creates a new AnaglyphUniversalCamera
  40564. * @param name defines camera name
  40565. * @param position defines initial position
  40566. * @param interaxialDistance defines distance between each color axis
  40567. * @param scene defines the hosting scene
  40568. */
  40569. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40570. /**
  40571. * Gets camera class name
  40572. * @returns AnaglyphUniversalCamera
  40573. */
  40574. getClassName(): string;
  40575. }
  40576. }
  40577. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40578. /** @hidden */
  40579. export var stereoscopicInterlacePixelShader: {
  40580. name: string;
  40581. shader: string;
  40582. };
  40583. }
  40584. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40585. import { Camera } from "babylonjs/Cameras/camera";
  40586. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40587. import { Engine } from "babylonjs/Engines/engine";
  40588. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40589. /**
  40590. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40591. */
  40592. export class StereoscopicInterlacePostProcess extends PostProcess {
  40593. private _stepSize;
  40594. private _passedProcess;
  40595. /**
  40596. * Initializes a StereoscopicInterlacePostProcess
  40597. * @param name The name of the effect.
  40598. * @param rigCameras The rig cameras to be appled to the post process
  40599. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40600. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40601. * @param engine The engine which the post process will be applied. (default: current engine)
  40602. * @param reusable If the post process can be reused on the same frame. (default: false)
  40603. */
  40604. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40605. }
  40606. }
  40607. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40608. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40609. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40610. import { Scene } from "babylonjs/scene";
  40611. import { Vector3 } from "babylonjs/Maths/math.vector";
  40612. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40613. /**
  40614. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40615. * @see http://doc.babylonjs.com/features/cameras
  40616. */
  40617. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40618. /**
  40619. * Creates a new StereoscopicArcRotateCamera
  40620. * @param name defines camera name
  40621. * @param alpha defines alpha angle (in radians)
  40622. * @param beta defines beta angle (in radians)
  40623. * @param radius defines radius
  40624. * @param target defines camera target
  40625. * @param interaxialDistance defines distance between each color axis
  40626. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40627. * @param scene defines the hosting scene
  40628. */
  40629. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40630. /**
  40631. * Gets camera class name
  40632. * @returns StereoscopicArcRotateCamera
  40633. */
  40634. getClassName(): string;
  40635. }
  40636. }
  40637. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40638. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40639. import { Scene } from "babylonjs/scene";
  40640. import { Vector3 } from "babylonjs/Maths/math.vector";
  40641. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40642. /**
  40643. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40644. * @see http://doc.babylonjs.com/features/cameras
  40645. */
  40646. export class StereoscopicFreeCamera extends FreeCamera {
  40647. /**
  40648. * Creates a new StereoscopicFreeCamera
  40649. * @param name defines camera name
  40650. * @param position defines initial position
  40651. * @param interaxialDistance defines distance between each color axis
  40652. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40653. * @param scene defines the hosting scene
  40654. */
  40655. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40656. /**
  40657. * Gets camera class name
  40658. * @returns StereoscopicFreeCamera
  40659. */
  40660. getClassName(): string;
  40661. }
  40662. }
  40663. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40664. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40665. import { Scene } from "babylonjs/scene";
  40666. import { Vector3 } from "babylonjs/Maths/math.vector";
  40667. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40668. /**
  40669. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40670. * @see http://doc.babylonjs.com/features/cameras
  40671. */
  40672. export class StereoscopicGamepadCamera extends GamepadCamera {
  40673. /**
  40674. * Creates a new StereoscopicGamepadCamera
  40675. * @param name defines camera name
  40676. * @param position defines initial position
  40677. * @param interaxialDistance defines distance between each color axis
  40678. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40679. * @param scene defines the hosting scene
  40680. */
  40681. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40682. /**
  40683. * Gets camera class name
  40684. * @returns StereoscopicGamepadCamera
  40685. */
  40686. getClassName(): string;
  40687. }
  40688. }
  40689. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40690. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40691. import { Scene } from "babylonjs/scene";
  40692. import { Vector3 } from "babylonjs/Maths/math.vector";
  40693. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40694. /**
  40695. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40696. * @see http://doc.babylonjs.com/features/cameras
  40697. */
  40698. export class StereoscopicUniversalCamera extends UniversalCamera {
  40699. /**
  40700. * Creates a new StereoscopicUniversalCamera
  40701. * @param name defines camera name
  40702. * @param position defines initial position
  40703. * @param interaxialDistance defines distance between each color axis
  40704. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40705. * @param scene defines the hosting scene
  40706. */
  40707. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40708. /**
  40709. * Gets camera class name
  40710. * @returns StereoscopicUniversalCamera
  40711. */
  40712. getClassName(): string;
  40713. }
  40714. }
  40715. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40716. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40717. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40718. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40719. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40720. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40721. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40722. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40723. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40724. }
  40725. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40726. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40727. import { Scene } from "babylonjs/scene";
  40728. import { Vector3 } from "babylonjs/Maths/math.vector";
  40729. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40730. /**
  40731. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40732. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40733. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40734. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40735. */
  40736. export class VirtualJoysticksCamera extends FreeCamera {
  40737. /**
  40738. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40739. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40740. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40741. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40742. * @param name Define the name of the camera in the scene
  40743. * @param position Define the start position of the camera in the scene
  40744. * @param scene Define the scene the camera belongs to
  40745. */
  40746. constructor(name: string, position: Vector3, scene: Scene);
  40747. /**
  40748. * Gets the current object class name.
  40749. * @return the class name
  40750. */
  40751. getClassName(): string;
  40752. }
  40753. }
  40754. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40755. import { Matrix } from "babylonjs/Maths/math.vector";
  40756. /**
  40757. * This represents all the required metrics to create a VR camera.
  40758. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40759. */
  40760. export class VRCameraMetrics {
  40761. /**
  40762. * Define the horizontal resolution off the screen.
  40763. */
  40764. hResolution: number;
  40765. /**
  40766. * Define the vertical resolution off the screen.
  40767. */
  40768. vResolution: number;
  40769. /**
  40770. * Define the horizontal screen size.
  40771. */
  40772. hScreenSize: number;
  40773. /**
  40774. * Define the vertical screen size.
  40775. */
  40776. vScreenSize: number;
  40777. /**
  40778. * Define the vertical screen center position.
  40779. */
  40780. vScreenCenter: number;
  40781. /**
  40782. * Define the distance of the eyes to the screen.
  40783. */
  40784. eyeToScreenDistance: number;
  40785. /**
  40786. * Define the distance between both lenses
  40787. */
  40788. lensSeparationDistance: number;
  40789. /**
  40790. * Define the distance between both viewer's eyes.
  40791. */
  40792. interpupillaryDistance: number;
  40793. /**
  40794. * Define the distortion factor of the VR postprocess.
  40795. * Please, touch with care.
  40796. */
  40797. distortionK: number[];
  40798. /**
  40799. * Define the chromatic aberration correction factors for the VR post process.
  40800. */
  40801. chromaAbCorrection: number[];
  40802. /**
  40803. * Define the scale factor of the post process.
  40804. * The smaller the better but the slower.
  40805. */
  40806. postProcessScaleFactor: number;
  40807. /**
  40808. * Define an offset for the lens center.
  40809. */
  40810. lensCenterOffset: number;
  40811. /**
  40812. * Define if the current vr camera should compensate the distortion of the lense or not.
  40813. */
  40814. compensateDistortion: boolean;
  40815. /**
  40816. * Defines if multiview should be enabled when rendering (Default: false)
  40817. */
  40818. multiviewEnabled: boolean;
  40819. /**
  40820. * Gets the rendering aspect ratio based on the provided resolutions.
  40821. */
  40822. readonly aspectRatio: number;
  40823. /**
  40824. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40825. */
  40826. readonly aspectRatioFov: number;
  40827. /**
  40828. * @hidden
  40829. */
  40830. readonly leftHMatrix: Matrix;
  40831. /**
  40832. * @hidden
  40833. */
  40834. readonly rightHMatrix: Matrix;
  40835. /**
  40836. * @hidden
  40837. */
  40838. readonly leftPreViewMatrix: Matrix;
  40839. /**
  40840. * @hidden
  40841. */
  40842. readonly rightPreViewMatrix: Matrix;
  40843. /**
  40844. * Get the default VRMetrics based on the most generic setup.
  40845. * @returns the default vr metrics
  40846. */
  40847. static GetDefault(): VRCameraMetrics;
  40848. }
  40849. }
  40850. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40851. /** @hidden */
  40852. export var vrDistortionCorrectionPixelShader: {
  40853. name: string;
  40854. shader: string;
  40855. };
  40856. }
  40857. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40858. import { Camera } from "babylonjs/Cameras/camera";
  40859. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40860. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40861. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40862. /**
  40863. * VRDistortionCorrectionPostProcess used for mobile VR
  40864. */
  40865. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40866. private _isRightEye;
  40867. private _distortionFactors;
  40868. private _postProcessScaleFactor;
  40869. private _lensCenterOffset;
  40870. private _scaleIn;
  40871. private _scaleFactor;
  40872. private _lensCenter;
  40873. /**
  40874. * Initializes the VRDistortionCorrectionPostProcess
  40875. * @param name The name of the effect.
  40876. * @param camera The camera to apply the render pass to.
  40877. * @param isRightEye If this is for the right eye distortion
  40878. * @param vrMetrics All the required metrics for the VR camera
  40879. */
  40880. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40881. }
  40882. }
  40883. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40884. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40885. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40886. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40887. import { Scene } from "babylonjs/scene";
  40888. import { Vector3 } from "babylonjs/Maths/math.vector";
  40889. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40890. import "babylonjs/Cameras/RigModes/vrRigMode";
  40891. /**
  40892. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40893. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40894. */
  40895. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40896. /**
  40897. * Creates a new VRDeviceOrientationArcRotateCamera
  40898. * @param name defines camera name
  40899. * @param alpha defines the camera rotation along the logitudinal axis
  40900. * @param beta defines the camera rotation along the latitudinal axis
  40901. * @param radius defines the camera distance from its target
  40902. * @param target defines the camera target
  40903. * @param scene defines the scene the camera belongs to
  40904. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40905. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40906. */
  40907. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40908. /**
  40909. * Gets camera class name
  40910. * @returns VRDeviceOrientationArcRotateCamera
  40911. */
  40912. getClassName(): string;
  40913. }
  40914. }
  40915. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40916. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40917. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40918. import { Scene } from "babylonjs/scene";
  40919. import { Vector3 } from "babylonjs/Maths/math.vector";
  40920. import "babylonjs/Cameras/RigModes/vrRigMode";
  40921. /**
  40922. * Camera used to simulate VR rendering (based on FreeCamera)
  40923. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40924. */
  40925. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40926. /**
  40927. * Creates a new VRDeviceOrientationFreeCamera
  40928. * @param name defines camera name
  40929. * @param position defines the start position of the camera
  40930. * @param scene defines the scene the camera belongs to
  40931. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40932. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40933. */
  40934. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40935. /**
  40936. * Gets camera class name
  40937. * @returns VRDeviceOrientationFreeCamera
  40938. */
  40939. getClassName(): string;
  40940. }
  40941. }
  40942. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40943. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40944. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40945. import { Scene } from "babylonjs/scene";
  40946. import { Vector3 } from "babylonjs/Maths/math.vector";
  40947. import "babylonjs/Gamepads/gamepadSceneComponent";
  40948. /**
  40949. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40950. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40951. */
  40952. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40953. /**
  40954. * Creates a new VRDeviceOrientationGamepadCamera
  40955. * @param name defines camera name
  40956. * @param position defines the start position of the camera
  40957. * @param scene defines the scene the camera belongs to
  40958. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40959. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40960. */
  40961. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40962. /**
  40963. * Gets camera class name
  40964. * @returns VRDeviceOrientationGamepadCamera
  40965. */
  40966. getClassName(): string;
  40967. }
  40968. }
  40969. declare module "babylonjs/Materials/pushMaterial" {
  40970. import { Nullable } from "babylonjs/types";
  40971. import { Scene } from "babylonjs/scene";
  40972. import { Matrix } from "babylonjs/Maths/math.vector";
  40973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40974. import { Mesh } from "babylonjs/Meshes/mesh";
  40975. import { Material } from "babylonjs/Materials/material";
  40976. import { Effect } from "babylonjs/Materials/effect";
  40977. /**
  40978. * Base class of materials working in push mode in babylon JS
  40979. * @hidden
  40980. */
  40981. export class PushMaterial extends Material {
  40982. protected _activeEffect: Effect;
  40983. protected _normalMatrix: Matrix;
  40984. /**
  40985. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40986. * This means that the material can keep using a previous shader while a new one is being compiled.
  40987. * This is mostly used when shader parallel compilation is supported (true by default)
  40988. */
  40989. allowShaderHotSwapping: boolean;
  40990. constructor(name: string, scene: Scene);
  40991. getEffect(): Effect;
  40992. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40993. /**
  40994. * Binds the given world matrix to the active effect
  40995. *
  40996. * @param world the matrix to bind
  40997. */
  40998. bindOnlyWorldMatrix(world: Matrix): void;
  40999. /**
  41000. * Binds the given normal matrix to the active effect
  41001. *
  41002. * @param normalMatrix the matrix to bind
  41003. */
  41004. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41005. bind(world: Matrix, mesh?: Mesh): void;
  41006. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41007. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41008. }
  41009. }
  41010. declare module "babylonjs/Materials/materialFlags" {
  41011. /**
  41012. * This groups all the flags used to control the materials channel.
  41013. */
  41014. export class MaterialFlags {
  41015. private static _DiffuseTextureEnabled;
  41016. /**
  41017. * Are diffuse textures enabled in the application.
  41018. */
  41019. static DiffuseTextureEnabled: boolean;
  41020. private static _AmbientTextureEnabled;
  41021. /**
  41022. * Are ambient textures enabled in the application.
  41023. */
  41024. static AmbientTextureEnabled: boolean;
  41025. private static _OpacityTextureEnabled;
  41026. /**
  41027. * Are opacity textures enabled in the application.
  41028. */
  41029. static OpacityTextureEnabled: boolean;
  41030. private static _ReflectionTextureEnabled;
  41031. /**
  41032. * Are reflection textures enabled in the application.
  41033. */
  41034. static ReflectionTextureEnabled: boolean;
  41035. private static _EmissiveTextureEnabled;
  41036. /**
  41037. * Are emissive textures enabled in the application.
  41038. */
  41039. static EmissiveTextureEnabled: boolean;
  41040. private static _SpecularTextureEnabled;
  41041. /**
  41042. * Are specular textures enabled in the application.
  41043. */
  41044. static SpecularTextureEnabled: boolean;
  41045. private static _BumpTextureEnabled;
  41046. /**
  41047. * Are bump textures enabled in the application.
  41048. */
  41049. static BumpTextureEnabled: boolean;
  41050. private static _LightmapTextureEnabled;
  41051. /**
  41052. * Are lightmap textures enabled in the application.
  41053. */
  41054. static LightmapTextureEnabled: boolean;
  41055. private static _RefractionTextureEnabled;
  41056. /**
  41057. * Are refraction textures enabled in the application.
  41058. */
  41059. static RefractionTextureEnabled: boolean;
  41060. private static _ColorGradingTextureEnabled;
  41061. /**
  41062. * Are color grading textures enabled in the application.
  41063. */
  41064. static ColorGradingTextureEnabled: boolean;
  41065. private static _FresnelEnabled;
  41066. /**
  41067. * Are fresnels enabled in the application.
  41068. */
  41069. static FresnelEnabled: boolean;
  41070. private static _ClearCoatTextureEnabled;
  41071. /**
  41072. * Are clear coat textures enabled in the application.
  41073. */
  41074. static ClearCoatTextureEnabled: boolean;
  41075. private static _ClearCoatBumpTextureEnabled;
  41076. /**
  41077. * Are clear coat bump textures enabled in the application.
  41078. */
  41079. static ClearCoatBumpTextureEnabled: boolean;
  41080. private static _ClearCoatTintTextureEnabled;
  41081. /**
  41082. * Are clear coat tint textures enabled in the application.
  41083. */
  41084. static ClearCoatTintTextureEnabled: boolean;
  41085. private static _SheenTextureEnabled;
  41086. /**
  41087. * Are sheen textures enabled in the application.
  41088. */
  41089. static SheenTextureEnabled: boolean;
  41090. private static _AnisotropicTextureEnabled;
  41091. /**
  41092. * Are anisotropic textures enabled in the application.
  41093. */
  41094. static AnisotropicTextureEnabled: boolean;
  41095. private static _ThicknessTextureEnabled;
  41096. /**
  41097. * Are thickness textures enabled in the application.
  41098. */
  41099. static ThicknessTextureEnabled: boolean;
  41100. }
  41101. }
  41102. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41103. /** @hidden */
  41104. export var defaultFragmentDeclaration: {
  41105. name: string;
  41106. shader: string;
  41107. };
  41108. }
  41109. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41110. /** @hidden */
  41111. export var defaultUboDeclaration: {
  41112. name: string;
  41113. shader: string;
  41114. };
  41115. }
  41116. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41117. /** @hidden */
  41118. export var lightFragmentDeclaration: {
  41119. name: string;
  41120. shader: string;
  41121. };
  41122. }
  41123. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41124. /** @hidden */
  41125. export var lightUboDeclaration: {
  41126. name: string;
  41127. shader: string;
  41128. };
  41129. }
  41130. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41131. /** @hidden */
  41132. export var lightsFragmentFunctions: {
  41133. name: string;
  41134. shader: string;
  41135. };
  41136. }
  41137. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41138. /** @hidden */
  41139. export var shadowsFragmentFunctions: {
  41140. name: string;
  41141. shader: string;
  41142. };
  41143. }
  41144. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41145. /** @hidden */
  41146. export var fresnelFunction: {
  41147. name: string;
  41148. shader: string;
  41149. };
  41150. }
  41151. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41152. /** @hidden */
  41153. export var reflectionFunction: {
  41154. name: string;
  41155. shader: string;
  41156. };
  41157. }
  41158. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41159. /** @hidden */
  41160. export var bumpFragmentFunctions: {
  41161. name: string;
  41162. shader: string;
  41163. };
  41164. }
  41165. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41166. /** @hidden */
  41167. export var logDepthDeclaration: {
  41168. name: string;
  41169. shader: string;
  41170. };
  41171. }
  41172. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41173. /** @hidden */
  41174. export var bumpFragment: {
  41175. name: string;
  41176. shader: string;
  41177. };
  41178. }
  41179. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41180. /** @hidden */
  41181. export var depthPrePass: {
  41182. name: string;
  41183. shader: string;
  41184. };
  41185. }
  41186. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41187. /** @hidden */
  41188. export var lightFragment: {
  41189. name: string;
  41190. shader: string;
  41191. };
  41192. }
  41193. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41194. /** @hidden */
  41195. export var logDepthFragment: {
  41196. name: string;
  41197. shader: string;
  41198. };
  41199. }
  41200. declare module "babylonjs/Shaders/default.fragment" {
  41201. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41202. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41203. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41204. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41205. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41206. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41207. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41208. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41209. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41210. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41211. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41212. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41213. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41214. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41215. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41216. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41217. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41218. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41219. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41220. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41221. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41222. /** @hidden */
  41223. export var defaultPixelShader: {
  41224. name: string;
  41225. shader: string;
  41226. };
  41227. }
  41228. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41229. /** @hidden */
  41230. export var defaultVertexDeclaration: {
  41231. name: string;
  41232. shader: string;
  41233. };
  41234. }
  41235. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41236. /** @hidden */
  41237. export var bumpVertexDeclaration: {
  41238. name: string;
  41239. shader: string;
  41240. };
  41241. }
  41242. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41243. /** @hidden */
  41244. export var bumpVertex: {
  41245. name: string;
  41246. shader: string;
  41247. };
  41248. }
  41249. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41250. /** @hidden */
  41251. export var fogVertex: {
  41252. name: string;
  41253. shader: string;
  41254. };
  41255. }
  41256. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41257. /** @hidden */
  41258. export var shadowsVertex: {
  41259. name: string;
  41260. shader: string;
  41261. };
  41262. }
  41263. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41264. /** @hidden */
  41265. export var pointCloudVertex: {
  41266. name: string;
  41267. shader: string;
  41268. };
  41269. }
  41270. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41271. /** @hidden */
  41272. export var logDepthVertex: {
  41273. name: string;
  41274. shader: string;
  41275. };
  41276. }
  41277. declare module "babylonjs/Shaders/default.vertex" {
  41278. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41279. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41280. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41281. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41282. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41283. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41284. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41285. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41286. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41287. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41288. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41289. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41290. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41291. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41292. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41293. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41294. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41295. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41296. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41297. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41298. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41299. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41300. /** @hidden */
  41301. export var defaultVertexShader: {
  41302. name: string;
  41303. shader: string;
  41304. };
  41305. }
  41306. declare module "babylonjs/Materials/standardMaterial" {
  41307. import { SmartArray } from "babylonjs/Misc/smartArray";
  41308. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41309. import { Nullable } from "babylonjs/types";
  41310. import { Scene } from "babylonjs/scene";
  41311. import { Matrix } from "babylonjs/Maths/math.vector";
  41312. import { Color3 } from "babylonjs/Maths/math.color";
  41313. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41314. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41315. import { Mesh } from "babylonjs/Meshes/mesh";
  41316. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41317. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41318. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41319. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41320. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41321. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41322. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41323. import "babylonjs/Shaders/default.fragment";
  41324. import "babylonjs/Shaders/default.vertex";
  41325. /** @hidden */
  41326. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41327. MAINUV1: boolean;
  41328. MAINUV2: boolean;
  41329. DIFFUSE: boolean;
  41330. DIFFUSEDIRECTUV: number;
  41331. AMBIENT: boolean;
  41332. AMBIENTDIRECTUV: number;
  41333. OPACITY: boolean;
  41334. OPACITYDIRECTUV: number;
  41335. OPACITYRGB: boolean;
  41336. REFLECTION: boolean;
  41337. EMISSIVE: boolean;
  41338. EMISSIVEDIRECTUV: number;
  41339. SPECULAR: boolean;
  41340. SPECULARDIRECTUV: number;
  41341. BUMP: boolean;
  41342. BUMPDIRECTUV: number;
  41343. PARALLAX: boolean;
  41344. PARALLAXOCCLUSION: boolean;
  41345. SPECULAROVERALPHA: boolean;
  41346. CLIPPLANE: boolean;
  41347. CLIPPLANE2: boolean;
  41348. CLIPPLANE3: boolean;
  41349. CLIPPLANE4: boolean;
  41350. ALPHATEST: boolean;
  41351. DEPTHPREPASS: boolean;
  41352. ALPHAFROMDIFFUSE: boolean;
  41353. POINTSIZE: boolean;
  41354. FOG: boolean;
  41355. SPECULARTERM: boolean;
  41356. DIFFUSEFRESNEL: boolean;
  41357. OPACITYFRESNEL: boolean;
  41358. REFLECTIONFRESNEL: boolean;
  41359. REFRACTIONFRESNEL: boolean;
  41360. EMISSIVEFRESNEL: boolean;
  41361. FRESNEL: boolean;
  41362. NORMAL: boolean;
  41363. UV1: boolean;
  41364. UV2: boolean;
  41365. VERTEXCOLOR: boolean;
  41366. VERTEXALPHA: boolean;
  41367. NUM_BONE_INFLUENCERS: number;
  41368. BonesPerMesh: number;
  41369. BONETEXTURE: boolean;
  41370. INSTANCES: boolean;
  41371. GLOSSINESS: boolean;
  41372. ROUGHNESS: boolean;
  41373. EMISSIVEASILLUMINATION: boolean;
  41374. LINKEMISSIVEWITHDIFFUSE: boolean;
  41375. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41376. LIGHTMAP: boolean;
  41377. LIGHTMAPDIRECTUV: number;
  41378. OBJECTSPACE_NORMALMAP: boolean;
  41379. USELIGHTMAPASSHADOWMAP: boolean;
  41380. REFLECTIONMAP_3D: boolean;
  41381. REFLECTIONMAP_SPHERICAL: boolean;
  41382. REFLECTIONMAP_PLANAR: boolean;
  41383. REFLECTIONMAP_CUBIC: boolean;
  41384. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41385. REFLECTIONMAP_PROJECTION: boolean;
  41386. REFLECTIONMAP_SKYBOX: boolean;
  41387. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41388. REFLECTIONMAP_EXPLICIT: boolean;
  41389. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41390. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41391. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41392. INVERTCUBICMAP: boolean;
  41393. LOGARITHMICDEPTH: boolean;
  41394. REFRACTION: boolean;
  41395. REFRACTIONMAP_3D: boolean;
  41396. REFLECTIONOVERALPHA: boolean;
  41397. TWOSIDEDLIGHTING: boolean;
  41398. SHADOWFLOAT: boolean;
  41399. MORPHTARGETS: boolean;
  41400. MORPHTARGETS_NORMAL: boolean;
  41401. MORPHTARGETS_TANGENT: boolean;
  41402. MORPHTARGETS_UV: boolean;
  41403. NUM_MORPH_INFLUENCERS: number;
  41404. NONUNIFORMSCALING: boolean;
  41405. PREMULTIPLYALPHA: boolean;
  41406. IMAGEPROCESSING: boolean;
  41407. VIGNETTE: boolean;
  41408. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41409. VIGNETTEBLENDMODEOPAQUE: boolean;
  41410. TONEMAPPING: boolean;
  41411. TONEMAPPING_ACES: boolean;
  41412. CONTRAST: boolean;
  41413. COLORCURVES: boolean;
  41414. COLORGRADING: boolean;
  41415. COLORGRADING3D: boolean;
  41416. SAMPLER3DGREENDEPTH: boolean;
  41417. SAMPLER3DBGRMAP: boolean;
  41418. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41419. MULTIVIEW: boolean;
  41420. /**
  41421. * If the reflection texture on this material is in linear color space
  41422. * @hidden
  41423. */
  41424. IS_REFLECTION_LINEAR: boolean;
  41425. /**
  41426. * If the refraction texture on this material is in linear color space
  41427. * @hidden
  41428. */
  41429. IS_REFRACTION_LINEAR: boolean;
  41430. EXPOSURE: boolean;
  41431. constructor();
  41432. setReflectionMode(modeToEnable: string): void;
  41433. }
  41434. /**
  41435. * This is the default material used in Babylon. It is the best trade off between quality
  41436. * and performances.
  41437. * @see http://doc.babylonjs.com/babylon101/materials
  41438. */
  41439. export class StandardMaterial extends PushMaterial {
  41440. private _diffuseTexture;
  41441. /**
  41442. * The basic texture of the material as viewed under a light.
  41443. */
  41444. diffuseTexture: Nullable<BaseTexture>;
  41445. private _ambientTexture;
  41446. /**
  41447. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41448. */
  41449. ambientTexture: Nullable<BaseTexture>;
  41450. private _opacityTexture;
  41451. /**
  41452. * Define the transparency of the material from a texture.
  41453. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41454. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41455. */
  41456. opacityTexture: Nullable<BaseTexture>;
  41457. private _reflectionTexture;
  41458. /**
  41459. * Define the texture used to display the reflection.
  41460. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41461. */
  41462. reflectionTexture: Nullable<BaseTexture>;
  41463. private _emissiveTexture;
  41464. /**
  41465. * Define texture of the material as if self lit.
  41466. * This will be mixed in the final result even in the absence of light.
  41467. */
  41468. emissiveTexture: Nullable<BaseTexture>;
  41469. private _specularTexture;
  41470. /**
  41471. * Define how the color and intensity of the highlight given by the light in the material.
  41472. */
  41473. specularTexture: Nullable<BaseTexture>;
  41474. private _bumpTexture;
  41475. /**
  41476. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41477. * 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.
  41478. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41479. */
  41480. bumpTexture: Nullable<BaseTexture>;
  41481. private _lightmapTexture;
  41482. /**
  41483. * Complex lighting can be computationally expensive to compute at runtime.
  41484. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41485. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41486. */
  41487. lightmapTexture: Nullable<BaseTexture>;
  41488. private _refractionTexture;
  41489. /**
  41490. * Define the texture used to display the refraction.
  41491. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41492. */
  41493. refractionTexture: Nullable<BaseTexture>;
  41494. /**
  41495. * The color of the material lit by the environmental background lighting.
  41496. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41497. */
  41498. ambientColor: Color3;
  41499. /**
  41500. * The basic color of the material as viewed under a light.
  41501. */
  41502. diffuseColor: Color3;
  41503. /**
  41504. * Define how the color and intensity of the highlight given by the light in the material.
  41505. */
  41506. specularColor: Color3;
  41507. /**
  41508. * Define the color of the material as if self lit.
  41509. * This will be mixed in the final result even in the absence of light.
  41510. */
  41511. emissiveColor: Color3;
  41512. /**
  41513. * Defines how sharp are the highlights in the material.
  41514. * The bigger the value the sharper giving a more glossy feeling to the result.
  41515. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41516. */
  41517. specularPower: number;
  41518. private _useAlphaFromDiffuseTexture;
  41519. /**
  41520. * Does the transparency come from the diffuse texture alpha channel.
  41521. */
  41522. useAlphaFromDiffuseTexture: boolean;
  41523. private _useEmissiveAsIllumination;
  41524. /**
  41525. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41526. */
  41527. useEmissiveAsIllumination: boolean;
  41528. private _linkEmissiveWithDiffuse;
  41529. /**
  41530. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41531. * the emissive level when the final color is close to one.
  41532. */
  41533. linkEmissiveWithDiffuse: boolean;
  41534. private _useSpecularOverAlpha;
  41535. /**
  41536. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41537. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41538. */
  41539. useSpecularOverAlpha: boolean;
  41540. private _useReflectionOverAlpha;
  41541. /**
  41542. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41543. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41544. */
  41545. useReflectionOverAlpha: boolean;
  41546. private _disableLighting;
  41547. /**
  41548. * Does lights from the scene impacts this material.
  41549. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41550. */
  41551. disableLighting: boolean;
  41552. private _useObjectSpaceNormalMap;
  41553. /**
  41554. * Allows using an object space normal map (instead of tangent space).
  41555. */
  41556. useObjectSpaceNormalMap: boolean;
  41557. private _useParallax;
  41558. /**
  41559. * Is parallax enabled or not.
  41560. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41561. */
  41562. useParallax: boolean;
  41563. private _useParallaxOcclusion;
  41564. /**
  41565. * Is parallax occlusion enabled or not.
  41566. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41567. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41568. */
  41569. useParallaxOcclusion: boolean;
  41570. /**
  41571. * 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.
  41572. */
  41573. parallaxScaleBias: number;
  41574. private _roughness;
  41575. /**
  41576. * Helps to define how blurry the reflections should appears in the material.
  41577. */
  41578. roughness: number;
  41579. /**
  41580. * In case of refraction, define the value of the index of refraction.
  41581. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41582. */
  41583. indexOfRefraction: number;
  41584. /**
  41585. * Invert the refraction texture alongside the y axis.
  41586. * It can be useful with procedural textures or probe for instance.
  41587. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41588. */
  41589. invertRefractionY: boolean;
  41590. /**
  41591. * Defines the alpha limits in alpha test mode.
  41592. */
  41593. alphaCutOff: number;
  41594. private _useLightmapAsShadowmap;
  41595. /**
  41596. * In case of light mapping, define whether the map contains light or shadow informations.
  41597. */
  41598. useLightmapAsShadowmap: boolean;
  41599. private _diffuseFresnelParameters;
  41600. /**
  41601. * Define the diffuse fresnel parameters of the material.
  41602. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41603. */
  41604. diffuseFresnelParameters: FresnelParameters;
  41605. private _opacityFresnelParameters;
  41606. /**
  41607. * Define the opacity fresnel parameters of the material.
  41608. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41609. */
  41610. opacityFresnelParameters: FresnelParameters;
  41611. private _reflectionFresnelParameters;
  41612. /**
  41613. * Define the reflection fresnel parameters of the material.
  41614. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41615. */
  41616. reflectionFresnelParameters: FresnelParameters;
  41617. private _refractionFresnelParameters;
  41618. /**
  41619. * Define the refraction fresnel parameters of the material.
  41620. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41621. */
  41622. refractionFresnelParameters: FresnelParameters;
  41623. private _emissiveFresnelParameters;
  41624. /**
  41625. * Define the emissive fresnel parameters of the material.
  41626. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41627. */
  41628. emissiveFresnelParameters: FresnelParameters;
  41629. private _useReflectionFresnelFromSpecular;
  41630. /**
  41631. * If true automatically deducts the fresnels values from the material specularity.
  41632. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41633. */
  41634. useReflectionFresnelFromSpecular: boolean;
  41635. private _useGlossinessFromSpecularMapAlpha;
  41636. /**
  41637. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41638. */
  41639. useGlossinessFromSpecularMapAlpha: boolean;
  41640. private _maxSimultaneousLights;
  41641. /**
  41642. * Defines the maximum number of lights that can be used in the material
  41643. */
  41644. maxSimultaneousLights: number;
  41645. private _invertNormalMapX;
  41646. /**
  41647. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41648. */
  41649. invertNormalMapX: boolean;
  41650. private _invertNormalMapY;
  41651. /**
  41652. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41653. */
  41654. invertNormalMapY: boolean;
  41655. private _twoSidedLighting;
  41656. /**
  41657. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41658. */
  41659. twoSidedLighting: boolean;
  41660. /**
  41661. * Default configuration related to image processing available in the standard Material.
  41662. */
  41663. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41664. /**
  41665. * Gets the image processing configuration used either in this material.
  41666. */
  41667. /**
  41668. * Sets the Default image processing configuration used either in the this material.
  41669. *
  41670. * If sets to null, the scene one is in use.
  41671. */
  41672. imageProcessingConfiguration: ImageProcessingConfiguration;
  41673. /**
  41674. * Keep track of the image processing observer to allow dispose and replace.
  41675. */
  41676. private _imageProcessingObserver;
  41677. /**
  41678. * Attaches a new image processing configuration to the Standard Material.
  41679. * @param configuration
  41680. */
  41681. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41682. /**
  41683. * Gets wether the color curves effect is enabled.
  41684. */
  41685. /**
  41686. * Sets wether the color curves effect is enabled.
  41687. */
  41688. cameraColorCurvesEnabled: boolean;
  41689. /**
  41690. * Gets wether the color grading effect is enabled.
  41691. */
  41692. /**
  41693. * Gets wether the color grading effect is enabled.
  41694. */
  41695. cameraColorGradingEnabled: boolean;
  41696. /**
  41697. * Gets wether tonemapping is enabled or not.
  41698. */
  41699. /**
  41700. * Sets wether tonemapping is enabled or not
  41701. */
  41702. cameraToneMappingEnabled: boolean;
  41703. /**
  41704. * The camera exposure used on this material.
  41705. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41706. * This corresponds to a photographic exposure.
  41707. */
  41708. /**
  41709. * The camera exposure used on this material.
  41710. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41711. * This corresponds to a photographic exposure.
  41712. */
  41713. cameraExposure: number;
  41714. /**
  41715. * Gets The camera contrast used on this material.
  41716. */
  41717. /**
  41718. * Sets The camera contrast used on this material.
  41719. */
  41720. cameraContrast: number;
  41721. /**
  41722. * Gets the Color Grading 2D Lookup Texture.
  41723. */
  41724. /**
  41725. * Sets the Color Grading 2D Lookup Texture.
  41726. */
  41727. cameraColorGradingTexture: Nullable<BaseTexture>;
  41728. /**
  41729. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41730. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41731. * 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;
  41732. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41733. */
  41734. /**
  41735. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41736. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41737. * 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;
  41738. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41739. */
  41740. cameraColorCurves: Nullable<ColorCurves>;
  41741. /**
  41742. * Custom callback helping to override the default shader used in the material.
  41743. */
  41744. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41745. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41746. protected _worldViewProjectionMatrix: Matrix;
  41747. protected _globalAmbientColor: Color3;
  41748. protected _useLogarithmicDepth: boolean;
  41749. protected _rebuildInParallel: boolean;
  41750. /**
  41751. * Instantiates a new standard material.
  41752. * This is the default material used in Babylon. It is the best trade off between quality
  41753. * and performances.
  41754. * @see http://doc.babylonjs.com/babylon101/materials
  41755. * @param name Define the name of the material in the scene
  41756. * @param scene Define the scene the material belong to
  41757. */
  41758. constructor(name: string, scene: Scene);
  41759. /**
  41760. * Gets a boolean indicating that current material needs to register RTT
  41761. */
  41762. readonly hasRenderTargetTextures: boolean;
  41763. /**
  41764. * Gets the current class name of the material e.g. "StandardMaterial"
  41765. * Mainly use in serialization.
  41766. * @returns the class name
  41767. */
  41768. getClassName(): string;
  41769. /**
  41770. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41771. * You can try switching to logarithmic depth.
  41772. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41773. */
  41774. useLogarithmicDepth: boolean;
  41775. /**
  41776. * Specifies if the material will require alpha blending
  41777. * @returns a boolean specifying if alpha blending is needed
  41778. */
  41779. needAlphaBlending(): boolean;
  41780. /**
  41781. * Specifies if this material should be rendered in alpha test mode
  41782. * @returns a boolean specifying if an alpha test is needed.
  41783. */
  41784. needAlphaTesting(): boolean;
  41785. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41786. /**
  41787. * Get the texture used for alpha test purpose.
  41788. * @returns the diffuse texture in case of the standard material.
  41789. */
  41790. getAlphaTestTexture(): Nullable<BaseTexture>;
  41791. /**
  41792. * Get if the submesh is ready to be used and all its information available.
  41793. * Child classes can use it to update shaders
  41794. * @param mesh defines the mesh to check
  41795. * @param subMesh defines which submesh to check
  41796. * @param useInstances specifies that instances should be used
  41797. * @returns a boolean indicating that the submesh is ready or not
  41798. */
  41799. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41800. /**
  41801. * Builds the material UBO layouts.
  41802. * Used internally during the effect preparation.
  41803. */
  41804. buildUniformLayout(): void;
  41805. /**
  41806. * Unbinds the material from the mesh
  41807. */
  41808. unbind(): void;
  41809. /**
  41810. * Binds the submesh to this material by preparing the effect and shader to draw
  41811. * @param world defines the world transformation matrix
  41812. * @param mesh defines the mesh containing the submesh
  41813. * @param subMesh defines the submesh to bind the material to
  41814. */
  41815. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41816. /**
  41817. * Get the list of animatables in the material.
  41818. * @returns the list of animatables object used in the material
  41819. */
  41820. getAnimatables(): IAnimatable[];
  41821. /**
  41822. * Gets the active textures from the material
  41823. * @returns an array of textures
  41824. */
  41825. getActiveTextures(): BaseTexture[];
  41826. /**
  41827. * Specifies if the material uses a texture
  41828. * @param texture defines the texture to check against the material
  41829. * @returns a boolean specifying if the material uses the texture
  41830. */
  41831. hasTexture(texture: BaseTexture): boolean;
  41832. /**
  41833. * Disposes the material
  41834. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41835. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41836. */
  41837. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41838. /**
  41839. * Makes a duplicate of the material, and gives it a new name
  41840. * @param name defines the new name for the duplicated material
  41841. * @returns the cloned material
  41842. */
  41843. clone(name: string): StandardMaterial;
  41844. /**
  41845. * Serializes this material in a JSON representation
  41846. * @returns the serialized material object
  41847. */
  41848. serialize(): any;
  41849. /**
  41850. * Creates a standard material from parsed material data
  41851. * @param source defines the JSON representation of the material
  41852. * @param scene defines the hosting scene
  41853. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41854. * @returns a new standard material
  41855. */
  41856. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41857. /**
  41858. * Are diffuse textures enabled in the application.
  41859. */
  41860. static DiffuseTextureEnabled: boolean;
  41861. /**
  41862. * Are ambient textures enabled in the application.
  41863. */
  41864. static AmbientTextureEnabled: boolean;
  41865. /**
  41866. * Are opacity textures enabled in the application.
  41867. */
  41868. static OpacityTextureEnabled: boolean;
  41869. /**
  41870. * Are reflection textures enabled in the application.
  41871. */
  41872. static ReflectionTextureEnabled: boolean;
  41873. /**
  41874. * Are emissive textures enabled in the application.
  41875. */
  41876. static EmissiveTextureEnabled: boolean;
  41877. /**
  41878. * Are specular textures enabled in the application.
  41879. */
  41880. static SpecularTextureEnabled: boolean;
  41881. /**
  41882. * Are bump textures enabled in the application.
  41883. */
  41884. static BumpTextureEnabled: boolean;
  41885. /**
  41886. * Are lightmap textures enabled in the application.
  41887. */
  41888. static LightmapTextureEnabled: boolean;
  41889. /**
  41890. * Are refraction textures enabled in the application.
  41891. */
  41892. static RefractionTextureEnabled: boolean;
  41893. /**
  41894. * Are color grading textures enabled in the application.
  41895. */
  41896. static ColorGradingTextureEnabled: boolean;
  41897. /**
  41898. * Are fresnels enabled in the application.
  41899. */
  41900. static FresnelEnabled: boolean;
  41901. }
  41902. }
  41903. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41904. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41905. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41906. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41907. /** @hidden */
  41908. export var imageProcessingPixelShader: {
  41909. name: string;
  41910. shader: string;
  41911. };
  41912. }
  41913. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41914. import { Nullable } from "babylonjs/types";
  41915. import { Color4 } from "babylonjs/Maths/math.color";
  41916. import { Camera } from "babylonjs/Cameras/camera";
  41917. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41918. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41919. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41920. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41921. import { Engine } from "babylonjs/Engines/engine";
  41922. import "babylonjs/Shaders/imageProcessing.fragment";
  41923. import "babylonjs/Shaders/postprocess.vertex";
  41924. /**
  41925. * ImageProcessingPostProcess
  41926. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41927. */
  41928. export class ImageProcessingPostProcess extends PostProcess {
  41929. /**
  41930. * Default configuration related to image processing available in the PBR Material.
  41931. */
  41932. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41933. /**
  41934. * Gets the image processing configuration used either in this material.
  41935. */
  41936. /**
  41937. * Sets the Default image processing configuration used either in the this material.
  41938. *
  41939. * If sets to null, the scene one is in use.
  41940. */
  41941. imageProcessingConfiguration: ImageProcessingConfiguration;
  41942. /**
  41943. * Keep track of the image processing observer to allow dispose and replace.
  41944. */
  41945. private _imageProcessingObserver;
  41946. /**
  41947. * Attaches a new image processing configuration to the PBR Material.
  41948. * @param configuration
  41949. */
  41950. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41951. /**
  41952. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41953. */
  41954. /**
  41955. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41956. */
  41957. colorCurves: Nullable<ColorCurves>;
  41958. /**
  41959. * Gets wether the color curves effect is enabled.
  41960. */
  41961. /**
  41962. * Sets wether the color curves effect is enabled.
  41963. */
  41964. colorCurvesEnabled: boolean;
  41965. /**
  41966. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41967. */
  41968. /**
  41969. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41970. */
  41971. colorGradingTexture: Nullable<BaseTexture>;
  41972. /**
  41973. * Gets wether the color grading effect is enabled.
  41974. */
  41975. /**
  41976. * Gets wether the color grading effect is enabled.
  41977. */
  41978. colorGradingEnabled: boolean;
  41979. /**
  41980. * Gets exposure used in the effect.
  41981. */
  41982. /**
  41983. * Sets exposure used in the effect.
  41984. */
  41985. exposure: number;
  41986. /**
  41987. * Gets wether tonemapping is enabled or not.
  41988. */
  41989. /**
  41990. * Sets wether tonemapping is enabled or not
  41991. */
  41992. toneMappingEnabled: boolean;
  41993. /**
  41994. * Gets the type of tone mapping effect.
  41995. */
  41996. /**
  41997. * Sets the type of tone mapping effect.
  41998. */
  41999. toneMappingType: number;
  42000. /**
  42001. * Gets contrast used in the effect.
  42002. */
  42003. /**
  42004. * Sets contrast used in the effect.
  42005. */
  42006. contrast: number;
  42007. /**
  42008. * Gets Vignette stretch size.
  42009. */
  42010. /**
  42011. * Sets Vignette stretch size.
  42012. */
  42013. vignetteStretch: number;
  42014. /**
  42015. * Gets Vignette centre X Offset.
  42016. */
  42017. /**
  42018. * Sets Vignette centre X Offset.
  42019. */
  42020. vignetteCentreX: number;
  42021. /**
  42022. * Gets Vignette centre Y Offset.
  42023. */
  42024. /**
  42025. * Sets Vignette centre Y Offset.
  42026. */
  42027. vignetteCentreY: number;
  42028. /**
  42029. * Gets Vignette weight or intensity of the vignette effect.
  42030. */
  42031. /**
  42032. * Sets Vignette weight or intensity of the vignette effect.
  42033. */
  42034. vignetteWeight: number;
  42035. /**
  42036. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42037. * if vignetteEnabled is set to true.
  42038. */
  42039. /**
  42040. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42041. * if vignetteEnabled is set to true.
  42042. */
  42043. vignetteColor: Color4;
  42044. /**
  42045. * Gets Camera field of view used by the Vignette effect.
  42046. */
  42047. /**
  42048. * Sets Camera field of view used by the Vignette effect.
  42049. */
  42050. vignetteCameraFov: number;
  42051. /**
  42052. * Gets the vignette blend mode allowing different kind of effect.
  42053. */
  42054. /**
  42055. * Sets the vignette blend mode allowing different kind of effect.
  42056. */
  42057. vignetteBlendMode: number;
  42058. /**
  42059. * Gets wether the vignette effect is enabled.
  42060. */
  42061. /**
  42062. * Sets wether the vignette effect is enabled.
  42063. */
  42064. vignetteEnabled: boolean;
  42065. private _fromLinearSpace;
  42066. /**
  42067. * Gets wether the input of the processing is in Gamma or Linear Space.
  42068. */
  42069. /**
  42070. * Sets wether the input of the processing is in Gamma or Linear Space.
  42071. */
  42072. fromLinearSpace: boolean;
  42073. /**
  42074. * Defines cache preventing GC.
  42075. */
  42076. private _defines;
  42077. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42078. /**
  42079. * "ImageProcessingPostProcess"
  42080. * @returns "ImageProcessingPostProcess"
  42081. */
  42082. getClassName(): string;
  42083. protected _updateParameters(): void;
  42084. dispose(camera?: Camera): void;
  42085. }
  42086. }
  42087. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42088. import { Scene } from "babylonjs/scene";
  42089. import { Color3 } from "babylonjs/Maths/math.color";
  42090. import { Mesh } from "babylonjs/Meshes/mesh";
  42091. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42092. import { Nullable } from "babylonjs/types";
  42093. /**
  42094. * Class containing static functions to help procedurally build meshes
  42095. */
  42096. export class GroundBuilder {
  42097. /**
  42098. * Creates a ground mesh
  42099. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42100. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42102. * @param name defines the name of the mesh
  42103. * @param options defines the options used to create the mesh
  42104. * @param scene defines the hosting scene
  42105. * @returns the ground mesh
  42106. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42107. */
  42108. static CreateGround(name: string, options: {
  42109. width?: number;
  42110. height?: number;
  42111. subdivisions?: number;
  42112. subdivisionsX?: number;
  42113. subdivisionsY?: number;
  42114. updatable?: boolean;
  42115. }, scene: any): Mesh;
  42116. /**
  42117. * Creates a tiled ground mesh
  42118. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42119. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42120. * * 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
  42121. * * 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
  42122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42123. * @param name defines the name of the mesh
  42124. * @param options defines the options used to create the mesh
  42125. * @param scene defines the hosting scene
  42126. * @returns the tiled ground mesh
  42127. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42128. */
  42129. static CreateTiledGround(name: string, options: {
  42130. xmin: number;
  42131. zmin: number;
  42132. xmax: number;
  42133. zmax: number;
  42134. subdivisions?: {
  42135. w: number;
  42136. h: number;
  42137. };
  42138. precision?: {
  42139. w: number;
  42140. h: number;
  42141. };
  42142. updatable?: boolean;
  42143. }, scene?: Nullable<Scene>): Mesh;
  42144. /**
  42145. * Creates a ground mesh from a height map
  42146. * * The parameter `url` sets the URL of the height map image resource.
  42147. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42148. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42149. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42150. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42151. * * 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.
  42152. * * 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).
  42153. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42155. * @param name defines the name of the mesh
  42156. * @param url defines the url to the height map
  42157. * @param options defines the options used to create the mesh
  42158. * @param scene defines the hosting scene
  42159. * @returns the ground mesh
  42160. * @see https://doc.babylonjs.com/babylon101/height_map
  42161. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42162. */
  42163. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42164. width?: number;
  42165. height?: number;
  42166. subdivisions?: number;
  42167. minHeight?: number;
  42168. maxHeight?: number;
  42169. colorFilter?: Color3;
  42170. alphaFilter?: number;
  42171. updatable?: boolean;
  42172. onReady?: (mesh: GroundMesh) => void;
  42173. }, scene?: Nullable<Scene>): GroundMesh;
  42174. }
  42175. }
  42176. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42177. import { Vector4 } from "babylonjs/Maths/math.vector";
  42178. import { Mesh } from "babylonjs/Meshes/mesh";
  42179. /**
  42180. * Class containing static functions to help procedurally build meshes
  42181. */
  42182. export class TorusBuilder {
  42183. /**
  42184. * Creates a torus mesh
  42185. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42186. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42187. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42189. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42191. * @param name defines the name of the mesh
  42192. * @param options defines the options used to create the mesh
  42193. * @param scene defines the hosting scene
  42194. * @returns the torus mesh
  42195. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42196. */
  42197. static CreateTorus(name: string, options: {
  42198. diameter?: number;
  42199. thickness?: number;
  42200. tessellation?: number;
  42201. updatable?: boolean;
  42202. sideOrientation?: number;
  42203. frontUVs?: Vector4;
  42204. backUVs?: Vector4;
  42205. }, scene: any): Mesh;
  42206. }
  42207. }
  42208. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42209. import { Vector4 } from "babylonjs/Maths/math.vector";
  42210. import { Color4 } from "babylonjs/Maths/math.color";
  42211. import { Mesh } from "babylonjs/Meshes/mesh";
  42212. /**
  42213. * Class containing static functions to help procedurally build meshes
  42214. */
  42215. export class CylinderBuilder {
  42216. /**
  42217. * Creates a cylinder or a cone mesh
  42218. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42219. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42220. * * 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.
  42221. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42222. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42223. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42224. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42225. * * 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).
  42226. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42227. * * 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).
  42228. * * 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
  42229. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42230. * * 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
  42231. * * 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.
  42232. * * If `enclose` is false, a ring surface is one element.
  42233. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42234. * * 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
  42235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42236. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42238. * @param name defines the name of the mesh
  42239. * @param options defines the options used to create the mesh
  42240. * @param scene defines the hosting scene
  42241. * @returns the cylinder mesh
  42242. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42243. */
  42244. static CreateCylinder(name: string, options: {
  42245. height?: number;
  42246. diameterTop?: number;
  42247. diameterBottom?: number;
  42248. diameter?: number;
  42249. tessellation?: number;
  42250. subdivisions?: number;
  42251. arc?: number;
  42252. faceColors?: Color4[];
  42253. faceUV?: Vector4[];
  42254. updatable?: boolean;
  42255. hasRings?: boolean;
  42256. enclose?: boolean;
  42257. cap?: number;
  42258. sideOrientation?: number;
  42259. frontUVs?: Vector4;
  42260. backUVs?: Vector4;
  42261. }, scene: any): Mesh;
  42262. }
  42263. }
  42264. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42265. import { Observable } from "babylonjs/Misc/observable";
  42266. import { Nullable } from "babylonjs/types";
  42267. import { Camera } from "babylonjs/Cameras/camera";
  42268. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42269. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42270. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42271. import { Scene } from "babylonjs/scene";
  42272. import { Vector3 } from "babylonjs/Maths/math.vector";
  42273. import { Color3 } from "babylonjs/Maths/math.color";
  42274. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42276. import { Mesh } from "babylonjs/Meshes/mesh";
  42277. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42278. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42279. import "babylonjs/Meshes/Builders/groundBuilder";
  42280. import "babylonjs/Meshes/Builders/torusBuilder";
  42281. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42282. import "babylonjs/Gamepads/gamepadSceneComponent";
  42283. import "babylonjs/Animations/animatable";
  42284. /**
  42285. * Options to modify the vr teleportation behavior.
  42286. */
  42287. export interface VRTeleportationOptions {
  42288. /**
  42289. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42290. */
  42291. floorMeshName?: string;
  42292. /**
  42293. * A list of meshes to be used as the teleportation floor. (default: empty)
  42294. */
  42295. floorMeshes?: Mesh[];
  42296. }
  42297. /**
  42298. * Options to modify the vr experience helper's behavior.
  42299. */
  42300. export interface VRExperienceHelperOptions extends WebVROptions {
  42301. /**
  42302. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42303. */
  42304. createDeviceOrientationCamera?: boolean;
  42305. /**
  42306. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42307. */
  42308. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42309. /**
  42310. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42311. */
  42312. laserToggle?: boolean;
  42313. /**
  42314. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42315. */
  42316. floorMeshes?: Mesh[];
  42317. /**
  42318. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42319. */
  42320. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42321. }
  42322. /**
  42323. * Event containing information after VR has been entered
  42324. */
  42325. export class OnAfterEnteringVRObservableEvent {
  42326. /**
  42327. * If entering vr was successful
  42328. */
  42329. success: boolean;
  42330. }
  42331. /**
  42332. * Helps to quickly add VR support to an existing scene.
  42333. * See http://doc.babylonjs.com/how_to/webvr_helper
  42334. */
  42335. export class VRExperienceHelper {
  42336. /** Options to modify the vr experience helper's behavior. */
  42337. webVROptions: VRExperienceHelperOptions;
  42338. private _scene;
  42339. private _position;
  42340. private _btnVR;
  42341. private _btnVRDisplayed;
  42342. private _webVRsupported;
  42343. private _webVRready;
  42344. private _webVRrequesting;
  42345. private _webVRpresenting;
  42346. private _hasEnteredVR;
  42347. private _fullscreenVRpresenting;
  42348. private _canvas;
  42349. private _webVRCamera;
  42350. private _vrDeviceOrientationCamera;
  42351. private _deviceOrientationCamera;
  42352. private _existingCamera;
  42353. private _onKeyDown;
  42354. private _onVrDisplayPresentChange;
  42355. private _onVRDisplayChanged;
  42356. private _onVRRequestPresentStart;
  42357. private _onVRRequestPresentComplete;
  42358. /**
  42359. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  42360. */
  42361. enableGazeEvenWhenNoPointerLock: boolean;
  42362. /**
  42363. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42364. */
  42365. exitVROnDoubleTap: boolean;
  42366. /**
  42367. * Observable raised right before entering VR.
  42368. */
  42369. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42370. /**
  42371. * Observable raised when entering VR has completed.
  42372. */
  42373. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42374. /**
  42375. * Observable raised when exiting VR.
  42376. */
  42377. onExitingVRObservable: Observable<VRExperienceHelper>;
  42378. /**
  42379. * Observable raised when controller mesh is loaded.
  42380. */
  42381. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42382. /** Return this.onEnteringVRObservable
  42383. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42384. */
  42385. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42386. /** Return this.onExitingVRObservable
  42387. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42388. */
  42389. readonly onExitingVR: Observable<VRExperienceHelper>;
  42390. /** Return this.onControllerMeshLoadedObservable
  42391. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42392. */
  42393. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42394. private _rayLength;
  42395. private _useCustomVRButton;
  42396. private _teleportationRequested;
  42397. private _teleportActive;
  42398. private _floorMeshName;
  42399. private _floorMeshesCollection;
  42400. private _rotationAllowed;
  42401. private _teleportBackwardsVector;
  42402. private _teleportationTarget;
  42403. private _isDefaultTeleportationTarget;
  42404. private _postProcessMove;
  42405. private _teleportationFillColor;
  42406. private _teleportationBorderColor;
  42407. private _rotationAngle;
  42408. private _haloCenter;
  42409. private _cameraGazer;
  42410. private _padSensibilityUp;
  42411. private _padSensibilityDown;
  42412. private _leftController;
  42413. private _rightController;
  42414. /**
  42415. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42416. */
  42417. onNewMeshSelected: Observable<AbstractMesh>;
  42418. /**
  42419. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42420. * This observable will provide the mesh and the controller used to select the mesh
  42421. */
  42422. onMeshSelectedWithController: Observable<{
  42423. mesh: AbstractMesh;
  42424. controller: WebVRController;
  42425. }>;
  42426. /**
  42427. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42428. */
  42429. onNewMeshPicked: Observable<PickingInfo>;
  42430. private _circleEase;
  42431. /**
  42432. * Observable raised before camera teleportation
  42433. */
  42434. onBeforeCameraTeleport: Observable<Vector3>;
  42435. /**
  42436. * Observable raised after camera teleportation
  42437. */
  42438. onAfterCameraTeleport: Observable<Vector3>;
  42439. /**
  42440. * Observable raised when current selected mesh gets unselected
  42441. */
  42442. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42443. private _raySelectionPredicate;
  42444. /**
  42445. * To be optionaly changed by user to define custom ray selection
  42446. */
  42447. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42448. /**
  42449. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42450. */
  42451. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42452. /**
  42453. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42454. */
  42455. teleportationEnabled: boolean;
  42456. private _defaultHeight;
  42457. private _teleportationInitialized;
  42458. private _interactionsEnabled;
  42459. private _interactionsRequested;
  42460. private _displayGaze;
  42461. private _displayLaserPointer;
  42462. /**
  42463. * The mesh used to display where the user is going to teleport.
  42464. */
  42465. /**
  42466. * Sets the mesh to be used to display where the user is going to teleport.
  42467. */
  42468. teleportationTarget: Mesh;
  42469. /**
  42470. * 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
  42471. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42472. * See http://doc.babylonjs.com/resources/baking_transformations
  42473. */
  42474. gazeTrackerMesh: Mesh;
  42475. /**
  42476. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42477. */
  42478. updateGazeTrackerScale: boolean;
  42479. /**
  42480. * If the gaze trackers color should be updated when selecting meshes
  42481. */
  42482. updateGazeTrackerColor: boolean;
  42483. /**
  42484. * If the controller laser color should be updated when selecting meshes
  42485. */
  42486. updateControllerLaserColor: boolean;
  42487. /**
  42488. * The gaze tracking mesh corresponding to the left controller
  42489. */
  42490. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42491. /**
  42492. * The gaze tracking mesh corresponding to the right controller
  42493. */
  42494. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42495. /**
  42496. * If the ray of the gaze should be displayed.
  42497. */
  42498. /**
  42499. * Sets if the ray of the gaze should be displayed.
  42500. */
  42501. displayGaze: boolean;
  42502. /**
  42503. * If the ray of the LaserPointer should be displayed.
  42504. */
  42505. /**
  42506. * Sets if the ray of the LaserPointer should be displayed.
  42507. */
  42508. displayLaserPointer: boolean;
  42509. /**
  42510. * The deviceOrientationCamera used as the camera when not in VR.
  42511. */
  42512. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42513. /**
  42514. * Based on the current WebVR support, returns the current VR camera used.
  42515. */
  42516. readonly currentVRCamera: Nullable<Camera>;
  42517. /**
  42518. * The webVRCamera which is used when in VR.
  42519. */
  42520. readonly webVRCamera: WebVRFreeCamera;
  42521. /**
  42522. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42523. */
  42524. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42525. /**
  42526. * The html button that is used to trigger entering into VR.
  42527. */
  42528. readonly vrButton: Nullable<HTMLButtonElement>;
  42529. private readonly _teleportationRequestInitiated;
  42530. /**
  42531. * Defines wether or not Pointer lock should be requested when switching to
  42532. * full screen.
  42533. */
  42534. requestPointerLockOnFullScreen: boolean;
  42535. /**
  42536. * Instantiates a VRExperienceHelper.
  42537. * Helps to quickly add VR support to an existing scene.
  42538. * @param scene The scene the VRExperienceHelper belongs to.
  42539. * @param webVROptions Options to modify the vr experience helper's behavior.
  42540. */
  42541. constructor(scene: Scene,
  42542. /** Options to modify the vr experience helper's behavior. */
  42543. webVROptions?: VRExperienceHelperOptions);
  42544. private _onDefaultMeshLoaded;
  42545. private _onResize;
  42546. private _onFullscreenChange;
  42547. /**
  42548. * Gets a value indicating if we are currently in VR mode.
  42549. */
  42550. readonly isInVRMode: boolean;
  42551. private onVrDisplayPresentChange;
  42552. private onVRDisplayChanged;
  42553. private moveButtonToBottomRight;
  42554. private displayVRButton;
  42555. private updateButtonVisibility;
  42556. private _cachedAngularSensibility;
  42557. /**
  42558. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42559. * Otherwise, will use the fullscreen API.
  42560. */
  42561. enterVR(): void;
  42562. /**
  42563. * Attempt to exit VR, or fullscreen.
  42564. */
  42565. exitVR(): void;
  42566. /**
  42567. * The position of the vr experience helper.
  42568. */
  42569. /**
  42570. * Sets the position of the vr experience helper.
  42571. */
  42572. position: Vector3;
  42573. /**
  42574. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42575. */
  42576. enableInteractions(): void;
  42577. private readonly _noControllerIsActive;
  42578. private beforeRender;
  42579. private _isTeleportationFloor;
  42580. /**
  42581. * Adds a floor mesh to be used for teleportation.
  42582. * @param floorMesh the mesh to be used for teleportation.
  42583. */
  42584. addFloorMesh(floorMesh: Mesh): void;
  42585. /**
  42586. * Removes a floor mesh from being used for teleportation.
  42587. * @param floorMesh the mesh to be removed.
  42588. */
  42589. removeFloorMesh(floorMesh: Mesh): void;
  42590. /**
  42591. * Enables interactions and teleportation using the VR controllers and gaze.
  42592. * @param vrTeleportationOptions options to modify teleportation behavior.
  42593. */
  42594. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42595. private _onNewGamepadConnected;
  42596. private _tryEnableInteractionOnController;
  42597. private _onNewGamepadDisconnected;
  42598. private _enableInteractionOnController;
  42599. private _checkTeleportWithRay;
  42600. private _checkRotate;
  42601. private _checkTeleportBackwards;
  42602. private _enableTeleportationOnController;
  42603. private _createTeleportationCircles;
  42604. private _displayTeleportationTarget;
  42605. private _hideTeleportationTarget;
  42606. private _rotateCamera;
  42607. private _moveTeleportationSelectorTo;
  42608. private _workingVector;
  42609. private _workingQuaternion;
  42610. private _workingMatrix;
  42611. /**
  42612. * Teleports the users feet to the desired location
  42613. * @param location The location where the user's feet should be placed
  42614. */
  42615. teleportCamera(location: Vector3): void;
  42616. private _convertNormalToDirectionOfRay;
  42617. private _castRayAndSelectObject;
  42618. private _notifySelectedMeshUnselected;
  42619. /**
  42620. * Sets the color of the laser ray from the vr controllers.
  42621. * @param color new color for the ray.
  42622. */
  42623. changeLaserColor(color: Color3): void;
  42624. /**
  42625. * Sets the color of the ray from the vr headsets gaze.
  42626. * @param color new color for the ray.
  42627. */
  42628. changeGazeColor(color: Color3): void;
  42629. /**
  42630. * Exits VR and disposes of the vr experience helper
  42631. */
  42632. dispose(): void;
  42633. /**
  42634. * Gets the name of the VRExperienceHelper class
  42635. * @returns "VRExperienceHelper"
  42636. */
  42637. getClassName(): string;
  42638. }
  42639. }
  42640. declare module "babylonjs/Cameras/VR/index" {
  42641. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42642. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42643. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42644. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42645. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42646. export * from "babylonjs/Cameras/VR/webVRCamera";
  42647. }
  42648. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42649. import { Observable } from "babylonjs/Misc/observable";
  42650. import { Nullable } from "babylonjs/types";
  42651. import { IDisposable, Scene } from "babylonjs/scene";
  42652. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42653. /**
  42654. * Manages an XRSession to work with Babylon's engine
  42655. * @see https://doc.babylonjs.com/how_to/webxr
  42656. */
  42657. export class WebXRSessionManager implements IDisposable {
  42658. private scene;
  42659. /**
  42660. * Fires every time a new xrFrame arrives which can be used to update the camera
  42661. */
  42662. onXRFrameObservable: Observable<any>;
  42663. /**
  42664. * Fires when the xr session is ended either by the device or manually done
  42665. */
  42666. onXRSessionEnded: Observable<any>;
  42667. /**
  42668. * Underlying xr session
  42669. */
  42670. session: XRSession;
  42671. /**
  42672. * Type of reference space used when creating the session
  42673. */
  42674. referenceSpace: XRReferenceSpace;
  42675. /** @hidden */
  42676. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42677. /**
  42678. * Current XR frame
  42679. */
  42680. currentFrame: Nullable<XRFrame>;
  42681. private _xrNavigator;
  42682. private baseLayer;
  42683. /**
  42684. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42685. * @param scene The scene which the session should be created for
  42686. */
  42687. constructor(scene: Scene);
  42688. /**
  42689. * Initializes the manager
  42690. * After initialization enterXR can be called to start an XR session
  42691. * @returns Promise which resolves after it is initialized
  42692. */
  42693. initializeAsync(): Promise<void>;
  42694. /**
  42695. * Initializes an xr session
  42696. * @param xrSessionMode mode to initialize
  42697. * @returns a promise which will resolve once the session has been initialized
  42698. */
  42699. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42700. /**
  42701. * Sets the reference space on the xr session
  42702. * @param referenceSpace space to set
  42703. * @returns a promise that will resolve once the reference space has been set
  42704. */
  42705. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42706. /**
  42707. * Updates the render state of the session
  42708. * @param state state to set
  42709. * @returns a promise that resolves once the render state has been updated
  42710. */
  42711. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42712. /**
  42713. * Starts rendering to the xr layer
  42714. * @returns a promise that will resolve once rendering has started
  42715. */
  42716. startRenderingToXRAsync(): Promise<void>;
  42717. /**
  42718. * Stops the xrSession and restores the renderloop
  42719. * @returns Promise which resolves after it exits XR
  42720. */
  42721. exitXRAsync(): Promise<unknown>;
  42722. /**
  42723. * Checks if a session would be supported for the creation options specified
  42724. * @param sessionMode session mode to check if supported eg. immersive-vr
  42725. * @returns true if supported
  42726. */
  42727. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42728. /**
  42729. * @hidden
  42730. * Converts the render layer of xrSession to a render target
  42731. * @param session session to create render target for
  42732. * @param scene scene the new render target should be created for
  42733. */
  42734. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42735. /**
  42736. * Disposes of the session manager
  42737. */
  42738. dispose(): void;
  42739. }
  42740. }
  42741. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42742. import { Scene } from "babylonjs/scene";
  42743. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42744. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42745. /**
  42746. * WebXR Camera which holds the views for the xrSession
  42747. * @see https://doc.babylonjs.com/how_to/webxr
  42748. */
  42749. export class WebXRCamera extends FreeCamera {
  42750. private static _TmpMatrix;
  42751. /**
  42752. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42753. * @param name the name of the camera
  42754. * @param scene the scene to add the camera to
  42755. */
  42756. constructor(name: string, scene: Scene);
  42757. private _updateNumberOfRigCameras;
  42758. /** @hidden */
  42759. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42760. /**
  42761. * Updates the cameras position from the current pose information of the XR session
  42762. * @param xrSessionManager the session containing pose information
  42763. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42764. */
  42765. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42766. }
  42767. }
  42768. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42769. import { Nullable } from "babylonjs/types";
  42770. import { IDisposable } from "babylonjs/scene";
  42771. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42772. /**
  42773. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42774. */
  42775. export class WebXRManagedOutputCanvas implements IDisposable {
  42776. private helper;
  42777. private _canvas;
  42778. /**
  42779. * xrpresent context of the canvas which can be used to display/mirror xr content
  42780. */
  42781. canvasContext: WebGLRenderingContext;
  42782. /**
  42783. * xr layer for the canvas
  42784. */
  42785. xrLayer: Nullable<XRWebGLLayer>;
  42786. /**
  42787. * Initializes the xr layer for the session
  42788. * @param xrSession xr session
  42789. * @returns a promise that will resolve once the XR Layer has been created
  42790. */
  42791. initializeXRLayerAsync(xrSession: any): any;
  42792. /**
  42793. * Initializes the canvas to be added/removed upon entering/exiting xr
  42794. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42795. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42796. */
  42797. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42798. /**
  42799. * Disposes of the object
  42800. */
  42801. dispose(): void;
  42802. private _setManagedOutputCanvas;
  42803. private _addCanvas;
  42804. private _removeCanvas;
  42805. }
  42806. }
  42807. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42808. import { Observable } from "babylonjs/Misc/observable";
  42809. import { IDisposable, Scene } from "babylonjs/scene";
  42810. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42812. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42813. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42814. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42815. /**
  42816. * States of the webXR experience
  42817. */
  42818. export enum WebXRState {
  42819. /**
  42820. * Transitioning to being in XR mode
  42821. */
  42822. ENTERING_XR = 0,
  42823. /**
  42824. * Transitioning to non XR mode
  42825. */
  42826. EXITING_XR = 1,
  42827. /**
  42828. * In XR mode and presenting
  42829. */
  42830. IN_XR = 2,
  42831. /**
  42832. * Not entered XR mode
  42833. */
  42834. NOT_IN_XR = 3
  42835. }
  42836. /**
  42837. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42838. * @see https://doc.babylonjs.com/how_to/webxr
  42839. */
  42840. export class WebXRExperienceHelper implements IDisposable {
  42841. private scene;
  42842. /**
  42843. * 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
  42844. */
  42845. container: AbstractMesh;
  42846. /**
  42847. * Camera used to render xr content
  42848. */
  42849. camera: WebXRCamera;
  42850. /**
  42851. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42852. */
  42853. state: WebXRState;
  42854. private _setState;
  42855. private static _TmpVector;
  42856. /**
  42857. * Fires when the state of the experience helper has changed
  42858. */
  42859. onStateChangedObservable: Observable<WebXRState>;
  42860. /** Session manager used to keep track of xr session */
  42861. sessionManager: WebXRSessionManager;
  42862. private _nonVRCamera;
  42863. private _originalSceneAutoClear;
  42864. private _supported;
  42865. /**
  42866. * Creates the experience helper
  42867. * @param scene the scene to attach the experience helper to
  42868. * @returns a promise for the experience helper
  42869. */
  42870. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42871. /**
  42872. * Creates a WebXRExperienceHelper
  42873. * @param scene The scene the helper should be created in
  42874. */
  42875. private constructor();
  42876. /**
  42877. * Exits XR mode and returns the scene to its original state
  42878. * @returns promise that resolves after xr mode has exited
  42879. */
  42880. exitXRAsync(): Promise<unknown>;
  42881. /**
  42882. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42883. * @param sessionCreationOptions options for the XR session
  42884. * @param referenceSpaceType frame of reference of the XR session
  42885. * @param outputCanvas the output canvas that will be used to enter XR mode
  42886. * @returns promise that resolves after xr mode has entered
  42887. */
  42888. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42889. /**
  42890. * Updates the global position of the camera by moving the camera's container
  42891. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42892. * @param position The desired global position of the camera
  42893. */
  42894. setPositionOfCameraUsingContainer(position: Vector3): void;
  42895. /**
  42896. * Rotates the xr camera by rotating the camera's container around the camera's position
  42897. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42898. * @param rotation the desired quaternion rotation to apply to the camera
  42899. */
  42900. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42901. /**
  42902. * Disposes of the experience helper
  42903. */
  42904. dispose(): void;
  42905. }
  42906. }
  42907. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42908. import { Nullable } from "babylonjs/types";
  42909. import { Observable } from "babylonjs/Misc/observable";
  42910. import { IDisposable, Scene } from "babylonjs/scene";
  42911. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42912. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42913. /**
  42914. * Button which can be used to enter a different mode of XR
  42915. */
  42916. export class WebXREnterExitUIButton {
  42917. /** button element */
  42918. element: HTMLElement;
  42919. /** XR initialization options for the button */
  42920. sessionMode: XRSessionMode;
  42921. /** Reference space type */
  42922. referenceSpaceType: XRReferenceSpaceType;
  42923. /**
  42924. * Creates a WebXREnterExitUIButton
  42925. * @param element button element
  42926. * @param sessionMode XR initialization session mode
  42927. * @param referenceSpaceType the type of reference space to be used
  42928. */
  42929. constructor(
  42930. /** button element */
  42931. element: HTMLElement,
  42932. /** XR initialization options for the button */
  42933. sessionMode: XRSessionMode,
  42934. /** Reference space type */
  42935. referenceSpaceType: XRReferenceSpaceType);
  42936. /**
  42937. * Overwritable function which can be used to update the button's visuals when the state changes
  42938. * @param activeButton the current active button in the UI
  42939. */
  42940. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42941. }
  42942. /**
  42943. * Options to create the webXR UI
  42944. */
  42945. export class WebXREnterExitUIOptions {
  42946. /**
  42947. * Context to enter xr with
  42948. */
  42949. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42950. /**
  42951. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42952. */
  42953. customButtons?: Array<WebXREnterExitUIButton>;
  42954. }
  42955. /**
  42956. * UI to allow the user to enter/exit XR mode
  42957. */
  42958. export class WebXREnterExitUI implements IDisposable {
  42959. private scene;
  42960. private _overlay;
  42961. private _buttons;
  42962. private _activeButton;
  42963. /**
  42964. * Fired every time the active button is changed.
  42965. *
  42966. * When xr is entered via a button that launches xr that button will be the callback parameter
  42967. *
  42968. * When exiting xr the callback parameter will be null)
  42969. */
  42970. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42971. /**
  42972. * Creates UI to allow the user to enter/exit XR mode
  42973. * @param scene the scene to add the ui to
  42974. * @param helper the xr experience helper to enter/exit xr with
  42975. * @param options options to configure the UI
  42976. * @returns the created ui
  42977. */
  42978. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42979. private constructor();
  42980. private _updateButtons;
  42981. /**
  42982. * Disposes of the object
  42983. */
  42984. dispose(): void;
  42985. }
  42986. }
  42987. declare module "babylonjs/Cameras/XR/webXRController" {
  42988. import { Nullable } from "babylonjs/types";
  42989. import { Observable } from "babylonjs/Misc/observable";
  42990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42991. import { Ray } from "babylonjs/Culling/ray";
  42992. import { Scene } from "babylonjs/scene";
  42993. /**
  42994. * Represents an XR input
  42995. */
  42996. export class WebXRController {
  42997. private scene;
  42998. /** The underlying input source for the controller */
  42999. inputSource: XRInputSource;
  43000. private parentContainer;
  43001. /**
  43002. * 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
  43003. */
  43004. grip?: AbstractMesh;
  43005. /**
  43006. * Pointer which can be used to select objects or attach a visible laser to
  43007. */
  43008. pointer: AbstractMesh;
  43009. /**
  43010. * Event that fires when the controller is removed/disposed
  43011. */
  43012. onDisposeObservable: Observable<{}>;
  43013. private _tmpMatrix;
  43014. private _tmpQuaternion;
  43015. private _tmpVector;
  43016. /**
  43017. * Creates the controller
  43018. * @see https://doc.babylonjs.com/how_to/webxr
  43019. * @param scene the scene which the controller should be associated to
  43020. * @param inputSource the underlying input source for the controller
  43021. * @param parentContainer parent that the controller meshes should be children of
  43022. */
  43023. constructor(scene: Scene,
  43024. /** The underlying input source for the controller */
  43025. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43026. /**
  43027. * Updates the controller pose based on the given XRFrame
  43028. * @param xrFrame xr frame to update the pose with
  43029. * @param referenceSpace reference space to use
  43030. */
  43031. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43032. /**
  43033. * Gets a world space ray coming from the controller
  43034. * @param result the resulting ray
  43035. */
  43036. getWorldPointerRayToRef(result: Ray): void;
  43037. /**
  43038. * Disposes of the object
  43039. */
  43040. dispose(): void;
  43041. }
  43042. }
  43043. declare module "babylonjs/Cameras/XR/webXRInput" {
  43044. import { Observable } from "babylonjs/Misc/observable";
  43045. import { IDisposable } from "babylonjs/scene";
  43046. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43047. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43048. /**
  43049. * XR input used to track XR inputs such as controllers/rays
  43050. */
  43051. export class WebXRInput implements IDisposable {
  43052. /**
  43053. * Base experience the input listens to
  43054. */
  43055. baseExperience: WebXRExperienceHelper;
  43056. /**
  43057. * XR controllers being tracked
  43058. */
  43059. controllers: Array<WebXRController>;
  43060. private _frameObserver;
  43061. private _stateObserver;
  43062. /**
  43063. * Event when a controller has been connected/added
  43064. */
  43065. onControllerAddedObservable: Observable<WebXRController>;
  43066. /**
  43067. * Event when a controller has been removed/disconnected
  43068. */
  43069. onControllerRemovedObservable: Observable<WebXRController>;
  43070. /**
  43071. * Initializes the WebXRInput
  43072. * @param baseExperience experience helper which the input should be created for
  43073. */
  43074. constructor(
  43075. /**
  43076. * Base experience the input listens to
  43077. */
  43078. baseExperience: WebXRExperienceHelper);
  43079. private _onInputSourcesChange;
  43080. private _addAndRemoveControllers;
  43081. /**
  43082. * Disposes of the object
  43083. */
  43084. dispose(): void;
  43085. }
  43086. }
  43087. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43089. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43090. /**
  43091. * Enables teleportation
  43092. */
  43093. export class WebXRControllerTeleportation {
  43094. private _teleportationFillColor;
  43095. private _teleportationBorderColor;
  43096. private _tmpRay;
  43097. private _tmpVector;
  43098. /**
  43099. * Creates a WebXRControllerTeleportation
  43100. * @param input input manager to add teleportation to
  43101. * @param floorMeshes floormeshes which can be teleported to
  43102. */
  43103. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43104. }
  43105. }
  43106. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43107. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43108. /**
  43109. * Handles pointer input automatically for the pointer of XR controllers
  43110. */
  43111. export class WebXRControllerPointerSelection {
  43112. private static _idCounter;
  43113. private _tmpRay;
  43114. /**
  43115. * Creates a WebXRControllerPointerSelection
  43116. * @param input input manager to setup pointer selection
  43117. */
  43118. constructor(input: WebXRInput);
  43119. private _convertNormalToDirectionOfRay;
  43120. private _updatePointerDistance;
  43121. }
  43122. }
  43123. declare module "babylonjs/Loading/sceneLoader" {
  43124. import { Observable } from "babylonjs/Misc/observable";
  43125. import { Nullable } from "babylonjs/types";
  43126. import { Scene } from "babylonjs/scene";
  43127. import { Engine } from "babylonjs/Engines/engine";
  43128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43129. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43130. import { AssetContainer } from "babylonjs/assetContainer";
  43131. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43132. import { Skeleton } from "babylonjs/Bones/skeleton";
  43133. /**
  43134. * Class used to represent data loading progression
  43135. */
  43136. export class SceneLoaderProgressEvent {
  43137. /** defines if data length to load can be evaluated */
  43138. readonly lengthComputable: boolean;
  43139. /** defines the loaded data length */
  43140. readonly loaded: number;
  43141. /** defines the data length to load */
  43142. readonly total: number;
  43143. /**
  43144. * Create a new progress event
  43145. * @param lengthComputable defines if data length to load can be evaluated
  43146. * @param loaded defines the loaded data length
  43147. * @param total defines the data length to load
  43148. */
  43149. constructor(
  43150. /** defines if data length to load can be evaluated */
  43151. lengthComputable: boolean,
  43152. /** defines the loaded data length */
  43153. loaded: number,
  43154. /** defines the data length to load */
  43155. total: number);
  43156. /**
  43157. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43158. * @param event defines the source event
  43159. * @returns a new SceneLoaderProgressEvent
  43160. */
  43161. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43162. }
  43163. /**
  43164. * Interface used by SceneLoader plugins to define supported file extensions
  43165. */
  43166. export interface ISceneLoaderPluginExtensions {
  43167. /**
  43168. * Defines the list of supported extensions
  43169. */
  43170. [extension: string]: {
  43171. isBinary: boolean;
  43172. };
  43173. }
  43174. /**
  43175. * Interface used by SceneLoader plugin factory
  43176. */
  43177. export interface ISceneLoaderPluginFactory {
  43178. /**
  43179. * Defines the name of the factory
  43180. */
  43181. name: string;
  43182. /**
  43183. * Function called to create a new plugin
  43184. * @return the new plugin
  43185. */
  43186. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43187. /**
  43188. * Boolean indicating if the plugin can direct load specific data
  43189. */
  43190. canDirectLoad?: (data: string) => boolean;
  43191. }
  43192. /**
  43193. * Interface used to define a SceneLoader plugin
  43194. */
  43195. export interface ISceneLoaderPlugin {
  43196. /**
  43197. * The friendly name of this plugin.
  43198. */
  43199. name: string;
  43200. /**
  43201. * The file extensions supported by this plugin.
  43202. */
  43203. extensions: string | ISceneLoaderPluginExtensions;
  43204. /**
  43205. * Import meshes into a scene.
  43206. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43207. * @param scene The scene to import into
  43208. * @param data The data to import
  43209. * @param rootUrl The root url for scene and resources
  43210. * @param meshes The meshes array to import into
  43211. * @param particleSystems The particle systems array to import into
  43212. * @param skeletons The skeletons array to import into
  43213. * @param onError The callback when import fails
  43214. * @returns True if successful or false otherwise
  43215. */
  43216. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43217. /**
  43218. * Load into a scene.
  43219. * @param scene The scene to load into
  43220. * @param data The data to import
  43221. * @param rootUrl The root url for scene and resources
  43222. * @param onError The callback when import fails
  43223. * @returns true if successful or false otherwise
  43224. */
  43225. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43226. /**
  43227. * The callback that returns true if the data can be directly loaded.
  43228. */
  43229. canDirectLoad?: (data: string) => boolean;
  43230. /**
  43231. * The callback that allows custom handling of the root url based on the response url.
  43232. */
  43233. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43234. /**
  43235. * Load into an asset container.
  43236. * @param scene The scene to load into
  43237. * @param data The data to import
  43238. * @param rootUrl The root url for scene and resources
  43239. * @param onError The callback when import fails
  43240. * @returns The loaded asset container
  43241. */
  43242. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43243. }
  43244. /**
  43245. * Interface used to define an async SceneLoader plugin
  43246. */
  43247. export interface ISceneLoaderPluginAsync {
  43248. /**
  43249. * The friendly name of this plugin.
  43250. */
  43251. name: string;
  43252. /**
  43253. * The file extensions supported by this plugin.
  43254. */
  43255. extensions: string | ISceneLoaderPluginExtensions;
  43256. /**
  43257. * Import meshes into a scene.
  43258. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43259. * @param scene The scene to import into
  43260. * @param data The data to import
  43261. * @param rootUrl The root url for scene and resources
  43262. * @param onProgress The callback when the load progresses
  43263. * @param fileName Defines the name of the file to load
  43264. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43265. */
  43266. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43267. meshes: AbstractMesh[];
  43268. particleSystems: IParticleSystem[];
  43269. skeletons: Skeleton[];
  43270. animationGroups: AnimationGroup[];
  43271. }>;
  43272. /**
  43273. * Load into a scene.
  43274. * @param scene The scene to load into
  43275. * @param data The data to import
  43276. * @param rootUrl The root url for scene and resources
  43277. * @param onProgress The callback when the load progresses
  43278. * @param fileName Defines the name of the file to load
  43279. * @returns Nothing
  43280. */
  43281. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43282. /**
  43283. * The callback that returns true if the data can be directly loaded.
  43284. */
  43285. canDirectLoad?: (data: string) => boolean;
  43286. /**
  43287. * The callback that allows custom handling of the root url based on the response url.
  43288. */
  43289. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43290. /**
  43291. * Load into an asset container.
  43292. * @param scene The scene to load into
  43293. * @param data The data to import
  43294. * @param rootUrl The root url for scene and resources
  43295. * @param onProgress The callback when the load progresses
  43296. * @param fileName Defines the name of the file to load
  43297. * @returns The loaded asset container
  43298. */
  43299. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43300. }
  43301. /**
  43302. * Class used to load scene from various file formats using registered plugins
  43303. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43304. */
  43305. export class SceneLoader {
  43306. /**
  43307. * No logging while loading
  43308. */
  43309. static readonly NO_LOGGING: number;
  43310. /**
  43311. * Minimal logging while loading
  43312. */
  43313. static readonly MINIMAL_LOGGING: number;
  43314. /**
  43315. * Summary logging while loading
  43316. */
  43317. static readonly SUMMARY_LOGGING: number;
  43318. /**
  43319. * Detailled logging while loading
  43320. */
  43321. static readonly DETAILED_LOGGING: number;
  43322. /**
  43323. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43324. */
  43325. static ForceFullSceneLoadingForIncremental: boolean;
  43326. /**
  43327. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43328. */
  43329. static ShowLoadingScreen: boolean;
  43330. /**
  43331. * Defines the current logging level (while loading the scene)
  43332. * @ignorenaming
  43333. */
  43334. static loggingLevel: number;
  43335. /**
  43336. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43337. */
  43338. static CleanBoneMatrixWeights: boolean;
  43339. /**
  43340. * Event raised when a plugin is used to load a scene
  43341. */
  43342. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43343. private static _registeredPlugins;
  43344. private static _getDefaultPlugin;
  43345. private static _getPluginForExtension;
  43346. private static _getPluginForDirectLoad;
  43347. private static _getPluginForFilename;
  43348. private static _getDirectLoad;
  43349. private static _loadData;
  43350. private static _getFileInfo;
  43351. /**
  43352. * Gets a plugin that can load the given extension
  43353. * @param extension defines the extension to load
  43354. * @returns a plugin or null if none works
  43355. */
  43356. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43357. /**
  43358. * Gets a boolean indicating that the given extension can be loaded
  43359. * @param extension defines the extension to load
  43360. * @returns true if the extension is supported
  43361. */
  43362. static IsPluginForExtensionAvailable(extension: string): boolean;
  43363. /**
  43364. * Adds a new plugin to the list of registered plugins
  43365. * @param plugin defines the plugin to add
  43366. */
  43367. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43368. /**
  43369. * Import meshes into a scene
  43370. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43371. * @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)
  43372. * @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)
  43373. * @param scene the instance of BABYLON.Scene to append to
  43374. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43375. * @param onProgress a callback with a progress event for each file being loaded
  43376. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43377. * @param pluginExtension the extension used to determine the plugin
  43378. * @returns The loaded plugin
  43379. */
  43380. 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>;
  43381. /**
  43382. * Import meshes into a scene
  43383. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43384. * @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)
  43385. * @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)
  43386. * @param scene the instance of BABYLON.Scene to append to
  43387. * @param onProgress a callback with a progress event for each file being loaded
  43388. * @param pluginExtension the extension used to determine the plugin
  43389. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43390. */
  43391. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43392. meshes: AbstractMesh[];
  43393. particleSystems: IParticleSystem[];
  43394. skeletons: Skeleton[];
  43395. animationGroups: AnimationGroup[];
  43396. }>;
  43397. /**
  43398. * Load a scene
  43399. * @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)
  43400. * @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)
  43401. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43402. * @param onSuccess a callback with the scene when import succeeds
  43403. * @param onProgress a callback with a progress event for each file being loaded
  43404. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43405. * @param pluginExtension the extension used to determine the plugin
  43406. * @returns The loaded plugin
  43407. */
  43408. 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>;
  43409. /**
  43410. * Load a scene
  43411. * @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)
  43412. * @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)
  43413. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43414. * @param onProgress a callback with a progress event for each file being loaded
  43415. * @param pluginExtension the extension used to determine the plugin
  43416. * @returns The loaded scene
  43417. */
  43418. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43419. /**
  43420. * Append a scene
  43421. * @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)
  43422. * @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)
  43423. * @param scene is the instance of BABYLON.Scene to append to
  43424. * @param onSuccess a callback with the scene when import succeeds
  43425. * @param onProgress a callback with a progress event for each file being loaded
  43426. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43427. * @param pluginExtension the extension used to determine the plugin
  43428. * @returns The loaded plugin
  43429. */
  43430. 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>;
  43431. /**
  43432. * Append a scene
  43433. * @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)
  43434. * @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)
  43435. * @param scene is the instance of BABYLON.Scene to append to
  43436. * @param onProgress a callback with a progress event for each file being loaded
  43437. * @param pluginExtension the extension used to determine the plugin
  43438. * @returns The given scene
  43439. */
  43440. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43441. /**
  43442. * Load a scene into an asset container
  43443. * @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)
  43444. * @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)
  43445. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43446. * @param onSuccess a callback with the scene when import succeeds
  43447. * @param onProgress a callback with a progress event for each file being loaded
  43448. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43449. * @param pluginExtension the extension used to determine the plugin
  43450. * @returns The loaded plugin
  43451. */
  43452. 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>;
  43453. /**
  43454. * Load a scene into an asset container
  43455. * @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)
  43456. * @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)
  43457. * @param scene is the instance of Scene to append to
  43458. * @param onProgress a callback with a progress event for each file being loaded
  43459. * @param pluginExtension the extension used to determine the plugin
  43460. * @returns The loaded asset container
  43461. */
  43462. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43463. }
  43464. }
  43465. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43466. import { Scene } from "babylonjs/scene";
  43467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43468. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43469. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43470. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43471. /**
  43472. * Generic Controller
  43473. */
  43474. export class GenericController extends WebVRController {
  43475. /**
  43476. * Base Url for the controller model.
  43477. */
  43478. static readonly MODEL_BASE_URL: string;
  43479. /**
  43480. * File name for the controller model.
  43481. */
  43482. static readonly MODEL_FILENAME: string;
  43483. /**
  43484. * Creates a new GenericController from a gamepad
  43485. * @param vrGamepad the gamepad that the controller should be created from
  43486. */
  43487. constructor(vrGamepad: any);
  43488. /**
  43489. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43490. * @param scene scene in which to add meshes
  43491. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43492. */
  43493. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43494. /**
  43495. * Called once for each button that changed state since the last frame
  43496. * @param buttonIdx Which button index changed
  43497. * @param state New state of the button
  43498. * @param changes Which properties on the state changed since last frame
  43499. */
  43500. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43501. }
  43502. }
  43503. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43504. import { Observable } from "babylonjs/Misc/observable";
  43505. import { Scene } from "babylonjs/scene";
  43506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43507. import { Ray } from "babylonjs/Culling/ray";
  43508. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43509. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43510. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43511. /**
  43512. * Defines the WindowsMotionController object that the state of the windows motion controller
  43513. */
  43514. export class WindowsMotionController extends WebVRController {
  43515. /**
  43516. * The base url used to load the left and right controller models
  43517. */
  43518. static MODEL_BASE_URL: string;
  43519. /**
  43520. * The name of the left controller model file
  43521. */
  43522. static MODEL_LEFT_FILENAME: string;
  43523. /**
  43524. * The name of the right controller model file
  43525. */
  43526. static MODEL_RIGHT_FILENAME: string;
  43527. /**
  43528. * The controller name prefix for this controller type
  43529. */
  43530. static readonly GAMEPAD_ID_PREFIX: string;
  43531. /**
  43532. * The controller id pattern for this controller type
  43533. */
  43534. private static readonly GAMEPAD_ID_PATTERN;
  43535. private _loadedMeshInfo;
  43536. private readonly _mapping;
  43537. /**
  43538. * Fired when the trackpad on this controller is clicked
  43539. */
  43540. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43541. /**
  43542. * Fired when the trackpad on this controller is modified
  43543. */
  43544. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43545. /**
  43546. * The current x and y values of this controller's trackpad
  43547. */
  43548. trackpad: StickValues;
  43549. /**
  43550. * Creates a new WindowsMotionController from a gamepad
  43551. * @param vrGamepad the gamepad that the controller should be created from
  43552. */
  43553. constructor(vrGamepad: any);
  43554. /**
  43555. * Fired when the trigger on this controller is modified
  43556. */
  43557. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43558. /**
  43559. * Fired when the menu button on this controller is modified
  43560. */
  43561. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43562. /**
  43563. * Fired when the grip button on this controller is modified
  43564. */
  43565. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43566. /**
  43567. * Fired when the thumbstick button on this controller is modified
  43568. */
  43569. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43570. /**
  43571. * Fired when the touchpad button on this controller is modified
  43572. */
  43573. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43574. /**
  43575. * Fired when the touchpad values on this controller are modified
  43576. */
  43577. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43578. private _updateTrackpad;
  43579. /**
  43580. * Called once per frame by the engine.
  43581. */
  43582. update(): void;
  43583. /**
  43584. * Called once for each button that changed state since the last frame
  43585. * @param buttonIdx Which button index changed
  43586. * @param state New state of the button
  43587. * @param changes Which properties on the state changed since last frame
  43588. */
  43589. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43590. /**
  43591. * Moves the buttons on the controller mesh based on their current state
  43592. * @param buttonName the name of the button to move
  43593. * @param buttonValue the value of the button which determines the buttons new position
  43594. */
  43595. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43596. /**
  43597. * Moves the axis on the controller mesh based on its current state
  43598. * @param axis the index of the axis
  43599. * @param axisValue the value of the axis which determines the meshes new position
  43600. * @hidden
  43601. */
  43602. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43603. /**
  43604. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43605. * @param scene scene in which to add meshes
  43606. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43607. */
  43608. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43609. /**
  43610. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43611. * can be transformed by button presses and axes values, based on this._mapping.
  43612. *
  43613. * @param scene scene in which the meshes exist
  43614. * @param meshes list of meshes that make up the controller model to process
  43615. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43616. */
  43617. private processModel;
  43618. private createMeshInfo;
  43619. /**
  43620. * Gets the ray of the controller in the direction the controller is pointing
  43621. * @param length the length the resulting ray should be
  43622. * @returns a ray in the direction the controller is pointing
  43623. */
  43624. getForwardRay(length?: number): Ray;
  43625. /**
  43626. * Disposes of the controller
  43627. */
  43628. dispose(): void;
  43629. }
  43630. }
  43631. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43632. import { Observable } from "babylonjs/Misc/observable";
  43633. import { Scene } from "babylonjs/scene";
  43634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43635. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43636. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43637. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43638. /**
  43639. * Oculus Touch Controller
  43640. */
  43641. export class OculusTouchController extends WebVRController {
  43642. /**
  43643. * Base Url for the controller model.
  43644. */
  43645. static MODEL_BASE_URL: string;
  43646. /**
  43647. * File name for the left controller model.
  43648. */
  43649. static MODEL_LEFT_FILENAME: string;
  43650. /**
  43651. * File name for the right controller model.
  43652. */
  43653. static MODEL_RIGHT_FILENAME: string;
  43654. /**
  43655. * Base Url for the Quest controller model.
  43656. */
  43657. static QUEST_MODEL_BASE_URL: string;
  43658. /**
  43659. * @hidden
  43660. * If the controllers are running on a device that needs the updated Quest controller models
  43661. */
  43662. static _IsQuest: boolean;
  43663. /**
  43664. * Fired when the secondary trigger on this controller is modified
  43665. */
  43666. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43667. /**
  43668. * Fired when the thumb rest on this controller is modified
  43669. */
  43670. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43671. /**
  43672. * Creates a new OculusTouchController from a gamepad
  43673. * @param vrGamepad the gamepad that the controller should be created from
  43674. */
  43675. constructor(vrGamepad: any);
  43676. /**
  43677. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43678. * @param scene scene in which to add meshes
  43679. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43680. */
  43681. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43682. /**
  43683. * Fired when the A button on this controller is modified
  43684. */
  43685. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43686. /**
  43687. * Fired when the B button on this controller is modified
  43688. */
  43689. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43690. /**
  43691. * Fired when the X button on this controller is modified
  43692. */
  43693. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43694. /**
  43695. * Fired when the Y button on this controller is modified
  43696. */
  43697. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43698. /**
  43699. * Called once for each button that changed state since the last frame
  43700. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43701. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43702. * 2) secondary trigger (same)
  43703. * 3) A (right) X (left), touch, pressed = value
  43704. * 4) B / Y
  43705. * 5) thumb rest
  43706. * @param buttonIdx Which button index changed
  43707. * @param state New state of the button
  43708. * @param changes Which properties on the state changed since last frame
  43709. */
  43710. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43711. }
  43712. }
  43713. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43714. import { Scene } from "babylonjs/scene";
  43715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43716. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43717. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43718. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43719. import { Observable } from "babylonjs/Misc/observable";
  43720. /**
  43721. * Vive Controller
  43722. */
  43723. export class ViveController extends WebVRController {
  43724. /**
  43725. * Base Url for the controller model.
  43726. */
  43727. static MODEL_BASE_URL: string;
  43728. /**
  43729. * File name for the controller model.
  43730. */
  43731. static MODEL_FILENAME: string;
  43732. /**
  43733. * Creates a new ViveController from a gamepad
  43734. * @param vrGamepad the gamepad that the controller should be created from
  43735. */
  43736. constructor(vrGamepad: any);
  43737. /**
  43738. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43739. * @param scene scene in which to add meshes
  43740. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43741. */
  43742. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43743. /**
  43744. * Fired when the left button on this controller is modified
  43745. */
  43746. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43747. /**
  43748. * Fired when the right button on this controller is modified
  43749. */
  43750. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43751. /**
  43752. * Fired when the menu button on this controller is modified
  43753. */
  43754. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43755. /**
  43756. * Called once for each button that changed state since the last frame
  43757. * Vive mapping:
  43758. * 0: touchpad
  43759. * 1: trigger
  43760. * 2: left AND right buttons
  43761. * 3: menu button
  43762. * @param buttonIdx Which button index changed
  43763. * @param state New state of the button
  43764. * @param changes Which properties on the state changed since last frame
  43765. */
  43766. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43767. }
  43768. }
  43769. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43770. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43771. /**
  43772. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43773. */
  43774. export class WebXRControllerModelLoader {
  43775. /**
  43776. * Creates the WebXRControllerModelLoader
  43777. * @param input xr input that creates the controllers
  43778. */
  43779. constructor(input: WebXRInput);
  43780. }
  43781. }
  43782. declare module "babylonjs/Cameras/XR/index" {
  43783. export * from "babylonjs/Cameras/XR/webXRCamera";
  43784. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43785. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43786. export * from "babylonjs/Cameras/XR/webXRInput";
  43787. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43788. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43789. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43790. export * from "babylonjs/Cameras/XR/webXRController";
  43791. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43792. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43793. }
  43794. declare module "babylonjs/Cameras/RigModes/index" {
  43795. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43796. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43797. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43798. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43799. }
  43800. declare module "babylonjs/Cameras/index" {
  43801. export * from "babylonjs/Cameras/Inputs/index";
  43802. export * from "babylonjs/Cameras/cameraInputsManager";
  43803. export * from "babylonjs/Cameras/camera";
  43804. export * from "babylonjs/Cameras/targetCamera";
  43805. export * from "babylonjs/Cameras/freeCamera";
  43806. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43807. export * from "babylonjs/Cameras/touchCamera";
  43808. export * from "babylonjs/Cameras/arcRotateCamera";
  43809. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43810. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43811. export * from "babylonjs/Cameras/flyCamera";
  43812. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43813. export * from "babylonjs/Cameras/followCamera";
  43814. export * from "babylonjs/Cameras/followCameraInputsManager";
  43815. export * from "babylonjs/Cameras/gamepadCamera";
  43816. export * from "babylonjs/Cameras/Stereoscopic/index";
  43817. export * from "babylonjs/Cameras/universalCamera";
  43818. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43819. export * from "babylonjs/Cameras/VR/index";
  43820. export * from "babylonjs/Cameras/XR/index";
  43821. export * from "babylonjs/Cameras/RigModes/index";
  43822. }
  43823. declare module "babylonjs/Collisions/index" {
  43824. export * from "babylonjs/Collisions/collider";
  43825. export * from "babylonjs/Collisions/collisionCoordinator";
  43826. export * from "babylonjs/Collisions/pickingInfo";
  43827. export * from "babylonjs/Collisions/intersectionInfo";
  43828. export * from "babylonjs/Collisions/meshCollisionData";
  43829. }
  43830. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43831. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43832. import { Vector3 } from "babylonjs/Maths/math.vector";
  43833. import { Ray } from "babylonjs/Culling/ray";
  43834. import { Plane } from "babylonjs/Maths/math.plane";
  43835. /**
  43836. * Contains an array of blocks representing the octree
  43837. */
  43838. export interface IOctreeContainer<T> {
  43839. /**
  43840. * Blocks within the octree
  43841. */
  43842. blocks: Array<OctreeBlock<T>>;
  43843. }
  43844. /**
  43845. * Class used to store a cell in an octree
  43846. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43847. */
  43848. export class OctreeBlock<T> {
  43849. /**
  43850. * Gets the content of the current block
  43851. */
  43852. entries: T[];
  43853. /**
  43854. * Gets the list of block children
  43855. */
  43856. blocks: Array<OctreeBlock<T>>;
  43857. private _depth;
  43858. private _maxDepth;
  43859. private _capacity;
  43860. private _minPoint;
  43861. private _maxPoint;
  43862. private _boundingVectors;
  43863. private _creationFunc;
  43864. /**
  43865. * Creates a new block
  43866. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43867. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43868. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43869. * @param depth defines the current depth of this block in the octree
  43870. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43871. * @param creationFunc defines a callback to call when an element is added to the block
  43872. */
  43873. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43874. /**
  43875. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43876. */
  43877. readonly capacity: number;
  43878. /**
  43879. * Gets the minimum vector (in world space) of the block's bounding box
  43880. */
  43881. readonly minPoint: Vector3;
  43882. /**
  43883. * Gets the maximum vector (in world space) of the block's bounding box
  43884. */
  43885. readonly maxPoint: Vector3;
  43886. /**
  43887. * Add a new element to this block
  43888. * @param entry defines the element to add
  43889. */
  43890. addEntry(entry: T): void;
  43891. /**
  43892. * Remove an element from this block
  43893. * @param entry defines the element to remove
  43894. */
  43895. removeEntry(entry: T): void;
  43896. /**
  43897. * Add an array of elements to this block
  43898. * @param entries defines the array of elements to add
  43899. */
  43900. addEntries(entries: T[]): void;
  43901. /**
  43902. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43903. * @param frustumPlanes defines the frustum planes to test
  43904. * @param selection defines the array to store current content if selection is positive
  43905. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43906. */
  43907. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43908. /**
  43909. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43910. * @param sphereCenter defines the bounding sphere center
  43911. * @param sphereRadius defines the bounding sphere radius
  43912. * @param selection defines the array to store current content if selection is positive
  43913. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43914. */
  43915. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43916. /**
  43917. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43918. * @param ray defines the ray to test with
  43919. * @param selection defines the array to store current content if selection is positive
  43920. */
  43921. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43922. /**
  43923. * Subdivide the content into child blocks (this block will then be empty)
  43924. */
  43925. createInnerBlocks(): void;
  43926. /**
  43927. * @hidden
  43928. */
  43929. 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;
  43930. }
  43931. }
  43932. declare module "babylonjs/Culling/Octrees/octree" {
  43933. import { SmartArray } from "babylonjs/Misc/smartArray";
  43934. import { Vector3 } from "babylonjs/Maths/math.vector";
  43935. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43937. import { Ray } from "babylonjs/Culling/ray";
  43938. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43939. import { Plane } from "babylonjs/Maths/math.plane";
  43940. /**
  43941. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43942. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43943. */
  43944. export class Octree<T> {
  43945. /** 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.) */
  43946. maxDepth: number;
  43947. /**
  43948. * Blocks within the octree containing objects
  43949. */
  43950. blocks: Array<OctreeBlock<T>>;
  43951. /**
  43952. * Content stored in the octree
  43953. */
  43954. dynamicContent: T[];
  43955. private _maxBlockCapacity;
  43956. private _selectionContent;
  43957. private _creationFunc;
  43958. /**
  43959. * Creates a octree
  43960. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43961. * @param creationFunc function to be used to instatiate the octree
  43962. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43963. * @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.)
  43964. */
  43965. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43966. /** 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.) */
  43967. maxDepth?: number);
  43968. /**
  43969. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43970. * @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);
  43971. * @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);
  43972. * @param entries meshes to be added to the octree blocks
  43973. */
  43974. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43975. /**
  43976. * Adds a mesh to the octree
  43977. * @param entry Mesh to add to the octree
  43978. */
  43979. addMesh(entry: T): void;
  43980. /**
  43981. * Remove an element from the octree
  43982. * @param entry defines the element to remove
  43983. */
  43984. removeMesh(entry: T): void;
  43985. /**
  43986. * Selects an array of meshes within the frustum
  43987. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43988. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43989. * @returns array of meshes within the frustum
  43990. */
  43991. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43992. /**
  43993. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43994. * @param sphereCenter defines the bounding sphere center
  43995. * @param sphereRadius defines the bounding sphere radius
  43996. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43997. * @returns an array of objects that intersect the sphere
  43998. */
  43999. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44000. /**
  44001. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44002. * @param ray defines the ray to test with
  44003. * @returns array of intersected objects
  44004. */
  44005. intersectsRay(ray: Ray): SmartArray<T>;
  44006. /**
  44007. * Adds a mesh into the octree block if it intersects the block
  44008. */
  44009. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44010. /**
  44011. * Adds a submesh into the octree block if it intersects the block
  44012. */
  44013. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44014. }
  44015. }
  44016. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44017. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44018. import { Scene } from "babylonjs/scene";
  44019. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44021. import { Ray } from "babylonjs/Culling/ray";
  44022. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44023. import { Collider } from "babylonjs/Collisions/collider";
  44024. module "babylonjs/scene" {
  44025. interface Scene {
  44026. /**
  44027. * @hidden
  44028. * Backing Filed
  44029. */
  44030. _selectionOctree: Octree<AbstractMesh>;
  44031. /**
  44032. * Gets the octree used to boost mesh selection (picking)
  44033. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44034. */
  44035. selectionOctree: Octree<AbstractMesh>;
  44036. /**
  44037. * Creates or updates the octree used to boost selection (picking)
  44038. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44039. * @param maxCapacity defines the maximum capacity per leaf
  44040. * @param maxDepth defines the maximum depth of the octree
  44041. * @returns an octree of AbstractMesh
  44042. */
  44043. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44044. }
  44045. }
  44046. module "babylonjs/Meshes/abstractMesh" {
  44047. interface AbstractMesh {
  44048. /**
  44049. * @hidden
  44050. * Backing Field
  44051. */
  44052. _submeshesOctree: Octree<SubMesh>;
  44053. /**
  44054. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44055. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44056. * @param maxCapacity defines the maximum size of each block (64 by default)
  44057. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44058. * @returns the new octree
  44059. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44060. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44061. */
  44062. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44063. }
  44064. }
  44065. /**
  44066. * Defines the octree scene component responsible to manage any octrees
  44067. * in a given scene.
  44068. */
  44069. export class OctreeSceneComponent {
  44070. /**
  44071. * The component name help to identify the component in the list of scene components.
  44072. */
  44073. readonly name: string;
  44074. /**
  44075. * The scene the component belongs to.
  44076. */
  44077. scene: Scene;
  44078. /**
  44079. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44080. */
  44081. readonly checksIsEnabled: boolean;
  44082. /**
  44083. * Creates a new instance of the component for the given scene
  44084. * @param scene Defines the scene to register the component in
  44085. */
  44086. constructor(scene: Scene);
  44087. /**
  44088. * Registers the component in a given scene
  44089. */
  44090. register(): void;
  44091. /**
  44092. * Return the list of active meshes
  44093. * @returns the list of active meshes
  44094. */
  44095. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44096. /**
  44097. * Return the list of active sub meshes
  44098. * @param mesh The mesh to get the candidates sub meshes from
  44099. * @returns the list of active sub meshes
  44100. */
  44101. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44102. private _tempRay;
  44103. /**
  44104. * Return the list of sub meshes intersecting with a given local ray
  44105. * @param mesh defines the mesh to find the submesh for
  44106. * @param localRay defines the ray in local space
  44107. * @returns the list of intersecting sub meshes
  44108. */
  44109. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44110. /**
  44111. * Return the list of sub meshes colliding with a collider
  44112. * @param mesh defines the mesh to find the submesh for
  44113. * @param collider defines the collider to evaluate the collision against
  44114. * @returns the list of colliding sub meshes
  44115. */
  44116. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44117. /**
  44118. * Rebuilds the elements related to this component in case of
  44119. * context lost for instance.
  44120. */
  44121. rebuild(): void;
  44122. /**
  44123. * Disposes the component and the associated ressources.
  44124. */
  44125. dispose(): void;
  44126. }
  44127. }
  44128. declare module "babylonjs/Culling/Octrees/index" {
  44129. export * from "babylonjs/Culling/Octrees/octree";
  44130. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44131. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44132. }
  44133. declare module "babylonjs/Culling/index" {
  44134. export * from "babylonjs/Culling/boundingBox";
  44135. export * from "babylonjs/Culling/boundingInfo";
  44136. export * from "babylonjs/Culling/boundingSphere";
  44137. export * from "babylonjs/Culling/Octrees/index";
  44138. export * from "babylonjs/Culling/ray";
  44139. }
  44140. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44141. import { IDisposable, Scene } from "babylonjs/scene";
  44142. import { Nullable } from "babylonjs/types";
  44143. import { Observable } from "babylonjs/Misc/observable";
  44144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44145. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44146. import { Camera } from "babylonjs/Cameras/camera";
  44147. /**
  44148. * Renders a layer on top of an existing scene
  44149. */
  44150. export class UtilityLayerRenderer implements IDisposable {
  44151. /** the original scene that will be rendered on top of */
  44152. originalScene: Scene;
  44153. private _pointerCaptures;
  44154. private _lastPointerEvents;
  44155. private static _DefaultUtilityLayer;
  44156. private static _DefaultKeepDepthUtilityLayer;
  44157. private _sharedGizmoLight;
  44158. private _renderCamera;
  44159. /**
  44160. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44161. * @returns the camera that is used when rendering the utility layer
  44162. */
  44163. getRenderCamera(): Nullable<Camera>;
  44164. /**
  44165. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44166. * @param cam the camera that should be used when rendering the utility layer
  44167. */
  44168. setRenderCamera(cam: Nullable<Camera>): void;
  44169. /**
  44170. * @hidden
  44171. * Light which used by gizmos to get light shading
  44172. */
  44173. _getSharedGizmoLight(): HemisphericLight;
  44174. /**
  44175. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44176. */
  44177. pickUtilitySceneFirst: boolean;
  44178. /**
  44179. * 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)
  44180. */
  44181. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44182. /**
  44183. * 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)
  44184. */
  44185. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44186. /**
  44187. * The scene that is rendered on top of the original scene
  44188. */
  44189. utilityLayerScene: Scene;
  44190. /**
  44191. * If the utility layer should automatically be rendered on top of existing scene
  44192. */
  44193. shouldRender: boolean;
  44194. /**
  44195. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44196. */
  44197. onlyCheckPointerDownEvents: boolean;
  44198. /**
  44199. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44200. */
  44201. processAllEvents: boolean;
  44202. /**
  44203. * Observable raised when the pointer move from the utility layer scene to the main scene
  44204. */
  44205. onPointerOutObservable: Observable<number>;
  44206. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44207. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44208. private _afterRenderObserver;
  44209. private _sceneDisposeObserver;
  44210. private _originalPointerObserver;
  44211. /**
  44212. * Instantiates a UtilityLayerRenderer
  44213. * @param originalScene the original scene that will be rendered on top of
  44214. * @param handleEvents boolean indicating if the utility layer should handle events
  44215. */
  44216. constructor(
  44217. /** the original scene that will be rendered on top of */
  44218. originalScene: Scene, handleEvents?: boolean);
  44219. private _notifyObservers;
  44220. /**
  44221. * Renders the utility layers scene on top of the original scene
  44222. */
  44223. render(): void;
  44224. /**
  44225. * Disposes of the renderer
  44226. */
  44227. dispose(): void;
  44228. private _updateCamera;
  44229. }
  44230. }
  44231. declare module "babylonjs/Gizmos/gizmo" {
  44232. import { Nullable } from "babylonjs/types";
  44233. import { IDisposable } from "babylonjs/scene";
  44234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44235. import { Mesh } from "babylonjs/Meshes/mesh";
  44236. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44237. /**
  44238. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44239. */
  44240. export class Gizmo implements IDisposable {
  44241. /** The utility layer the gizmo will be added to */
  44242. gizmoLayer: UtilityLayerRenderer;
  44243. /**
  44244. * The root mesh of the gizmo
  44245. */
  44246. _rootMesh: Mesh;
  44247. private _attachedMesh;
  44248. /**
  44249. * Ratio for the scale of the gizmo (Default: 1)
  44250. */
  44251. scaleRatio: number;
  44252. /**
  44253. * If a custom mesh has been set (Default: false)
  44254. */
  44255. protected _customMeshSet: boolean;
  44256. /**
  44257. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44258. * * When set, interactions will be enabled
  44259. */
  44260. attachedMesh: Nullable<AbstractMesh>;
  44261. /**
  44262. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44263. * @param mesh The mesh to replace the default mesh of the gizmo
  44264. */
  44265. setCustomMesh(mesh: Mesh): void;
  44266. /**
  44267. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44268. */
  44269. updateGizmoRotationToMatchAttachedMesh: boolean;
  44270. /**
  44271. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44272. */
  44273. updateGizmoPositionToMatchAttachedMesh: boolean;
  44274. /**
  44275. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44276. */
  44277. updateScale: boolean;
  44278. protected _interactionsEnabled: boolean;
  44279. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44280. private _beforeRenderObserver;
  44281. private _tempVector;
  44282. /**
  44283. * Creates a gizmo
  44284. * @param gizmoLayer The utility layer the gizmo will be added to
  44285. */
  44286. constructor(
  44287. /** The utility layer the gizmo will be added to */
  44288. gizmoLayer?: UtilityLayerRenderer);
  44289. /**
  44290. * Updates the gizmo to match the attached mesh's position/rotation
  44291. */
  44292. protected _update(): void;
  44293. /**
  44294. * Disposes of the gizmo
  44295. */
  44296. dispose(): void;
  44297. }
  44298. }
  44299. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44300. import { Observable } from "babylonjs/Misc/observable";
  44301. import { Nullable } from "babylonjs/types";
  44302. import { Vector3 } from "babylonjs/Maths/math.vector";
  44303. import { Color3 } from "babylonjs/Maths/math.color";
  44304. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44306. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44307. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44308. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44309. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44310. import { Scene } from "babylonjs/scene";
  44311. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44312. /**
  44313. * Single plane drag gizmo
  44314. */
  44315. export class PlaneDragGizmo extends Gizmo {
  44316. /**
  44317. * Drag behavior responsible for the gizmos dragging interactions
  44318. */
  44319. dragBehavior: PointerDragBehavior;
  44320. private _pointerObserver;
  44321. /**
  44322. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44323. */
  44324. snapDistance: number;
  44325. /**
  44326. * Event that fires each time the gizmo snaps to a new location.
  44327. * * snapDistance is the the change in distance
  44328. */
  44329. onSnapObservable: Observable<{
  44330. snapDistance: number;
  44331. }>;
  44332. private _plane;
  44333. private _coloredMaterial;
  44334. private _hoverMaterial;
  44335. private _isEnabled;
  44336. private _parent;
  44337. /** @hidden */
  44338. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44339. /** @hidden */
  44340. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44341. /**
  44342. * Creates a PlaneDragGizmo
  44343. * @param gizmoLayer The utility layer the gizmo will be added to
  44344. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44345. * @param color The color of the gizmo
  44346. */
  44347. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44348. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44349. /**
  44350. * If the gizmo is enabled
  44351. */
  44352. isEnabled: boolean;
  44353. /**
  44354. * Disposes of the gizmo
  44355. */
  44356. dispose(): void;
  44357. }
  44358. }
  44359. declare module "babylonjs/Gizmos/positionGizmo" {
  44360. import { Observable } from "babylonjs/Misc/observable";
  44361. import { Nullable } from "babylonjs/types";
  44362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44363. import { Mesh } from "babylonjs/Meshes/mesh";
  44364. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44365. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44366. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44367. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44368. /**
  44369. * Gizmo that enables dragging a mesh along 3 axis
  44370. */
  44371. export class PositionGizmo extends Gizmo {
  44372. /**
  44373. * Internal gizmo used for interactions on the x axis
  44374. */
  44375. xGizmo: AxisDragGizmo;
  44376. /**
  44377. * Internal gizmo used for interactions on the y axis
  44378. */
  44379. yGizmo: AxisDragGizmo;
  44380. /**
  44381. * Internal gizmo used for interactions on the z axis
  44382. */
  44383. zGizmo: AxisDragGizmo;
  44384. /**
  44385. * Internal gizmo used for interactions on the yz plane
  44386. */
  44387. xPlaneGizmo: PlaneDragGizmo;
  44388. /**
  44389. * Internal gizmo used for interactions on the xz plane
  44390. */
  44391. yPlaneGizmo: PlaneDragGizmo;
  44392. /**
  44393. * Internal gizmo used for interactions on the xy plane
  44394. */
  44395. zPlaneGizmo: PlaneDragGizmo;
  44396. /**
  44397. * private variables
  44398. */
  44399. private _meshAttached;
  44400. private _updateGizmoRotationToMatchAttachedMesh;
  44401. private _snapDistance;
  44402. private _scaleRatio;
  44403. /** Fires an event when any of it's sub gizmos are dragged */
  44404. onDragStartObservable: Observable<unknown>;
  44405. /** Fires an event when any of it's sub gizmos are released from dragging */
  44406. onDragEndObservable: Observable<unknown>;
  44407. /**
  44408. * If set to true, planar drag is enabled
  44409. */
  44410. private _planarGizmoEnabled;
  44411. attachedMesh: Nullable<AbstractMesh>;
  44412. /**
  44413. * Creates a PositionGizmo
  44414. * @param gizmoLayer The utility layer the gizmo will be added to
  44415. */
  44416. constructor(gizmoLayer?: UtilityLayerRenderer);
  44417. /**
  44418. * If the planar drag gizmo is enabled
  44419. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44420. */
  44421. planarGizmoEnabled: boolean;
  44422. updateGizmoRotationToMatchAttachedMesh: boolean;
  44423. /**
  44424. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44425. */
  44426. snapDistance: number;
  44427. /**
  44428. * Ratio for the scale of the gizmo (Default: 1)
  44429. */
  44430. scaleRatio: number;
  44431. /**
  44432. * Disposes of the gizmo
  44433. */
  44434. dispose(): void;
  44435. /**
  44436. * CustomMeshes are not supported by this gizmo
  44437. * @param mesh The mesh to replace the default mesh of the gizmo
  44438. */
  44439. setCustomMesh(mesh: Mesh): void;
  44440. }
  44441. }
  44442. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44443. import { Observable } from "babylonjs/Misc/observable";
  44444. import { Nullable } from "babylonjs/types";
  44445. import { Vector3 } from "babylonjs/Maths/math.vector";
  44446. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44448. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44449. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44450. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44451. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44452. import { Scene } from "babylonjs/scene";
  44453. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44454. import { Color3 } from "babylonjs/Maths/math.color";
  44455. /**
  44456. * Single axis drag gizmo
  44457. */
  44458. export class AxisDragGizmo extends Gizmo {
  44459. /**
  44460. * Drag behavior responsible for the gizmos dragging interactions
  44461. */
  44462. dragBehavior: PointerDragBehavior;
  44463. private _pointerObserver;
  44464. /**
  44465. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44466. */
  44467. snapDistance: number;
  44468. /**
  44469. * Event that fires each time the gizmo snaps to a new location.
  44470. * * snapDistance is the the change in distance
  44471. */
  44472. onSnapObservable: Observable<{
  44473. snapDistance: number;
  44474. }>;
  44475. private _isEnabled;
  44476. private _parent;
  44477. private _arrow;
  44478. private _coloredMaterial;
  44479. private _hoverMaterial;
  44480. /** @hidden */
  44481. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44482. /** @hidden */
  44483. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44484. /**
  44485. * Creates an AxisDragGizmo
  44486. * @param gizmoLayer The utility layer the gizmo will be added to
  44487. * @param dragAxis The axis which the gizmo will be able to drag on
  44488. * @param color The color of the gizmo
  44489. */
  44490. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44491. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44492. /**
  44493. * If the gizmo is enabled
  44494. */
  44495. isEnabled: boolean;
  44496. /**
  44497. * Disposes of the gizmo
  44498. */
  44499. dispose(): void;
  44500. }
  44501. }
  44502. declare module "babylonjs/Debug/axesViewer" {
  44503. import { Vector3 } from "babylonjs/Maths/math.vector";
  44504. import { Nullable } from "babylonjs/types";
  44505. import { Scene } from "babylonjs/scene";
  44506. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44507. /**
  44508. * The Axes viewer will show 3 axes in a specific point in space
  44509. */
  44510. export class AxesViewer {
  44511. private _xAxis;
  44512. private _yAxis;
  44513. private _zAxis;
  44514. private _scaleLinesFactor;
  44515. private _instanced;
  44516. /**
  44517. * Gets the hosting scene
  44518. */
  44519. scene: Scene;
  44520. /**
  44521. * Gets or sets a number used to scale line length
  44522. */
  44523. scaleLines: number;
  44524. /** Gets the node hierarchy used to render x-axis */
  44525. readonly xAxis: TransformNode;
  44526. /** Gets the node hierarchy used to render y-axis */
  44527. readonly yAxis: TransformNode;
  44528. /** Gets the node hierarchy used to render z-axis */
  44529. readonly zAxis: TransformNode;
  44530. /**
  44531. * Creates a new AxesViewer
  44532. * @param scene defines the hosting scene
  44533. * @param scaleLines defines a number used to scale line length (1 by default)
  44534. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44535. * @param xAxis defines the node hierarchy used to render the x-axis
  44536. * @param yAxis defines the node hierarchy used to render the y-axis
  44537. * @param zAxis defines the node hierarchy used to render the z-axis
  44538. */
  44539. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44540. /**
  44541. * Force the viewer to update
  44542. * @param position defines the position of the viewer
  44543. * @param xaxis defines the x axis of the viewer
  44544. * @param yaxis defines the y axis of the viewer
  44545. * @param zaxis defines the z axis of the viewer
  44546. */
  44547. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44548. /**
  44549. * Creates an instance of this axes viewer.
  44550. * @returns a new axes viewer with instanced meshes
  44551. */
  44552. createInstance(): AxesViewer;
  44553. /** Releases resources */
  44554. dispose(): void;
  44555. private static _SetRenderingGroupId;
  44556. }
  44557. }
  44558. declare module "babylonjs/Debug/boneAxesViewer" {
  44559. import { Nullable } from "babylonjs/types";
  44560. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44561. import { Vector3 } from "babylonjs/Maths/math.vector";
  44562. import { Mesh } from "babylonjs/Meshes/mesh";
  44563. import { Bone } from "babylonjs/Bones/bone";
  44564. import { Scene } from "babylonjs/scene";
  44565. /**
  44566. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44567. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44568. */
  44569. export class BoneAxesViewer extends AxesViewer {
  44570. /**
  44571. * Gets or sets the target mesh where to display the axes viewer
  44572. */
  44573. mesh: Nullable<Mesh>;
  44574. /**
  44575. * Gets or sets the target bone where to display the axes viewer
  44576. */
  44577. bone: Nullable<Bone>;
  44578. /** Gets current position */
  44579. pos: Vector3;
  44580. /** Gets direction of X axis */
  44581. xaxis: Vector3;
  44582. /** Gets direction of Y axis */
  44583. yaxis: Vector3;
  44584. /** Gets direction of Z axis */
  44585. zaxis: Vector3;
  44586. /**
  44587. * Creates a new BoneAxesViewer
  44588. * @param scene defines the hosting scene
  44589. * @param bone defines the target bone
  44590. * @param mesh defines the target mesh
  44591. * @param scaleLines defines a scaling factor for line length (1 by default)
  44592. */
  44593. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44594. /**
  44595. * Force the viewer to update
  44596. */
  44597. update(): void;
  44598. /** Releases resources */
  44599. dispose(): void;
  44600. }
  44601. }
  44602. declare module "babylonjs/Debug/debugLayer" {
  44603. import { Scene } from "babylonjs/scene";
  44604. /**
  44605. * Interface used to define scene explorer extensibility option
  44606. */
  44607. export interface IExplorerExtensibilityOption {
  44608. /**
  44609. * Define the option label
  44610. */
  44611. label: string;
  44612. /**
  44613. * Defines the action to execute on click
  44614. */
  44615. action: (entity: any) => void;
  44616. }
  44617. /**
  44618. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44619. */
  44620. export interface IExplorerExtensibilityGroup {
  44621. /**
  44622. * Defines a predicate to test if a given type mut be extended
  44623. */
  44624. predicate: (entity: any) => boolean;
  44625. /**
  44626. * Gets the list of options added to a type
  44627. */
  44628. entries: IExplorerExtensibilityOption[];
  44629. }
  44630. /**
  44631. * Interface used to define the options to use to create the Inspector
  44632. */
  44633. export interface IInspectorOptions {
  44634. /**
  44635. * Display in overlay mode (default: false)
  44636. */
  44637. overlay?: boolean;
  44638. /**
  44639. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44640. */
  44641. globalRoot?: HTMLElement;
  44642. /**
  44643. * Display the Scene explorer
  44644. */
  44645. showExplorer?: boolean;
  44646. /**
  44647. * Display the property inspector
  44648. */
  44649. showInspector?: boolean;
  44650. /**
  44651. * Display in embed mode (both panes on the right)
  44652. */
  44653. embedMode?: boolean;
  44654. /**
  44655. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44656. */
  44657. handleResize?: boolean;
  44658. /**
  44659. * Allow the panes to popup (default: true)
  44660. */
  44661. enablePopup?: boolean;
  44662. /**
  44663. * Allow the panes to be closed by users (default: true)
  44664. */
  44665. enableClose?: boolean;
  44666. /**
  44667. * Optional list of extensibility entries
  44668. */
  44669. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44670. /**
  44671. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44672. */
  44673. inspectorURL?: string;
  44674. }
  44675. module "babylonjs/scene" {
  44676. interface Scene {
  44677. /**
  44678. * @hidden
  44679. * Backing field
  44680. */
  44681. _debugLayer: DebugLayer;
  44682. /**
  44683. * Gets the debug layer (aka Inspector) associated with the scene
  44684. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44685. */
  44686. debugLayer: DebugLayer;
  44687. }
  44688. }
  44689. /**
  44690. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44691. * what is happening in your scene
  44692. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44693. */
  44694. export class DebugLayer {
  44695. /**
  44696. * Define the url to get the inspector script from.
  44697. * By default it uses the babylonjs CDN.
  44698. * @ignoreNaming
  44699. */
  44700. static InspectorURL: string;
  44701. private _scene;
  44702. private BJSINSPECTOR;
  44703. private _onPropertyChangedObservable?;
  44704. /**
  44705. * Observable triggered when a property is changed through the inspector.
  44706. */
  44707. readonly onPropertyChangedObservable: any;
  44708. /**
  44709. * Instantiates a new debug layer.
  44710. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44711. * what is happening in your scene
  44712. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44713. * @param scene Defines the scene to inspect
  44714. */
  44715. constructor(scene: Scene);
  44716. /** Creates the inspector window. */
  44717. private _createInspector;
  44718. /**
  44719. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44720. * @param entity defines the entity to select
  44721. * @param lineContainerTitle defines the specific block to highlight
  44722. */
  44723. select(entity: any, lineContainerTitle?: string): void;
  44724. /** Get the inspector from bundle or global */
  44725. private _getGlobalInspector;
  44726. /**
  44727. * Get if the inspector is visible or not.
  44728. * @returns true if visible otherwise, false
  44729. */
  44730. isVisible(): boolean;
  44731. /**
  44732. * Hide the inspector and close its window.
  44733. */
  44734. hide(): void;
  44735. /**
  44736. * Launch the debugLayer.
  44737. * @param config Define the configuration of the inspector
  44738. * @return a promise fulfilled when the debug layer is visible
  44739. */
  44740. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44741. }
  44742. }
  44743. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44744. import { Nullable } from "babylonjs/types";
  44745. import { Scene } from "babylonjs/scene";
  44746. import { Vector4 } from "babylonjs/Maths/math.vector";
  44747. import { Color4 } from "babylonjs/Maths/math.color";
  44748. import { Mesh } from "babylonjs/Meshes/mesh";
  44749. /**
  44750. * Class containing static functions to help procedurally build meshes
  44751. */
  44752. export class BoxBuilder {
  44753. /**
  44754. * Creates a box mesh
  44755. * * The parameter `size` sets the size (float) of each box side (default 1)
  44756. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44757. * * 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)
  44758. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44759. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44760. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44762. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44763. * @param name defines the name of the mesh
  44764. * @param options defines the options used to create the mesh
  44765. * @param scene defines the hosting scene
  44766. * @returns the box mesh
  44767. */
  44768. static CreateBox(name: string, options: {
  44769. size?: number;
  44770. width?: number;
  44771. height?: number;
  44772. depth?: number;
  44773. faceUV?: Vector4[];
  44774. faceColors?: Color4[];
  44775. sideOrientation?: number;
  44776. frontUVs?: Vector4;
  44777. backUVs?: Vector4;
  44778. wrap?: boolean;
  44779. topBaseAt?: number;
  44780. bottomBaseAt?: number;
  44781. updatable?: boolean;
  44782. }, scene?: Nullable<Scene>): Mesh;
  44783. }
  44784. }
  44785. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44786. import { Vector4 } from "babylonjs/Maths/math.vector";
  44787. import { Mesh } from "babylonjs/Meshes/mesh";
  44788. import { Scene } from "babylonjs/scene";
  44789. import { Nullable } from "babylonjs/types";
  44790. /**
  44791. * Class containing static functions to help procedurally build meshes
  44792. */
  44793. export class SphereBuilder {
  44794. /**
  44795. * Creates a sphere mesh
  44796. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44797. * * 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`)
  44798. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44799. * * 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
  44800. * * 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)
  44801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44802. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44804. * @param name defines the name of the mesh
  44805. * @param options defines the options used to create the mesh
  44806. * @param scene defines the hosting scene
  44807. * @returns the sphere mesh
  44808. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44809. */
  44810. static CreateSphere(name: string, options: {
  44811. segments?: number;
  44812. diameter?: number;
  44813. diameterX?: number;
  44814. diameterY?: number;
  44815. diameterZ?: number;
  44816. arc?: number;
  44817. slice?: number;
  44818. sideOrientation?: number;
  44819. frontUVs?: Vector4;
  44820. backUVs?: Vector4;
  44821. updatable?: boolean;
  44822. }, scene?: Nullable<Scene>): Mesh;
  44823. }
  44824. }
  44825. declare module "babylonjs/Debug/physicsViewer" {
  44826. import { Nullable } from "babylonjs/types";
  44827. import { Scene } from "babylonjs/scene";
  44828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44829. import { Mesh } from "babylonjs/Meshes/mesh";
  44830. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44831. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44832. /**
  44833. * Used to show the physics impostor around the specific mesh
  44834. */
  44835. export class PhysicsViewer {
  44836. /** @hidden */
  44837. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44838. /** @hidden */
  44839. protected _meshes: Array<Nullable<AbstractMesh>>;
  44840. /** @hidden */
  44841. protected _scene: Nullable<Scene>;
  44842. /** @hidden */
  44843. protected _numMeshes: number;
  44844. /** @hidden */
  44845. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44846. private _renderFunction;
  44847. private _utilityLayer;
  44848. private _debugBoxMesh;
  44849. private _debugSphereMesh;
  44850. private _debugCylinderMesh;
  44851. private _debugMaterial;
  44852. private _debugMeshMeshes;
  44853. /**
  44854. * Creates a new PhysicsViewer
  44855. * @param scene defines the hosting scene
  44856. */
  44857. constructor(scene: Scene);
  44858. /** @hidden */
  44859. protected _updateDebugMeshes(): void;
  44860. /**
  44861. * Renders a specified physic impostor
  44862. * @param impostor defines the impostor to render
  44863. * @param targetMesh defines the mesh represented by the impostor
  44864. * @returns the new debug mesh used to render the impostor
  44865. */
  44866. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44867. /**
  44868. * Hides a specified physic impostor
  44869. * @param impostor defines the impostor to hide
  44870. */
  44871. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44872. private _getDebugMaterial;
  44873. private _getDebugBoxMesh;
  44874. private _getDebugSphereMesh;
  44875. private _getDebugCylinderMesh;
  44876. private _getDebugMeshMesh;
  44877. private _getDebugMesh;
  44878. /** Releases all resources */
  44879. dispose(): void;
  44880. }
  44881. }
  44882. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44883. import { Vector3 } from "babylonjs/Maths/math.vector";
  44884. import { Color4 } from "babylonjs/Maths/math.color";
  44885. import { Nullable } from "babylonjs/types";
  44886. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44887. import { Scene } from "babylonjs/scene";
  44888. /**
  44889. * Class containing static functions to help procedurally build meshes
  44890. */
  44891. export class LinesBuilder {
  44892. /**
  44893. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44894. * * 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
  44895. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44896. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44897. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44898. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44899. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44900. * * 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
  44901. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44903. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44904. * @param name defines the name of the new line system
  44905. * @param options defines the options used to create the line system
  44906. * @param scene defines the hosting scene
  44907. * @returns a new line system mesh
  44908. */
  44909. static CreateLineSystem(name: string, options: {
  44910. lines: Vector3[][];
  44911. updatable?: boolean;
  44912. instance?: Nullable<LinesMesh>;
  44913. colors?: Nullable<Color4[][]>;
  44914. useVertexAlpha?: boolean;
  44915. }, scene: Nullable<Scene>): LinesMesh;
  44916. /**
  44917. * Creates a line mesh
  44918. * 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
  44919. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44920. * * The parameter `points` is an array successive Vector3
  44921. * * 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
  44922. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44923. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44924. * * When updating an instance, remember that only point positions can change, not the number of points
  44925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44926. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44927. * @param name defines the name of the new line system
  44928. * @param options defines the options used to create the line system
  44929. * @param scene defines the hosting scene
  44930. * @returns a new line mesh
  44931. */
  44932. static CreateLines(name: string, options: {
  44933. points: Vector3[];
  44934. updatable?: boolean;
  44935. instance?: Nullable<LinesMesh>;
  44936. colors?: Color4[];
  44937. useVertexAlpha?: boolean;
  44938. }, scene?: Nullable<Scene>): LinesMesh;
  44939. /**
  44940. * Creates a dashed line mesh
  44941. * * 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
  44942. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44943. * * The parameter `points` is an array successive Vector3
  44944. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44945. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44946. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44947. * * 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
  44948. * * When updating an instance, remember that only point positions can change, not the number of points
  44949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44950. * @param name defines the name of the mesh
  44951. * @param options defines the options used to create the mesh
  44952. * @param scene defines the hosting scene
  44953. * @returns the dashed line mesh
  44954. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44955. */
  44956. static CreateDashedLines(name: string, options: {
  44957. points: Vector3[];
  44958. dashSize?: number;
  44959. gapSize?: number;
  44960. dashNb?: number;
  44961. updatable?: boolean;
  44962. instance?: LinesMesh;
  44963. }, scene?: Nullable<Scene>): LinesMesh;
  44964. }
  44965. }
  44966. declare module "babylonjs/Debug/rayHelper" {
  44967. import { Nullable } from "babylonjs/types";
  44968. import { Ray } from "babylonjs/Culling/ray";
  44969. import { Vector3 } from "babylonjs/Maths/math.vector";
  44970. import { Color3 } from "babylonjs/Maths/math.color";
  44971. import { Scene } from "babylonjs/scene";
  44972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44973. import "babylonjs/Meshes/Builders/linesBuilder";
  44974. /**
  44975. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44976. * in order to better appreciate the issue one might have.
  44977. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44978. */
  44979. export class RayHelper {
  44980. /**
  44981. * Defines the ray we are currently tryin to visualize.
  44982. */
  44983. ray: Nullable<Ray>;
  44984. private _renderPoints;
  44985. private _renderLine;
  44986. private _renderFunction;
  44987. private _scene;
  44988. private _updateToMeshFunction;
  44989. private _attachedToMesh;
  44990. private _meshSpaceDirection;
  44991. private _meshSpaceOrigin;
  44992. /**
  44993. * Helper function to create a colored helper in a scene in one line.
  44994. * @param ray Defines the ray we are currently tryin to visualize
  44995. * @param scene Defines the scene the ray is used in
  44996. * @param color Defines the color we want to see the ray in
  44997. * @returns The newly created ray helper.
  44998. */
  44999. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45000. /**
  45001. * Instantiate a new ray helper.
  45002. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45003. * in order to better appreciate the issue one might have.
  45004. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45005. * @param ray Defines the ray we are currently tryin to visualize
  45006. */
  45007. constructor(ray: Ray);
  45008. /**
  45009. * Shows the ray we are willing to debug.
  45010. * @param scene Defines the scene the ray needs to be rendered in
  45011. * @param color Defines the color the ray needs to be rendered in
  45012. */
  45013. show(scene: Scene, color?: Color3): void;
  45014. /**
  45015. * Hides the ray we are debugging.
  45016. */
  45017. hide(): void;
  45018. private _render;
  45019. /**
  45020. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45021. * @param mesh Defines the mesh we want the helper attached to
  45022. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45023. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45024. * @param length Defines the length of the ray
  45025. */
  45026. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45027. /**
  45028. * Detach the ray helper from the mesh it has previously been attached to.
  45029. */
  45030. detachFromMesh(): void;
  45031. private _updateToMesh;
  45032. /**
  45033. * Dispose the helper and release its associated resources.
  45034. */
  45035. dispose(): void;
  45036. }
  45037. }
  45038. declare module "babylonjs/Debug/skeletonViewer" {
  45039. import { Color3 } from "babylonjs/Maths/math.color";
  45040. import { Scene } from "babylonjs/scene";
  45041. import { Nullable } from "babylonjs/types";
  45042. import { Skeleton } from "babylonjs/Bones/skeleton";
  45043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45044. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45045. /**
  45046. * Class used to render a debug view of a given skeleton
  45047. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45048. */
  45049. export class SkeletonViewer {
  45050. /** defines the skeleton to render */
  45051. skeleton: Skeleton;
  45052. /** defines the mesh attached to the skeleton */
  45053. mesh: AbstractMesh;
  45054. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45055. autoUpdateBonesMatrices: boolean;
  45056. /** defines the rendering group id to use with the viewer */
  45057. renderingGroupId: number;
  45058. /** Gets or sets the color used to render the skeleton */
  45059. color: Color3;
  45060. private _scene;
  45061. private _debugLines;
  45062. private _debugMesh;
  45063. private _isEnabled;
  45064. private _renderFunction;
  45065. private _utilityLayer;
  45066. /**
  45067. * Returns the mesh used to render the bones
  45068. */
  45069. readonly debugMesh: Nullable<LinesMesh>;
  45070. /**
  45071. * Creates a new SkeletonViewer
  45072. * @param skeleton defines the skeleton to render
  45073. * @param mesh defines the mesh attached to the skeleton
  45074. * @param scene defines the hosting scene
  45075. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45076. * @param renderingGroupId defines the rendering group id to use with the viewer
  45077. */
  45078. constructor(
  45079. /** defines the skeleton to render */
  45080. skeleton: Skeleton,
  45081. /** defines the mesh attached to the skeleton */
  45082. mesh: AbstractMesh, scene: Scene,
  45083. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45084. autoUpdateBonesMatrices?: boolean,
  45085. /** defines the rendering group id to use with the viewer */
  45086. renderingGroupId?: number);
  45087. /** Gets or sets a boolean indicating if the viewer is enabled */
  45088. isEnabled: boolean;
  45089. private _getBonePosition;
  45090. private _getLinesForBonesWithLength;
  45091. private _getLinesForBonesNoLength;
  45092. /** Update the viewer to sync with current skeleton state */
  45093. update(): void;
  45094. /** Release associated resources */
  45095. dispose(): void;
  45096. }
  45097. }
  45098. declare module "babylonjs/Debug/index" {
  45099. export * from "babylonjs/Debug/axesViewer";
  45100. export * from "babylonjs/Debug/boneAxesViewer";
  45101. export * from "babylonjs/Debug/debugLayer";
  45102. export * from "babylonjs/Debug/physicsViewer";
  45103. export * from "babylonjs/Debug/rayHelper";
  45104. export * from "babylonjs/Debug/skeletonViewer";
  45105. }
  45106. declare module "babylonjs/Engines/nullEngine" {
  45107. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45108. import { Scene } from "babylonjs/scene";
  45109. import { Engine } from "babylonjs/Engines/engine";
  45110. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45111. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45112. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45113. import { Effect } from "babylonjs/Materials/effect";
  45114. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45115. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45116. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45117. /**
  45118. * Options to create the null engine
  45119. */
  45120. export class NullEngineOptions {
  45121. /**
  45122. * Render width (Default: 512)
  45123. */
  45124. renderWidth: number;
  45125. /**
  45126. * Render height (Default: 256)
  45127. */
  45128. renderHeight: number;
  45129. /**
  45130. * Texture size (Default: 512)
  45131. */
  45132. textureSize: number;
  45133. /**
  45134. * If delta time between frames should be constant
  45135. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45136. */
  45137. deterministicLockstep: boolean;
  45138. /**
  45139. * Maximum about of steps between frames (Default: 4)
  45140. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45141. */
  45142. lockstepMaxSteps: number;
  45143. }
  45144. /**
  45145. * The null engine class provides support for headless version of babylon.js.
  45146. * This can be used in server side scenario or for testing purposes
  45147. */
  45148. export class NullEngine extends Engine {
  45149. private _options;
  45150. /**
  45151. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45152. */
  45153. isDeterministicLockStep(): boolean;
  45154. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  45155. getLockstepMaxSteps(): number;
  45156. /**
  45157. * Sets hardware scaling, used to save performance if needed
  45158. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  45159. */
  45160. getHardwareScalingLevel(): number;
  45161. constructor(options?: NullEngineOptions);
  45162. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45163. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45164. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45165. getRenderWidth(useScreen?: boolean): number;
  45166. getRenderHeight(useScreen?: boolean): number;
  45167. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45168. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45169. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45170. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45171. bindSamplers(effect: Effect): void;
  45172. enableEffect(effect: Effect): void;
  45173. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45174. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45175. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45176. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45177. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45178. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45179. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45180. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45181. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45182. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45183. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45184. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45185. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45186. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45187. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45188. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45189. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45190. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45191. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45192. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45193. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45194. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45195. bindBuffers(vertexBuffers: {
  45196. [key: string]: VertexBuffer;
  45197. }, indexBuffer: DataBuffer, effect: Effect): void;
  45198. wipeCaches(bruteForce?: boolean): void;
  45199. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45200. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45201. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45202. /** @hidden */
  45203. _createTexture(): WebGLTexture;
  45204. /** @hidden */
  45205. _releaseTexture(texture: InternalTexture): void;
  45206. 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;
  45207. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45208. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45209. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45210. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45211. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45212. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45213. areAllEffectsReady(): boolean;
  45214. /**
  45215. * @hidden
  45216. * Get the current error code of the webGL context
  45217. * @returns the error code
  45218. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45219. */
  45220. getError(): number;
  45221. /** @hidden */
  45222. _getUnpackAlignement(): number;
  45223. /** @hidden */
  45224. _unpackFlipY(value: boolean): void;
  45225. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45226. /**
  45227. * Updates a dynamic vertex buffer.
  45228. * @param vertexBuffer the vertex buffer to update
  45229. * @param data the data used to update the vertex buffer
  45230. * @param byteOffset the byte offset of the data (optional)
  45231. * @param byteLength the byte length of the data (optional)
  45232. */
  45233. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45234. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45235. /** @hidden */
  45236. _bindTexture(channel: number, texture: InternalTexture): void;
  45237. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45238. releaseEffects(): void;
  45239. displayLoadingUI(): void;
  45240. hideLoadingUI(): void;
  45241. /** @hidden */
  45242. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45243. /** @hidden */
  45244. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45245. /** @hidden */
  45246. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45247. /** @hidden */
  45248. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45249. }
  45250. }
  45251. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45252. import { Nullable, int } from "babylonjs/types";
  45253. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45254. /** @hidden */
  45255. export class _OcclusionDataStorage {
  45256. /** @hidden */
  45257. occlusionInternalRetryCounter: number;
  45258. /** @hidden */
  45259. isOcclusionQueryInProgress: boolean;
  45260. /** @hidden */
  45261. isOccluded: boolean;
  45262. /** @hidden */
  45263. occlusionRetryCount: number;
  45264. /** @hidden */
  45265. occlusionType: number;
  45266. /** @hidden */
  45267. occlusionQueryAlgorithmType: number;
  45268. }
  45269. module "babylonjs/Engines/engine" {
  45270. interface Engine {
  45271. /**
  45272. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45273. * @return the new query
  45274. */
  45275. createQuery(): WebGLQuery;
  45276. /**
  45277. * Delete and release a webGL query
  45278. * @param query defines the query to delete
  45279. * @return the current engine
  45280. */
  45281. deleteQuery(query: WebGLQuery): Engine;
  45282. /**
  45283. * Check if a given query has resolved and got its value
  45284. * @param query defines the query to check
  45285. * @returns true if the query got its value
  45286. */
  45287. isQueryResultAvailable(query: WebGLQuery): boolean;
  45288. /**
  45289. * Gets the value of a given query
  45290. * @param query defines the query to check
  45291. * @returns the value of the query
  45292. */
  45293. getQueryResult(query: WebGLQuery): number;
  45294. /**
  45295. * Initiates an occlusion query
  45296. * @param algorithmType defines the algorithm to use
  45297. * @param query defines the query to use
  45298. * @returns the current engine
  45299. * @see http://doc.babylonjs.com/features/occlusionquery
  45300. */
  45301. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45302. /**
  45303. * Ends an occlusion query
  45304. * @see http://doc.babylonjs.com/features/occlusionquery
  45305. * @param algorithmType defines the algorithm to use
  45306. * @returns the current engine
  45307. */
  45308. endOcclusionQuery(algorithmType: number): Engine;
  45309. /**
  45310. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45311. * Please note that only one query can be issued at a time
  45312. * @returns a time token used to track the time span
  45313. */
  45314. startTimeQuery(): Nullable<_TimeToken>;
  45315. /**
  45316. * Ends a time query
  45317. * @param token defines the token used to measure the time span
  45318. * @returns the time spent (in ns)
  45319. */
  45320. endTimeQuery(token: _TimeToken): int;
  45321. /** @hidden */
  45322. _currentNonTimestampToken: Nullable<_TimeToken>;
  45323. /** @hidden */
  45324. _createTimeQuery(): WebGLQuery;
  45325. /** @hidden */
  45326. _deleteTimeQuery(query: WebGLQuery): void;
  45327. /** @hidden */
  45328. _getGlAlgorithmType(algorithmType: number): number;
  45329. /** @hidden */
  45330. _getTimeQueryResult(query: WebGLQuery): any;
  45331. /** @hidden */
  45332. _getTimeQueryAvailability(query: WebGLQuery): any;
  45333. }
  45334. }
  45335. module "babylonjs/Meshes/abstractMesh" {
  45336. interface AbstractMesh {
  45337. /**
  45338. * Backing filed
  45339. * @hidden
  45340. */
  45341. __occlusionDataStorage: _OcclusionDataStorage;
  45342. /**
  45343. * Access property
  45344. * @hidden
  45345. */
  45346. _occlusionDataStorage: _OcclusionDataStorage;
  45347. /**
  45348. * 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.
  45349. * The default value is -1 which means don't break the query and wait till the result
  45350. * @see http://doc.babylonjs.com/features/occlusionquery
  45351. */
  45352. occlusionRetryCount: number;
  45353. /**
  45354. * 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:
  45355. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45356. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45357. * * 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.
  45358. * @see http://doc.babylonjs.com/features/occlusionquery
  45359. */
  45360. occlusionType: number;
  45361. /**
  45362. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45363. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45364. * * 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.
  45365. * @see http://doc.babylonjs.com/features/occlusionquery
  45366. */
  45367. occlusionQueryAlgorithmType: number;
  45368. /**
  45369. * 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
  45370. * @see http://doc.babylonjs.com/features/occlusionquery
  45371. */
  45372. isOccluded: boolean;
  45373. /**
  45374. * Flag to check the progress status of the query
  45375. * @see http://doc.babylonjs.com/features/occlusionquery
  45376. */
  45377. isOcclusionQueryInProgress: boolean;
  45378. }
  45379. }
  45380. }
  45381. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45382. import { Nullable } from "babylonjs/types";
  45383. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45384. /** @hidden */
  45385. export var _forceTransformFeedbackToBundle: boolean;
  45386. module "babylonjs/Engines/engine" {
  45387. interface Engine {
  45388. /**
  45389. * Creates a webGL transform feedback object
  45390. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45391. * @returns the webGL transform feedback object
  45392. */
  45393. createTransformFeedback(): WebGLTransformFeedback;
  45394. /**
  45395. * Delete a webGL transform feedback object
  45396. * @param value defines the webGL transform feedback object to delete
  45397. */
  45398. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45399. /**
  45400. * Bind a webGL transform feedback object to the webgl context
  45401. * @param value defines the webGL transform feedback object to bind
  45402. */
  45403. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45404. /**
  45405. * Begins a transform feedback operation
  45406. * @param usePoints defines if points or triangles must be used
  45407. */
  45408. beginTransformFeedback(usePoints: boolean): void;
  45409. /**
  45410. * Ends a transform feedback operation
  45411. */
  45412. endTransformFeedback(): void;
  45413. /**
  45414. * Specify the varyings to use with transform feedback
  45415. * @param program defines the associated webGL program
  45416. * @param value defines the list of strings representing the varying names
  45417. */
  45418. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45419. /**
  45420. * Bind a webGL buffer for a transform feedback operation
  45421. * @param value defines the webGL buffer to bind
  45422. */
  45423. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45424. }
  45425. }
  45426. }
  45427. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45428. import { Scene } from "babylonjs/scene";
  45429. import { Engine } from "babylonjs/Engines/engine";
  45430. import { Texture } from "babylonjs/Materials/Textures/texture";
  45431. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45432. import "babylonjs/Engines/Extensions/engine.multiRender";
  45433. /**
  45434. * Creation options of the multi render target texture.
  45435. */
  45436. export interface IMultiRenderTargetOptions {
  45437. /**
  45438. * Define if the texture needs to create mip maps after render.
  45439. */
  45440. generateMipMaps?: boolean;
  45441. /**
  45442. * Define the types of all the draw buffers we want to create
  45443. */
  45444. types?: number[];
  45445. /**
  45446. * Define the sampling modes of all the draw buffers we want to create
  45447. */
  45448. samplingModes?: number[];
  45449. /**
  45450. * Define if a depth buffer is required
  45451. */
  45452. generateDepthBuffer?: boolean;
  45453. /**
  45454. * Define if a stencil buffer is required
  45455. */
  45456. generateStencilBuffer?: boolean;
  45457. /**
  45458. * Define if a depth texture is required instead of a depth buffer
  45459. */
  45460. generateDepthTexture?: boolean;
  45461. /**
  45462. * Define the number of desired draw buffers
  45463. */
  45464. textureCount?: number;
  45465. /**
  45466. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45467. */
  45468. doNotChangeAspectRatio?: boolean;
  45469. /**
  45470. * Define the default type of the buffers we are creating
  45471. */
  45472. defaultType?: number;
  45473. }
  45474. /**
  45475. * A multi render target, like a render target provides the ability to render to a texture.
  45476. * Unlike the render target, it can render to several draw buffers in one draw.
  45477. * This is specially interesting in deferred rendering or for any effects requiring more than
  45478. * just one color from a single pass.
  45479. */
  45480. export class MultiRenderTarget extends RenderTargetTexture {
  45481. private _internalTextures;
  45482. private _textures;
  45483. private _multiRenderTargetOptions;
  45484. /**
  45485. * Get if draw buffers are currently supported by the used hardware and browser.
  45486. */
  45487. readonly isSupported: boolean;
  45488. /**
  45489. * Get the list of textures generated by the multi render target.
  45490. */
  45491. readonly textures: Texture[];
  45492. /**
  45493. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45494. */
  45495. readonly depthTexture: Texture;
  45496. /**
  45497. * Set the wrapping mode on U of all the textures we are rendering to.
  45498. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45499. */
  45500. wrapU: number;
  45501. /**
  45502. * Set the wrapping mode on V of all the textures we are rendering to.
  45503. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45504. */
  45505. wrapV: number;
  45506. /**
  45507. * Instantiate a new multi render target texture.
  45508. * A multi render target, like a render target provides the ability to render to a texture.
  45509. * Unlike the render target, it can render to several draw buffers in one draw.
  45510. * This is specially interesting in deferred rendering or for any effects requiring more than
  45511. * just one color from a single pass.
  45512. * @param name Define the name of the texture
  45513. * @param size Define the size of the buffers to render to
  45514. * @param count Define the number of target we are rendering into
  45515. * @param scene Define the scene the texture belongs to
  45516. * @param options Define the options used to create the multi render target
  45517. */
  45518. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45519. /** @hidden */
  45520. _rebuild(): void;
  45521. private _createInternalTextures;
  45522. private _createTextures;
  45523. /**
  45524. * Define the number of samples used if MSAA is enabled.
  45525. */
  45526. samples: number;
  45527. /**
  45528. * Resize all the textures in the multi render target.
  45529. * Be carrefull as it will recreate all the data in the new texture.
  45530. * @param size Define the new size
  45531. */
  45532. resize(size: any): void;
  45533. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45534. /**
  45535. * Dispose the render targets and their associated resources
  45536. */
  45537. dispose(): void;
  45538. /**
  45539. * Release all the underlying texture used as draw buffers.
  45540. */
  45541. releaseInternalTextures(): void;
  45542. }
  45543. }
  45544. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45545. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45546. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45547. import { Nullable } from "babylonjs/types";
  45548. module "babylonjs/Engines/engine" {
  45549. interface Engine {
  45550. /**
  45551. * Unbind a list of render target textures from the webGL context
  45552. * This is used only when drawBuffer extension or webGL2 are active
  45553. * @param textures defines the render target textures to unbind
  45554. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45555. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45556. */
  45557. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45558. /**
  45559. * Create a multi render target texture
  45560. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45561. * @param size defines the size of the texture
  45562. * @param options defines the creation options
  45563. * @returns the cube texture as an InternalTexture
  45564. */
  45565. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45566. /**
  45567. * Update the sample count for a given multiple render target texture
  45568. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45569. * @param textures defines the textures to update
  45570. * @param samples defines the sample count to set
  45571. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45572. */
  45573. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45574. }
  45575. }
  45576. }
  45577. declare module "babylonjs/Engines/Extensions/index" {
  45578. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45579. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45580. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45581. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45582. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45583. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45584. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45585. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45586. }
  45587. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  45588. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45589. /** @hidden */
  45590. export var rgbdEncodePixelShader: {
  45591. name: string;
  45592. shader: string;
  45593. };
  45594. }
  45595. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45596. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45597. /** @hidden */
  45598. export var rgbdDecodePixelShader: {
  45599. name: string;
  45600. shader: string;
  45601. };
  45602. }
  45603. declare module "babylonjs/Misc/environmentTextureTools" {
  45604. import { Nullable } from "babylonjs/types";
  45605. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  45606. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45607. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  45608. import "babylonjs/Engines/Extensions/engine.renderTarget";
  45609. import "babylonjs/Shaders/rgbdEncode.fragment";
  45610. import "babylonjs/Shaders/rgbdDecode.fragment";
  45611. /**
  45612. * Raw texture data and descriptor sufficient for WebGL texture upload
  45613. */
  45614. export interface EnvironmentTextureInfo {
  45615. /**
  45616. * Version of the environment map
  45617. */
  45618. version: number;
  45619. /**
  45620. * Width of image
  45621. */
  45622. width: number;
  45623. /**
  45624. * Irradiance information stored in the file.
  45625. */
  45626. irradiance: any;
  45627. /**
  45628. * Specular information stored in the file.
  45629. */
  45630. specular: any;
  45631. }
  45632. /**
  45633. * Defines One Image in the file. It requires only the position in the file
  45634. * as well as the length.
  45635. */
  45636. interface BufferImageData {
  45637. /**
  45638. * Length of the image data.
  45639. */
  45640. length: number;
  45641. /**
  45642. * Position of the data from the null terminator delimiting the end of the JSON.
  45643. */
  45644. position: number;
  45645. }
  45646. /**
  45647. * Defines the specular data enclosed in the file.
  45648. * This corresponds to the version 1 of the data.
  45649. */
  45650. export interface EnvironmentTextureSpecularInfoV1 {
  45651. /**
  45652. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  45653. */
  45654. specularDataPosition?: number;
  45655. /**
  45656. * This contains all the images data needed to reconstruct the cubemap.
  45657. */
  45658. mipmaps: Array<BufferImageData>;
  45659. /**
  45660. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  45661. */
  45662. lodGenerationScale: number;
  45663. }
  45664. /**
  45665. * Sets of helpers addressing the serialization and deserialization of environment texture
  45666. * stored in a BabylonJS env file.
  45667. * Those files are usually stored as .env files.
  45668. */
  45669. export class EnvironmentTextureTools {
  45670. /**
  45671. * Magic number identifying the env file.
  45672. */
  45673. private static _MagicBytes;
  45674. /**
  45675. * Gets the environment info from an env file.
  45676. * @param data The array buffer containing the .env bytes.
  45677. * @returns the environment file info (the json header) if successfully parsed.
  45678. */
  45679. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45680. /**
  45681. * Creates an environment texture from a loaded cube texture.
  45682. * @param texture defines the cube texture to convert in env file
  45683. * @return a promise containing the environment data if succesfull.
  45684. */
  45685. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45686. /**
  45687. * Creates a JSON representation of the spherical data.
  45688. * @param texture defines the texture containing the polynomials
  45689. * @return the JSON representation of the spherical info
  45690. */
  45691. private static _CreateEnvTextureIrradiance;
  45692. /**
  45693. * Creates the ArrayBufferViews used for initializing environment texture image data.
  45694. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  45695. * @param info parameters that determine what views will be created for accessing the underlying buffer
  45696. * @return the views described by info providing access to the underlying buffer
  45697. */
  45698. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  45699. /**
  45700. * Uploads the texture info contained in the env file to the GPU.
  45701. * @param texture defines the internal texture to upload to
  45702. * @param arrayBuffer defines the buffer cotaining the data to load
  45703. * @param info defines the texture info retrieved through the GetEnvInfo method
  45704. * @returns a promise
  45705. */
  45706. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45707. /**
  45708. * Uploads the levels of image data to the GPU.
  45709. * @param texture defines the internal texture to upload to
  45710. * @param imageData defines the array buffer views of image data [mipmap][face]
  45711. * @returns a promise
  45712. */
  45713. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45714. /**
  45715. * Uploads spherical polynomials information to the texture.
  45716. * @param texture defines the texture we are trying to upload the information to
  45717. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45718. */
  45719. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45720. /** @hidden */
  45721. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45722. }
  45723. }
  45724. declare module "babylonjs/Maths/math.vertexFormat" {
  45725. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  45726. /**
  45727. * Contains position and normal vectors for a vertex
  45728. */
  45729. export class PositionNormalVertex {
  45730. /** the position of the vertex (defaut: 0,0,0) */
  45731. position: Vector3;
  45732. /** the normal of the vertex (defaut: 0,1,0) */
  45733. normal: Vector3;
  45734. /**
  45735. * Creates a PositionNormalVertex
  45736. * @param position the position of the vertex (defaut: 0,0,0)
  45737. * @param normal the normal of the vertex (defaut: 0,1,0)
  45738. */
  45739. constructor(
  45740. /** the position of the vertex (defaut: 0,0,0) */
  45741. position?: Vector3,
  45742. /** the normal of the vertex (defaut: 0,1,0) */
  45743. normal?: Vector3);
  45744. /**
  45745. * Clones the PositionNormalVertex
  45746. * @returns the cloned PositionNormalVertex
  45747. */
  45748. clone(): PositionNormalVertex;
  45749. }
  45750. /**
  45751. * Contains position, normal and uv vectors for a vertex
  45752. */
  45753. export class PositionNormalTextureVertex {
  45754. /** the position of the vertex (defaut: 0,0,0) */
  45755. position: Vector3;
  45756. /** the normal of the vertex (defaut: 0,1,0) */
  45757. normal: Vector3;
  45758. /** the uv of the vertex (default: 0,0) */
  45759. uv: Vector2;
  45760. /**
  45761. * Creates a PositionNormalTextureVertex
  45762. * @param position the position of the vertex (defaut: 0,0,0)
  45763. * @param normal the normal of the vertex (defaut: 0,1,0)
  45764. * @param uv the uv of the vertex (default: 0,0)
  45765. */
  45766. constructor(
  45767. /** the position of the vertex (defaut: 0,0,0) */
  45768. position?: Vector3,
  45769. /** the normal of the vertex (defaut: 0,1,0) */
  45770. normal?: Vector3,
  45771. /** the uv of the vertex (default: 0,0) */
  45772. uv?: Vector2);
  45773. /**
  45774. * Clones the PositionNormalTextureVertex
  45775. * @returns the cloned PositionNormalTextureVertex
  45776. */
  45777. clone(): PositionNormalTextureVertex;
  45778. }
  45779. }
  45780. declare module "babylonjs/Maths/math" {
  45781. export * from "babylonjs/Maths/math.axis";
  45782. export * from "babylonjs/Maths/math.color";
  45783. export * from "babylonjs/Maths/math.constants";
  45784. export * from "babylonjs/Maths/math.frustum";
  45785. export * from "babylonjs/Maths/math.path";
  45786. export * from "babylonjs/Maths/math.plane";
  45787. export * from "babylonjs/Maths/math.size";
  45788. export * from "babylonjs/Maths/math.vector";
  45789. export * from "babylonjs/Maths/math.vertexFormat";
  45790. export * from "babylonjs/Maths/math.viewport";
  45791. }
  45792. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  45793. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45794. /** @hidden */
  45795. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  45796. private _genericAttributeLocation;
  45797. private _varyingLocationCount;
  45798. private _varyingLocationMap;
  45799. private _replacements;
  45800. private _textureCount;
  45801. private _uniforms;
  45802. lineProcessor(line: string): string;
  45803. attributeProcessor(attribute: string): string;
  45804. varyingProcessor(varying: string, isFragment: boolean): string;
  45805. uniformProcessor(uniform: string): string;
  45806. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  45807. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  45808. }
  45809. }
  45810. declare module "babylonjs/Engines/nativeEngine" {
  45811. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  45812. import { Engine } from "babylonjs/Engines/engine";
  45813. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45814. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45815. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45816. import { Effect } from "babylonjs/Materials/effect";
  45817. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45818. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  45819. import { Scene } from "babylonjs/scene";
  45820. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45821. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45822. /**
  45823. * Container for accessors for natively-stored mesh data buffers.
  45824. */
  45825. class NativeDataBuffer extends DataBuffer {
  45826. /**
  45827. * Accessor value used to identify/retrieve a natively-stored index buffer.
  45828. */
  45829. nativeIndexBuffer?: any;
  45830. /**
  45831. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  45832. */
  45833. nativeVertexBuffer?: any;
  45834. }
  45835. /** @hidden */
  45836. export class NativeEngine extends Engine {
  45837. private readonly _native;
  45838. getHardwareScalingLevel(): number;
  45839. constructor();
  45840. /**
  45841. * Can be used to override the current requestAnimationFrame requester.
  45842. * @hidden
  45843. */
  45844. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  45845. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45846. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45847. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45848. recordVertexArrayObject(vertexBuffers: {
  45849. [key: string]: VertexBuffer;
  45850. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45851. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45852. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45853. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45854. /**
  45855. * Draw a list of indexed primitives
  45856. * @param fillMode defines the primitive to use
  45857. * @param indexStart defines the starting index
  45858. * @param indexCount defines the number of index to draw
  45859. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45860. */
  45861. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45862. /**
  45863. * Draw a list of unindexed primitives
  45864. * @param fillMode defines the primitive to use
  45865. * @param verticesStart defines the index of first vertex to draw
  45866. * @param verticesCount defines the count of vertices to draw
  45867. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45868. */
  45869. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45870. createPipelineContext(): IPipelineContext;
  45871. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45872. /** @hidden */
  45873. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45874. /** @hidden */
  45875. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45876. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45877. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45878. protected _setProgram(program: WebGLProgram): void;
  45879. _releaseEffect(effect: Effect): void;
  45880. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45881. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  45882. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45883. bindSamplers(effect: Effect): void;
  45884. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  45885. getRenderWidth(useScreen?: boolean): number;
  45886. getRenderHeight(useScreen?: boolean): number;
  45887. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  45888. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45889. /**
  45890. * Set the z offset to apply to current rendering
  45891. * @param value defines the offset to apply
  45892. */
  45893. setZOffset(value: number): void;
  45894. /**
  45895. * Gets the current value of the zOffset
  45896. * @returns the current zOffset state
  45897. */
  45898. getZOffset(): number;
  45899. /**
  45900. * Enable or disable depth buffering
  45901. * @param enable defines the state to set
  45902. */
  45903. setDepthBuffer(enable: boolean): void;
  45904. /**
  45905. * Gets a boolean indicating if depth writing is enabled
  45906. * @returns the current depth writing state
  45907. */
  45908. getDepthWrite(): boolean;
  45909. /**
  45910. * Enable or disable depth writing
  45911. * @param enable defines the state to set
  45912. */
  45913. setDepthWrite(enable: boolean): void;
  45914. /**
  45915. * Enable or disable color writing
  45916. * @param enable defines the state to set
  45917. */
  45918. setColorWrite(enable: boolean): void;
  45919. /**
  45920. * Gets a boolean indicating if color writing is enabled
  45921. * @returns the current color writing state
  45922. */
  45923. getColorWrite(): boolean;
  45924. /**
  45925. * Sets alpha constants used by some alpha blending modes
  45926. * @param r defines the red component
  45927. * @param g defines the green component
  45928. * @param b defines the blue component
  45929. * @param a defines the alpha component
  45930. */
  45931. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45932. /**
  45933. * Sets the current alpha mode
  45934. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  45935. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45936. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45937. */
  45938. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45939. /**
  45940. * Gets the current alpha mode
  45941. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45942. * @returns the current alpha mode
  45943. */
  45944. getAlphaMode(): number;
  45945. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45946. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45947. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45948. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45949. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45950. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45951. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45952. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45953. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45954. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45955. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45956. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45957. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45958. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45959. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45960. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45961. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45962. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45963. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45964. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45965. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45966. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45967. wipeCaches(bruteForce?: boolean): void;
  45968. _createTexture(): WebGLTexture;
  45969. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45970. /**
  45971. * Usually called from BABYLON.Texture.ts.
  45972. * Passed information to create a WebGLTexture
  45973. * @param urlArg defines a value which contains one of the following:
  45974. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45975. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45976. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45977. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45978. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  45979. * @param scene needed for loading to the correct scene
  45980. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45981. * @param onLoad optional callback to be called upon successful completion
  45982. * @param onError optional callback to be called upon failure
  45983. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  45984. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45985. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45986. * @param forcedExtension defines the extension to use to pick the right loader
  45987. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45988. */
  45989. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  45990. /**
  45991. * Creates a cube texture
  45992. * @param rootUrl defines the url where the files to load is located
  45993. * @param scene defines the current scene
  45994. * @param files defines the list of files to load (1 per face)
  45995. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45996. * @param onLoad defines an optional callback raised when the texture is loaded
  45997. * @param onError defines an optional callback raised if there is an issue to load the texture
  45998. * @param format defines the format of the data
  45999. * @param forcedExtension defines the extension to use to pick the right loader
  46000. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46001. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46002. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46003. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46004. * @returns the cube texture as an InternalTexture
  46005. */
  46006. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  46007. private _getSamplingFilter;
  46008. private static _GetNativeTextureFormat;
  46009. createRenderTargetTexture(size: number | {
  46010. width: number;
  46011. height: number;
  46012. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46013. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46014. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46015. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46016. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46017. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46018. /**
  46019. * Updates a dynamic vertex buffer.
  46020. * @param vertexBuffer the vertex buffer to update
  46021. * @param data the data used to update the vertex buffer
  46022. * @param byteOffset the byte offset of the data (optional)
  46023. * @param byteLength the byte length of the data (optional)
  46024. */
  46025. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46026. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46027. private _updateAnisotropicLevel;
  46028. private _getAddressMode;
  46029. /** @hidden */
  46030. _bindTexture(channel: number, texture: InternalTexture): void;
  46031. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46032. releaseEffects(): void;
  46033. /** @hidden */
  46034. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46035. /** @hidden */
  46036. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46037. /** @hidden */
  46038. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46039. /** @hidden */
  46040. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46041. }
  46042. }
  46043. declare module "babylonjs/Engines/index" {
  46044. export * from "babylonjs/Engines/constants";
  46045. export * from "babylonjs/Engines/engine";
  46046. export * from "babylonjs/Engines/engineStore";
  46047. export * from "babylonjs/Engines/nullEngine";
  46048. export * from "babylonjs/Engines/Extensions/index";
  46049. export * from "babylonjs/Engines/IPipelineContext";
  46050. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46051. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46052. export * from "babylonjs/Engines/nativeEngine";
  46053. }
  46054. declare module "babylonjs/Events/clipboardEvents" {
  46055. /**
  46056. * Gather the list of clipboard event types as constants.
  46057. */
  46058. export class ClipboardEventTypes {
  46059. /**
  46060. * The clipboard event is fired when a copy command is active (pressed).
  46061. */
  46062. static readonly COPY: number;
  46063. /**
  46064. * The clipboard event is fired when a cut command is active (pressed).
  46065. */
  46066. static readonly CUT: number;
  46067. /**
  46068. * The clipboard event is fired when a paste command is active (pressed).
  46069. */
  46070. static readonly PASTE: number;
  46071. }
  46072. /**
  46073. * This class is used to store clipboard related info for the onClipboardObservable event.
  46074. */
  46075. export class ClipboardInfo {
  46076. /**
  46077. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46078. */
  46079. type: number;
  46080. /**
  46081. * Defines the related dom event
  46082. */
  46083. event: ClipboardEvent;
  46084. /**
  46085. *Creates an instance of ClipboardInfo.
  46086. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46087. * @param event Defines the related dom event
  46088. */
  46089. constructor(
  46090. /**
  46091. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46092. */
  46093. type: number,
  46094. /**
  46095. * Defines the related dom event
  46096. */
  46097. event: ClipboardEvent);
  46098. /**
  46099. * Get the clipboard event's type from the keycode.
  46100. * @param keyCode Defines the keyCode for the current keyboard event.
  46101. * @return {number}
  46102. */
  46103. static GetTypeFromCharacter(keyCode: number): number;
  46104. }
  46105. }
  46106. declare module "babylonjs/Events/index" {
  46107. export * from "babylonjs/Events/keyboardEvents";
  46108. export * from "babylonjs/Events/pointerEvents";
  46109. export * from "babylonjs/Events/clipboardEvents";
  46110. }
  46111. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46112. import { Scene } from "babylonjs/scene";
  46113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46114. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46115. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46116. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46117. /**
  46118. * Google Daydream controller
  46119. */
  46120. export class DaydreamController extends WebVRController {
  46121. /**
  46122. * Base Url for the controller model.
  46123. */
  46124. static MODEL_BASE_URL: string;
  46125. /**
  46126. * File name for the controller model.
  46127. */
  46128. static MODEL_FILENAME: string;
  46129. /**
  46130. * Gamepad Id prefix used to identify Daydream Controller.
  46131. */
  46132. static readonly GAMEPAD_ID_PREFIX: string;
  46133. /**
  46134. * Creates a new DaydreamController from a gamepad
  46135. * @param vrGamepad the gamepad that the controller should be created from
  46136. */
  46137. constructor(vrGamepad: any);
  46138. /**
  46139. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46140. * @param scene scene in which to add meshes
  46141. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46142. */
  46143. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46144. /**
  46145. * Called once for each button that changed state since the last frame
  46146. * @param buttonIdx Which button index changed
  46147. * @param state New state of the button
  46148. * @param changes Which properties on the state changed since last frame
  46149. */
  46150. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46151. }
  46152. }
  46153. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46154. import { Scene } from "babylonjs/scene";
  46155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46156. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46157. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46158. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46159. /**
  46160. * Gear VR Controller
  46161. */
  46162. export class GearVRController extends WebVRController {
  46163. /**
  46164. * Base Url for the controller model.
  46165. */
  46166. static MODEL_BASE_URL: string;
  46167. /**
  46168. * File name for the controller model.
  46169. */
  46170. static MODEL_FILENAME: string;
  46171. /**
  46172. * Gamepad Id prefix used to identify this controller.
  46173. */
  46174. static readonly GAMEPAD_ID_PREFIX: string;
  46175. private readonly _buttonIndexToObservableNameMap;
  46176. /**
  46177. * Creates a new GearVRController from a gamepad
  46178. * @param vrGamepad the gamepad that the controller should be created from
  46179. */
  46180. constructor(vrGamepad: any);
  46181. /**
  46182. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46183. * @param scene scene in which to add meshes
  46184. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46185. */
  46186. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46187. /**
  46188. * Called once for each button that changed state since the last frame
  46189. * @param buttonIdx Which button index changed
  46190. * @param state New state of the button
  46191. * @param changes Which properties on the state changed since last frame
  46192. */
  46193. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46194. }
  46195. }
  46196. declare module "babylonjs/Gamepads/Controllers/index" {
  46197. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46198. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46199. export * from "babylonjs/Gamepads/Controllers/genericController";
  46200. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46201. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46202. export * from "babylonjs/Gamepads/Controllers/viveController";
  46203. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46204. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46205. }
  46206. declare module "babylonjs/Gamepads/index" {
  46207. export * from "babylonjs/Gamepads/Controllers/index";
  46208. export * from "babylonjs/Gamepads/gamepad";
  46209. export * from "babylonjs/Gamepads/gamepadManager";
  46210. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46211. export * from "babylonjs/Gamepads/xboxGamepad";
  46212. export * from "babylonjs/Gamepads/dualShockGamepad";
  46213. }
  46214. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46215. import { Scene } from "babylonjs/scene";
  46216. import { Vector4 } from "babylonjs/Maths/math.vector";
  46217. import { Color4 } from "babylonjs/Maths/math.color";
  46218. import { Mesh } from "babylonjs/Meshes/mesh";
  46219. import { Nullable } from "babylonjs/types";
  46220. /**
  46221. * Class containing static functions to help procedurally build meshes
  46222. */
  46223. export class PolyhedronBuilder {
  46224. /**
  46225. * Creates a polyhedron mesh
  46226. * * 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
  46227. * * The parameter `size` (positive float, default 1) sets the polygon size
  46228. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46229. * * 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`
  46230. * * 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
  46231. * * 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)`)
  46232. * * 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
  46233. * * 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
  46234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46235. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46237. * @param name defines the name of the mesh
  46238. * @param options defines the options used to create the mesh
  46239. * @param scene defines the hosting scene
  46240. * @returns the polyhedron mesh
  46241. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46242. */
  46243. static CreatePolyhedron(name: string, options: {
  46244. type?: number;
  46245. size?: number;
  46246. sizeX?: number;
  46247. sizeY?: number;
  46248. sizeZ?: number;
  46249. custom?: any;
  46250. faceUV?: Vector4[];
  46251. faceColors?: Color4[];
  46252. flat?: boolean;
  46253. updatable?: boolean;
  46254. sideOrientation?: number;
  46255. frontUVs?: Vector4;
  46256. backUVs?: Vector4;
  46257. }, scene?: Nullable<Scene>): Mesh;
  46258. }
  46259. }
  46260. declare module "babylonjs/Gizmos/scaleGizmo" {
  46261. import { Observable } from "babylonjs/Misc/observable";
  46262. import { Nullable } from "babylonjs/types";
  46263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46264. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46265. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46266. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46267. /**
  46268. * Gizmo that enables scaling a mesh along 3 axis
  46269. */
  46270. export class ScaleGizmo extends Gizmo {
  46271. /**
  46272. * Internal gizmo used for interactions on the x axis
  46273. */
  46274. xGizmo: AxisScaleGizmo;
  46275. /**
  46276. * Internal gizmo used for interactions on the y axis
  46277. */
  46278. yGizmo: AxisScaleGizmo;
  46279. /**
  46280. * Internal gizmo used for interactions on the z axis
  46281. */
  46282. zGizmo: AxisScaleGizmo;
  46283. /**
  46284. * Internal gizmo used to scale all axis equally
  46285. */
  46286. uniformScaleGizmo: AxisScaleGizmo;
  46287. private _meshAttached;
  46288. private _updateGizmoRotationToMatchAttachedMesh;
  46289. private _snapDistance;
  46290. private _scaleRatio;
  46291. private _uniformScalingMesh;
  46292. private _octahedron;
  46293. /** Fires an event when any of it's sub gizmos are dragged */
  46294. onDragStartObservable: Observable<unknown>;
  46295. /** Fires an event when any of it's sub gizmos are released from dragging */
  46296. onDragEndObservable: Observable<unknown>;
  46297. attachedMesh: Nullable<AbstractMesh>;
  46298. /**
  46299. * Creates a ScaleGizmo
  46300. * @param gizmoLayer The utility layer the gizmo will be added to
  46301. */
  46302. constructor(gizmoLayer?: UtilityLayerRenderer);
  46303. updateGizmoRotationToMatchAttachedMesh: boolean;
  46304. /**
  46305. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46306. */
  46307. snapDistance: number;
  46308. /**
  46309. * Ratio for the scale of the gizmo (Default: 1)
  46310. */
  46311. scaleRatio: number;
  46312. /**
  46313. * Disposes of the gizmo
  46314. */
  46315. dispose(): void;
  46316. }
  46317. }
  46318. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46319. import { Observable } from "babylonjs/Misc/observable";
  46320. import { Nullable } from "babylonjs/types";
  46321. import { Vector3 } from "babylonjs/Maths/math.vector";
  46322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46323. import { Mesh } from "babylonjs/Meshes/mesh";
  46324. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46325. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46326. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46327. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46328. import { Color3 } from "babylonjs/Maths/math.color";
  46329. /**
  46330. * Single axis scale gizmo
  46331. */
  46332. export class AxisScaleGizmo extends Gizmo {
  46333. /**
  46334. * Drag behavior responsible for the gizmos dragging interactions
  46335. */
  46336. dragBehavior: PointerDragBehavior;
  46337. private _pointerObserver;
  46338. /**
  46339. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46340. */
  46341. snapDistance: number;
  46342. /**
  46343. * Event that fires each time the gizmo snaps to a new location.
  46344. * * snapDistance is the the change in distance
  46345. */
  46346. onSnapObservable: Observable<{
  46347. snapDistance: number;
  46348. }>;
  46349. /**
  46350. * If the scaling operation should be done on all axis (default: false)
  46351. */
  46352. uniformScaling: boolean;
  46353. private _isEnabled;
  46354. private _parent;
  46355. private _arrow;
  46356. private _coloredMaterial;
  46357. private _hoverMaterial;
  46358. /**
  46359. * Creates an AxisScaleGizmo
  46360. * @param gizmoLayer The utility layer the gizmo will be added to
  46361. * @param dragAxis The axis which the gizmo will be able to scale on
  46362. * @param color The color of the gizmo
  46363. */
  46364. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46365. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46366. /**
  46367. * If the gizmo is enabled
  46368. */
  46369. isEnabled: boolean;
  46370. /**
  46371. * Disposes of the gizmo
  46372. */
  46373. dispose(): void;
  46374. /**
  46375. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46376. * @param mesh The mesh to replace the default mesh of the gizmo
  46377. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46378. */
  46379. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46380. }
  46381. }
  46382. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46383. import { Observable } from "babylonjs/Misc/observable";
  46384. import { Nullable } from "babylonjs/types";
  46385. import { Vector3 } from "babylonjs/Maths/math.vector";
  46386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46387. import { Mesh } from "babylonjs/Meshes/mesh";
  46388. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46389. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46390. import { Color3 } from "babylonjs/Maths/math.color";
  46391. import "babylonjs/Meshes/Builders/boxBuilder";
  46392. /**
  46393. * Bounding box gizmo
  46394. */
  46395. export class BoundingBoxGizmo extends Gizmo {
  46396. private _lineBoundingBox;
  46397. private _rotateSpheresParent;
  46398. private _scaleBoxesParent;
  46399. private _boundingDimensions;
  46400. private _renderObserver;
  46401. private _pointerObserver;
  46402. private _scaleDragSpeed;
  46403. private _tmpQuaternion;
  46404. private _tmpVector;
  46405. private _tmpRotationMatrix;
  46406. /**
  46407. * 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)
  46408. */
  46409. ignoreChildren: boolean;
  46410. /**
  46411. * 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)
  46412. */
  46413. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46414. /**
  46415. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46416. */
  46417. rotationSphereSize: number;
  46418. /**
  46419. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46420. */
  46421. scaleBoxSize: number;
  46422. /**
  46423. * 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)
  46424. */
  46425. fixedDragMeshScreenSize: boolean;
  46426. /**
  46427. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46428. */
  46429. fixedDragMeshScreenSizeDistanceFactor: number;
  46430. /**
  46431. * Fired when a rotation sphere or scale box is dragged
  46432. */
  46433. onDragStartObservable: Observable<{}>;
  46434. /**
  46435. * Fired when a scale box is dragged
  46436. */
  46437. onScaleBoxDragObservable: Observable<{}>;
  46438. /**
  46439. * Fired when a scale box drag is ended
  46440. */
  46441. onScaleBoxDragEndObservable: Observable<{}>;
  46442. /**
  46443. * Fired when a rotation sphere is dragged
  46444. */
  46445. onRotationSphereDragObservable: Observable<{}>;
  46446. /**
  46447. * Fired when a rotation sphere drag is ended
  46448. */
  46449. onRotationSphereDragEndObservable: Observable<{}>;
  46450. /**
  46451. * 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)
  46452. */
  46453. scalePivot: Nullable<Vector3>;
  46454. /**
  46455. * Mesh used as a pivot to rotate the attached mesh
  46456. */
  46457. private _anchorMesh;
  46458. private _existingMeshScale;
  46459. private _dragMesh;
  46460. private pointerDragBehavior;
  46461. private coloredMaterial;
  46462. private hoverColoredMaterial;
  46463. /**
  46464. * Sets the color of the bounding box gizmo
  46465. * @param color the color to set
  46466. */
  46467. setColor(color: Color3): void;
  46468. /**
  46469. * Creates an BoundingBoxGizmo
  46470. * @param gizmoLayer The utility layer the gizmo will be added to
  46471. * @param color The color of the gizmo
  46472. */
  46473. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46474. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46475. private _selectNode;
  46476. /**
  46477. * Updates the bounding box information for the Gizmo
  46478. */
  46479. updateBoundingBox(): void;
  46480. private _updateRotationSpheres;
  46481. private _updateScaleBoxes;
  46482. /**
  46483. * Enables rotation on the specified axis and disables rotation on the others
  46484. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46485. */
  46486. setEnabledRotationAxis(axis: string): void;
  46487. /**
  46488. * Enables/disables scaling
  46489. * @param enable if scaling should be enabled
  46490. */
  46491. setEnabledScaling(enable: boolean): void;
  46492. private _updateDummy;
  46493. /**
  46494. * Enables a pointer drag behavior on the bounding box of the gizmo
  46495. */
  46496. enableDragBehavior(): void;
  46497. /**
  46498. * Disposes of the gizmo
  46499. */
  46500. dispose(): void;
  46501. /**
  46502. * 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)
  46503. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  46504. * @returns the bounding box mesh with the passed in mesh as a child
  46505. */
  46506. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  46507. /**
  46508. * CustomMeshes are not supported by this gizmo
  46509. * @param mesh The mesh to replace the default mesh of the gizmo
  46510. */
  46511. setCustomMesh(mesh: Mesh): void;
  46512. }
  46513. }
  46514. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  46515. import { Observable } from "babylonjs/Misc/observable";
  46516. import { Nullable } from "babylonjs/types";
  46517. import { Vector3 } from "babylonjs/Maths/math.vector";
  46518. import { Color3 } from "babylonjs/Maths/math.color";
  46519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46520. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46521. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46522. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46523. import "babylonjs/Meshes/Builders/linesBuilder";
  46524. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46525. /**
  46526. * Single plane rotation gizmo
  46527. */
  46528. export class PlaneRotationGizmo extends Gizmo {
  46529. /**
  46530. * Drag behavior responsible for the gizmos dragging interactions
  46531. */
  46532. dragBehavior: PointerDragBehavior;
  46533. private _pointerObserver;
  46534. /**
  46535. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  46536. */
  46537. snapDistance: number;
  46538. /**
  46539. * Event that fires each time the gizmo snaps to a new location.
  46540. * * snapDistance is the the change in distance
  46541. */
  46542. onSnapObservable: Observable<{
  46543. snapDistance: number;
  46544. }>;
  46545. private _isEnabled;
  46546. private _parent;
  46547. /**
  46548. * Creates a PlaneRotationGizmo
  46549. * @param gizmoLayer The utility layer the gizmo will be added to
  46550. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  46551. * @param color The color of the gizmo
  46552. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46553. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46554. */
  46555. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  46556. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46557. /**
  46558. * If the gizmo is enabled
  46559. */
  46560. isEnabled: boolean;
  46561. /**
  46562. * Disposes of the gizmo
  46563. */
  46564. dispose(): void;
  46565. }
  46566. }
  46567. declare module "babylonjs/Gizmos/rotationGizmo" {
  46568. import { Observable } from "babylonjs/Misc/observable";
  46569. import { Nullable } from "babylonjs/types";
  46570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46571. import { Mesh } from "babylonjs/Meshes/mesh";
  46572. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46573. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  46574. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46575. /**
  46576. * Gizmo that enables rotating a mesh along 3 axis
  46577. */
  46578. export class RotationGizmo extends Gizmo {
  46579. /**
  46580. * Internal gizmo used for interactions on the x axis
  46581. */
  46582. xGizmo: PlaneRotationGizmo;
  46583. /**
  46584. * Internal gizmo used for interactions on the y axis
  46585. */
  46586. yGizmo: PlaneRotationGizmo;
  46587. /**
  46588. * Internal gizmo used for interactions on the z axis
  46589. */
  46590. zGizmo: PlaneRotationGizmo;
  46591. /** Fires an event when any of it's sub gizmos are dragged */
  46592. onDragStartObservable: Observable<unknown>;
  46593. /** Fires an event when any of it's sub gizmos are released from dragging */
  46594. onDragEndObservable: Observable<unknown>;
  46595. private _meshAttached;
  46596. attachedMesh: Nullable<AbstractMesh>;
  46597. /**
  46598. * Creates a RotationGizmo
  46599. * @param gizmoLayer The utility layer the gizmo will be added to
  46600. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46601. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46602. */
  46603. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46604. updateGizmoRotationToMatchAttachedMesh: boolean;
  46605. /**
  46606. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46607. */
  46608. snapDistance: number;
  46609. /**
  46610. * Ratio for the scale of the gizmo (Default: 1)
  46611. */
  46612. scaleRatio: number;
  46613. /**
  46614. * Disposes of the gizmo
  46615. */
  46616. dispose(): void;
  46617. /**
  46618. * CustomMeshes are not supported by this gizmo
  46619. * @param mesh The mesh to replace the default mesh of the gizmo
  46620. */
  46621. setCustomMesh(mesh: Mesh): void;
  46622. }
  46623. }
  46624. declare module "babylonjs/Gizmos/gizmoManager" {
  46625. import { Observable } from "babylonjs/Misc/observable";
  46626. import { Nullable } from "babylonjs/types";
  46627. import { Scene, IDisposable } from "babylonjs/scene";
  46628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46629. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46630. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  46631. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46632. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46633. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46634. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  46635. /**
  46636. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46637. */
  46638. export class GizmoManager implements IDisposable {
  46639. private scene;
  46640. /**
  46641. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46642. */
  46643. gizmos: {
  46644. positionGizmo: Nullable<PositionGizmo>;
  46645. rotationGizmo: Nullable<RotationGizmo>;
  46646. scaleGizmo: Nullable<ScaleGizmo>;
  46647. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46648. };
  46649. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46650. clearGizmoOnEmptyPointerEvent: boolean;
  46651. /** Fires an event when the manager is attached to a mesh */
  46652. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46653. private _gizmosEnabled;
  46654. private _pointerObserver;
  46655. private _attachedMesh;
  46656. private _boundingBoxColor;
  46657. private _defaultUtilityLayer;
  46658. private _defaultKeepDepthUtilityLayer;
  46659. /**
  46660. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46661. */
  46662. boundingBoxDragBehavior: SixDofDragBehavior;
  46663. /**
  46664. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46665. */
  46666. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46667. /**
  46668. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46669. */
  46670. usePointerToAttachGizmos: boolean;
  46671. /**
  46672. * Utility layer that the bounding box gizmo belongs to
  46673. */
  46674. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46675. /**
  46676. * Utility layer that all gizmos besides bounding box belong to
  46677. */
  46678. readonly utilityLayer: UtilityLayerRenderer;
  46679. /**
  46680. * Instatiates a gizmo manager
  46681. * @param scene the scene to overlay the gizmos on top of
  46682. */
  46683. constructor(scene: Scene);
  46684. /**
  46685. * Attaches a set of gizmos to the specified mesh
  46686. * @param mesh The mesh the gizmo's should be attached to
  46687. */
  46688. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46689. /**
  46690. * If the position gizmo is enabled
  46691. */
  46692. positionGizmoEnabled: boolean;
  46693. /**
  46694. * If the rotation gizmo is enabled
  46695. */
  46696. rotationGizmoEnabled: boolean;
  46697. /**
  46698. * If the scale gizmo is enabled
  46699. */
  46700. scaleGizmoEnabled: boolean;
  46701. /**
  46702. * If the boundingBox gizmo is enabled
  46703. */
  46704. boundingBoxGizmoEnabled: boolean;
  46705. /**
  46706. * Disposes of the gizmo manager
  46707. */
  46708. dispose(): void;
  46709. }
  46710. }
  46711. declare module "babylonjs/Lights/directionalLight" {
  46712. import { Camera } from "babylonjs/Cameras/camera";
  46713. import { Scene } from "babylonjs/scene";
  46714. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46716. import { Light } from "babylonjs/Lights/light";
  46717. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46718. import { Effect } from "babylonjs/Materials/effect";
  46719. /**
  46720. * A directional light is defined by a direction (what a surprise!).
  46721. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46722. * 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.
  46723. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46724. */
  46725. export class DirectionalLight extends ShadowLight {
  46726. private _shadowFrustumSize;
  46727. /**
  46728. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46729. */
  46730. /**
  46731. * Specifies a fix frustum size for the shadow generation.
  46732. */
  46733. shadowFrustumSize: number;
  46734. private _shadowOrthoScale;
  46735. /**
  46736. * Gets the shadow projection scale against the optimal computed one.
  46737. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46738. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46739. */
  46740. /**
  46741. * Sets the shadow projection scale against the optimal computed one.
  46742. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46743. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46744. */
  46745. shadowOrthoScale: number;
  46746. /**
  46747. * Automatically compute the projection matrix to best fit (including all the casters)
  46748. * on each frame.
  46749. */
  46750. autoUpdateExtends: boolean;
  46751. private _orthoLeft;
  46752. private _orthoRight;
  46753. private _orthoTop;
  46754. private _orthoBottom;
  46755. /**
  46756. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46757. * The directional light is emitted from everywhere in the given direction.
  46758. * It can cast shadows.
  46759. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46760. * @param name The friendly name of the light
  46761. * @param direction The direction of the light
  46762. * @param scene The scene the light belongs to
  46763. */
  46764. constructor(name: string, direction: Vector3, scene: Scene);
  46765. /**
  46766. * Returns the string "DirectionalLight".
  46767. * @return The class name
  46768. */
  46769. getClassName(): string;
  46770. /**
  46771. * Returns the integer 1.
  46772. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46773. */
  46774. getTypeID(): number;
  46775. /**
  46776. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46777. * Returns the DirectionalLight Shadow projection matrix.
  46778. */
  46779. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46780. /**
  46781. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46782. * Returns the DirectionalLight Shadow projection matrix.
  46783. */
  46784. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46785. /**
  46786. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46787. * Returns the DirectionalLight Shadow projection matrix.
  46788. */
  46789. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46790. protected _buildUniformLayout(): void;
  46791. /**
  46792. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46793. * @param effect The effect to update
  46794. * @param lightIndex The index of the light in the effect to update
  46795. * @returns The directional light
  46796. */
  46797. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46798. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  46799. /**
  46800. * Gets the minZ used for shadow according to both the scene and the light.
  46801. *
  46802. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46803. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46804. * @param activeCamera The camera we are returning the min for
  46805. * @returns the depth min z
  46806. */
  46807. getDepthMinZ(activeCamera: Camera): number;
  46808. /**
  46809. * Gets the maxZ used for shadow according to both the scene and the light.
  46810. *
  46811. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46812. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46813. * @param activeCamera The camera we are returning the max for
  46814. * @returns the depth max z
  46815. */
  46816. getDepthMaxZ(activeCamera: Camera): number;
  46817. /**
  46818. * Prepares the list of defines specific to the light type.
  46819. * @param defines the list of defines
  46820. * @param lightIndex defines the index of the light for the effect
  46821. */
  46822. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46823. }
  46824. }
  46825. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46826. import { Mesh } from "babylonjs/Meshes/mesh";
  46827. /**
  46828. * Class containing static functions to help procedurally build meshes
  46829. */
  46830. export class HemisphereBuilder {
  46831. /**
  46832. * Creates a hemisphere mesh
  46833. * @param name defines the name of the mesh
  46834. * @param options defines the options used to create the mesh
  46835. * @param scene defines the hosting scene
  46836. * @returns the hemisphere mesh
  46837. */
  46838. static CreateHemisphere(name: string, options: {
  46839. segments?: number;
  46840. diameter?: number;
  46841. sideOrientation?: number;
  46842. }, scene: any): Mesh;
  46843. }
  46844. }
  46845. declare module "babylonjs/Lights/spotLight" {
  46846. import { Nullable } from "babylonjs/types";
  46847. import { Scene } from "babylonjs/scene";
  46848. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46850. import { Effect } from "babylonjs/Materials/effect";
  46851. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46852. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46853. /**
  46854. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46855. * These values define a cone of light starting from the position, emitting toward the direction.
  46856. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46857. * and the exponent defines the speed of the decay of the light with distance (reach).
  46858. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46859. */
  46860. export class SpotLight extends ShadowLight {
  46861. private _angle;
  46862. private _innerAngle;
  46863. private _cosHalfAngle;
  46864. private _lightAngleScale;
  46865. private _lightAngleOffset;
  46866. /**
  46867. * Gets the cone angle of the spot light in Radians.
  46868. */
  46869. /**
  46870. * Sets the cone angle of the spot light in Radians.
  46871. */
  46872. angle: number;
  46873. /**
  46874. * Only used in gltf falloff mode, this defines the angle where
  46875. * the directional falloff will start before cutting at angle which could be seen
  46876. * as outer angle.
  46877. */
  46878. /**
  46879. * Only used in gltf falloff mode, this defines the angle where
  46880. * the directional falloff will start before cutting at angle which could be seen
  46881. * as outer angle.
  46882. */
  46883. innerAngle: number;
  46884. private _shadowAngleScale;
  46885. /**
  46886. * Allows scaling the angle of the light for shadow generation only.
  46887. */
  46888. /**
  46889. * Allows scaling the angle of the light for shadow generation only.
  46890. */
  46891. shadowAngleScale: number;
  46892. /**
  46893. * The light decay speed with the distance from the emission spot.
  46894. */
  46895. exponent: number;
  46896. private _projectionTextureMatrix;
  46897. /**
  46898. * Allows reading the projecton texture
  46899. */
  46900. readonly projectionTextureMatrix: Matrix;
  46901. protected _projectionTextureLightNear: number;
  46902. /**
  46903. * Gets the near clip of the Spotlight for texture projection.
  46904. */
  46905. /**
  46906. * Sets the near clip of the Spotlight for texture projection.
  46907. */
  46908. projectionTextureLightNear: number;
  46909. protected _projectionTextureLightFar: number;
  46910. /**
  46911. * Gets the far clip of the Spotlight for texture projection.
  46912. */
  46913. /**
  46914. * Sets the far clip of the Spotlight for texture projection.
  46915. */
  46916. projectionTextureLightFar: number;
  46917. protected _projectionTextureUpDirection: Vector3;
  46918. /**
  46919. * Gets the Up vector of the Spotlight for texture projection.
  46920. */
  46921. /**
  46922. * Sets the Up vector of the Spotlight for texture projection.
  46923. */
  46924. projectionTextureUpDirection: Vector3;
  46925. private _projectionTexture;
  46926. /**
  46927. * Gets the projection texture of the light.
  46928. */
  46929. /**
  46930. * Sets the projection texture of the light.
  46931. */
  46932. projectionTexture: Nullable<BaseTexture>;
  46933. private _projectionTextureViewLightDirty;
  46934. private _projectionTextureProjectionLightDirty;
  46935. private _projectionTextureDirty;
  46936. private _projectionTextureViewTargetVector;
  46937. private _projectionTextureViewLightMatrix;
  46938. private _projectionTextureProjectionLightMatrix;
  46939. private _projectionTextureScalingMatrix;
  46940. /**
  46941. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46942. * It can cast shadows.
  46943. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46944. * @param name The light friendly name
  46945. * @param position The position of the spot light in the scene
  46946. * @param direction The direction of the light in the scene
  46947. * @param angle The cone angle of the light in Radians
  46948. * @param exponent The light decay speed with the distance from the emission spot
  46949. * @param scene The scene the lights belongs to
  46950. */
  46951. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46952. /**
  46953. * Returns the string "SpotLight".
  46954. * @returns the class name
  46955. */
  46956. getClassName(): string;
  46957. /**
  46958. * Returns the integer 2.
  46959. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46960. */
  46961. getTypeID(): number;
  46962. /**
  46963. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46964. */
  46965. protected _setDirection(value: Vector3): void;
  46966. /**
  46967. * Overrides the position setter to recompute the projection texture view light Matrix.
  46968. */
  46969. protected _setPosition(value: Vector3): void;
  46970. /**
  46971. * 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.
  46972. * Returns the SpotLight.
  46973. */
  46974. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46975. protected _computeProjectionTextureViewLightMatrix(): void;
  46976. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46977. /**
  46978. * Main function for light texture projection matrix computing.
  46979. */
  46980. protected _computeProjectionTextureMatrix(): void;
  46981. protected _buildUniformLayout(): void;
  46982. private _computeAngleValues;
  46983. /**
  46984. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46985. * @param effect The effect to update
  46986. * @param lightIndex The index of the light in the effect to update
  46987. * @returns The spot light
  46988. */
  46989. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46990. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  46991. /**
  46992. * Disposes the light and the associated resources.
  46993. */
  46994. dispose(): void;
  46995. /**
  46996. * Prepares the list of defines specific to the light type.
  46997. * @param defines the list of defines
  46998. * @param lightIndex defines the index of the light for the effect
  46999. */
  47000. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47001. }
  47002. }
  47003. declare module "babylonjs/Gizmos/lightGizmo" {
  47004. import { Nullable } from "babylonjs/types";
  47005. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47006. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47007. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47008. import { Light } from "babylonjs/Lights/light";
  47009. /**
  47010. * Gizmo that enables viewing a light
  47011. */
  47012. export class LightGizmo extends Gizmo {
  47013. private _lightMesh;
  47014. private _material;
  47015. private cachedPosition;
  47016. private cachedForward;
  47017. /**
  47018. * Creates a LightGizmo
  47019. * @param gizmoLayer The utility layer the gizmo will be added to
  47020. */
  47021. constructor(gizmoLayer?: UtilityLayerRenderer);
  47022. private _light;
  47023. /**
  47024. * The light that the gizmo is attached to
  47025. */
  47026. light: Nullable<Light>;
  47027. /**
  47028. * Gets the material used to render the light gizmo
  47029. */
  47030. readonly material: StandardMaterial;
  47031. /**
  47032. * @hidden
  47033. * Updates the gizmo to match the attached mesh's position/rotation
  47034. */
  47035. protected _update(): void;
  47036. private static _Scale;
  47037. /**
  47038. * Creates the lines for a light mesh
  47039. */
  47040. private static _createLightLines;
  47041. /**
  47042. * Disposes of the light gizmo
  47043. */
  47044. dispose(): void;
  47045. private static _CreateHemisphericLightMesh;
  47046. private static _CreatePointLightMesh;
  47047. private static _CreateSpotLightMesh;
  47048. private static _CreateDirectionalLightMesh;
  47049. }
  47050. }
  47051. declare module "babylonjs/Gizmos/index" {
  47052. export * from "babylonjs/Gizmos/axisDragGizmo";
  47053. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47054. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47055. export * from "babylonjs/Gizmos/gizmo";
  47056. export * from "babylonjs/Gizmos/gizmoManager";
  47057. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47058. export * from "babylonjs/Gizmos/positionGizmo";
  47059. export * from "babylonjs/Gizmos/rotationGizmo";
  47060. export * from "babylonjs/Gizmos/scaleGizmo";
  47061. export * from "babylonjs/Gizmos/lightGizmo";
  47062. export * from "babylonjs/Gizmos/planeDragGizmo";
  47063. }
  47064. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47065. /** @hidden */
  47066. export var backgroundFragmentDeclaration: {
  47067. name: string;
  47068. shader: string;
  47069. };
  47070. }
  47071. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47072. /** @hidden */
  47073. export var backgroundUboDeclaration: {
  47074. name: string;
  47075. shader: string;
  47076. };
  47077. }
  47078. declare module "babylonjs/Shaders/background.fragment" {
  47079. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47080. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47081. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47082. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47083. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47084. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47085. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47086. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47087. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47088. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47089. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47090. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47091. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47092. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47093. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47094. /** @hidden */
  47095. export var backgroundPixelShader: {
  47096. name: string;
  47097. shader: string;
  47098. };
  47099. }
  47100. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47101. /** @hidden */
  47102. export var backgroundVertexDeclaration: {
  47103. name: string;
  47104. shader: string;
  47105. };
  47106. }
  47107. declare module "babylonjs/Shaders/background.vertex" {
  47108. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47109. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47110. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47111. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47112. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47113. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47114. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47115. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47116. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47117. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47118. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47119. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47120. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47121. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47122. /** @hidden */
  47123. export var backgroundVertexShader: {
  47124. name: string;
  47125. shader: string;
  47126. };
  47127. }
  47128. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47129. import { Nullable, int, float } from "babylonjs/types";
  47130. import { Scene } from "babylonjs/scene";
  47131. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47132. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47134. import { Mesh } from "babylonjs/Meshes/mesh";
  47135. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47136. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47137. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47138. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47139. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47140. import { Color3 } from "babylonjs/Maths/math.color";
  47141. import "babylonjs/Shaders/background.fragment";
  47142. import "babylonjs/Shaders/background.vertex";
  47143. /**
  47144. * Background material used to create an efficient environement around your scene.
  47145. */
  47146. export class BackgroundMaterial extends PushMaterial {
  47147. /**
  47148. * Standard reflectance value at parallel view angle.
  47149. */
  47150. static StandardReflectance0: number;
  47151. /**
  47152. * Standard reflectance value at grazing angle.
  47153. */
  47154. static StandardReflectance90: number;
  47155. protected _primaryColor: Color3;
  47156. /**
  47157. * Key light Color (multiply against the environement texture)
  47158. */
  47159. primaryColor: Color3;
  47160. protected __perceptualColor: Nullable<Color3>;
  47161. /**
  47162. * Experimental Internal Use Only.
  47163. *
  47164. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47165. * This acts as a helper to set the primary color to a more "human friendly" value.
  47166. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47167. * output color as close as possible from the chosen value.
  47168. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47169. * part of lighting setup.)
  47170. */
  47171. _perceptualColor: Nullable<Color3>;
  47172. protected _primaryColorShadowLevel: float;
  47173. /**
  47174. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47175. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47176. */
  47177. primaryColorShadowLevel: float;
  47178. protected _primaryColorHighlightLevel: float;
  47179. /**
  47180. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47181. * The primary color is used at the level chosen to define what the white area would look.
  47182. */
  47183. primaryColorHighlightLevel: float;
  47184. protected _reflectionTexture: Nullable<BaseTexture>;
  47185. /**
  47186. * Reflection Texture used in the material.
  47187. * Should be author in a specific way for the best result (refer to the documentation).
  47188. */
  47189. reflectionTexture: Nullable<BaseTexture>;
  47190. protected _reflectionBlur: float;
  47191. /**
  47192. * Reflection Texture level of blur.
  47193. *
  47194. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47195. * texture twice.
  47196. */
  47197. reflectionBlur: float;
  47198. protected _diffuseTexture: Nullable<BaseTexture>;
  47199. /**
  47200. * Diffuse Texture used in the material.
  47201. * Should be author in a specific way for the best result (refer to the documentation).
  47202. */
  47203. diffuseTexture: Nullable<BaseTexture>;
  47204. protected _shadowLights: Nullable<IShadowLight[]>;
  47205. /**
  47206. * Specify the list of lights casting shadow on the material.
  47207. * All scene shadow lights will be included if null.
  47208. */
  47209. shadowLights: Nullable<IShadowLight[]>;
  47210. protected _shadowLevel: float;
  47211. /**
  47212. * Helps adjusting the shadow to a softer level if required.
  47213. * 0 means black shadows and 1 means no shadows.
  47214. */
  47215. shadowLevel: float;
  47216. protected _sceneCenter: Vector3;
  47217. /**
  47218. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47219. * It is usually zero but might be interesting to modify according to your setup.
  47220. */
  47221. sceneCenter: Vector3;
  47222. protected _opacityFresnel: boolean;
  47223. /**
  47224. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47225. * This helps ensuring a nice transition when the camera goes under the ground.
  47226. */
  47227. opacityFresnel: boolean;
  47228. protected _reflectionFresnel: boolean;
  47229. /**
  47230. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47231. * This helps adding a mirror texture on the ground.
  47232. */
  47233. reflectionFresnel: boolean;
  47234. protected _reflectionFalloffDistance: number;
  47235. /**
  47236. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47237. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47238. */
  47239. reflectionFalloffDistance: number;
  47240. protected _reflectionAmount: number;
  47241. /**
  47242. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47243. */
  47244. reflectionAmount: number;
  47245. protected _reflectionReflectance0: number;
  47246. /**
  47247. * This specifies the weight of the reflection at grazing angle.
  47248. */
  47249. reflectionReflectance0: number;
  47250. protected _reflectionReflectance90: number;
  47251. /**
  47252. * This specifies the weight of the reflection at a perpendicular point of view.
  47253. */
  47254. reflectionReflectance90: number;
  47255. /**
  47256. * Sets the reflection reflectance fresnel values according to the default standard
  47257. * empirically know to work well :-)
  47258. */
  47259. reflectionStandardFresnelWeight: number;
  47260. protected _useRGBColor: boolean;
  47261. /**
  47262. * Helps to directly use the maps channels instead of their level.
  47263. */
  47264. useRGBColor: boolean;
  47265. protected _enableNoise: boolean;
  47266. /**
  47267. * This helps reducing the banding effect that could occur on the background.
  47268. */
  47269. enableNoise: boolean;
  47270. /**
  47271. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47272. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47273. * Recommended to be keep at 1.0 except for special cases.
  47274. */
  47275. fovMultiplier: number;
  47276. private _fovMultiplier;
  47277. /**
  47278. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47279. */
  47280. useEquirectangularFOV: boolean;
  47281. private _maxSimultaneousLights;
  47282. /**
  47283. * Number of Simultaneous lights allowed on the material.
  47284. */
  47285. maxSimultaneousLights: int;
  47286. /**
  47287. * Default configuration related to image processing available in the Background Material.
  47288. */
  47289. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47290. /**
  47291. * Keep track of the image processing observer to allow dispose and replace.
  47292. */
  47293. private _imageProcessingObserver;
  47294. /**
  47295. * Attaches a new image processing configuration to the PBR Material.
  47296. * @param configuration (if null the scene configuration will be use)
  47297. */
  47298. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47299. /**
  47300. * Gets the image processing configuration used either in this material.
  47301. */
  47302. /**
  47303. * Sets the Default image processing configuration used either in the this material.
  47304. *
  47305. * If sets to null, the scene one is in use.
  47306. */
  47307. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47308. /**
  47309. * Gets wether the color curves effect is enabled.
  47310. */
  47311. /**
  47312. * Sets wether the color curves effect is enabled.
  47313. */
  47314. cameraColorCurvesEnabled: boolean;
  47315. /**
  47316. * Gets wether the color grading effect is enabled.
  47317. */
  47318. /**
  47319. * Gets wether the color grading effect is enabled.
  47320. */
  47321. cameraColorGradingEnabled: boolean;
  47322. /**
  47323. * Gets wether tonemapping is enabled or not.
  47324. */
  47325. /**
  47326. * Sets wether tonemapping is enabled or not
  47327. */
  47328. cameraToneMappingEnabled: boolean;
  47329. /**
  47330. * The camera exposure used on this material.
  47331. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47332. * This corresponds to a photographic exposure.
  47333. */
  47334. /**
  47335. * The camera exposure used on this material.
  47336. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47337. * This corresponds to a photographic exposure.
  47338. */
  47339. cameraExposure: float;
  47340. /**
  47341. * Gets The camera contrast used on this material.
  47342. */
  47343. /**
  47344. * Sets The camera contrast used on this material.
  47345. */
  47346. cameraContrast: float;
  47347. /**
  47348. * Gets the Color Grading 2D Lookup Texture.
  47349. */
  47350. /**
  47351. * Sets the Color Grading 2D Lookup Texture.
  47352. */
  47353. cameraColorGradingTexture: Nullable<BaseTexture>;
  47354. /**
  47355. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47356. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47357. * 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;
  47358. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47359. */
  47360. /**
  47361. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47362. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47363. * 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;
  47364. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47365. */
  47366. cameraColorCurves: Nullable<ColorCurves>;
  47367. /**
  47368. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47369. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47370. */
  47371. switchToBGR: boolean;
  47372. private _renderTargets;
  47373. private _reflectionControls;
  47374. private _white;
  47375. private _primaryShadowColor;
  47376. private _primaryHighlightColor;
  47377. /**
  47378. * Instantiates a Background Material in the given scene
  47379. * @param name The friendly name of the material
  47380. * @param scene The scene to add the material to
  47381. */
  47382. constructor(name: string, scene: Scene);
  47383. /**
  47384. * Gets a boolean indicating that current material needs to register RTT
  47385. */
  47386. readonly hasRenderTargetTextures: boolean;
  47387. /**
  47388. * The entire material has been created in order to prevent overdraw.
  47389. * @returns false
  47390. */
  47391. needAlphaTesting(): boolean;
  47392. /**
  47393. * The entire material has been created in order to prevent overdraw.
  47394. * @returns true if blending is enable
  47395. */
  47396. needAlphaBlending(): boolean;
  47397. /**
  47398. * Checks wether the material is ready to be rendered for a given mesh.
  47399. * @param mesh The mesh to render
  47400. * @param subMesh The submesh to check against
  47401. * @param useInstances Specify wether or not the material is used with instances
  47402. * @returns true if all the dependencies are ready (Textures, Effects...)
  47403. */
  47404. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47405. /**
  47406. * Compute the primary color according to the chosen perceptual color.
  47407. */
  47408. private _computePrimaryColorFromPerceptualColor;
  47409. /**
  47410. * Compute the highlights and shadow colors according to their chosen levels.
  47411. */
  47412. private _computePrimaryColors;
  47413. /**
  47414. * Build the uniform buffer used in the material.
  47415. */
  47416. buildUniformLayout(): void;
  47417. /**
  47418. * Unbind the material.
  47419. */
  47420. unbind(): void;
  47421. /**
  47422. * Bind only the world matrix to the material.
  47423. * @param world The world matrix to bind.
  47424. */
  47425. bindOnlyWorldMatrix(world: Matrix): void;
  47426. /**
  47427. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47428. * @param world The world matrix to bind.
  47429. * @param subMesh The submesh to bind for.
  47430. */
  47431. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47432. /**
  47433. * Checks to see if a texture is used in the material.
  47434. * @param texture - Base texture to use.
  47435. * @returns - Boolean specifying if a texture is used in the material.
  47436. */
  47437. hasTexture(texture: BaseTexture): boolean;
  47438. /**
  47439. * Dispose the material.
  47440. * @param forceDisposeEffect Force disposal of the associated effect.
  47441. * @param forceDisposeTextures Force disposal of the associated textures.
  47442. */
  47443. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47444. /**
  47445. * Clones the material.
  47446. * @param name The cloned name.
  47447. * @returns The cloned material.
  47448. */
  47449. clone(name: string): BackgroundMaterial;
  47450. /**
  47451. * Serializes the current material to its JSON representation.
  47452. * @returns The JSON representation.
  47453. */
  47454. serialize(): any;
  47455. /**
  47456. * Gets the class name of the material
  47457. * @returns "BackgroundMaterial"
  47458. */
  47459. getClassName(): string;
  47460. /**
  47461. * Parse a JSON input to create back a background material.
  47462. * @param source The JSON data to parse
  47463. * @param scene The scene to create the parsed material in
  47464. * @param rootUrl The root url of the assets the material depends upon
  47465. * @returns the instantiated BackgroundMaterial.
  47466. */
  47467. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47468. }
  47469. }
  47470. declare module "babylonjs/Helpers/environmentHelper" {
  47471. import { Observable } from "babylonjs/Misc/observable";
  47472. import { Nullable } from "babylonjs/types";
  47473. import { Scene } from "babylonjs/scene";
  47474. import { Vector3 } from "babylonjs/Maths/math.vector";
  47475. import { Color3 } from "babylonjs/Maths/math.color";
  47476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47477. import { Mesh } from "babylonjs/Meshes/mesh";
  47478. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47479. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  47480. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47481. import "babylonjs/Meshes/Builders/planeBuilder";
  47482. import "babylonjs/Meshes/Builders/boxBuilder";
  47483. /**
  47484. * Represents the different options available during the creation of
  47485. * a Environment helper.
  47486. *
  47487. * This can control the default ground, skybox and image processing setup of your scene.
  47488. */
  47489. export interface IEnvironmentHelperOptions {
  47490. /**
  47491. * Specifies wether or not to create a ground.
  47492. * True by default.
  47493. */
  47494. createGround: boolean;
  47495. /**
  47496. * Specifies the ground size.
  47497. * 15 by default.
  47498. */
  47499. groundSize: number;
  47500. /**
  47501. * The texture used on the ground for the main color.
  47502. * Comes from the BabylonJS CDN by default.
  47503. *
  47504. * Remarks: Can be either a texture or a url.
  47505. */
  47506. groundTexture: string | BaseTexture;
  47507. /**
  47508. * The color mixed in the ground texture by default.
  47509. * BabylonJS clearColor by default.
  47510. */
  47511. groundColor: Color3;
  47512. /**
  47513. * Specifies the ground opacity.
  47514. * 1 by default.
  47515. */
  47516. groundOpacity: number;
  47517. /**
  47518. * Enables the ground to receive shadows.
  47519. * True by default.
  47520. */
  47521. enableGroundShadow: boolean;
  47522. /**
  47523. * Helps preventing the shadow to be fully black on the ground.
  47524. * 0.5 by default.
  47525. */
  47526. groundShadowLevel: number;
  47527. /**
  47528. * Creates a mirror texture attach to the ground.
  47529. * false by default.
  47530. */
  47531. enableGroundMirror: boolean;
  47532. /**
  47533. * Specifies the ground mirror size ratio.
  47534. * 0.3 by default as the default kernel is 64.
  47535. */
  47536. groundMirrorSizeRatio: number;
  47537. /**
  47538. * Specifies the ground mirror blur kernel size.
  47539. * 64 by default.
  47540. */
  47541. groundMirrorBlurKernel: number;
  47542. /**
  47543. * Specifies the ground mirror visibility amount.
  47544. * 1 by default
  47545. */
  47546. groundMirrorAmount: number;
  47547. /**
  47548. * Specifies the ground mirror reflectance weight.
  47549. * This uses the standard weight of the background material to setup the fresnel effect
  47550. * of the mirror.
  47551. * 1 by default.
  47552. */
  47553. groundMirrorFresnelWeight: number;
  47554. /**
  47555. * Specifies the ground mirror Falloff distance.
  47556. * This can helps reducing the size of the reflection.
  47557. * 0 by Default.
  47558. */
  47559. groundMirrorFallOffDistance: number;
  47560. /**
  47561. * Specifies the ground mirror texture type.
  47562. * Unsigned Int by Default.
  47563. */
  47564. groundMirrorTextureType: number;
  47565. /**
  47566. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47567. * the shown objects.
  47568. */
  47569. groundYBias: number;
  47570. /**
  47571. * Specifies wether or not to create a skybox.
  47572. * True by default.
  47573. */
  47574. createSkybox: boolean;
  47575. /**
  47576. * Specifies the skybox size.
  47577. * 20 by default.
  47578. */
  47579. skyboxSize: number;
  47580. /**
  47581. * The texture used on the skybox for the main color.
  47582. * Comes from the BabylonJS CDN by default.
  47583. *
  47584. * Remarks: Can be either a texture or a url.
  47585. */
  47586. skyboxTexture: string | BaseTexture;
  47587. /**
  47588. * The color mixed in the skybox texture by default.
  47589. * BabylonJS clearColor by default.
  47590. */
  47591. skyboxColor: Color3;
  47592. /**
  47593. * The background rotation around the Y axis of the scene.
  47594. * This helps aligning the key lights of your scene with the background.
  47595. * 0 by default.
  47596. */
  47597. backgroundYRotation: number;
  47598. /**
  47599. * Compute automatically the size of the elements to best fit with the scene.
  47600. */
  47601. sizeAuto: boolean;
  47602. /**
  47603. * Default position of the rootMesh if autoSize is not true.
  47604. */
  47605. rootPosition: Vector3;
  47606. /**
  47607. * Sets up the image processing in the scene.
  47608. * true by default.
  47609. */
  47610. setupImageProcessing: boolean;
  47611. /**
  47612. * The texture used as your environment texture in the scene.
  47613. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47614. *
  47615. * Remarks: Can be either a texture or a url.
  47616. */
  47617. environmentTexture: string | BaseTexture;
  47618. /**
  47619. * The value of the exposure to apply to the scene.
  47620. * 0.6 by default if setupImageProcessing is true.
  47621. */
  47622. cameraExposure: number;
  47623. /**
  47624. * The value of the contrast to apply to the scene.
  47625. * 1.6 by default if setupImageProcessing is true.
  47626. */
  47627. cameraContrast: number;
  47628. /**
  47629. * Specifies wether or not tonemapping should be enabled in the scene.
  47630. * true by default if setupImageProcessing is true.
  47631. */
  47632. toneMappingEnabled: boolean;
  47633. }
  47634. /**
  47635. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47636. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47637. * It also helps with the default setup of your imageProcessing configuration.
  47638. */
  47639. export class EnvironmentHelper {
  47640. /**
  47641. * Default ground texture URL.
  47642. */
  47643. private static _groundTextureCDNUrl;
  47644. /**
  47645. * Default skybox texture URL.
  47646. */
  47647. private static _skyboxTextureCDNUrl;
  47648. /**
  47649. * Default environment texture URL.
  47650. */
  47651. private static _environmentTextureCDNUrl;
  47652. /**
  47653. * Creates the default options for the helper.
  47654. */
  47655. private static _getDefaultOptions;
  47656. private _rootMesh;
  47657. /**
  47658. * Gets the root mesh created by the helper.
  47659. */
  47660. readonly rootMesh: Mesh;
  47661. private _skybox;
  47662. /**
  47663. * Gets the skybox created by the helper.
  47664. */
  47665. readonly skybox: Nullable<Mesh>;
  47666. private _skyboxTexture;
  47667. /**
  47668. * Gets the skybox texture created by the helper.
  47669. */
  47670. readonly skyboxTexture: Nullable<BaseTexture>;
  47671. private _skyboxMaterial;
  47672. /**
  47673. * Gets the skybox material created by the helper.
  47674. */
  47675. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47676. private _ground;
  47677. /**
  47678. * Gets the ground mesh created by the helper.
  47679. */
  47680. readonly ground: Nullable<Mesh>;
  47681. private _groundTexture;
  47682. /**
  47683. * Gets the ground texture created by the helper.
  47684. */
  47685. readonly groundTexture: Nullable<BaseTexture>;
  47686. private _groundMirror;
  47687. /**
  47688. * Gets the ground mirror created by the helper.
  47689. */
  47690. readonly groundMirror: Nullable<MirrorTexture>;
  47691. /**
  47692. * Gets the ground mirror render list to helps pushing the meshes
  47693. * you wish in the ground reflection.
  47694. */
  47695. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47696. private _groundMaterial;
  47697. /**
  47698. * Gets the ground material created by the helper.
  47699. */
  47700. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47701. /**
  47702. * Stores the creation options.
  47703. */
  47704. private readonly _scene;
  47705. private _options;
  47706. /**
  47707. * This observable will be notified with any error during the creation of the environment,
  47708. * mainly texture creation errors.
  47709. */
  47710. onErrorObservable: Observable<{
  47711. message?: string;
  47712. exception?: any;
  47713. }>;
  47714. /**
  47715. * constructor
  47716. * @param options Defines the options we want to customize the helper
  47717. * @param scene The scene to add the material to
  47718. */
  47719. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47720. /**
  47721. * Updates the background according to the new options
  47722. * @param options
  47723. */
  47724. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47725. /**
  47726. * Sets the primary color of all the available elements.
  47727. * @param color the main color to affect to the ground and the background
  47728. */
  47729. setMainColor(color: Color3): void;
  47730. /**
  47731. * Setup the image processing according to the specified options.
  47732. */
  47733. private _setupImageProcessing;
  47734. /**
  47735. * Setup the environment texture according to the specified options.
  47736. */
  47737. private _setupEnvironmentTexture;
  47738. /**
  47739. * Setup the background according to the specified options.
  47740. */
  47741. private _setupBackground;
  47742. /**
  47743. * Get the scene sizes according to the setup.
  47744. */
  47745. private _getSceneSize;
  47746. /**
  47747. * Setup the ground according to the specified options.
  47748. */
  47749. private _setupGround;
  47750. /**
  47751. * Setup the ground material according to the specified options.
  47752. */
  47753. private _setupGroundMaterial;
  47754. /**
  47755. * Setup the ground diffuse texture according to the specified options.
  47756. */
  47757. private _setupGroundDiffuseTexture;
  47758. /**
  47759. * Setup the ground mirror texture according to the specified options.
  47760. */
  47761. private _setupGroundMirrorTexture;
  47762. /**
  47763. * Setup the ground to receive the mirror texture.
  47764. */
  47765. private _setupMirrorInGroundMaterial;
  47766. /**
  47767. * Setup the skybox according to the specified options.
  47768. */
  47769. private _setupSkybox;
  47770. /**
  47771. * Setup the skybox material according to the specified options.
  47772. */
  47773. private _setupSkyboxMaterial;
  47774. /**
  47775. * Setup the skybox reflection texture according to the specified options.
  47776. */
  47777. private _setupSkyboxReflectionTexture;
  47778. private _errorHandler;
  47779. /**
  47780. * Dispose all the elements created by the Helper.
  47781. */
  47782. dispose(): void;
  47783. }
  47784. }
  47785. declare module "babylonjs/Helpers/photoDome" {
  47786. import { Observable } from "babylonjs/Misc/observable";
  47787. import { Nullable } from "babylonjs/types";
  47788. import { Scene } from "babylonjs/scene";
  47789. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47790. import { Mesh } from "babylonjs/Meshes/mesh";
  47791. import { Texture } from "babylonjs/Materials/Textures/texture";
  47792. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47793. import "babylonjs/Meshes/Builders/sphereBuilder";
  47794. /**
  47795. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47796. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47797. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47798. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47799. */
  47800. export class PhotoDome extends TransformNode {
  47801. /**
  47802. * Define the image as a Monoscopic panoramic 360 image.
  47803. */
  47804. static readonly MODE_MONOSCOPIC: number;
  47805. /**
  47806. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47807. */
  47808. static readonly MODE_TOPBOTTOM: number;
  47809. /**
  47810. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47811. */
  47812. static readonly MODE_SIDEBYSIDE: number;
  47813. private _useDirectMapping;
  47814. /**
  47815. * The texture being displayed on the sphere
  47816. */
  47817. protected _photoTexture: Texture;
  47818. /**
  47819. * Gets or sets the texture being displayed on the sphere
  47820. */
  47821. photoTexture: Texture;
  47822. /**
  47823. * Observable raised when an error occured while loading the 360 image
  47824. */
  47825. onLoadErrorObservable: Observable<string>;
  47826. /**
  47827. * The skybox material
  47828. */
  47829. protected _material: BackgroundMaterial;
  47830. /**
  47831. * The surface used for the skybox
  47832. */
  47833. protected _mesh: Mesh;
  47834. /**
  47835. * Gets the mesh used for the skybox.
  47836. */
  47837. readonly mesh: Mesh;
  47838. /**
  47839. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47840. * Also see the options.resolution property.
  47841. */
  47842. fovMultiplier: number;
  47843. private _imageMode;
  47844. /**
  47845. * Gets or set the current video mode for the video. It can be:
  47846. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47847. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47848. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47849. */
  47850. imageMode: number;
  47851. /**
  47852. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47853. * @param name Element's name, child elements will append suffixes for their own names.
  47854. * @param urlsOfPhoto defines the url of the photo to display
  47855. * @param options defines an object containing optional or exposed sub element properties
  47856. * @param onError defines a callback called when an error occured while loading the texture
  47857. */
  47858. constructor(name: string, urlOfPhoto: string, options: {
  47859. resolution?: number;
  47860. size?: number;
  47861. useDirectMapping?: boolean;
  47862. faceForward?: boolean;
  47863. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47864. private _onBeforeCameraRenderObserver;
  47865. private _changeImageMode;
  47866. /**
  47867. * Releases resources associated with this node.
  47868. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47869. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47870. */
  47871. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47872. }
  47873. }
  47874. declare module "babylonjs/Misc/rgbdTextureTools" {
  47875. import "babylonjs/Shaders/rgbdDecode.fragment";
  47876. import { Texture } from "babylonjs/Materials/Textures/texture";
  47877. /**
  47878. * Class used to host RGBD texture specific utilities
  47879. */
  47880. export class RGBDTextureTools {
  47881. /**
  47882. * Expand the RGBD Texture from RGBD to Half Float if possible.
  47883. * @param texture the texture to expand.
  47884. */
  47885. static ExpandRGBDTexture(texture: Texture): void;
  47886. }
  47887. }
  47888. declare module "babylonjs/Misc/brdfTextureTools" {
  47889. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47890. import { Scene } from "babylonjs/scene";
  47891. /**
  47892. * Class used to host texture specific utilities
  47893. */
  47894. export class BRDFTextureTools {
  47895. /**
  47896. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47897. * @param scene defines the hosting scene
  47898. * @returns the environment BRDF texture
  47899. */
  47900. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47901. private static _environmentBRDFBase64Texture;
  47902. }
  47903. }
  47904. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47905. import { Nullable } from "babylonjs/types";
  47906. import { Color3 } from "babylonjs/Maths/math.color";
  47907. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47908. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47909. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47910. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47911. import { Engine } from "babylonjs/Engines/engine";
  47912. import { Scene } from "babylonjs/scene";
  47913. /**
  47914. * @hidden
  47915. */
  47916. export interface IMaterialClearCoatDefines {
  47917. CLEARCOAT: boolean;
  47918. CLEARCOAT_DEFAULTIOR: boolean;
  47919. CLEARCOAT_TEXTURE: boolean;
  47920. CLEARCOAT_TEXTUREDIRECTUV: number;
  47921. CLEARCOAT_BUMP: boolean;
  47922. CLEARCOAT_BUMPDIRECTUV: number;
  47923. CLEARCOAT_TINT: boolean;
  47924. CLEARCOAT_TINT_TEXTURE: boolean;
  47925. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47926. /** @hidden */
  47927. _areTexturesDirty: boolean;
  47928. }
  47929. /**
  47930. * Define the code related to the clear coat parameters of the pbr material.
  47931. */
  47932. export class PBRClearCoatConfiguration {
  47933. /**
  47934. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47935. * The default fits with a polyurethane material.
  47936. */
  47937. private static readonly _DefaultIndexOfRefraction;
  47938. private _isEnabled;
  47939. /**
  47940. * Defines if the clear coat is enabled in the material.
  47941. */
  47942. isEnabled: boolean;
  47943. /**
  47944. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47945. */
  47946. intensity: number;
  47947. /**
  47948. * Defines the clear coat layer roughness.
  47949. */
  47950. roughness: number;
  47951. private _indexOfRefraction;
  47952. /**
  47953. * Defines the index of refraction of the clear coat.
  47954. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47955. * The default fits with a polyurethane material.
  47956. * Changing the default value is more performance intensive.
  47957. */
  47958. indexOfRefraction: number;
  47959. private _texture;
  47960. /**
  47961. * Stores the clear coat values in a texture.
  47962. */
  47963. texture: Nullable<BaseTexture>;
  47964. private _bumpTexture;
  47965. /**
  47966. * Define the clear coat specific bump texture.
  47967. */
  47968. bumpTexture: Nullable<BaseTexture>;
  47969. private _isTintEnabled;
  47970. /**
  47971. * Defines if the clear coat tint is enabled in the material.
  47972. */
  47973. isTintEnabled: boolean;
  47974. /**
  47975. * Defines the clear coat tint of the material.
  47976. * This is only use if tint is enabled
  47977. */
  47978. tintColor: Color3;
  47979. /**
  47980. * Defines the distance at which the tint color should be found in the
  47981. * clear coat media.
  47982. * This is only use if tint is enabled
  47983. */
  47984. tintColorAtDistance: number;
  47985. /**
  47986. * Defines the clear coat layer thickness.
  47987. * This is only use if tint is enabled
  47988. */
  47989. tintThickness: number;
  47990. private _tintTexture;
  47991. /**
  47992. * Stores the clear tint values in a texture.
  47993. * rgb is tint
  47994. * a is a thickness factor
  47995. */
  47996. tintTexture: Nullable<BaseTexture>;
  47997. /** @hidden */
  47998. private _internalMarkAllSubMeshesAsTexturesDirty;
  47999. /** @hidden */
  48000. _markAllSubMeshesAsTexturesDirty(): void;
  48001. /**
  48002. * Instantiate a new istance of clear coat configuration.
  48003. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48004. */
  48005. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48006. /**
  48007. * Gets wehter the submesh is ready to be used or not.
  48008. * @param defines the list of "defines" to update.
  48009. * @param scene defines the scene the material belongs to.
  48010. * @param engine defines the engine the material belongs to.
  48011. * @param disableBumpMap defines wether the material disables bump or not.
  48012. * @returns - boolean indicating that the submesh is ready or not.
  48013. */
  48014. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48015. /**
  48016. * Checks to see if a texture is used in the material.
  48017. * @param defines the list of "defines" to update.
  48018. * @param scene defines the scene to the material belongs to.
  48019. */
  48020. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48021. /**
  48022. * Binds the material data.
  48023. * @param uniformBuffer defines the Uniform buffer to fill in.
  48024. * @param scene defines the scene the material belongs to.
  48025. * @param engine defines the engine the material belongs to.
  48026. * @param disableBumpMap defines wether the material disables bump or not.
  48027. * @param isFrozen defines wether the material is frozen or not.
  48028. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48029. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48030. */
  48031. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48032. /**
  48033. * Checks to see if a texture is used in the material.
  48034. * @param texture - Base texture to use.
  48035. * @returns - Boolean specifying if a texture is used in the material.
  48036. */
  48037. hasTexture(texture: BaseTexture): boolean;
  48038. /**
  48039. * Returns an array of the actively used textures.
  48040. * @param activeTextures Array of BaseTextures
  48041. */
  48042. getActiveTextures(activeTextures: BaseTexture[]): void;
  48043. /**
  48044. * Returns the animatable textures.
  48045. * @param animatables Array of animatable textures.
  48046. */
  48047. getAnimatables(animatables: IAnimatable[]): void;
  48048. /**
  48049. * Disposes the resources of the material.
  48050. * @param forceDisposeTextures - Forces the disposal of all textures.
  48051. */
  48052. dispose(forceDisposeTextures?: boolean): void;
  48053. /**
  48054. * Get the current class name of the texture useful for serialization or dynamic coding.
  48055. * @returns "PBRClearCoatConfiguration"
  48056. */
  48057. getClassName(): string;
  48058. /**
  48059. * Add fallbacks to the effect fallbacks list.
  48060. * @param defines defines the Base texture to use.
  48061. * @param fallbacks defines the current fallback list.
  48062. * @param currentRank defines the current fallback rank.
  48063. * @returns the new fallback rank.
  48064. */
  48065. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48066. /**
  48067. * Add the required uniforms to the current list.
  48068. * @param uniforms defines the current uniform list.
  48069. */
  48070. static AddUniforms(uniforms: string[]): void;
  48071. /**
  48072. * Add the required samplers to the current list.
  48073. * @param samplers defines the current sampler list.
  48074. */
  48075. static AddSamplers(samplers: string[]): void;
  48076. /**
  48077. * Add the required uniforms to the current buffer.
  48078. * @param uniformBuffer defines the current uniform buffer.
  48079. */
  48080. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48081. /**
  48082. * Makes a duplicate of the current configuration into another one.
  48083. * @param clearCoatConfiguration define the config where to copy the info
  48084. */
  48085. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48086. /**
  48087. * Serializes this clear coat configuration.
  48088. * @returns - An object with the serialized config.
  48089. */
  48090. serialize(): any;
  48091. /**
  48092. * Parses a anisotropy Configuration from a serialized object.
  48093. * @param source - Serialized object.
  48094. * @param scene Defines the scene we are parsing for
  48095. * @param rootUrl Defines the rootUrl to load from
  48096. */
  48097. parse(source: any, scene: Scene, rootUrl: string): void;
  48098. }
  48099. }
  48100. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48101. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48102. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48104. import { Vector2 } from "babylonjs/Maths/math.vector";
  48105. import { Scene } from "babylonjs/scene";
  48106. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48107. import { Nullable } from "babylonjs/types";
  48108. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48109. /**
  48110. * @hidden
  48111. */
  48112. export interface IMaterialAnisotropicDefines {
  48113. ANISOTROPIC: boolean;
  48114. ANISOTROPIC_TEXTURE: boolean;
  48115. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48116. MAINUV1: boolean;
  48117. _areTexturesDirty: boolean;
  48118. _needUVs: boolean;
  48119. }
  48120. /**
  48121. * Define the code related to the anisotropic parameters of the pbr material.
  48122. */
  48123. export class PBRAnisotropicConfiguration {
  48124. private _isEnabled;
  48125. /**
  48126. * Defines if the anisotropy is enabled in the material.
  48127. */
  48128. isEnabled: boolean;
  48129. /**
  48130. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48131. */
  48132. intensity: number;
  48133. /**
  48134. * Defines if the effect is along the tangents, bitangents or in between.
  48135. * By default, the effect is "strectching" the highlights along the tangents.
  48136. */
  48137. direction: Vector2;
  48138. private _texture;
  48139. /**
  48140. * Stores the anisotropy values in a texture.
  48141. * rg is direction (like normal from -1 to 1)
  48142. * b is a intensity
  48143. */
  48144. texture: Nullable<BaseTexture>;
  48145. /** @hidden */
  48146. private _internalMarkAllSubMeshesAsTexturesDirty;
  48147. /** @hidden */
  48148. _markAllSubMeshesAsTexturesDirty(): void;
  48149. /**
  48150. * Instantiate a new istance of anisotropy configuration.
  48151. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48152. */
  48153. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48154. /**
  48155. * Specifies that the submesh is ready to be used.
  48156. * @param defines the list of "defines" to update.
  48157. * @param scene defines the scene the material belongs to.
  48158. * @returns - boolean indicating that the submesh is ready or not.
  48159. */
  48160. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48161. /**
  48162. * Checks to see if a texture is used in the material.
  48163. * @param defines the list of "defines" to update.
  48164. * @param mesh the mesh we are preparing the defines for.
  48165. * @param scene defines the scene the material belongs to.
  48166. */
  48167. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48168. /**
  48169. * Binds the material data.
  48170. * @param uniformBuffer defines the Uniform buffer to fill in.
  48171. * @param scene defines the scene the material belongs to.
  48172. * @param isFrozen defines wether the material is frozen or not.
  48173. */
  48174. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48175. /**
  48176. * Checks to see if a texture is used in the material.
  48177. * @param texture - Base texture to use.
  48178. * @returns - Boolean specifying if a texture is used in the material.
  48179. */
  48180. hasTexture(texture: BaseTexture): boolean;
  48181. /**
  48182. * Returns an array of the actively used textures.
  48183. * @param activeTextures Array of BaseTextures
  48184. */
  48185. getActiveTextures(activeTextures: BaseTexture[]): void;
  48186. /**
  48187. * Returns the animatable textures.
  48188. * @param animatables Array of animatable textures.
  48189. */
  48190. getAnimatables(animatables: IAnimatable[]): void;
  48191. /**
  48192. * Disposes the resources of the material.
  48193. * @param forceDisposeTextures - Forces the disposal of all textures.
  48194. */
  48195. dispose(forceDisposeTextures?: boolean): void;
  48196. /**
  48197. * Get the current class name of the texture useful for serialization or dynamic coding.
  48198. * @returns "PBRAnisotropicConfiguration"
  48199. */
  48200. getClassName(): string;
  48201. /**
  48202. * Add fallbacks to the effect fallbacks list.
  48203. * @param defines defines the Base texture to use.
  48204. * @param fallbacks defines the current fallback list.
  48205. * @param currentRank defines the current fallback rank.
  48206. * @returns the new fallback rank.
  48207. */
  48208. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48209. /**
  48210. * Add the required uniforms to the current list.
  48211. * @param uniforms defines the current uniform list.
  48212. */
  48213. static AddUniforms(uniforms: string[]): void;
  48214. /**
  48215. * Add the required uniforms to the current buffer.
  48216. * @param uniformBuffer defines the current uniform buffer.
  48217. */
  48218. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48219. /**
  48220. * Add the required samplers to the current list.
  48221. * @param samplers defines the current sampler list.
  48222. */
  48223. static AddSamplers(samplers: string[]): void;
  48224. /**
  48225. * Makes a duplicate of the current configuration into another one.
  48226. * @param anisotropicConfiguration define the config where to copy the info
  48227. */
  48228. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48229. /**
  48230. * Serializes this anisotropy configuration.
  48231. * @returns - An object with the serialized config.
  48232. */
  48233. serialize(): any;
  48234. /**
  48235. * Parses a anisotropy Configuration from a serialized object.
  48236. * @param source - Serialized object.
  48237. * @param scene Defines the scene we are parsing for
  48238. * @param rootUrl Defines the rootUrl to load from
  48239. */
  48240. parse(source: any, scene: Scene, rootUrl: string): void;
  48241. }
  48242. }
  48243. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48244. import { Scene } from "babylonjs/scene";
  48245. /**
  48246. * @hidden
  48247. */
  48248. export interface IMaterialBRDFDefines {
  48249. BRDF_V_HEIGHT_CORRELATED: boolean;
  48250. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48251. SPHERICAL_HARMONICS: boolean;
  48252. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48253. /** @hidden */
  48254. _areMiscDirty: boolean;
  48255. }
  48256. /**
  48257. * Define the code related to the BRDF parameters of the pbr material.
  48258. */
  48259. export class PBRBRDFConfiguration {
  48260. /**
  48261. * Default value used for the energy conservation.
  48262. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48263. */
  48264. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48265. /**
  48266. * Default value used for the Smith Visibility Height Correlated mode.
  48267. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48268. */
  48269. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48270. /**
  48271. * Default value used for the IBL diffuse part.
  48272. * This can help switching back to the polynomials mode globally which is a tiny bit
  48273. * less GPU intensive at the drawback of a lower quality.
  48274. */
  48275. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48276. /**
  48277. * Default value used for activating energy conservation for the specular workflow.
  48278. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48279. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48280. */
  48281. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48282. private _useEnergyConservation;
  48283. /**
  48284. * Defines if the material uses energy conservation.
  48285. */
  48286. useEnergyConservation: boolean;
  48287. private _useSmithVisibilityHeightCorrelated;
  48288. /**
  48289. * LEGACY Mode set to false
  48290. * Defines if the material uses height smith correlated visibility term.
  48291. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48292. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48293. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48294. * Not relying on height correlated will also disable energy conservation.
  48295. */
  48296. useSmithVisibilityHeightCorrelated: boolean;
  48297. private _useSphericalHarmonics;
  48298. /**
  48299. * LEGACY Mode set to false
  48300. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48301. * diffuse part of the IBL.
  48302. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48303. * to the ground truth.
  48304. */
  48305. useSphericalHarmonics: boolean;
  48306. private _useSpecularGlossinessInputEnergyConservation;
  48307. /**
  48308. * Defines if the material uses energy conservation, when the specular workflow is active.
  48309. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48310. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48311. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48312. */
  48313. useSpecularGlossinessInputEnergyConservation: boolean;
  48314. /** @hidden */
  48315. private _internalMarkAllSubMeshesAsMiscDirty;
  48316. /** @hidden */
  48317. _markAllSubMeshesAsMiscDirty(): void;
  48318. /**
  48319. * Instantiate a new istance of clear coat configuration.
  48320. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48321. */
  48322. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48323. /**
  48324. * Checks to see if a texture is used in the material.
  48325. * @param defines the list of "defines" to update.
  48326. */
  48327. prepareDefines(defines: IMaterialBRDFDefines): void;
  48328. /**
  48329. * Get the current class name of the texture useful for serialization or dynamic coding.
  48330. * @returns "PBRClearCoatConfiguration"
  48331. */
  48332. getClassName(): string;
  48333. /**
  48334. * Makes a duplicate of the current configuration into another one.
  48335. * @param brdfConfiguration define the config where to copy the info
  48336. */
  48337. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48338. /**
  48339. * Serializes this BRDF configuration.
  48340. * @returns - An object with the serialized config.
  48341. */
  48342. serialize(): any;
  48343. /**
  48344. * Parses a anisotropy Configuration from a serialized object.
  48345. * @param source - Serialized object.
  48346. * @param scene Defines the scene we are parsing for
  48347. * @param rootUrl Defines the rootUrl to load from
  48348. */
  48349. parse(source: any, scene: Scene, rootUrl: string): void;
  48350. }
  48351. }
  48352. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48353. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48354. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48355. import { Color3 } from "babylonjs/Maths/math.color";
  48356. import { Scene } from "babylonjs/scene";
  48357. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48358. import { Nullable } from "babylonjs/types";
  48359. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48360. /**
  48361. * @hidden
  48362. */
  48363. export interface IMaterialSheenDefines {
  48364. SHEEN: boolean;
  48365. SHEEN_TEXTURE: boolean;
  48366. SHEEN_TEXTUREDIRECTUV: number;
  48367. SHEEN_LINKWITHALBEDO: boolean;
  48368. /** @hidden */
  48369. _areTexturesDirty: boolean;
  48370. }
  48371. /**
  48372. * Define the code related to the Sheen parameters of the pbr material.
  48373. */
  48374. export class PBRSheenConfiguration {
  48375. private _isEnabled;
  48376. /**
  48377. * Defines if the material uses sheen.
  48378. */
  48379. isEnabled: boolean;
  48380. private _linkSheenWithAlbedo;
  48381. /**
  48382. * Defines if the sheen is linked to the sheen color.
  48383. */
  48384. linkSheenWithAlbedo: boolean;
  48385. /**
  48386. * Defines the sheen intensity.
  48387. */
  48388. intensity: number;
  48389. /**
  48390. * Defines the sheen color.
  48391. */
  48392. color: Color3;
  48393. private _texture;
  48394. /**
  48395. * Stores the sheen tint values in a texture.
  48396. * rgb is tint
  48397. * a is a intensity
  48398. */
  48399. texture: Nullable<BaseTexture>;
  48400. /** @hidden */
  48401. private _internalMarkAllSubMeshesAsTexturesDirty;
  48402. /** @hidden */
  48403. _markAllSubMeshesAsTexturesDirty(): void;
  48404. /**
  48405. * Instantiate a new istance of clear coat configuration.
  48406. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48407. */
  48408. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48409. /**
  48410. * Specifies that the submesh is ready to be used.
  48411. * @param defines the list of "defines" to update.
  48412. * @param scene defines the scene the material belongs to.
  48413. * @returns - boolean indicating that the submesh is ready or not.
  48414. */
  48415. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48416. /**
  48417. * Checks to see if a texture is used in the material.
  48418. * @param defines the list of "defines" to update.
  48419. * @param scene defines the scene the material belongs to.
  48420. */
  48421. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48422. /**
  48423. * Binds the material data.
  48424. * @param uniformBuffer defines the Uniform buffer to fill in.
  48425. * @param scene defines the scene the material belongs to.
  48426. * @param isFrozen defines wether the material is frozen or not.
  48427. */
  48428. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48429. /**
  48430. * Checks to see if a texture is used in the material.
  48431. * @param texture - Base texture to use.
  48432. * @returns - Boolean specifying if a texture is used in the material.
  48433. */
  48434. hasTexture(texture: BaseTexture): boolean;
  48435. /**
  48436. * Returns an array of the actively used textures.
  48437. * @param activeTextures Array of BaseTextures
  48438. */
  48439. getActiveTextures(activeTextures: BaseTexture[]): void;
  48440. /**
  48441. * Returns the animatable textures.
  48442. * @param animatables Array of animatable textures.
  48443. */
  48444. getAnimatables(animatables: IAnimatable[]): void;
  48445. /**
  48446. * Disposes the resources of the material.
  48447. * @param forceDisposeTextures - Forces the disposal of all textures.
  48448. */
  48449. dispose(forceDisposeTextures?: boolean): void;
  48450. /**
  48451. * Get the current class name of the texture useful for serialization or dynamic coding.
  48452. * @returns "PBRSheenConfiguration"
  48453. */
  48454. getClassName(): string;
  48455. /**
  48456. * Add fallbacks to the effect fallbacks list.
  48457. * @param defines defines the Base texture to use.
  48458. * @param fallbacks defines the current fallback list.
  48459. * @param currentRank defines the current fallback rank.
  48460. * @returns the new fallback rank.
  48461. */
  48462. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48463. /**
  48464. * Add the required uniforms to the current list.
  48465. * @param uniforms defines the current uniform list.
  48466. */
  48467. static AddUniforms(uniforms: string[]): void;
  48468. /**
  48469. * Add the required uniforms to the current buffer.
  48470. * @param uniformBuffer defines the current uniform buffer.
  48471. */
  48472. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48473. /**
  48474. * Add the required samplers to the current list.
  48475. * @param samplers defines the current sampler list.
  48476. */
  48477. static AddSamplers(samplers: string[]): void;
  48478. /**
  48479. * Makes a duplicate of the current configuration into another one.
  48480. * @param sheenConfiguration define the config where to copy the info
  48481. */
  48482. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48483. /**
  48484. * Serializes this BRDF configuration.
  48485. * @returns - An object with the serialized config.
  48486. */
  48487. serialize(): any;
  48488. /**
  48489. * Parses a anisotropy Configuration from a serialized object.
  48490. * @param source - Serialized object.
  48491. * @param scene Defines the scene we are parsing for
  48492. * @param rootUrl Defines the rootUrl to load from
  48493. */
  48494. parse(source: any, scene: Scene, rootUrl: string): void;
  48495. }
  48496. }
  48497. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  48498. import { Nullable } from "babylonjs/types";
  48499. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48500. import { Color3 } from "babylonjs/Maths/math.color";
  48501. import { SmartArray } from "babylonjs/Misc/smartArray";
  48502. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48503. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48504. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  48505. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48506. import { Engine } from "babylonjs/Engines/engine";
  48507. import { Scene } from "babylonjs/scene";
  48508. /**
  48509. * @hidden
  48510. */
  48511. export interface IMaterialSubSurfaceDefines {
  48512. SUBSURFACE: boolean;
  48513. SS_REFRACTION: boolean;
  48514. SS_TRANSLUCENCY: boolean;
  48515. SS_SCATERRING: boolean;
  48516. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48517. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48518. SS_REFRACTIONMAP_3D: boolean;
  48519. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48520. SS_LODINREFRACTIONALPHA: boolean;
  48521. SS_GAMMAREFRACTION: boolean;
  48522. SS_RGBDREFRACTION: boolean;
  48523. SS_LINEARSPECULARREFRACTION: boolean;
  48524. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48525. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48526. /** @hidden */
  48527. _areTexturesDirty: boolean;
  48528. }
  48529. /**
  48530. * Define the code related to the sub surface parameters of the pbr material.
  48531. */
  48532. export class PBRSubSurfaceConfiguration {
  48533. private _isRefractionEnabled;
  48534. /**
  48535. * Defines if the refraction is enabled in the material.
  48536. */
  48537. isRefractionEnabled: boolean;
  48538. private _isTranslucencyEnabled;
  48539. /**
  48540. * Defines if the translucency is enabled in the material.
  48541. */
  48542. isTranslucencyEnabled: boolean;
  48543. private _isScatteringEnabled;
  48544. /**
  48545. * Defines the refraction intensity of the material.
  48546. * The refraction when enabled replaces the Diffuse part of the material.
  48547. * The intensity helps transitionning between diffuse and refraction.
  48548. */
  48549. refractionIntensity: number;
  48550. /**
  48551. * Defines the translucency intensity of the material.
  48552. * When translucency has been enabled, this defines how much of the "translucency"
  48553. * is addded to the diffuse part of the material.
  48554. */
  48555. translucencyIntensity: number;
  48556. /**
  48557. * Defines the scattering intensity of the material.
  48558. * When scattering has been enabled, this defines how much of the "scattered light"
  48559. * is addded to the diffuse part of the material.
  48560. */
  48561. scatteringIntensity: number;
  48562. private _thicknessTexture;
  48563. /**
  48564. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48565. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48566. * 0 would mean minimumThickness
  48567. * 1 would mean maximumThickness
  48568. * The other channels might be use as a mask to vary the different effects intensity.
  48569. */
  48570. thicknessTexture: Nullable<BaseTexture>;
  48571. private _refractionTexture;
  48572. /**
  48573. * Defines the texture to use for refraction.
  48574. */
  48575. refractionTexture: Nullable<BaseTexture>;
  48576. private _indexOfRefraction;
  48577. /**
  48578. * Defines the index of refraction used in the material.
  48579. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48580. */
  48581. indexOfRefraction: number;
  48582. private _invertRefractionY;
  48583. /**
  48584. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48585. */
  48586. invertRefractionY: boolean;
  48587. private _linkRefractionWithTransparency;
  48588. /**
  48589. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48590. * Materials half opaque for instance using refraction could benefit from this control.
  48591. */
  48592. linkRefractionWithTransparency: boolean;
  48593. /**
  48594. * Defines the minimum thickness stored in the thickness map.
  48595. * If no thickness map is defined, this value will be used to simulate thickness.
  48596. */
  48597. minimumThickness: number;
  48598. /**
  48599. * Defines the maximum thickness stored in the thickness map.
  48600. */
  48601. maximumThickness: number;
  48602. /**
  48603. * Defines the volume tint of the material.
  48604. * This is used for both translucency and scattering.
  48605. */
  48606. tintColor: Color3;
  48607. /**
  48608. * Defines the distance at which the tint color should be found in the media.
  48609. * This is used for refraction only.
  48610. */
  48611. tintColorAtDistance: number;
  48612. /**
  48613. * Defines how far each channel transmit through the media.
  48614. * It is defined as a color to simplify it selection.
  48615. */
  48616. diffusionDistance: Color3;
  48617. private _useMaskFromThicknessTexture;
  48618. /**
  48619. * Stores the intensity of the different subsurface effects in the thickness texture.
  48620. * * the green channel is the translucency intensity.
  48621. * * the blue channel is the scattering intensity.
  48622. * * the alpha channel is the refraction intensity.
  48623. */
  48624. useMaskFromThicknessTexture: boolean;
  48625. /** @hidden */
  48626. private _internalMarkAllSubMeshesAsTexturesDirty;
  48627. /** @hidden */
  48628. _markAllSubMeshesAsTexturesDirty(): void;
  48629. /**
  48630. * Instantiate a new istance of sub surface configuration.
  48631. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48632. */
  48633. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48634. /**
  48635. * Gets wehter the submesh is ready to be used or not.
  48636. * @param defines the list of "defines" to update.
  48637. * @param scene defines the scene the material belongs to.
  48638. * @returns - boolean indicating that the submesh is ready or not.
  48639. */
  48640. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48641. /**
  48642. * Checks to see if a texture is used in the material.
  48643. * @param defines the list of "defines" to update.
  48644. * @param scene defines the scene to the material belongs to.
  48645. */
  48646. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48647. /**
  48648. * Binds the material data.
  48649. * @param uniformBuffer defines the Uniform buffer to fill in.
  48650. * @param scene defines the scene the material belongs to.
  48651. * @param engine defines the engine the material belongs to.
  48652. * @param isFrozen defines wether the material is frozen or not.
  48653. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48654. */
  48655. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48656. /**
  48657. * Unbinds the material from the mesh.
  48658. * @param activeEffect defines the effect that should be unbound from.
  48659. * @returns true if unbound, otherwise false
  48660. */
  48661. unbind(activeEffect: Effect): boolean;
  48662. /**
  48663. * Returns the texture used for refraction or null if none is used.
  48664. * @param scene defines the scene the material belongs to.
  48665. * @returns - Refraction texture if present. If no refraction texture and refraction
  48666. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48667. */
  48668. private _getRefractionTexture;
  48669. /**
  48670. * Returns true if alpha blending should be disabled.
  48671. */
  48672. readonly disableAlphaBlending: boolean;
  48673. /**
  48674. * Fills the list of render target textures.
  48675. * @param renderTargets the list of render targets to update
  48676. */
  48677. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48678. /**
  48679. * Checks to see if a texture is used in the material.
  48680. * @param texture - Base texture to use.
  48681. * @returns - Boolean specifying if a texture is used in the material.
  48682. */
  48683. hasTexture(texture: BaseTexture): boolean;
  48684. /**
  48685. * Gets a boolean indicating that current material needs to register RTT
  48686. * @returns true if this uses a render target otherwise false.
  48687. */
  48688. hasRenderTargetTextures(): boolean;
  48689. /**
  48690. * Returns an array of the actively used textures.
  48691. * @param activeTextures Array of BaseTextures
  48692. */
  48693. getActiveTextures(activeTextures: BaseTexture[]): void;
  48694. /**
  48695. * Returns the animatable textures.
  48696. * @param animatables Array of animatable textures.
  48697. */
  48698. getAnimatables(animatables: IAnimatable[]): void;
  48699. /**
  48700. * Disposes the resources of the material.
  48701. * @param forceDisposeTextures - Forces the disposal of all textures.
  48702. */
  48703. dispose(forceDisposeTextures?: boolean): void;
  48704. /**
  48705. * Get the current class name of the texture useful for serialization or dynamic coding.
  48706. * @returns "PBRSubSurfaceConfiguration"
  48707. */
  48708. getClassName(): string;
  48709. /**
  48710. * Add fallbacks to the effect fallbacks list.
  48711. * @param defines defines the Base texture to use.
  48712. * @param fallbacks defines the current fallback list.
  48713. * @param currentRank defines the current fallback rank.
  48714. * @returns the new fallback rank.
  48715. */
  48716. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48717. /**
  48718. * Add the required uniforms to the current list.
  48719. * @param uniforms defines the current uniform list.
  48720. */
  48721. static AddUniforms(uniforms: string[]): void;
  48722. /**
  48723. * Add the required samplers to the current list.
  48724. * @param samplers defines the current sampler list.
  48725. */
  48726. static AddSamplers(samplers: string[]): void;
  48727. /**
  48728. * Add the required uniforms to the current buffer.
  48729. * @param uniformBuffer defines the current uniform buffer.
  48730. */
  48731. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48732. /**
  48733. * Makes a duplicate of the current configuration into another one.
  48734. * @param configuration define the config where to copy the info
  48735. */
  48736. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48737. /**
  48738. * Serializes this Sub Surface configuration.
  48739. * @returns - An object with the serialized config.
  48740. */
  48741. serialize(): any;
  48742. /**
  48743. * Parses a anisotropy Configuration from a serialized object.
  48744. * @param source - Serialized object.
  48745. * @param scene Defines the scene we are parsing for
  48746. * @param rootUrl Defines the rootUrl to load from
  48747. */
  48748. parse(source: any, scene: Scene, rootUrl: string): void;
  48749. }
  48750. }
  48751. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48752. /** @hidden */
  48753. export var pbrFragmentDeclaration: {
  48754. name: string;
  48755. shader: string;
  48756. };
  48757. }
  48758. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48759. /** @hidden */
  48760. export var pbrUboDeclaration: {
  48761. name: string;
  48762. shader: string;
  48763. };
  48764. }
  48765. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48766. /** @hidden */
  48767. export var pbrFragmentExtraDeclaration: {
  48768. name: string;
  48769. shader: string;
  48770. };
  48771. }
  48772. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48773. /** @hidden */
  48774. export var pbrFragmentSamplersDeclaration: {
  48775. name: string;
  48776. shader: string;
  48777. };
  48778. }
  48779. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48780. /** @hidden */
  48781. export var pbrHelperFunctions: {
  48782. name: string;
  48783. shader: string;
  48784. };
  48785. }
  48786. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48787. /** @hidden */
  48788. export var harmonicsFunctions: {
  48789. name: string;
  48790. shader: string;
  48791. };
  48792. }
  48793. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48794. /** @hidden */
  48795. export var pbrDirectLightingSetupFunctions: {
  48796. name: string;
  48797. shader: string;
  48798. };
  48799. }
  48800. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48801. /** @hidden */
  48802. export var pbrDirectLightingFalloffFunctions: {
  48803. name: string;
  48804. shader: string;
  48805. };
  48806. }
  48807. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48808. /** @hidden */
  48809. export var pbrBRDFFunctions: {
  48810. name: string;
  48811. shader: string;
  48812. };
  48813. }
  48814. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48815. /** @hidden */
  48816. export var pbrDirectLightingFunctions: {
  48817. name: string;
  48818. shader: string;
  48819. };
  48820. }
  48821. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48822. /** @hidden */
  48823. export var pbrIBLFunctions: {
  48824. name: string;
  48825. shader: string;
  48826. };
  48827. }
  48828. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48829. /** @hidden */
  48830. export var pbrDebug: {
  48831. name: string;
  48832. shader: string;
  48833. };
  48834. }
  48835. declare module "babylonjs/Shaders/pbr.fragment" {
  48836. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48837. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48838. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48839. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48840. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48841. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48842. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48843. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48844. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48845. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48846. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48847. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48848. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48849. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48850. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48851. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48852. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48853. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48854. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48855. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48856. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48857. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48858. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48859. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48860. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48861. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48862. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48863. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48864. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48865. /** @hidden */
  48866. export var pbrPixelShader: {
  48867. name: string;
  48868. shader: string;
  48869. };
  48870. }
  48871. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48872. /** @hidden */
  48873. export var pbrVertexDeclaration: {
  48874. name: string;
  48875. shader: string;
  48876. };
  48877. }
  48878. declare module "babylonjs/Shaders/pbr.vertex" {
  48879. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48880. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48881. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48882. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48883. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48884. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48885. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48886. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48887. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48888. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48889. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48890. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48891. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48892. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48893. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48894. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48895. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48896. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48897. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48898. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48899. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48900. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48901. /** @hidden */
  48902. export var pbrVertexShader: {
  48903. name: string;
  48904. shader: string;
  48905. };
  48906. }
  48907. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48908. import { Nullable } from "babylonjs/types";
  48909. import { Scene } from "babylonjs/scene";
  48910. import { Matrix } from "babylonjs/Maths/math.vector";
  48911. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48913. import { Mesh } from "babylonjs/Meshes/mesh";
  48914. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48915. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48916. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48917. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48918. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48919. import { Color3 } from "babylonjs/Maths/math.color";
  48920. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48921. import { Material } from "babylonjs/Materials/material";
  48922. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48923. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48924. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48925. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48926. import "babylonjs/Shaders/pbr.fragment";
  48927. import "babylonjs/Shaders/pbr.vertex";
  48928. /**
  48929. * Manages the defines for the PBR Material.
  48930. * @hidden
  48931. */
  48932. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48933. PBR: boolean;
  48934. MAINUV1: boolean;
  48935. MAINUV2: boolean;
  48936. UV1: boolean;
  48937. UV2: boolean;
  48938. ALBEDO: boolean;
  48939. ALBEDODIRECTUV: number;
  48940. VERTEXCOLOR: boolean;
  48941. AMBIENT: boolean;
  48942. AMBIENTDIRECTUV: number;
  48943. AMBIENTINGRAYSCALE: boolean;
  48944. OPACITY: boolean;
  48945. VERTEXALPHA: boolean;
  48946. OPACITYDIRECTUV: number;
  48947. OPACITYRGB: boolean;
  48948. ALPHATEST: boolean;
  48949. DEPTHPREPASS: boolean;
  48950. ALPHABLEND: boolean;
  48951. ALPHAFROMALBEDO: boolean;
  48952. ALPHATESTVALUE: string;
  48953. SPECULAROVERALPHA: boolean;
  48954. RADIANCEOVERALPHA: boolean;
  48955. ALPHAFRESNEL: boolean;
  48956. LINEARALPHAFRESNEL: boolean;
  48957. PREMULTIPLYALPHA: boolean;
  48958. EMISSIVE: boolean;
  48959. EMISSIVEDIRECTUV: number;
  48960. REFLECTIVITY: boolean;
  48961. REFLECTIVITYDIRECTUV: number;
  48962. SPECULARTERM: boolean;
  48963. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48964. MICROSURFACEAUTOMATIC: boolean;
  48965. LODBASEDMICROSFURACE: boolean;
  48966. MICROSURFACEMAP: boolean;
  48967. MICROSURFACEMAPDIRECTUV: number;
  48968. METALLICWORKFLOW: boolean;
  48969. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48970. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48971. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48972. AOSTOREINMETALMAPRED: boolean;
  48973. ENVIRONMENTBRDF: boolean;
  48974. ENVIRONMENTBRDF_RGBD: boolean;
  48975. NORMAL: boolean;
  48976. TANGENT: boolean;
  48977. BUMP: boolean;
  48978. BUMPDIRECTUV: number;
  48979. OBJECTSPACE_NORMALMAP: boolean;
  48980. PARALLAX: boolean;
  48981. PARALLAXOCCLUSION: boolean;
  48982. NORMALXYSCALE: boolean;
  48983. LIGHTMAP: boolean;
  48984. LIGHTMAPDIRECTUV: number;
  48985. USELIGHTMAPASSHADOWMAP: boolean;
  48986. GAMMALIGHTMAP: boolean;
  48987. RGBDLIGHTMAP: boolean;
  48988. REFLECTION: boolean;
  48989. REFLECTIONMAP_3D: boolean;
  48990. REFLECTIONMAP_SPHERICAL: boolean;
  48991. REFLECTIONMAP_PLANAR: boolean;
  48992. REFLECTIONMAP_CUBIC: boolean;
  48993. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48994. REFLECTIONMAP_PROJECTION: boolean;
  48995. REFLECTIONMAP_SKYBOX: boolean;
  48996. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48997. REFLECTIONMAP_EXPLICIT: boolean;
  48998. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48999. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49000. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49001. INVERTCUBICMAP: boolean;
  49002. USESPHERICALFROMREFLECTIONMAP: boolean;
  49003. USEIRRADIANCEMAP: boolean;
  49004. SPHERICAL_HARMONICS: boolean;
  49005. USESPHERICALINVERTEX: boolean;
  49006. REFLECTIONMAP_OPPOSITEZ: boolean;
  49007. LODINREFLECTIONALPHA: boolean;
  49008. GAMMAREFLECTION: boolean;
  49009. RGBDREFLECTION: boolean;
  49010. LINEARSPECULARREFLECTION: boolean;
  49011. RADIANCEOCCLUSION: boolean;
  49012. HORIZONOCCLUSION: boolean;
  49013. INSTANCES: boolean;
  49014. NUM_BONE_INFLUENCERS: number;
  49015. BonesPerMesh: number;
  49016. BONETEXTURE: boolean;
  49017. NONUNIFORMSCALING: boolean;
  49018. MORPHTARGETS: boolean;
  49019. MORPHTARGETS_NORMAL: boolean;
  49020. MORPHTARGETS_TANGENT: boolean;
  49021. MORPHTARGETS_UV: boolean;
  49022. NUM_MORPH_INFLUENCERS: number;
  49023. IMAGEPROCESSING: boolean;
  49024. VIGNETTE: boolean;
  49025. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49026. VIGNETTEBLENDMODEOPAQUE: boolean;
  49027. TONEMAPPING: boolean;
  49028. TONEMAPPING_ACES: boolean;
  49029. CONTRAST: boolean;
  49030. COLORCURVES: boolean;
  49031. COLORGRADING: boolean;
  49032. COLORGRADING3D: boolean;
  49033. SAMPLER3DGREENDEPTH: boolean;
  49034. SAMPLER3DBGRMAP: boolean;
  49035. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49036. EXPOSURE: boolean;
  49037. MULTIVIEW: boolean;
  49038. USEPHYSICALLIGHTFALLOFF: boolean;
  49039. USEGLTFLIGHTFALLOFF: boolean;
  49040. TWOSIDEDLIGHTING: boolean;
  49041. SHADOWFLOAT: boolean;
  49042. CLIPPLANE: boolean;
  49043. CLIPPLANE2: boolean;
  49044. CLIPPLANE3: boolean;
  49045. CLIPPLANE4: boolean;
  49046. POINTSIZE: boolean;
  49047. FOG: boolean;
  49048. LOGARITHMICDEPTH: boolean;
  49049. FORCENORMALFORWARD: boolean;
  49050. SPECULARAA: boolean;
  49051. CLEARCOAT: boolean;
  49052. CLEARCOAT_DEFAULTIOR: boolean;
  49053. CLEARCOAT_TEXTURE: boolean;
  49054. CLEARCOAT_TEXTUREDIRECTUV: number;
  49055. CLEARCOAT_BUMP: boolean;
  49056. CLEARCOAT_BUMPDIRECTUV: number;
  49057. CLEARCOAT_TINT: boolean;
  49058. CLEARCOAT_TINT_TEXTURE: boolean;
  49059. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49060. ANISOTROPIC: boolean;
  49061. ANISOTROPIC_TEXTURE: boolean;
  49062. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49063. BRDF_V_HEIGHT_CORRELATED: boolean;
  49064. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49065. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49066. SHEEN: boolean;
  49067. SHEEN_TEXTURE: boolean;
  49068. SHEEN_TEXTUREDIRECTUV: number;
  49069. SHEEN_LINKWITHALBEDO: boolean;
  49070. SUBSURFACE: boolean;
  49071. SS_REFRACTION: boolean;
  49072. SS_TRANSLUCENCY: boolean;
  49073. SS_SCATERRING: boolean;
  49074. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49075. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49076. SS_REFRACTIONMAP_3D: boolean;
  49077. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49078. SS_LODINREFRACTIONALPHA: boolean;
  49079. SS_GAMMAREFRACTION: boolean;
  49080. SS_RGBDREFRACTION: boolean;
  49081. SS_LINEARSPECULARREFRACTION: boolean;
  49082. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49083. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49084. UNLIT: boolean;
  49085. DEBUGMODE: number;
  49086. /**
  49087. * Initializes the PBR Material defines.
  49088. */
  49089. constructor();
  49090. /**
  49091. * Resets the PBR Material defines.
  49092. */
  49093. reset(): void;
  49094. }
  49095. /**
  49096. * The Physically based material base class of BJS.
  49097. *
  49098. * This offers the main features of a standard PBR material.
  49099. * For more information, please refer to the documentation :
  49100. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49101. */
  49102. export abstract class PBRBaseMaterial extends PushMaterial {
  49103. /**
  49104. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49105. */
  49106. static readonly PBRMATERIAL_OPAQUE: number;
  49107. /**
  49108. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49109. */
  49110. static readonly PBRMATERIAL_ALPHATEST: number;
  49111. /**
  49112. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49113. */
  49114. static readonly PBRMATERIAL_ALPHABLEND: number;
  49115. /**
  49116. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49117. * They are also discarded below the alpha cutoff threshold to improve performances.
  49118. */
  49119. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49120. /**
  49121. * Defines the default value of how much AO map is occluding the analytical lights
  49122. * (point spot...).
  49123. */
  49124. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49125. /**
  49126. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49127. */
  49128. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49129. /**
  49130. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49131. * to enhance interoperability with other engines.
  49132. */
  49133. static readonly LIGHTFALLOFF_GLTF: number;
  49134. /**
  49135. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49136. * to enhance interoperability with other materials.
  49137. */
  49138. static readonly LIGHTFALLOFF_STANDARD: number;
  49139. /**
  49140. * Intensity of the direct lights e.g. the four lights available in your scene.
  49141. * This impacts both the direct diffuse and specular highlights.
  49142. */
  49143. protected _directIntensity: number;
  49144. /**
  49145. * Intensity of the emissive part of the material.
  49146. * This helps controlling the emissive effect without modifying the emissive color.
  49147. */
  49148. protected _emissiveIntensity: number;
  49149. /**
  49150. * Intensity of the environment e.g. how much the environment will light the object
  49151. * either through harmonics for rough material or through the refelction for shiny ones.
  49152. */
  49153. protected _environmentIntensity: number;
  49154. /**
  49155. * This is a special control allowing the reduction of the specular highlights coming from the
  49156. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49157. */
  49158. protected _specularIntensity: number;
  49159. /**
  49160. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49161. */
  49162. private _lightingInfos;
  49163. /**
  49164. * Debug Control allowing disabling the bump map on this material.
  49165. */
  49166. protected _disableBumpMap: boolean;
  49167. /**
  49168. * AKA Diffuse Texture in standard nomenclature.
  49169. */
  49170. protected _albedoTexture: Nullable<BaseTexture>;
  49171. /**
  49172. * AKA Occlusion Texture in other nomenclature.
  49173. */
  49174. protected _ambientTexture: Nullable<BaseTexture>;
  49175. /**
  49176. * AKA Occlusion Texture Intensity in other nomenclature.
  49177. */
  49178. protected _ambientTextureStrength: number;
  49179. /**
  49180. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49181. * 1 means it completely occludes it
  49182. * 0 mean it has no impact
  49183. */
  49184. protected _ambientTextureImpactOnAnalyticalLights: number;
  49185. /**
  49186. * Stores the alpha values in a texture.
  49187. */
  49188. protected _opacityTexture: Nullable<BaseTexture>;
  49189. /**
  49190. * Stores the reflection values in a texture.
  49191. */
  49192. protected _reflectionTexture: Nullable<BaseTexture>;
  49193. /**
  49194. * Stores the emissive values in a texture.
  49195. */
  49196. protected _emissiveTexture: Nullable<BaseTexture>;
  49197. /**
  49198. * AKA Specular texture in other nomenclature.
  49199. */
  49200. protected _reflectivityTexture: Nullable<BaseTexture>;
  49201. /**
  49202. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49203. */
  49204. protected _metallicTexture: Nullable<BaseTexture>;
  49205. /**
  49206. * Specifies the metallic scalar of the metallic/roughness workflow.
  49207. * Can also be used to scale the metalness values of the metallic texture.
  49208. */
  49209. protected _metallic: Nullable<number>;
  49210. /**
  49211. * Specifies the roughness scalar of the metallic/roughness workflow.
  49212. * Can also be used to scale the roughness values of the metallic texture.
  49213. */
  49214. protected _roughness: Nullable<number>;
  49215. /**
  49216. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49217. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49218. */
  49219. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49220. /**
  49221. * Stores surface normal data used to displace a mesh in a texture.
  49222. */
  49223. protected _bumpTexture: Nullable<BaseTexture>;
  49224. /**
  49225. * Stores the pre-calculated light information of a mesh in a texture.
  49226. */
  49227. protected _lightmapTexture: Nullable<BaseTexture>;
  49228. /**
  49229. * The color of a material in ambient lighting.
  49230. */
  49231. protected _ambientColor: Color3;
  49232. /**
  49233. * AKA Diffuse Color in other nomenclature.
  49234. */
  49235. protected _albedoColor: Color3;
  49236. /**
  49237. * AKA Specular Color in other nomenclature.
  49238. */
  49239. protected _reflectivityColor: Color3;
  49240. /**
  49241. * The color applied when light is reflected from a material.
  49242. */
  49243. protected _reflectionColor: Color3;
  49244. /**
  49245. * The color applied when light is emitted from a material.
  49246. */
  49247. protected _emissiveColor: Color3;
  49248. /**
  49249. * AKA Glossiness in other nomenclature.
  49250. */
  49251. protected _microSurface: number;
  49252. /**
  49253. * Specifies that the material will use the light map as a show map.
  49254. */
  49255. protected _useLightmapAsShadowmap: boolean;
  49256. /**
  49257. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49258. * makes the reflect vector face the model (under horizon).
  49259. */
  49260. protected _useHorizonOcclusion: boolean;
  49261. /**
  49262. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49263. * too much the area relying on ambient texture to define their ambient occlusion.
  49264. */
  49265. protected _useRadianceOcclusion: boolean;
  49266. /**
  49267. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49268. */
  49269. protected _useAlphaFromAlbedoTexture: boolean;
  49270. /**
  49271. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49272. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49273. */
  49274. protected _useSpecularOverAlpha: boolean;
  49275. /**
  49276. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49277. */
  49278. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49279. /**
  49280. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49281. */
  49282. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49283. /**
  49284. * Specifies if the metallic texture contains the roughness information in its green channel.
  49285. */
  49286. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49287. /**
  49288. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49289. */
  49290. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49291. /**
  49292. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49293. */
  49294. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49295. /**
  49296. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49297. */
  49298. protected _useAmbientInGrayScale: boolean;
  49299. /**
  49300. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49301. * The material will try to infer what glossiness each pixel should be.
  49302. */
  49303. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49304. /**
  49305. * Defines the falloff type used in this material.
  49306. * It by default is Physical.
  49307. */
  49308. protected _lightFalloff: number;
  49309. /**
  49310. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49311. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49312. */
  49313. protected _useRadianceOverAlpha: boolean;
  49314. /**
  49315. * Allows using an object space normal map (instead of tangent space).
  49316. */
  49317. protected _useObjectSpaceNormalMap: boolean;
  49318. /**
  49319. * Allows using the bump map in parallax mode.
  49320. */
  49321. protected _useParallax: boolean;
  49322. /**
  49323. * Allows using the bump map in parallax occlusion mode.
  49324. */
  49325. protected _useParallaxOcclusion: boolean;
  49326. /**
  49327. * Controls the scale bias of the parallax mode.
  49328. */
  49329. protected _parallaxScaleBias: number;
  49330. /**
  49331. * If sets to true, disables all the lights affecting the material.
  49332. */
  49333. protected _disableLighting: boolean;
  49334. /**
  49335. * Number of Simultaneous lights allowed on the material.
  49336. */
  49337. protected _maxSimultaneousLights: number;
  49338. /**
  49339. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49340. */
  49341. protected _invertNormalMapX: boolean;
  49342. /**
  49343. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49344. */
  49345. protected _invertNormalMapY: boolean;
  49346. /**
  49347. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49348. */
  49349. protected _twoSidedLighting: boolean;
  49350. /**
  49351. * Defines the alpha limits in alpha test mode.
  49352. */
  49353. protected _alphaCutOff: number;
  49354. /**
  49355. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49356. */
  49357. protected _forceAlphaTest: boolean;
  49358. /**
  49359. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49360. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49361. */
  49362. protected _useAlphaFresnel: boolean;
  49363. /**
  49364. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49365. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49366. */
  49367. protected _useLinearAlphaFresnel: boolean;
  49368. /**
  49369. * The transparency mode of the material.
  49370. */
  49371. protected _transparencyMode: Nullable<number>;
  49372. /**
  49373. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49374. * from cos thetav and roughness:
  49375. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49376. */
  49377. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49378. /**
  49379. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49380. */
  49381. protected _forceIrradianceInFragment: boolean;
  49382. /**
  49383. * Force normal to face away from face.
  49384. */
  49385. protected _forceNormalForward: boolean;
  49386. /**
  49387. * Enables specular anti aliasing in the PBR shader.
  49388. * It will both interacts on the Geometry for analytical and IBL lighting.
  49389. * It also prefilter the roughness map based on the bump values.
  49390. */
  49391. protected _enableSpecularAntiAliasing: boolean;
  49392. /**
  49393. * Default configuration related to image processing available in the PBR Material.
  49394. */
  49395. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49396. /**
  49397. * Keep track of the image processing observer to allow dispose and replace.
  49398. */
  49399. private _imageProcessingObserver;
  49400. /**
  49401. * Attaches a new image processing configuration to the PBR Material.
  49402. * @param configuration
  49403. */
  49404. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49405. /**
  49406. * Stores the available render targets.
  49407. */
  49408. private _renderTargets;
  49409. /**
  49410. * Sets the global ambient color for the material used in lighting calculations.
  49411. */
  49412. private _globalAmbientColor;
  49413. /**
  49414. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49415. */
  49416. private _useLogarithmicDepth;
  49417. /**
  49418. * If set to true, no lighting calculations will be applied.
  49419. */
  49420. private _unlit;
  49421. private _debugMode;
  49422. /**
  49423. * @hidden
  49424. * This is reserved for the inspector.
  49425. * Defines the material debug mode.
  49426. * It helps seeing only some components of the material while troubleshooting.
  49427. */
  49428. debugMode: number;
  49429. /**
  49430. * @hidden
  49431. * This is reserved for the inspector.
  49432. * Specify from where on screen the debug mode should start.
  49433. * The value goes from -1 (full screen) to 1 (not visible)
  49434. * It helps with side by side comparison against the final render
  49435. * This defaults to -1
  49436. */
  49437. private debugLimit;
  49438. /**
  49439. * @hidden
  49440. * This is reserved for the inspector.
  49441. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49442. * You can use the factor to better multiply the final value.
  49443. */
  49444. private debugFactor;
  49445. /**
  49446. * Defines the clear coat layer parameters for the material.
  49447. */
  49448. readonly clearCoat: PBRClearCoatConfiguration;
  49449. /**
  49450. * Defines the anisotropic parameters for the material.
  49451. */
  49452. readonly anisotropy: PBRAnisotropicConfiguration;
  49453. /**
  49454. * Defines the BRDF parameters for the material.
  49455. */
  49456. readonly brdf: PBRBRDFConfiguration;
  49457. /**
  49458. * Defines the Sheen parameters for the material.
  49459. */
  49460. readonly sheen: PBRSheenConfiguration;
  49461. /**
  49462. * Defines the SubSurface parameters for the material.
  49463. */
  49464. readonly subSurface: PBRSubSurfaceConfiguration;
  49465. /**
  49466. * Custom callback helping to override the default shader used in the material.
  49467. */
  49468. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49469. protected _rebuildInParallel: boolean;
  49470. /**
  49471. * Instantiates a new PBRMaterial instance.
  49472. *
  49473. * @param name The material name
  49474. * @param scene The scene the material will be use in.
  49475. */
  49476. constructor(name: string, scene: Scene);
  49477. /**
  49478. * Gets a boolean indicating that current material needs to register RTT
  49479. */
  49480. readonly hasRenderTargetTextures: boolean;
  49481. /**
  49482. * Gets the name of the material class.
  49483. */
  49484. getClassName(): string;
  49485. /**
  49486. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49487. */
  49488. /**
  49489. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49490. */
  49491. useLogarithmicDepth: boolean;
  49492. /**
  49493. * Gets the current transparency mode.
  49494. */
  49495. /**
  49496. * Sets the transparency mode of the material.
  49497. *
  49498. * | Value | Type | Description |
  49499. * | ----- | ----------------------------------- | ----------- |
  49500. * | 0 | OPAQUE | |
  49501. * | 1 | ALPHATEST | |
  49502. * | 2 | ALPHABLEND | |
  49503. * | 3 | ALPHATESTANDBLEND | |
  49504. *
  49505. */
  49506. transparencyMode: Nullable<number>;
  49507. /**
  49508. * Returns true if alpha blending should be disabled.
  49509. */
  49510. private readonly _disableAlphaBlending;
  49511. /**
  49512. * Specifies whether or not this material should be rendered in alpha blend mode.
  49513. */
  49514. needAlphaBlending(): boolean;
  49515. /**
  49516. * Specifies if the mesh will require alpha blending.
  49517. * @param mesh - BJS mesh.
  49518. */
  49519. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  49520. /**
  49521. * Specifies whether or not this material should be rendered in alpha test mode.
  49522. */
  49523. needAlphaTesting(): boolean;
  49524. /**
  49525. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  49526. */
  49527. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  49528. /**
  49529. * Gets the texture used for the alpha test.
  49530. */
  49531. getAlphaTestTexture(): Nullable<BaseTexture>;
  49532. /**
  49533. * Specifies that the submesh is ready to be used.
  49534. * @param mesh - BJS mesh.
  49535. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  49536. * @param useInstances - Specifies that instances should be used.
  49537. * @returns - boolean indicating that the submesh is ready or not.
  49538. */
  49539. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49540. /**
  49541. * Specifies if the material uses metallic roughness workflow.
  49542. * @returns boolean specifiying if the material uses metallic roughness workflow.
  49543. */
  49544. isMetallicWorkflow(): boolean;
  49545. private _prepareEffect;
  49546. private _prepareDefines;
  49547. /**
  49548. * Force shader compilation
  49549. */
  49550. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  49551. clipPlane: boolean;
  49552. }>): void;
  49553. /**
  49554. * Initializes the uniform buffer layout for the shader.
  49555. */
  49556. buildUniformLayout(): void;
  49557. /**
  49558. * Unbinds the material from the mesh
  49559. */
  49560. unbind(): void;
  49561. /**
  49562. * Binds the submesh data.
  49563. * @param world - The world matrix.
  49564. * @param mesh - The BJS mesh.
  49565. * @param subMesh - A submesh of the BJS mesh.
  49566. */
  49567. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49568. /**
  49569. * Returns the animatable textures.
  49570. * @returns - Array of animatable textures.
  49571. */
  49572. getAnimatables(): IAnimatable[];
  49573. /**
  49574. * Returns the texture used for reflections.
  49575. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49576. */
  49577. private _getReflectionTexture;
  49578. /**
  49579. * Returns an array of the actively used textures.
  49580. * @returns - Array of BaseTextures
  49581. */
  49582. getActiveTextures(): BaseTexture[];
  49583. /**
  49584. * Checks to see if a texture is used in the material.
  49585. * @param texture - Base texture to use.
  49586. * @returns - Boolean specifying if a texture is used in the material.
  49587. */
  49588. hasTexture(texture: BaseTexture): boolean;
  49589. /**
  49590. * Disposes the resources of the material.
  49591. * @param forceDisposeEffect - Forces the disposal of effects.
  49592. * @param forceDisposeTextures - Forces the disposal of all textures.
  49593. */
  49594. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49595. }
  49596. }
  49597. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  49598. import { Nullable } from "babylonjs/types";
  49599. import { Scene } from "babylonjs/scene";
  49600. import { Color3 } from "babylonjs/Maths/math.color";
  49601. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  49602. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  49603. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49604. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49605. /**
  49606. * The Physically based material of BJS.
  49607. *
  49608. * This offers the main features of a standard PBR material.
  49609. * For more information, please refer to the documentation :
  49610. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49611. */
  49612. export class PBRMaterial extends PBRBaseMaterial {
  49613. /**
  49614. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49615. */
  49616. static readonly PBRMATERIAL_OPAQUE: number;
  49617. /**
  49618. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49619. */
  49620. static readonly PBRMATERIAL_ALPHATEST: number;
  49621. /**
  49622. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49623. */
  49624. static readonly PBRMATERIAL_ALPHABLEND: number;
  49625. /**
  49626. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49627. * They are also discarded below the alpha cutoff threshold to improve performances.
  49628. */
  49629. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49630. /**
  49631. * Defines the default value of how much AO map is occluding the analytical lights
  49632. * (point spot...).
  49633. */
  49634. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49635. /**
  49636. * Intensity of the direct lights e.g. the four lights available in your scene.
  49637. * This impacts both the direct diffuse and specular highlights.
  49638. */
  49639. directIntensity: number;
  49640. /**
  49641. * Intensity of the emissive part of the material.
  49642. * This helps controlling the emissive effect without modifying the emissive color.
  49643. */
  49644. emissiveIntensity: number;
  49645. /**
  49646. * Intensity of the environment e.g. how much the environment will light the object
  49647. * either through harmonics for rough material or through the refelction for shiny ones.
  49648. */
  49649. environmentIntensity: number;
  49650. /**
  49651. * This is a special control allowing the reduction of the specular highlights coming from the
  49652. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49653. */
  49654. specularIntensity: number;
  49655. /**
  49656. * Debug Control allowing disabling the bump map on this material.
  49657. */
  49658. disableBumpMap: boolean;
  49659. /**
  49660. * AKA Diffuse Texture in standard nomenclature.
  49661. */
  49662. albedoTexture: BaseTexture;
  49663. /**
  49664. * AKA Occlusion Texture in other nomenclature.
  49665. */
  49666. ambientTexture: BaseTexture;
  49667. /**
  49668. * AKA Occlusion Texture Intensity in other nomenclature.
  49669. */
  49670. ambientTextureStrength: number;
  49671. /**
  49672. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49673. * 1 means it completely occludes it
  49674. * 0 mean it has no impact
  49675. */
  49676. ambientTextureImpactOnAnalyticalLights: number;
  49677. /**
  49678. * Stores the alpha values in a texture.
  49679. */
  49680. opacityTexture: BaseTexture;
  49681. /**
  49682. * Stores the reflection values in a texture.
  49683. */
  49684. reflectionTexture: Nullable<BaseTexture>;
  49685. /**
  49686. * Stores the emissive values in a texture.
  49687. */
  49688. emissiveTexture: BaseTexture;
  49689. /**
  49690. * AKA Specular texture in other nomenclature.
  49691. */
  49692. reflectivityTexture: BaseTexture;
  49693. /**
  49694. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49695. */
  49696. metallicTexture: BaseTexture;
  49697. /**
  49698. * Specifies the metallic scalar of the metallic/roughness workflow.
  49699. * Can also be used to scale the metalness values of the metallic texture.
  49700. */
  49701. metallic: Nullable<number>;
  49702. /**
  49703. * Specifies the roughness scalar of the metallic/roughness workflow.
  49704. * Can also be used to scale the roughness values of the metallic texture.
  49705. */
  49706. roughness: Nullable<number>;
  49707. /**
  49708. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49709. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49710. */
  49711. microSurfaceTexture: BaseTexture;
  49712. /**
  49713. * Stores surface normal data used to displace a mesh in a texture.
  49714. */
  49715. bumpTexture: BaseTexture;
  49716. /**
  49717. * Stores the pre-calculated light information of a mesh in a texture.
  49718. */
  49719. lightmapTexture: BaseTexture;
  49720. /**
  49721. * Stores the refracted light information in a texture.
  49722. */
  49723. refractionTexture: Nullable<BaseTexture>;
  49724. /**
  49725. * The color of a material in ambient lighting.
  49726. */
  49727. ambientColor: Color3;
  49728. /**
  49729. * AKA Diffuse Color in other nomenclature.
  49730. */
  49731. albedoColor: Color3;
  49732. /**
  49733. * AKA Specular Color in other nomenclature.
  49734. */
  49735. reflectivityColor: Color3;
  49736. /**
  49737. * The color reflected from the material.
  49738. */
  49739. reflectionColor: Color3;
  49740. /**
  49741. * The color emitted from the material.
  49742. */
  49743. emissiveColor: Color3;
  49744. /**
  49745. * AKA Glossiness in other nomenclature.
  49746. */
  49747. microSurface: number;
  49748. /**
  49749. * source material index of refraction (IOR)' / 'destination material IOR.
  49750. */
  49751. indexOfRefraction: number;
  49752. /**
  49753. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49754. */
  49755. invertRefractionY: boolean;
  49756. /**
  49757. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49758. * Materials half opaque for instance using refraction could benefit from this control.
  49759. */
  49760. linkRefractionWithTransparency: boolean;
  49761. /**
  49762. * If true, the light map contains occlusion information instead of lighting info.
  49763. */
  49764. useLightmapAsShadowmap: boolean;
  49765. /**
  49766. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49767. */
  49768. useAlphaFromAlbedoTexture: boolean;
  49769. /**
  49770. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49771. */
  49772. forceAlphaTest: boolean;
  49773. /**
  49774. * Defines the alpha limits in alpha test mode.
  49775. */
  49776. alphaCutOff: number;
  49777. /**
  49778. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49779. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49780. */
  49781. useSpecularOverAlpha: boolean;
  49782. /**
  49783. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49784. */
  49785. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49786. /**
  49787. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49788. */
  49789. useRoughnessFromMetallicTextureAlpha: boolean;
  49790. /**
  49791. * Specifies if the metallic texture contains the roughness information in its green channel.
  49792. */
  49793. useRoughnessFromMetallicTextureGreen: boolean;
  49794. /**
  49795. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49796. */
  49797. useMetallnessFromMetallicTextureBlue: boolean;
  49798. /**
  49799. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49800. */
  49801. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49802. /**
  49803. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49804. */
  49805. useAmbientInGrayScale: boolean;
  49806. /**
  49807. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49808. * The material will try to infer what glossiness each pixel should be.
  49809. */
  49810. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49811. /**
  49812. * BJS is using an harcoded light falloff based on a manually sets up range.
  49813. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49814. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49815. */
  49816. /**
  49817. * BJS is using an harcoded light falloff based on a manually sets up range.
  49818. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49819. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49820. */
  49821. usePhysicalLightFalloff: boolean;
  49822. /**
  49823. * In order to support the falloff compatibility with gltf, a special mode has been added
  49824. * to reproduce the gltf light falloff.
  49825. */
  49826. /**
  49827. * In order to support the falloff compatibility with gltf, a special mode has been added
  49828. * to reproduce the gltf light falloff.
  49829. */
  49830. useGLTFLightFalloff: boolean;
  49831. /**
  49832. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49833. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49834. */
  49835. useRadianceOverAlpha: boolean;
  49836. /**
  49837. * Allows using an object space normal map (instead of tangent space).
  49838. */
  49839. useObjectSpaceNormalMap: boolean;
  49840. /**
  49841. * Allows using the bump map in parallax mode.
  49842. */
  49843. useParallax: boolean;
  49844. /**
  49845. * Allows using the bump map in parallax occlusion mode.
  49846. */
  49847. useParallaxOcclusion: boolean;
  49848. /**
  49849. * Controls the scale bias of the parallax mode.
  49850. */
  49851. parallaxScaleBias: number;
  49852. /**
  49853. * If sets to true, disables all the lights affecting the material.
  49854. */
  49855. disableLighting: boolean;
  49856. /**
  49857. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49858. */
  49859. forceIrradianceInFragment: boolean;
  49860. /**
  49861. * Number of Simultaneous lights allowed on the material.
  49862. */
  49863. maxSimultaneousLights: number;
  49864. /**
  49865. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49866. */
  49867. invertNormalMapX: boolean;
  49868. /**
  49869. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49870. */
  49871. invertNormalMapY: boolean;
  49872. /**
  49873. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49874. */
  49875. twoSidedLighting: boolean;
  49876. /**
  49877. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49878. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49879. */
  49880. useAlphaFresnel: boolean;
  49881. /**
  49882. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49883. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49884. */
  49885. useLinearAlphaFresnel: boolean;
  49886. /**
  49887. * Let user defines the brdf lookup texture used for IBL.
  49888. * A default 8bit version is embedded but you could point at :
  49889. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49890. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49891. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49892. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49893. */
  49894. environmentBRDFTexture: Nullable<BaseTexture>;
  49895. /**
  49896. * Force normal to face away from face.
  49897. */
  49898. forceNormalForward: boolean;
  49899. /**
  49900. * Enables specular anti aliasing in the PBR shader.
  49901. * It will both interacts on the Geometry for analytical and IBL lighting.
  49902. * It also prefilter the roughness map based on the bump values.
  49903. */
  49904. enableSpecularAntiAliasing: boolean;
  49905. /**
  49906. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49907. * makes the reflect vector face the model (under horizon).
  49908. */
  49909. useHorizonOcclusion: boolean;
  49910. /**
  49911. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49912. * too much the area relying on ambient texture to define their ambient occlusion.
  49913. */
  49914. useRadianceOcclusion: boolean;
  49915. /**
  49916. * If set to true, no lighting calculations will be applied.
  49917. */
  49918. unlit: boolean;
  49919. /**
  49920. * Gets the image processing configuration used either in this material.
  49921. */
  49922. /**
  49923. * Sets the Default image processing configuration used either in the this material.
  49924. *
  49925. * If sets to null, the scene one is in use.
  49926. */
  49927. imageProcessingConfiguration: ImageProcessingConfiguration;
  49928. /**
  49929. * Gets wether the color curves effect is enabled.
  49930. */
  49931. /**
  49932. * Sets wether the color curves effect is enabled.
  49933. */
  49934. cameraColorCurvesEnabled: boolean;
  49935. /**
  49936. * Gets wether the color grading effect is enabled.
  49937. */
  49938. /**
  49939. * Gets wether the color grading effect is enabled.
  49940. */
  49941. cameraColorGradingEnabled: boolean;
  49942. /**
  49943. * Gets wether tonemapping is enabled or not.
  49944. */
  49945. /**
  49946. * Sets wether tonemapping is enabled or not
  49947. */
  49948. cameraToneMappingEnabled: boolean;
  49949. /**
  49950. * The camera exposure used on this material.
  49951. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49952. * This corresponds to a photographic exposure.
  49953. */
  49954. /**
  49955. * The camera exposure used on this material.
  49956. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49957. * This corresponds to a photographic exposure.
  49958. */
  49959. cameraExposure: number;
  49960. /**
  49961. * Gets The camera contrast used on this material.
  49962. */
  49963. /**
  49964. * Sets The camera contrast used on this material.
  49965. */
  49966. cameraContrast: number;
  49967. /**
  49968. * Gets the Color Grading 2D Lookup Texture.
  49969. */
  49970. /**
  49971. * Sets the Color Grading 2D Lookup Texture.
  49972. */
  49973. cameraColorGradingTexture: Nullable<BaseTexture>;
  49974. /**
  49975. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49976. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49977. * 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;
  49978. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49979. */
  49980. /**
  49981. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49982. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49983. * 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;
  49984. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49985. */
  49986. cameraColorCurves: Nullable<ColorCurves>;
  49987. /**
  49988. * Instantiates a new PBRMaterial instance.
  49989. *
  49990. * @param name The material name
  49991. * @param scene The scene the material will be use in.
  49992. */
  49993. constructor(name: string, scene: Scene);
  49994. /**
  49995. * Returns the name of this material class.
  49996. */
  49997. getClassName(): string;
  49998. /**
  49999. * Makes a duplicate of the current material.
  50000. * @param name - name to use for the new material.
  50001. */
  50002. clone(name: string): PBRMaterial;
  50003. /**
  50004. * Serializes this PBR Material.
  50005. * @returns - An object with the serialized material.
  50006. */
  50007. serialize(): any;
  50008. /**
  50009. * Parses a PBR Material from a serialized object.
  50010. * @param source - Serialized object.
  50011. * @param scene - BJS scene instance.
  50012. * @param rootUrl - url for the scene object
  50013. * @returns - PBRMaterial
  50014. */
  50015. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50016. }
  50017. }
  50018. declare module "babylonjs/Misc/dds" {
  50019. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50020. import { Engine } from "babylonjs/Engines/engine";
  50021. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50022. import { Nullable } from "babylonjs/types";
  50023. import { Scene } from "babylonjs/scene";
  50024. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50025. /**
  50026. * Direct draw surface info
  50027. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50028. */
  50029. export interface DDSInfo {
  50030. /**
  50031. * Width of the texture
  50032. */
  50033. width: number;
  50034. /**
  50035. * Width of the texture
  50036. */
  50037. height: number;
  50038. /**
  50039. * Number of Mipmaps for the texture
  50040. * @see https://en.wikipedia.org/wiki/Mipmap
  50041. */
  50042. mipmapCount: number;
  50043. /**
  50044. * If the textures format is a known fourCC format
  50045. * @see https://www.fourcc.org/
  50046. */
  50047. isFourCC: boolean;
  50048. /**
  50049. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50050. */
  50051. isRGB: boolean;
  50052. /**
  50053. * If the texture is a lumincance format
  50054. */
  50055. isLuminance: boolean;
  50056. /**
  50057. * If this is a cube texture
  50058. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50059. */
  50060. isCube: boolean;
  50061. /**
  50062. * If the texture is a compressed format eg. FOURCC_DXT1
  50063. */
  50064. isCompressed: boolean;
  50065. /**
  50066. * The dxgiFormat of the texture
  50067. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50068. */
  50069. dxgiFormat: number;
  50070. /**
  50071. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50072. */
  50073. textureType: number;
  50074. /**
  50075. * Sphericle polynomial created for the dds texture
  50076. */
  50077. sphericalPolynomial?: SphericalPolynomial;
  50078. }
  50079. /**
  50080. * Class used to provide DDS decompression tools
  50081. */
  50082. export class DDSTools {
  50083. /**
  50084. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50085. */
  50086. static StoreLODInAlphaChannel: boolean;
  50087. /**
  50088. * Gets DDS information from an array buffer
  50089. * @param arrayBuffer defines the array buffer to read data from
  50090. * @returns the DDS information
  50091. */
  50092. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50093. private static _FloatView;
  50094. private static _Int32View;
  50095. private static _ToHalfFloat;
  50096. private static _FromHalfFloat;
  50097. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50098. private static _GetHalfFloatRGBAArrayBuffer;
  50099. private static _GetFloatRGBAArrayBuffer;
  50100. private static _GetFloatAsUIntRGBAArrayBuffer;
  50101. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50102. private static _GetRGBAArrayBuffer;
  50103. private static _ExtractLongWordOrder;
  50104. private static _GetRGBArrayBuffer;
  50105. private static _GetLuminanceArrayBuffer;
  50106. /**
  50107. * Uploads DDS Levels to a Babylon Texture
  50108. * @hidden
  50109. */
  50110. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50111. }
  50112. module "babylonjs/Engines/engine" {
  50113. interface Engine {
  50114. /**
  50115. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50116. * @param rootUrl defines the url where the file to load is located
  50117. * @param scene defines the current scene
  50118. * @param lodScale defines scale to apply to the mip map selection
  50119. * @param lodOffset defines offset to apply to the mip map selection
  50120. * @param onLoad defines an optional callback raised when the texture is loaded
  50121. * @param onError defines an optional callback raised if there is an issue to load the texture
  50122. * @param format defines the format of the data
  50123. * @param forcedExtension defines the extension to use to pick the right loader
  50124. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50125. * @returns the cube texture as an InternalTexture
  50126. */
  50127. 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;
  50128. }
  50129. }
  50130. }
  50131. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50132. import { Nullable } from "babylonjs/types";
  50133. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50134. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50135. /**
  50136. * Implementation of the DDS Texture Loader.
  50137. * @hidden
  50138. */
  50139. export class _DDSTextureLoader implements IInternalTextureLoader {
  50140. /**
  50141. * Defines wether the loader supports cascade loading the different faces.
  50142. */
  50143. readonly supportCascades: boolean;
  50144. /**
  50145. * This returns if the loader support the current file information.
  50146. * @param extension defines the file extension of the file being loaded
  50147. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50148. * @param fallback defines the fallback internal texture if any
  50149. * @param isBase64 defines whether the texture is encoded as a base64
  50150. * @param isBuffer defines whether the texture data are stored as a buffer
  50151. * @returns true if the loader can load the specified file
  50152. */
  50153. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50154. /**
  50155. * Transform the url before loading if required.
  50156. * @param rootUrl the url of the texture
  50157. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50158. * @returns the transformed texture
  50159. */
  50160. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50161. /**
  50162. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50163. * @param rootUrl the url of the texture
  50164. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50165. * @returns the fallback texture
  50166. */
  50167. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50168. /**
  50169. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50170. * @param data contains the texture data
  50171. * @param texture defines the BabylonJS internal texture
  50172. * @param createPolynomials will be true if polynomials have been requested
  50173. * @param onLoad defines the callback to trigger once the texture is ready
  50174. * @param onError defines the callback to trigger in case of error
  50175. */
  50176. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50177. /**
  50178. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50179. * @param data contains the texture data
  50180. * @param texture defines the BabylonJS internal texture
  50181. * @param callback defines the method to call once ready to upload
  50182. */
  50183. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50184. }
  50185. }
  50186. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50187. import { Nullable } from "babylonjs/types";
  50188. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50189. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50190. /**
  50191. * Implementation of the ENV Texture Loader.
  50192. * @hidden
  50193. */
  50194. export class _ENVTextureLoader implements IInternalTextureLoader {
  50195. /**
  50196. * Defines wether the loader supports cascade loading the different faces.
  50197. */
  50198. readonly supportCascades: boolean;
  50199. /**
  50200. * This returns if the loader support the current file information.
  50201. * @param extension defines the file extension of the file being loaded
  50202. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50203. * @param fallback defines the fallback internal texture if any
  50204. * @param isBase64 defines whether the texture is encoded as a base64
  50205. * @param isBuffer defines whether the texture data are stored as a buffer
  50206. * @returns true if the loader can load the specified file
  50207. */
  50208. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50209. /**
  50210. * Transform the url before loading if required.
  50211. * @param rootUrl the url of the texture
  50212. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50213. * @returns the transformed texture
  50214. */
  50215. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50216. /**
  50217. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50218. * @param rootUrl the url of the texture
  50219. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50220. * @returns the fallback texture
  50221. */
  50222. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50223. /**
  50224. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50225. * @param data contains the texture data
  50226. * @param texture defines the BabylonJS internal texture
  50227. * @param createPolynomials will be true if polynomials have been requested
  50228. * @param onLoad defines the callback to trigger once the texture is ready
  50229. * @param onError defines the callback to trigger in case of error
  50230. */
  50231. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50232. /**
  50233. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50234. * @param data contains the texture data
  50235. * @param texture defines the BabylonJS internal texture
  50236. * @param callback defines the method to call once ready to upload
  50237. */
  50238. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50239. }
  50240. }
  50241. declare module "babylonjs/Misc/khronosTextureContainer" {
  50242. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50243. /**
  50244. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50245. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50246. */
  50247. export class KhronosTextureContainer {
  50248. /** contents of the KTX container file */
  50249. arrayBuffer: any;
  50250. private static HEADER_LEN;
  50251. private static COMPRESSED_2D;
  50252. private static COMPRESSED_3D;
  50253. private static TEX_2D;
  50254. private static TEX_3D;
  50255. /**
  50256. * Gets the openGL type
  50257. */
  50258. glType: number;
  50259. /**
  50260. * Gets the openGL type size
  50261. */
  50262. glTypeSize: number;
  50263. /**
  50264. * Gets the openGL format
  50265. */
  50266. glFormat: number;
  50267. /**
  50268. * Gets the openGL internal format
  50269. */
  50270. glInternalFormat: number;
  50271. /**
  50272. * Gets the base internal format
  50273. */
  50274. glBaseInternalFormat: number;
  50275. /**
  50276. * Gets image width in pixel
  50277. */
  50278. pixelWidth: number;
  50279. /**
  50280. * Gets image height in pixel
  50281. */
  50282. pixelHeight: number;
  50283. /**
  50284. * Gets image depth in pixels
  50285. */
  50286. pixelDepth: number;
  50287. /**
  50288. * Gets the number of array elements
  50289. */
  50290. numberOfArrayElements: number;
  50291. /**
  50292. * Gets the number of faces
  50293. */
  50294. numberOfFaces: number;
  50295. /**
  50296. * Gets the number of mipmap levels
  50297. */
  50298. numberOfMipmapLevels: number;
  50299. /**
  50300. * Gets the bytes of key value data
  50301. */
  50302. bytesOfKeyValueData: number;
  50303. /**
  50304. * Gets the load type
  50305. */
  50306. loadType: number;
  50307. /**
  50308. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50309. */
  50310. isInvalid: boolean;
  50311. /**
  50312. * Creates a new KhronosTextureContainer
  50313. * @param arrayBuffer contents of the KTX container file
  50314. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50315. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50316. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50317. */
  50318. constructor(
  50319. /** contents of the KTX container file */
  50320. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50321. /**
  50322. * Uploads KTX content to a Babylon Texture.
  50323. * It is assumed that the texture has already been created & is currently bound
  50324. * @hidden
  50325. */
  50326. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50327. private _upload2DCompressedLevels;
  50328. }
  50329. }
  50330. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50331. import { Nullable } from "babylonjs/types";
  50332. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50333. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50334. /**
  50335. * Implementation of the KTX Texture Loader.
  50336. * @hidden
  50337. */
  50338. export class _KTXTextureLoader implements IInternalTextureLoader {
  50339. /**
  50340. * Defines wether the loader supports cascade loading the different faces.
  50341. */
  50342. readonly supportCascades: boolean;
  50343. /**
  50344. * This returns if the loader support the current file information.
  50345. * @param extension defines the file extension of the file being loaded
  50346. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50347. * @param fallback defines the fallback internal texture if any
  50348. * @param isBase64 defines whether the texture is encoded as a base64
  50349. * @param isBuffer defines whether the texture data are stored as a buffer
  50350. * @returns true if the loader can load the specified file
  50351. */
  50352. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50353. /**
  50354. * Transform the url before loading if required.
  50355. * @param rootUrl the url of the texture
  50356. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50357. * @returns the transformed texture
  50358. */
  50359. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50360. /**
  50361. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50362. * @param rootUrl the url of the texture
  50363. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50364. * @returns the fallback texture
  50365. */
  50366. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50367. /**
  50368. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50369. * @param data contains the texture data
  50370. * @param texture defines the BabylonJS internal texture
  50371. * @param createPolynomials will be true if polynomials have been requested
  50372. * @param onLoad defines the callback to trigger once the texture is ready
  50373. * @param onError defines the callback to trigger in case of error
  50374. */
  50375. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50376. /**
  50377. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50378. * @param data contains the texture data
  50379. * @param texture defines the BabylonJS internal texture
  50380. * @param callback defines the method to call once ready to upload
  50381. */
  50382. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50383. }
  50384. }
  50385. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50386. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50387. import { Scene } from "babylonjs/scene";
  50388. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50389. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50390. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50391. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50392. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50393. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50395. /**
  50396. * Options for the default xr helper
  50397. */
  50398. export class WebXRDefaultExperienceOptions {
  50399. /**
  50400. * Floor meshes that should be used for teleporting
  50401. */
  50402. floorMeshes: Array<AbstractMesh>;
  50403. }
  50404. /**
  50405. * Default experience which provides a similar setup to the previous webVRExperience
  50406. */
  50407. export class WebXRDefaultExperience {
  50408. /**
  50409. * Base experience
  50410. */
  50411. baseExperience: WebXRExperienceHelper;
  50412. /**
  50413. * Input experience extension
  50414. */
  50415. input: WebXRInput;
  50416. /**
  50417. * Loads the controller models
  50418. */
  50419. controllerModelLoader: WebXRControllerModelLoader;
  50420. /**
  50421. * Enables laser pointer and selection
  50422. */
  50423. pointerSelection: WebXRControllerPointerSelection;
  50424. /**
  50425. * Enables teleportation
  50426. */
  50427. teleportation: WebXRControllerTeleportation;
  50428. /**
  50429. * Enables ui for enetering/exiting xr
  50430. */
  50431. enterExitUI: WebXREnterExitUI;
  50432. /**
  50433. * Default output canvas xr should render to
  50434. */
  50435. outputCanvas: WebXRManagedOutputCanvas;
  50436. /**
  50437. * Creates the default xr experience
  50438. * @param scene scene
  50439. * @param options options for basic configuration
  50440. * @returns resulting WebXRDefaultExperience
  50441. */
  50442. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50443. private constructor();
  50444. /**
  50445. * DIsposes of the experience helper
  50446. */
  50447. dispose(): void;
  50448. }
  50449. }
  50450. declare module "babylonjs/Helpers/sceneHelpers" {
  50451. import { Nullable } from "babylonjs/types";
  50452. import { Mesh } from "babylonjs/Meshes/mesh";
  50453. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50454. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50455. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50456. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50457. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50458. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50459. import "babylonjs/Meshes/Builders/boxBuilder";
  50460. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50461. /** @hidden */
  50462. export var _forceSceneHelpersToBundle: boolean;
  50463. module "babylonjs/scene" {
  50464. interface Scene {
  50465. /**
  50466. * Creates a default light for the scene.
  50467. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50468. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50469. */
  50470. createDefaultLight(replace?: boolean): void;
  50471. /**
  50472. * Creates a default camera for the scene.
  50473. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50474. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50475. * @param replace has default false, when true replaces the active camera in the scene
  50476. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50477. */
  50478. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50479. /**
  50480. * Creates a default camera and a default light.
  50481. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50482. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50483. * @param replace has the default false, when true replaces the active camera/light in the scene
  50484. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50485. */
  50486. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50487. /**
  50488. * Creates a new sky box
  50489. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50490. * @param environmentTexture defines the texture to use as environment texture
  50491. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50492. * @param scale defines the overall scale of the skybox
  50493. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50494. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50495. * @returns a new mesh holding the sky box
  50496. */
  50497. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50498. /**
  50499. * Creates a new environment
  50500. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50501. * @param options defines the options you can use to configure the environment
  50502. * @returns the new EnvironmentHelper
  50503. */
  50504. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50505. /**
  50506. * Creates a new VREXperienceHelper
  50507. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50508. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50509. * @returns a new VREXperienceHelper
  50510. */
  50511. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50512. /**
  50513. * Creates a new WebXRDefaultExperience
  50514. * @see http://doc.babylonjs.com/how_to/webxr
  50515. * @param options experience options
  50516. * @returns a promise for a new WebXRDefaultExperience
  50517. */
  50518. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50519. }
  50520. }
  50521. }
  50522. declare module "babylonjs/Helpers/videoDome" {
  50523. import { Scene } from "babylonjs/scene";
  50524. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50525. import { Mesh } from "babylonjs/Meshes/mesh";
  50526. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  50527. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50528. import "babylonjs/Meshes/Builders/sphereBuilder";
  50529. /**
  50530. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50531. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50532. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50533. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50534. */
  50535. export class VideoDome extends TransformNode {
  50536. /**
  50537. * Define the video source as a Monoscopic panoramic 360 video.
  50538. */
  50539. static readonly MODE_MONOSCOPIC: number;
  50540. /**
  50541. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50542. */
  50543. static readonly MODE_TOPBOTTOM: number;
  50544. /**
  50545. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50546. */
  50547. static readonly MODE_SIDEBYSIDE: number;
  50548. private _halfDome;
  50549. private _useDirectMapping;
  50550. /**
  50551. * The video texture being displayed on the sphere
  50552. */
  50553. protected _videoTexture: VideoTexture;
  50554. /**
  50555. * Gets the video texture being displayed on the sphere
  50556. */
  50557. readonly videoTexture: VideoTexture;
  50558. /**
  50559. * The skybox material
  50560. */
  50561. protected _material: BackgroundMaterial;
  50562. /**
  50563. * The surface used for the skybox
  50564. */
  50565. protected _mesh: Mesh;
  50566. /**
  50567. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50568. */
  50569. private _halfDomeMask;
  50570. /**
  50571. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50572. * Also see the options.resolution property.
  50573. */
  50574. fovMultiplier: number;
  50575. private _videoMode;
  50576. /**
  50577. * Gets or set the current video mode for the video. It can be:
  50578. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50579. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50580. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50581. */
  50582. videoMode: number;
  50583. /**
  50584. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50585. *
  50586. */
  50587. /**
  50588. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50589. */
  50590. halfDome: boolean;
  50591. /**
  50592. * Oberserver used in Stereoscopic VR Mode.
  50593. */
  50594. private _onBeforeCameraRenderObserver;
  50595. /**
  50596. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50597. * @param name Element's name, child elements will append suffixes for their own names.
  50598. * @param urlsOrVideo defines the url(s) or the video element to use
  50599. * @param options An object containing optional or exposed sub element properties
  50600. */
  50601. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50602. resolution?: number;
  50603. clickToPlay?: boolean;
  50604. autoPlay?: boolean;
  50605. loop?: boolean;
  50606. size?: number;
  50607. poster?: string;
  50608. faceForward?: boolean;
  50609. useDirectMapping?: boolean;
  50610. halfDomeMode?: boolean;
  50611. }, scene: Scene);
  50612. private _changeVideoMode;
  50613. /**
  50614. * Releases resources associated with this node.
  50615. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50616. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50617. */
  50618. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50619. }
  50620. }
  50621. declare module "babylonjs/Helpers/index" {
  50622. export * from "babylonjs/Helpers/environmentHelper";
  50623. export * from "babylonjs/Helpers/photoDome";
  50624. export * from "babylonjs/Helpers/sceneHelpers";
  50625. export * from "babylonjs/Helpers/videoDome";
  50626. }
  50627. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50628. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50629. import { IDisposable } from "babylonjs/scene";
  50630. import { Engine } from "babylonjs/Engines/engine";
  50631. /**
  50632. * This class can be used to get instrumentation data from a Babylon engine
  50633. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50634. */
  50635. export class EngineInstrumentation implements IDisposable {
  50636. /**
  50637. * Define the instrumented engine.
  50638. */
  50639. engine: Engine;
  50640. private _captureGPUFrameTime;
  50641. private _gpuFrameTimeToken;
  50642. private _gpuFrameTime;
  50643. private _captureShaderCompilationTime;
  50644. private _shaderCompilationTime;
  50645. private _onBeginFrameObserver;
  50646. private _onEndFrameObserver;
  50647. private _onBeforeShaderCompilationObserver;
  50648. private _onAfterShaderCompilationObserver;
  50649. /**
  50650. * Gets the perf counter used for GPU frame time
  50651. */
  50652. readonly gpuFrameTimeCounter: PerfCounter;
  50653. /**
  50654. * Gets the GPU frame time capture status
  50655. */
  50656. /**
  50657. * Enable or disable the GPU frame time capture
  50658. */
  50659. captureGPUFrameTime: boolean;
  50660. /**
  50661. * Gets the perf counter used for shader compilation time
  50662. */
  50663. readonly shaderCompilationTimeCounter: PerfCounter;
  50664. /**
  50665. * Gets the shader compilation time capture status
  50666. */
  50667. /**
  50668. * Enable or disable the shader compilation time capture
  50669. */
  50670. captureShaderCompilationTime: boolean;
  50671. /**
  50672. * Instantiates a new engine instrumentation.
  50673. * This class can be used to get instrumentation data from a Babylon engine
  50674. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50675. * @param engine Defines the engine to instrument
  50676. */
  50677. constructor(
  50678. /**
  50679. * Define the instrumented engine.
  50680. */
  50681. engine: Engine);
  50682. /**
  50683. * Dispose and release associated resources.
  50684. */
  50685. dispose(): void;
  50686. }
  50687. }
  50688. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50689. import { Scene, IDisposable } from "babylonjs/scene";
  50690. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50691. /**
  50692. * This class can be used to get instrumentation data from a Babylon engine
  50693. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50694. */
  50695. export class SceneInstrumentation implements IDisposable {
  50696. /**
  50697. * Defines the scene to instrument
  50698. */
  50699. scene: Scene;
  50700. private _captureActiveMeshesEvaluationTime;
  50701. private _activeMeshesEvaluationTime;
  50702. private _captureRenderTargetsRenderTime;
  50703. private _renderTargetsRenderTime;
  50704. private _captureFrameTime;
  50705. private _frameTime;
  50706. private _captureRenderTime;
  50707. private _renderTime;
  50708. private _captureInterFrameTime;
  50709. private _interFrameTime;
  50710. private _captureParticlesRenderTime;
  50711. private _particlesRenderTime;
  50712. private _captureSpritesRenderTime;
  50713. private _spritesRenderTime;
  50714. private _capturePhysicsTime;
  50715. private _physicsTime;
  50716. private _captureAnimationsTime;
  50717. private _animationsTime;
  50718. private _captureCameraRenderTime;
  50719. private _cameraRenderTime;
  50720. private _onBeforeActiveMeshesEvaluationObserver;
  50721. private _onAfterActiveMeshesEvaluationObserver;
  50722. private _onBeforeRenderTargetsRenderObserver;
  50723. private _onAfterRenderTargetsRenderObserver;
  50724. private _onAfterRenderObserver;
  50725. private _onBeforeDrawPhaseObserver;
  50726. private _onAfterDrawPhaseObserver;
  50727. private _onBeforeAnimationsObserver;
  50728. private _onBeforeParticlesRenderingObserver;
  50729. private _onAfterParticlesRenderingObserver;
  50730. private _onBeforeSpritesRenderingObserver;
  50731. private _onAfterSpritesRenderingObserver;
  50732. private _onBeforePhysicsObserver;
  50733. private _onAfterPhysicsObserver;
  50734. private _onAfterAnimationsObserver;
  50735. private _onBeforeCameraRenderObserver;
  50736. private _onAfterCameraRenderObserver;
  50737. /**
  50738. * Gets the perf counter used for active meshes evaluation time
  50739. */
  50740. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50741. /**
  50742. * Gets the active meshes evaluation time capture status
  50743. */
  50744. /**
  50745. * Enable or disable the active meshes evaluation time capture
  50746. */
  50747. captureActiveMeshesEvaluationTime: boolean;
  50748. /**
  50749. * Gets the perf counter used for render targets render time
  50750. */
  50751. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50752. /**
  50753. * Gets the render targets render time capture status
  50754. */
  50755. /**
  50756. * Enable or disable the render targets render time capture
  50757. */
  50758. captureRenderTargetsRenderTime: boolean;
  50759. /**
  50760. * Gets the perf counter used for particles render time
  50761. */
  50762. readonly particlesRenderTimeCounter: PerfCounter;
  50763. /**
  50764. * Gets the particles render time capture status
  50765. */
  50766. /**
  50767. * Enable or disable the particles render time capture
  50768. */
  50769. captureParticlesRenderTime: boolean;
  50770. /**
  50771. * Gets the perf counter used for sprites render time
  50772. */
  50773. readonly spritesRenderTimeCounter: PerfCounter;
  50774. /**
  50775. * Gets the sprites render time capture status
  50776. */
  50777. /**
  50778. * Enable or disable the sprites render time capture
  50779. */
  50780. captureSpritesRenderTime: boolean;
  50781. /**
  50782. * Gets the perf counter used for physics time
  50783. */
  50784. readonly physicsTimeCounter: PerfCounter;
  50785. /**
  50786. * Gets the physics time capture status
  50787. */
  50788. /**
  50789. * Enable or disable the physics time capture
  50790. */
  50791. capturePhysicsTime: boolean;
  50792. /**
  50793. * Gets the perf counter used for animations time
  50794. */
  50795. readonly animationsTimeCounter: PerfCounter;
  50796. /**
  50797. * Gets the animations time capture status
  50798. */
  50799. /**
  50800. * Enable or disable the animations time capture
  50801. */
  50802. captureAnimationsTime: boolean;
  50803. /**
  50804. * Gets the perf counter used for frame time capture
  50805. */
  50806. readonly frameTimeCounter: PerfCounter;
  50807. /**
  50808. * Gets the frame time capture status
  50809. */
  50810. /**
  50811. * Enable or disable the frame time capture
  50812. */
  50813. captureFrameTime: boolean;
  50814. /**
  50815. * Gets the perf counter used for inter-frames time capture
  50816. */
  50817. readonly interFrameTimeCounter: PerfCounter;
  50818. /**
  50819. * Gets the inter-frames time capture status
  50820. */
  50821. /**
  50822. * Enable or disable the inter-frames time capture
  50823. */
  50824. captureInterFrameTime: boolean;
  50825. /**
  50826. * Gets the perf counter used for render time capture
  50827. */
  50828. readonly renderTimeCounter: PerfCounter;
  50829. /**
  50830. * Gets the render time capture status
  50831. */
  50832. /**
  50833. * Enable or disable the render time capture
  50834. */
  50835. captureRenderTime: boolean;
  50836. /**
  50837. * Gets the perf counter used for camera render time capture
  50838. */
  50839. readonly cameraRenderTimeCounter: PerfCounter;
  50840. /**
  50841. * Gets the camera render time capture status
  50842. */
  50843. /**
  50844. * Enable or disable the camera render time capture
  50845. */
  50846. captureCameraRenderTime: boolean;
  50847. /**
  50848. * Gets the perf counter used for draw calls
  50849. */
  50850. readonly drawCallsCounter: PerfCounter;
  50851. /**
  50852. * Instantiates a new scene instrumentation.
  50853. * This class can be used to get instrumentation data from a Babylon engine
  50854. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50855. * @param scene Defines the scene to instrument
  50856. */
  50857. constructor(
  50858. /**
  50859. * Defines the scene to instrument
  50860. */
  50861. scene: Scene);
  50862. /**
  50863. * Dispose and release associated resources.
  50864. */
  50865. dispose(): void;
  50866. }
  50867. }
  50868. declare module "babylonjs/Instrumentation/index" {
  50869. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50870. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50871. export * from "babylonjs/Instrumentation/timeToken";
  50872. }
  50873. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50874. /** @hidden */
  50875. export var glowMapGenerationPixelShader: {
  50876. name: string;
  50877. shader: string;
  50878. };
  50879. }
  50880. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50881. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50882. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50883. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50884. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50885. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50886. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50887. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50888. /** @hidden */
  50889. export var glowMapGenerationVertexShader: {
  50890. name: string;
  50891. shader: string;
  50892. };
  50893. }
  50894. declare module "babylonjs/Layers/effectLayer" {
  50895. import { Observable } from "babylonjs/Misc/observable";
  50896. import { Nullable } from "babylonjs/types";
  50897. import { Camera } from "babylonjs/Cameras/camera";
  50898. import { Scene } from "babylonjs/scene";
  50899. import { ISize } from "babylonjs/Maths/math.size";
  50900. import { Color4 } from "babylonjs/Maths/math.color";
  50901. import { Engine } from "babylonjs/Engines/engine";
  50902. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50904. import { Mesh } from "babylonjs/Meshes/mesh";
  50905. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50906. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50907. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50908. import { Effect } from "babylonjs/Materials/effect";
  50909. import { Material } from "babylonjs/Materials/material";
  50910. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50911. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50912. /**
  50913. * Effect layer options. This helps customizing the behaviour
  50914. * of the effect layer.
  50915. */
  50916. export interface IEffectLayerOptions {
  50917. /**
  50918. * Multiplication factor apply to the canvas size to compute the render target size
  50919. * used to generated the objects (the smaller the faster).
  50920. */
  50921. mainTextureRatio: number;
  50922. /**
  50923. * Enforces a fixed size texture to ensure effect stability across devices.
  50924. */
  50925. mainTextureFixedSize?: number;
  50926. /**
  50927. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50928. */
  50929. alphaBlendingMode: number;
  50930. /**
  50931. * The camera attached to the layer.
  50932. */
  50933. camera: Nullable<Camera>;
  50934. /**
  50935. * The rendering group to draw the layer in.
  50936. */
  50937. renderingGroupId: number;
  50938. }
  50939. /**
  50940. * The effect layer Helps adding post process effect blended with the main pass.
  50941. *
  50942. * This can be for instance use to generate glow or higlight effects on the scene.
  50943. *
  50944. * The effect layer class can not be used directly and is intented to inherited from to be
  50945. * customized per effects.
  50946. */
  50947. export abstract class EffectLayer {
  50948. private _vertexBuffers;
  50949. private _indexBuffer;
  50950. private _cachedDefines;
  50951. private _effectLayerMapGenerationEffect;
  50952. private _effectLayerOptions;
  50953. private _mergeEffect;
  50954. protected _scene: Scene;
  50955. protected _engine: Engine;
  50956. protected _maxSize: number;
  50957. protected _mainTextureDesiredSize: ISize;
  50958. protected _mainTexture: RenderTargetTexture;
  50959. protected _shouldRender: boolean;
  50960. protected _postProcesses: PostProcess[];
  50961. protected _textures: BaseTexture[];
  50962. protected _emissiveTextureAndColor: {
  50963. texture: Nullable<BaseTexture>;
  50964. color: Color4;
  50965. };
  50966. /**
  50967. * The name of the layer
  50968. */
  50969. name: string;
  50970. /**
  50971. * The clear color of the texture used to generate the glow map.
  50972. */
  50973. neutralColor: Color4;
  50974. /**
  50975. * Specifies wether the highlight layer is enabled or not.
  50976. */
  50977. isEnabled: boolean;
  50978. /**
  50979. * Gets the camera attached to the layer.
  50980. */
  50981. readonly camera: Nullable<Camera>;
  50982. /**
  50983. * Gets the rendering group id the layer should render in.
  50984. */
  50985. renderingGroupId: number;
  50986. /**
  50987. * An event triggered when the effect layer has been disposed.
  50988. */
  50989. onDisposeObservable: Observable<EffectLayer>;
  50990. /**
  50991. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50992. */
  50993. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50994. /**
  50995. * An event triggered when the generated texture is being merged in the scene.
  50996. */
  50997. onBeforeComposeObservable: Observable<EffectLayer>;
  50998. /**
  50999. * An event triggered when the generated texture has been merged in the scene.
  51000. */
  51001. onAfterComposeObservable: Observable<EffectLayer>;
  51002. /**
  51003. * An event triggered when the efffect layer changes its size.
  51004. */
  51005. onSizeChangedObservable: Observable<EffectLayer>;
  51006. /** @hidden */
  51007. static _SceneComponentInitialization: (scene: Scene) => void;
  51008. /**
  51009. * Instantiates a new effect Layer and references it in the scene.
  51010. * @param name The name of the layer
  51011. * @param scene The scene to use the layer in
  51012. */
  51013. constructor(
  51014. /** The Friendly of the effect in the scene */
  51015. name: string, scene: Scene);
  51016. /**
  51017. * Get the effect name of the layer.
  51018. * @return The effect name
  51019. */
  51020. abstract getEffectName(): string;
  51021. /**
  51022. * Checks for the readiness of the element composing the layer.
  51023. * @param subMesh the mesh to check for
  51024. * @param useInstances specify wether or not to use instances to render the mesh
  51025. * @return true if ready otherwise, false
  51026. */
  51027. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51028. /**
  51029. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51030. * @returns true if the effect requires stencil during the main canvas render pass.
  51031. */
  51032. abstract needStencil(): boolean;
  51033. /**
  51034. * Create the merge effect. This is the shader use to blit the information back
  51035. * to the main canvas at the end of the scene rendering.
  51036. * @returns The effect containing the shader used to merge the effect on the main canvas
  51037. */
  51038. protected abstract _createMergeEffect(): Effect;
  51039. /**
  51040. * Creates the render target textures and post processes used in the effect layer.
  51041. */
  51042. protected abstract _createTextureAndPostProcesses(): void;
  51043. /**
  51044. * Implementation specific of rendering the generating effect on the main canvas.
  51045. * @param effect The effect used to render through
  51046. */
  51047. protected abstract _internalRender(effect: Effect): void;
  51048. /**
  51049. * Sets the required values for both the emissive texture and and the main color.
  51050. */
  51051. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51052. /**
  51053. * Free any resources and references associated to a mesh.
  51054. * Internal use
  51055. * @param mesh The mesh to free.
  51056. */
  51057. abstract _disposeMesh(mesh: Mesh): void;
  51058. /**
  51059. * Serializes this layer (Glow or Highlight for example)
  51060. * @returns a serialized layer object
  51061. */
  51062. abstract serialize?(): any;
  51063. /**
  51064. * Initializes the effect layer with the required options.
  51065. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51066. */
  51067. protected _init(options: Partial<IEffectLayerOptions>): void;
  51068. /**
  51069. * Generates the index buffer of the full screen quad blending to the main canvas.
  51070. */
  51071. private _generateIndexBuffer;
  51072. /**
  51073. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51074. */
  51075. private _generateVertexBuffer;
  51076. /**
  51077. * Sets the main texture desired size which is the closest power of two
  51078. * of the engine canvas size.
  51079. */
  51080. private _setMainTextureSize;
  51081. /**
  51082. * Creates the main texture for the effect layer.
  51083. */
  51084. protected _createMainTexture(): void;
  51085. /**
  51086. * Adds specific effects defines.
  51087. * @param defines The defines to add specifics to.
  51088. */
  51089. protected _addCustomEffectDefines(defines: string[]): void;
  51090. /**
  51091. * Checks for the readiness of the element composing the layer.
  51092. * @param subMesh the mesh to check for
  51093. * @param useInstances specify wether or not to use instances to render the mesh
  51094. * @param emissiveTexture the associated emissive texture used to generate the glow
  51095. * @return true if ready otherwise, false
  51096. */
  51097. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51098. /**
  51099. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51100. */
  51101. render(): void;
  51102. /**
  51103. * Determine if a given mesh will be used in the current effect.
  51104. * @param mesh mesh to test
  51105. * @returns true if the mesh will be used
  51106. */
  51107. hasMesh(mesh: AbstractMesh): boolean;
  51108. /**
  51109. * Returns true if the layer contains information to display, otherwise false.
  51110. * @returns true if the glow layer should be rendered
  51111. */
  51112. shouldRender(): boolean;
  51113. /**
  51114. * Returns true if the mesh should render, otherwise false.
  51115. * @param mesh The mesh to render
  51116. * @returns true if it should render otherwise false
  51117. */
  51118. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51119. /**
  51120. * Returns true if the mesh can be rendered, otherwise false.
  51121. * @param mesh The mesh to render
  51122. * @param material The material used on the mesh
  51123. * @returns true if it can be rendered otherwise false
  51124. */
  51125. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51126. /**
  51127. * Returns true if the mesh should render, otherwise false.
  51128. * @param mesh The mesh to render
  51129. * @returns true if it should render otherwise false
  51130. */
  51131. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51132. /**
  51133. * Renders the submesh passed in parameter to the generation map.
  51134. */
  51135. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51136. /**
  51137. * Rebuild the required buffers.
  51138. * @hidden Internal use only.
  51139. */
  51140. _rebuild(): void;
  51141. /**
  51142. * Dispose only the render target textures and post process.
  51143. */
  51144. private _disposeTextureAndPostProcesses;
  51145. /**
  51146. * Dispose the highlight layer and free resources.
  51147. */
  51148. dispose(): void;
  51149. /**
  51150. * Gets the class name of the effect layer
  51151. * @returns the string with the class name of the effect layer
  51152. */
  51153. getClassName(): string;
  51154. /**
  51155. * Creates an effect layer from parsed effect layer data
  51156. * @param parsedEffectLayer defines effect layer data
  51157. * @param scene defines the current scene
  51158. * @param rootUrl defines the root URL containing the effect layer information
  51159. * @returns a parsed effect Layer
  51160. */
  51161. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51162. }
  51163. }
  51164. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51165. import { Scene } from "babylonjs/scene";
  51166. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51167. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51168. import { AbstractScene } from "babylonjs/abstractScene";
  51169. module "babylonjs/abstractScene" {
  51170. interface AbstractScene {
  51171. /**
  51172. * The list of effect layers (highlights/glow) added to the scene
  51173. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51174. * @see http://doc.babylonjs.com/how_to/glow_layer
  51175. */
  51176. effectLayers: Array<EffectLayer>;
  51177. /**
  51178. * Removes the given effect layer from this scene.
  51179. * @param toRemove defines the effect layer to remove
  51180. * @returns the index of the removed effect layer
  51181. */
  51182. removeEffectLayer(toRemove: EffectLayer): number;
  51183. /**
  51184. * Adds the given effect layer to this scene
  51185. * @param newEffectLayer defines the effect layer to add
  51186. */
  51187. addEffectLayer(newEffectLayer: EffectLayer): void;
  51188. }
  51189. }
  51190. /**
  51191. * Defines the layer scene component responsible to manage any effect layers
  51192. * in a given scene.
  51193. */
  51194. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51195. /**
  51196. * The component name helpfull to identify the component in the list of scene components.
  51197. */
  51198. readonly name: string;
  51199. /**
  51200. * The scene the component belongs to.
  51201. */
  51202. scene: Scene;
  51203. private _engine;
  51204. private _renderEffects;
  51205. private _needStencil;
  51206. private _previousStencilState;
  51207. /**
  51208. * Creates a new instance of the component for the given scene
  51209. * @param scene Defines the scene to register the component in
  51210. */
  51211. constructor(scene: Scene);
  51212. /**
  51213. * Registers the component in a given scene
  51214. */
  51215. register(): void;
  51216. /**
  51217. * Rebuilds the elements related to this component in case of
  51218. * context lost for instance.
  51219. */
  51220. rebuild(): void;
  51221. /**
  51222. * Serializes the component data to the specified json object
  51223. * @param serializationObject The object to serialize to
  51224. */
  51225. serialize(serializationObject: any): void;
  51226. /**
  51227. * Adds all the elements from the container to the scene
  51228. * @param container the container holding the elements
  51229. */
  51230. addFromContainer(container: AbstractScene): void;
  51231. /**
  51232. * Removes all the elements in the container from the scene
  51233. * @param container contains the elements to remove
  51234. * @param dispose if the removed element should be disposed (default: false)
  51235. */
  51236. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51237. /**
  51238. * Disposes the component and the associated ressources.
  51239. */
  51240. dispose(): void;
  51241. private _isReadyForMesh;
  51242. private _renderMainTexture;
  51243. private _setStencil;
  51244. private _setStencilBack;
  51245. private _draw;
  51246. private _drawCamera;
  51247. private _drawRenderingGroup;
  51248. }
  51249. }
  51250. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51251. /** @hidden */
  51252. export var glowMapMergePixelShader: {
  51253. name: string;
  51254. shader: string;
  51255. };
  51256. }
  51257. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51258. /** @hidden */
  51259. export var glowMapMergeVertexShader: {
  51260. name: string;
  51261. shader: string;
  51262. };
  51263. }
  51264. declare module "babylonjs/Layers/glowLayer" {
  51265. import { Nullable } from "babylonjs/types";
  51266. import { Camera } from "babylonjs/Cameras/camera";
  51267. import { Scene } from "babylonjs/scene";
  51268. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51270. import { Mesh } from "babylonjs/Meshes/mesh";
  51271. import { Texture } from "babylonjs/Materials/Textures/texture";
  51272. import { Effect } from "babylonjs/Materials/effect";
  51273. import { Material } from "babylonjs/Materials/material";
  51274. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51275. import { Color4 } from "babylonjs/Maths/math.color";
  51276. import "babylonjs/Shaders/glowMapMerge.fragment";
  51277. import "babylonjs/Shaders/glowMapMerge.vertex";
  51278. import "babylonjs/Layers/effectLayerSceneComponent";
  51279. module "babylonjs/abstractScene" {
  51280. interface AbstractScene {
  51281. /**
  51282. * Return a the first highlight layer of the scene with a given name.
  51283. * @param name The name of the highlight layer to look for.
  51284. * @return The highlight layer if found otherwise null.
  51285. */
  51286. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51287. }
  51288. }
  51289. /**
  51290. * Glow layer options. This helps customizing the behaviour
  51291. * of the glow layer.
  51292. */
  51293. export interface IGlowLayerOptions {
  51294. /**
  51295. * Multiplication factor apply to the canvas size to compute the render target size
  51296. * used to generated the glowing objects (the smaller the faster).
  51297. */
  51298. mainTextureRatio: number;
  51299. /**
  51300. * Enforces a fixed size texture to ensure resize independant blur.
  51301. */
  51302. mainTextureFixedSize?: number;
  51303. /**
  51304. * How big is the kernel of the blur texture.
  51305. */
  51306. blurKernelSize: number;
  51307. /**
  51308. * The camera attached to the layer.
  51309. */
  51310. camera: Nullable<Camera>;
  51311. /**
  51312. * Enable MSAA by chosing the number of samples.
  51313. */
  51314. mainTextureSamples?: number;
  51315. /**
  51316. * The rendering group to draw the layer in.
  51317. */
  51318. renderingGroupId: number;
  51319. }
  51320. /**
  51321. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51322. *
  51323. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51324. * glowy meshes to your scene.
  51325. *
  51326. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51327. */
  51328. export class GlowLayer extends EffectLayer {
  51329. /**
  51330. * Effect Name of the layer.
  51331. */
  51332. static readonly EffectName: string;
  51333. /**
  51334. * The default blur kernel size used for the glow.
  51335. */
  51336. static DefaultBlurKernelSize: number;
  51337. /**
  51338. * The default texture size ratio used for the glow.
  51339. */
  51340. static DefaultTextureRatio: number;
  51341. /**
  51342. * Sets the kernel size of the blur.
  51343. */
  51344. /**
  51345. * Gets the kernel size of the blur.
  51346. */
  51347. blurKernelSize: number;
  51348. /**
  51349. * Sets the glow intensity.
  51350. */
  51351. /**
  51352. * Gets the glow intensity.
  51353. */
  51354. intensity: number;
  51355. private _options;
  51356. private _intensity;
  51357. private _horizontalBlurPostprocess1;
  51358. private _verticalBlurPostprocess1;
  51359. private _horizontalBlurPostprocess2;
  51360. private _verticalBlurPostprocess2;
  51361. private _blurTexture1;
  51362. private _blurTexture2;
  51363. private _postProcesses1;
  51364. private _postProcesses2;
  51365. private _includedOnlyMeshes;
  51366. private _excludedMeshes;
  51367. /**
  51368. * Callback used to let the user override the color selection on a per mesh basis
  51369. */
  51370. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51371. /**
  51372. * Callback used to let the user override the texture selection on a per mesh basis
  51373. */
  51374. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51375. /**
  51376. * Instantiates a new glow Layer and references it to the scene.
  51377. * @param name The name of the layer
  51378. * @param scene The scene to use the layer in
  51379. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51380. */
  51381. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51382. /**
  51383. * Get the effect name of the layer.
  51384. * @return The effect name
  51385. */
  51386. getEffectName(): string;
  51387. /**
  51388. * Create the merge effect. This is the shader use to blit the information back
  51389. * to the main canvas at the end of the scene rendering.
  51390. */
  51391. protected _createMergeEffect(): Effect;
  51392. /**
  51393. * Creates the render target textures and post processes used in the glow layer.
  51394. */
  51395. protected _createTextureAndPostProcesses(): void;
  51396. /**
  51397. * Checks for the readiness of the element composing the layer.
  51398. * @param subMesh the mesh to check for
  51399. * @param useInstances specify wether or not to use instances to render the mesh
  51400. * @param emissiveTexture the associated emissive texture used to generate the glow
  51401. * @return true if ready otherwise, false
  51402. */
  51403. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51404. /**
  51405. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51406. */
  51407. needStencil(): boolean;
  51408. /**
  51409. * Returns true if the mesh can be rendered, otherwise false.
  51410. * @param mesh The mesh to render
  51411. * @param material The material used on the mesh
  51412. * @returns true if it can be rendered otherwise false
  51413. */
  51414. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51415. /**
  51416. * Implementation specific of rendering the generating effect on the main canvas.
  51417. * @param effect The effect used to render through
  51418. */
  51419. protected _internalRender(effect: Effect): void;
  51420. /**
  51421. * Sets the required values for both the emissive texture and and the main color.
  51422. */
  51423. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51424. /**
  51425. * Returns true if the mesh should render, otherwise false.
  51426. * @param mesh The mesh to render
  51427. * @returns true if it should render otherwise false
  51428. */
  51429. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51430. /**
  51431. * Adds specific effects defines.
  51432. * @param defines The defines to add specifics to.
  51433. */
  51434. protected _addCustomEffectDefines(defines: string[]): void;
  51435. /**
  51436. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51437. * @param mesh The mesh to exclude from the glow layer
  51438. */
  51439. addExcludedMesh(mesh: Mesh): void;
  51440. /**
  51441. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51442. * @param mesh The mesh to remove
  51443. */
  51444. removeExcludedMesh(mesh: Mesh): void;
  51445. /**
  51446. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51447. * @param mesh The mesh to include in the glow layer
  51448. */
  51449. addIncludedOnlyMesh(mesh: Mesh): void;
  51450. /**
  51451. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51452. * @param mesh The mesh to remove
  51453. */
  51454. removeIncludedOnlyMesh(mesh: Mesh): void;
  51455. /**
  51456. * Determine if a given mesh will be used in the glow layer
  51457. * @param mesh The mesh to test
  51458. * @returns true if the mesh will be highlighted by the current glow layer
  51459. */
  51460. hasMesh(mesh: AbstractMesh): boolean;
  51461. /**
  51462. * Free any resources and references associated to a mesh.
  51463. * Internal use
  51464. * @param mesh The mesh to free.
  51465. * @hidden
  51466. */
  51467. _disposeMesh(mesh: Mesh): void;
  51468. /**
  51469. * Gets the class name of the effect layer
  51470. * @returns the string with the class name of the effect layer
  51471. */
  51472. getClassName(): string;
  51473. /**
  51474. * Serializes this glow layer
  51475. * @returns a serialized glow layer object
  51476. */
  51477. serialize(): any;
  51478. /**
  51479. * Creates a Glow Layer from parsed glow layer data
  51480. * @param parsedGlowLayer defines glow layer data
  51481. * @param scene defines the current scene
  51482. * @param rootUrl defines the root URL containing the glow layer information
  51483. * @returns a parsed Glow Layer
  51484. */
  51485. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51486. }
  51487. }
  51488. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51489. /** @hidden */
  51490. export var glowBlurPostProcessPixelShader: {
  51491. name: string;
  51492. shader: string;
  51493. };
  51494. }
  51495. declare module "babylonjs/Layers/highlightLayer" {
  51496. import { Observable } from "babylonjs/Misc/observable";
  51497. import { Nullable } from "babylonjs/types";
  51498. import { Camera } from "babylonjs/Cameras/camera";
  51499. import { Scene } from "babylonjs/scene";
  51500. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51502. import { Mesh } from "babylonjs/Meshes/mesh";
  51503. import { Effect } from "babylonjs/Materials/effect";
  51504. import { Material } from "babylonjs/Materials/material";
  51505. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51506. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51507. import "babylonjs/Shaders/glowMapMerge.fragment";
  51508. import "babylonjs/Shaders/glowMapMerge.vertex";
  51509. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  51510. module "babylonjs/abstractScene" {
  51511. interface AbstractScene {
  51512. /**
  51513. * Return a the first highlight layer of the scene with a given name.
  51514. * @param name The name of the highlight layer to look for.
  51515. * @return The highlight layer if found otherwise null.
  51516. */
  51517. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51518. }
  51519. }
  51520. /**
  51521. * Highlight layer options. This helps customizing the behaviour
  51522. * of the highlight layer.
  51523. */
  51524. export interface IHighlightLayerOptions {
  51525. /**
  51526. * Multiplication factor apply to the canvas size to compute the render target size
  51527. * used to generated the glowing objects (the smaller the faster).
  51528. */
  51529. mainTextureRatio: number;
  51530. /**
  51531. * Enforces a fixed size texture to ensure resize independant blur.
  51532. */
  51533. mainTextureFixedSize?: number;
  51534. /**
  51535. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51536. * of the picture to blur (the smaller the faster).
  51537. */
  51538. blurTextureSizeRatio: number;
  51539. /**
  51540. * How big in texel of the blur texture is the vertical blur.
  51541. */
  51542. blurVerticalSize: number;
  51543. /**
  51544. * How big in texel of the blur texture is the horizontal blur.
  51545. */
  51546. blurHorizontalSize: number;
  51547. /**
  51548. * Alpha blending mode used to apply the blur. Default is combine.
  51549. */
  51550. alphaBlendingMode: number;
  51551. /**
  51552. * The camera attached to the layer.
  51553. */
  51554. camera: Nullable<Camera>;
  51555. /**
  51556. * Should we display highlight as a solid stroke?
  51557. */
  51558. isStroke?: boolean;
  51559. /**
  51560. * The rendering group to draw the layer in.
  51561. */
  51562. renderingGroupId: number;
  51563. }
  51564. /**
  51565. * The highlight layer Helps adding a glow effect around a mesh.
  51566. *
  51567. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51568. * glowy meshes to your scene.
  51569. *
  51570. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51571. */
  51572. export class HighlightLayer extends EffectLayer {
  51573. name: string;
  51574. /**
  51575. * Effect Name of the highlight layer.
  51576. */
  51577. static readonly EffectName: string;
  51578. /**
  51579. * The neutral color used during the preparation of the glow effect.
  51580. * This is black by default as the blend operation is a blend operation.
  51581. */
  51582. static NeutralColor: Color4;
  51583. /**
  51584. * Stencil value used for glowing meshes.
  51585. */
  51586. static GlowingMeshStencilReference: number;
  51587. /**
  51588. * Stencil value used for the other meshes in the scene.
  51589. */
  51590. static NormalMeshStencilReference: number;
  51591. /**
  51592. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51593. */
  51594. innerGlow: boolean;
  51595. /**
  51596. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51597. */
  51598. outerGlow: boolean;
  51599. /**
  51600. * Specifies the horizontal size of the blur.
  51601. */
  51602. /**
  51603. * Gets the horizontal size of the blur.
  51604. */
  51605. blurHorizontalSize: number;
  51606. /**
  51607. * Specifies the vertical size of the blur.
  51608. */
  51609. /**
  51610. * Gets the vertical size of the blur.
  51611. */
  51612. blurVerticalSize: number;
  51613. /**
  51614. * An event triggered when the highlight layer is being blurred.
  51615. */
  51616. onBeforeBlurObservable: Observable<HighlightLayer>;
  51617. /**
  51618. * An event triggered when the highlight layer has been blurred.
  51619. */
  51620. onAfterBlurObservable: Observable<HighlightLayer>;
  51621. private _instanceGlowingMeshStencilReference;
  51622. private _options;
  51623. private _downSamplePostprocess;
  51624. private _horizontalBlurPostprocess;
  51625. private _verticalBlurPostprocess;
  51626. private _blurTexture;
  51627. private _meshes;
  51628. private _excludedMeshes;
  51629. /**
  51630. * Instantiates a new highlight Layer and references it to the scene..
  51631. * @param name The name of the layer
  51632. * @param scene The scene to use the layer in
  51633. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51634. */
  51635. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51636. /**
  51637. * Get the effect name of the layer.
  51638. * @return The effect name
  51639. */
  51640. getEffectName(): string;
  51641. /**
  51642. * Create the merge effect. This is the shader use to blit the information back
  51643. * to the main canvas at the end of the scene rendering.
  51644. */
  51645. protected _createMergeEffect(): Effect;
  51646. /**
  51647. * Creates the render target textures and post processes used in the highlight layer.
  51648. */
  51649. protected _createTextureAndPostProcesses(): void;
  51650. /**
  51651. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51652. */
  51653. needStencil(): boolean;
  51654. /**
  51655. * Checks for the readiness of the element composing the layer.
  51656. * @param subMesh the mesh to check for
  51657. * @param useInstances specify wether or not to use instances to render the mesh
  51658. * @param emissiveTexture the associated emissive texture used to generate the glow
  51659. * @return true if ready otherwise, false
  51660. */
  51661. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51662. /**
  51663. * Implementation specific of rendering the generating effect on the main canvas.
  51664. * @param effect The effect used to render through
  51665. */
  51666. protected _internalRender(effect: Effect): void;
  51667. /**
  51668. * Returns true if the layer contains information to display, otherwise false.
  51669. */
  51670. shouldRender(): boolean;
  51671. /**
  51672. * Returns true if the mesh should render, otherwise false.
  51673. * @param mesh The mesh to render
  51674. * @returns true if it should render otherwise false
  51675. */
  51676. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51677. /**
  51678. * Sets the required values for both the emissive texture and and the main color.
  51679. */
  51680. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51681. /**
  51682. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51683. * @param mesh The mesh to exclude from the highlight layer
  51684. */
  51685. addExcludedMesh(mesh: Mesh): void;
  51686. /**
  51687. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51688. * @param mesh The mesh to highlight
  51689. */
  51690. removeExcludedMesh(mesh: Mesh): void;
  51691. /**
  51692. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51693. * @param mesh mesh to test
  51694. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51695. */
  51696. hasMesh(mesh: AbstractMesh): boolean;
  51697. /**
  51698. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51699. * @param mesh The mesh to highlight
  51700. * @param color The color of the highlight
  51701. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51702. */
  51703. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51704. /**
  51705. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51706. * @param mesh The mesh to highlight
  51707. */
  51708. removeMesh(mesh: Mesh): void;
  51709. /**
  51710. * Force the stencil to the normal expected value for none glowing parts
  51711. */
  51712. private _defaultStencilReference;
  51713. /**
  51714. * Free any resources and references associated to a mesh.
  51715. * Internal use
  51716. * @param mesh The mesh to free.
  51717. * @hidden
  51718. */
  51719. _disposeMesh(mesh: Mesh): void;
  51720. /**
  51721. * Dispose the highlight layer and free resources.
  51722. */
  51723. dispose(): void;
  51724. /**
  51725. * Gets the class name of the effect layer
  51726. * @returns the string with the class name of the effect layer
  51727. */
  51728. getClassName(): string;
  51729. /**
  51730. * Serializes this Highlight layer
  51731. * @returns a serialized Highlight layer object
  51732. */
  51733. serialize(): any;
  51734. /**
  51735. * Creates a Highlight layer from parsed Highlight layer data
  51736. * @param parsedHightlightLayer defines the Highlight layer data
  51737. * @param scene defines the current scene
  51738. * @param rootUrl defines the root URL containing the Highlight layer information
  51739. * @returns a parsed Highlight layer
  51740. */
  51741. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51742. }
  51743. }
  51744. declare module "babylonjs/Layers/layerSceneComponent" {
  51745. import { Scene } from "babylonjs/scene";
  51746. import { ISceneComponent } from "babylonjs/sceneComponent";
  51747. import { Layer } from "babylonjs/Layers/layer";
  51748. import { AbstractScene } from "babylonjs/abstractScene";
  51749. module "babylonjs/abstractScene" {
  51750. interface AbstractScene {
  51751. /**
  51752. * The list of layers (background and foreground) of the scene
  51753. */
  51754. layers: Array<Layer>;
  51755. }
  51756. }
  51757. /**
  51758. * Defines the layer scene component responsible to manage any layers
  51759. * in a given scene.
  51760. */
  51761. export class LayerSceneComponent implements ISceneComponent {
  51762. /**
  51763. * The component name helpfull to identify the component in the list of scene components.
  51764. */
  51765. readonly name: string;
  51766. /**
  51767. * The scene the component belongs to.
  51768. */
  51769. scene: Scene;
  51770. private _engine;
  51771. /**
  51772. * Creates a new instance of the component for the given scene
  51773. * @param scene Defines the scene to register the component in
  51774. */
  51775. constructor(scene: Scene);
  51776. /**
  51777. * Registers the component in a given scene
  51778. */
  51779. register(): void;
  51780. /**
  51781. * Rebuilds the elements related to this component in case of
  51782. * context lost for instance.
  51783. */
  51784. rebuild(): void;
  51785. /**
  51786. * Disposes the component and the associated ressources.
  51787. */
  51788. dispose(): void;
  51789. private _draw;
  51790. private _drawCameraPredicate;
  51791. private _drawCameraBackground;
  51792. private _drawCameraForeground;
  51793. private _drawRenderTargetPredicate;
  51794. private _drawRenderTargetBackground;
  51795. private _drawRenderTargetForeground;
  51796. /**
  51797. * Adds all the elements from the container to the scene
  51798. * @param container the container holding the elements
  51799. */
  51800. addFromContainer(container: AbstractScene): void;
  51801. /**
  51802. * Removes all the elements in the container from the scene
  51803. * @param container contains the elements to remove
  51804. * @param dispose if the removed element should be disposed (default: false)
  51805. */
  51806. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51807. }
  51808. }
  51809. declare module "babylonjs/Shaders/layer.fragment" {
  51810. /** @hidden */
  51811. export var layerPixelShader: {
  51812. name: string;
  51813. shader: string;
  51814. };
  51815. }
  51816. declare module "babylonjs/Shaders/layer.vertex" {
  51817. /** @hidden */
  51818. export var layerVertexShader: {
  51819. name: string;
  51820. shader: string;
  51821. };
  51822. }
  51823. declare module "babylonjs/Layers/layer" {
  51824. import { Observable } from "babylonjs/Misc/observable";
  51825. import { Nullable } from "babylonjs/types";
  51826. import { Scene } from "babylonjs/scene";
  51827. import { Vector2 } from "babylonjs/Maths/math.vector";
  51828. import { Color4 } from "babylonjs/Maths/math.color";
  51829. import { Texture } from "babylonjs/Materials/Textures/texture";
  51830. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51831. import "babylonjs/Shaders/layer.fragment";
  51832. import "babylonjs/Shaders/layer.vertex";
  51833. /**
  51834. * This represents a full screen 2d layer.
  51835. * This can be useful to display a picture in the background of your scene for instance.
  51836. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51837. */
  51838. export class Layer {
  51839. /**
  51840. * Define the name of the layer.
  51841. */
  51842. name: string;
  51843. /**
  51844. * Define the texture the layer should display.
  51845. */
  51846. texture: Nullable<Texture>;
  51847. /**
  51848. * Is the layer in background or foreground.
  51849. */
  51850. isBackground: boolean;
  51851. /**
  51852. * Define the color of the layer (instead of texture).
  51853. */
  51854. color: Color4;
  51855. /**
  51856. * Define the scale of the layer in order to zoom in out of the texture.
  51857. */
  51858. scale: Vector2;
  51859. /**
  51860. * Define an offset for the layer in order to shift the texture.
  51861. */
  51862. offset: Vector2;
  51863. /**
  51864. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51865. */
  51866. alphaBlendingMode: number;
  51867. /**
  51868. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51869. * Alpha test will not mix with the background color in case of transparency.
  51870. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51871. */
  51872. alphaTest: boolean;
  51873. /**
  51874. * Define a mask to restrict the layer to only some of the scene cameras.
  51875. */
  51876. layerMask: number;
  51877. /**
  51878. * Define the list of render target the layer is visible into.
  51879. */
  51880. renderTargetTextures: RenderTargetTexture[];
  51881. /**
  51882. * Define if the layer is only used in renderTarget or if it also
  51883. * renders in the main frame buffer of the canvas.
  51884. */
  51885. renderOnlyInRenderTargetTextures: boolean;
  51886. private _scene;
  51887. private _vertexBuffers;
  51888. private _indexBuffer;
  51889. private _effect;
  51890. private _alphaTestEffect;
  51891. /**
  51892. * An event triggered when the layer is disposed.
  51893. */
  51894. onDisposeObservable: Observable<Layer>;
  51895. private _onDisposeObserver;
  51896. /**
  51897. * Back compatibility with callback before the onDisposeObservable existed.
  51898. * The set callback will be triggered when the layer has been disposed.
  51899. */
  51900. onDispose: () => void;
  51901. /**
  51902. * An event triggered before rendering the scene
  51903. */
  51904. onBeforeRenderObservable: Observable<Layer>;
  51905. private _onBeforeRenderObserver;
  51906. /**
  51907. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51908. * The set callback will be triggered just before rendering the layer.
  51909. */
  51910. onBeforeRender: () => void;
  51911. /**
  51912. * An event triggered after rendering the scene
  51913. */
  51914. onAfterRenderObservable: Observable<Layer>;
  51915. private _onAfterRenderObserver;
  51916. /**
  51917. * Back compatibility with callback before the onAfterRenderObservable existed.
  51918. * The set callback will be triggered just after rendering the layer.
  51919. */
  51920. onAfterRender: () => void;
  51921. /**
  51922. * Instantiates a new layer.
  51923. * This represents a full screen 2d layer.
  51924. * This can be useful to display a picture in the background of your scene for instance.
  51925. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51926. * @param name Define the name of the layer in the scene
  51927. * @param imgUrl Define the url of the texture to display in the layer
  51928. * @param scene Define the scene the layer belongs to
  51929. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51930. * @param color Defines a color for the layer
  51931. */
  51932. constructor(
  51933. /**
  51934. * Define the name of the layer.
  51935. */
  51936. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51937. private _createIndexBuffer;
  51938. /** @hidden */
  51939. _rebuild(): void;
  51940. /**
  51941. * Renders the layer in the scene.
  51942. */
  51943. render(): void;
  51944. /**
  51945. * Disposes and releases the associated ressources.
  51946. */
  51947. dispose(): void;
  51948. }
  51949. }
  51950. declare module "babylonjs/Layers/index" {
  51951. export * from "babylonjs/Layers/effectLayer";
  51952. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51953. export * from "babylonjs/Layers/glowLayer";
  51954. export * from "babylonjs/Layers/highlightLayer";
  51955. export * from "babylonjs/Layers/layer";
  51956. export * from "babylonjs/Layers/layerSceneComponent";
  51957. }
  51958. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51959. /** @hidden */
  51960. export var lensFlarePixelShader: {
  51961. name: string;
  51962. shader: string;
  51963. };
  51964. }
  51965. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51966. /** @hidden */
  51967. export var lensFlareVertexShader: {
  51968. name: string;
  51969. shader: string;
  51970. };
  51971. }
  51972. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51973. import { Scene } from "babylonjs/scene";
  51974. import { Vector3 } from "babylonjs/Maths/math.vector";
  51975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51976. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51977. import "babylonjs/Shaders/lensFlare.fragment";
  51978. import "babylonjs/Shaders/lensFlare.vertex";
  51979. import { Viewport } from "babylonjs/Maths/math.viewport";
  51980. /**
  51981. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51982. * It is usually composed of several `lensFlare`.
  51983. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51984. */
  51985. export class LensFlareSystem {
  51986. /**
  51987. * Define the name of the lens flare system
  51988. */
  51989. name: string;
  51990. /**
  51991. * List of lens flares used in this system.
  51992. */
  51993. lensFlares: LensFlare[];
  51994. /**
  51995. * Define a limit from the border the lens flare can be visible.
  51996. */
  51997. borderLimit: number;
  51998. /**
  51999. * Define a viewport border we do not want to see the lens flare in.
  52000. */
  52001. viewportBorder: number;
  52002. /**
  52003. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52004. */
  52005. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52006. /**
  52007. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52008. */
  52009. layerMask: number;
  52010. /**
  52011. * Define the id of the lens flare system in the scene.
  52012. * (equal to name by default)
  52013. */
  52014. id: string;
  52015. private _scene;
  52016. private _emitter;
  52017. private _vertexBuffers;
  52018. private _indexBuffer;
  52019. private _effect;
  52020. private _positionX;
  52021. private _positionY;
  52022. private _isEnabled;
  52023. /** @hidden */
  52024. static _SceneComponentInitialization: (scene: Scene) => void;
  52025. /**
  52026. * Instantiates a lens flare system.
  52027. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52028. * It is usually composed of several `lensFlare`.
  52029. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52030. * @param name Define the name of the lens flare system in the scene
  52031. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52032. * @param scene Define the scene the lens flare system belongs to
  52033. */
  52034. constructor(
  52035. /**
  52036. * Define the name of the lens flare system
  52037. */
  52038. name: string, emitter: any, scene: Scene);
  52039. /**
  52040. * Define if the lens flare system is enabled.
  52041. */
  52042. isEnabled: boolean;
  52043. /**
  52044. * Get the scene the effects belongs to.
  52045. * @returns the scene holding the lens flare system
  52046. */
  52047. getScene(): Scene;
  52048. /**
  52049. * Get the emitter of the lens flare system.
  52050. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52051. * @returns the emitter of the lens flare system
  52052. */
  52053. getEmitter(): any;
  52054. /**
  52055. * Set the emitter of the lens flare system.
  52056. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52057. * @param newEmitter Define the new emitter of the system
  52058. */
  52059. setEmitter(newEmitter: any): void;
  52060. /**
  52061. * Get the lens flare system emitter position.
  52062. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52063. * @returns the position
  52064. */
  52065. getEmitterPosition(): Vector3;
  52066. /**
  52067. * @hidden
  52068. */
  52069. computeEffectivePosition(globalViewport: Viewport): boolean;
  52070. /** @hidden */
  52071. _isVisible(): boolean;
  52072. /**
  52073. * @hidden
  52074. */
  52075. render(): boolean;
  52076. /**
  52077. * Dispose and release the lens flare with its associated resources.
  52078. */
  52079. dispose(): void;
  52080. /**
  52081. * Parse a lens flare system from a JSON repressentation
  52082. * @param parsedLensFlareSystem Define the JSON to parse
  52083. * @param scene Define the scene the parsed system should be instantiated in
  52084. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52085. * @returns the parsed system
  52086. */
  52087. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52088. /**
  52089. * Serialize the current Lens Flare System into a JSON representation.
  52090. * @returns the serialized JSON
  52091. */
  52092. serialize(): any;
  52093. }
  52094. }
  52095. declare module "babylonjs/LensFlares/lensFlare" {
  52096. import { Nullable } from "babylonjs/types";
  52097. import { Color3 } from "babylonjs/Maths/math.color";
  52098. import { Texture } from "babylonjs/Materials/Textures/texture";
  52099. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52100. /**
  52101. * This represents one of the lens effect in a `lensFlareSystem`.
  52102. * It controls one of the indiviual texture used in the effect.
  52103. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52104. */
  52105. export class LensFlare {
  52106. /**
  52107. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52108. */
  52109. size: number;
  52110. /**
  52111. * 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.
  52112. */
  52113. position: number;
  52114. /**
  52115. * Define the lens color.
  52116. */
  52117. color: Color3;
  52118. /**
  52119. * Define the lens texture.
  52120. */
  52121. texture: Nullable<Texture>;
  52122. /**
  52123. * Define the alpha mode to render this particular lens.
  52124. */
  52125. alphaMode: number;
  52126. private _system;
  52127. /**
  52128. * Creates a new Lens Flare.
  52129. * This represents one of the lens effect in a `lensFlareSystem`.
  52130. * It controls one of the indiviual texture used in the effect.
  52131. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52132. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52133. * @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.
  52134. * @param color Define the lens color
  52135. * @param imgUrl Define the lens texture url
  52136. * @param system Define the `lensFlareSystem` this flare is part of
  52137. * @returns The newly created Lens Flare
  52138. */
  52139. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52140. /**
  52141. * Instantiates a new Lens Flare.
  52142. * This represents one of the lens effect in a `lensFlareSystem`.
  52143. * It controls one of the indiviual texture used in the effect.
  52144. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52145. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52146. * @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.
  52147. * @param color Define the lens color
  52148. * @param imgUrl Define the lens texture url
  52149. * @param system Define the `lensFlareSystem` this flare is part of
  52150. */
  52151. constructor(
  52152. /**
  52153. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52154. */
  52155. size: number,
  52156. /**
  52157. * 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.
  52158. */
  52159. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52160. /**
  52161. * Dispose and release the lens flare with its associated resources.
  52162. */
  52163. dispose(): void;
  52164. }
  52165. }
  52166. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52167. import { Nullable } from "babylonjs/types";
  52168. import { Scene } from "babylonjs/scene";
  52169. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52170. import { AbstractScene } from "babylonjs/abstractScene";
  52171. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52172. module "babylonjs/abstractScene" {
  52173. interface AbstractScene {
  52174. /**
  52175. * The list of lens flare system added to the scene
  52176. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52177. */
  52178. lensFlareSystems: Array<LensFlareSystem>;
  52179. /**
  52180. * Removes the given lens flare system from this scene.
  52181. * @param toRemove The lens flare system to remove
  52182. * @returns The index of the removed lens flare system
  52183. */
  52184. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52185. /**
  52186. * Adds the given lens flare system to this scene
  52187. * @param newLensFlareSystem The lens flare system to add
  52188. */
  52189. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52190. /**
  52191. * Gets a lens flare system using its name
  52192. * @param name defines the name to look for
  52193. * @returns the lens flare system or null if not found
  52194. */
  52195. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52196. /**
  52197. * Gets a lens flare system using its id
  52198. * @param id defines the id to look for
  52199. * @returns the lens flare system or null if not found
  52200. */
  52201. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52202. }
  52203. }
  52204. /**
  52205. * Defines the lens flare scene component responsible to manage any lens flares
  52206. * in a given scene.
  52207. */
  52208. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52209. /**
  52210. * The component name helpfull to identify the component in the list of scene components.
  52211. */
  52212. readonly name: string;
  52213. /**
  52214. * The scene the component belongs to.
  52215. */
  52216. scene: Scene;
  52217. /**
  52218. * Creates a new instance of the component for the given scene
  52219. * @param scene Defines the scene to register the component in
  52220. */
  52221. constructor(scene: Scene);
  52222. /**
  52223. * Registers the component in a given scene
  52224. */
  52225. register(): void;
  52226. /**
  52227. * Rebuilds the elements related to this component in case of
  52228. * context lost for instance.
  52229. */
  52230. rebuild(): void;
  52231. /**
  52232. * Adds all the elements from the container to the scene
  52233. * @param container the container holding the elements
  52234. */
  52235. addFromContainer(container: AbstractScene): void;
  52236. /**
  52237. * Removes all the elements in the container from the scene
  52238. * @param container contains the elements to remove
  52239. * @param dispose if the removed element should be disposed (default: false)
  52240. */
  52241. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52242. /**
  52243. * Serializes the component data to the specified json object
  52244. * @param serializationObject The object to serialize to
  52245. */
  52246. serialize(serializationObject: any): void;
  52247. /**
  52248. * Disposes the component and the associated ressources.
  52249. */
  52250. dispose(): void;
  52251. private _draw;
  52252. }
  52253. }
  52254. declare module "babylonjs/LensFlares/index" {
  52255. export * from "babylonjs/LensFlares/lensFlare";
  52256. export * from "babylonjs/LensFlares/lensFlareSystem";
  52257. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52258. }
  52259. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52260. import { Scene } from "babylonjs/scene";
  52261. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52262. import { AbstractScene } from "babylonjs/abstractScene";
  52263. /**
  52264. * Defines the shadow generator component responsible to manage any shadow generators
  52265. * in a given scene.
  52266. */
  52267. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52268. /**
  52269. * The component name helpfull to identify the component in the list of scene components.
  52270. */
  52271. readonly name: string;
  52272. /**
  52273. * The scene the component belongs to.
  52274. */
  52275. scene: Scene;
  52276. /**
  52277. * Creates a new instance of the component for the given scene
  52278. * @param scene Defines the scene to register the component in
  52279. */
  52280. constructor(scene: Scene);
  52281. /**
  52282. * Registers the component in a given scene
  52283. */
  52284. register(): void;
  52285. /**
  52286. * Rebuilds the elements related to this component in case of
  52287. * context lost for instance.
  52288. */
  52289. rebuild(): void;
  52290. /**
  52291. * Serializes the component data to the specified json object
  52292. * @param serializationObject The object to serialize to
  52293. */
  52294. serialize(serializationObject: any): void;
  52295. /**
  52296. * Adds all the elements from the container to the scene
  52297. * @param container the container holding the elements
  52298. */
  52299. addFromContainer(container: AbstractScene): void;
  52300. /**
  52301. * Removes all the elements in the container from the scene
  52302. * @param container contains the elements to remove
  52303. * @param dispose if the removed element should be disposed (default: false)
  52304. */
  52305. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52306. /**
  52307. * Rebuilds the elements related to this component in case of
  52308. * context lost for instance.
  52309. */
  52310. dispose(): void;
  52311. private _gatherRenderTargets;
  52312. }
  52313. }
  52314. declare module "babylonjs/Lights/Shadows/index" {
  52315. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52316. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52317. }
  52318. declare module "babylonjs/Lights/pointLight" {
  52319. import { Scene } from "babylonjs/scene";
  52320. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52322. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52323. import { Effect } from "babylonjs/Materials/effect";
  52324. /**
  52325. * A point light is a light defined by an unique point in world space.
  52326. * The light is emitted in every direction from this point.
  52327. * A good example of a point light is a standard light bulb.
  52328. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52329. */
  52330. export class PointLight extends ShadowLight {
  52331. private _shadowAngle;
  52332. /**
  52333. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52334. * This specifies what angle the shadow will use to be created.
  52335. *
  52336. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52337. */
  52338. /**
  52339. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52340. * This specifies what angle the shadow will use to be created.
  52341. *
  52342. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52343. */
  52344. shadowAngle: number;
  52345. /**
  52346. * Gets the direction if it has been set.
  52347. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52348. */
  52349. /**
  52350. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52351. */
  52352. direction: Vector3;
  52353. /**
  52354. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52355. * A PointLight emits the light in every direction.
  52356. * It can cast shadows.
  52357. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52358. * ```javascript
  52359. * var pointLight = new PointLight("pl", camera.position, scene);
  52360. * ```
  52361. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52362. * @param name The light friendly name
  52363. * @param position The position of the point light in the scene
  52364. * @param scene The scene the lights belongs to
  52365. */
  52366. constructor(name: string, position: Vector3, scene: Scene);
  52367. /**
  52368. * Returns the string "PointLight"
  52369. * @returns the class name
  52370. */
  52371. getClassName(): string;
  52372. /**
  52373. * Returns the integer 0.
  52374. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52375. */
  52376. getTypeID(): number;
  52377. /**
  52378. * Specifies wether or not the shadowmap should be a cube texture.
  52379. * @returns true if the shadowmap needs to be a cube texture.
  52380. */
  52381. needCube(): boolean;
  52382. /**
  52383. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52384. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52385. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52386. */
  52387. getShadowDirection(faceIndex?: number): Vector3;
  52388. /**
  52389. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52390. * - fov = PI / 2
  52391. * - aspect ratio : 1.0
  52392. * - z-near and far equal to the active camera minZ and maxZ.
  52393. * Returns the PointLight.
  52394. */
  52395. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52396. protected _buildUniformLayout(): void;
  52397. /**
  52398. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52399. * @param effect The effect to update
  52400. * @param lightIndex The index of the light in the effect to update
  52401. * @returns The point light
  52402. */
  52403. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52404. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52405. /**
  52406. * Prepares the list of defines specific to the light type.
  52407. * @param defines the list of defines
  52408. * @param lightIndex defines the index of the light for the effect
  52409. */
  52410. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52411. }
  52412. }
  52413. declare module "babylonjs/Lights/index" {
  52414. export * from "babylonjs/Lights/light";
  52415. export * from "babylonjs/Lights/shadowLight";
  52416. export * from "babylonjs/Lights/Shadows/index";
  52417. export * from "babylonjs/Lights/directionalLight";
  52418. export * from "babylonjs/Lights/hemisphericLight";
  52419. export * from "babylonjs/Lights/pointLight";
  52420. export * from "babylonjs/Lights/spotLight";
  52421. }
  52422. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52423. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52424. /**
  52425. * Header information of HDR texture files.
  52426. */
  52427. export interface HDRInfo {
  52428. /**
  52429. * The height of the texture in pixels.
  52430. */
  52431. height: number;
  52432. /**
  52433. * The width of the texture in pixels.
  52434. */
  52435. width: number;
  52436. /**
  52437. * The index of the beginning of the data in the binary file.
  52438. */
  52439. dataPosition: number;
  52440. }
  52441. /**
  52442. * This groups tools to convert HDR texture to native colors array.
  52443. */
  52444. export class HDRTools {
  52445. private static Ldexp;
  52446. private static Rgbe2float;
  52447. private static readStringLine;
  52448. /**
  52449. * Reads header information from an RGBE texture stored in a native array.
  52450. * More information on this format are available here:
  52451. * https://en.wikipedia.org/wiki/RGBE_image_format
  52452. *
  52453. * @param uint8array The binary file stored in native array.
  52454. * @return The header information.
  52455. */
  52456. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52457. /**
  52458. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52459. * This RGBE texture needs to store the information as a panorama.
  52460. *
  52461. * More information on this format are available here:
  52462. * https://en.wikipedia.org/wiki/RGBE_image_format
  52463. *
  52464. * @param buffer The binary file stored in an array buffer.
  52465. * @param size The expected size of the extracted cubemap.
  52466. * @return The Cube Map information.
  52467. */
  52468. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52469. /**
  52470. * Returns the pixels data extracted from an RGBE texture.
  52471. * This pixels will be stored left to right up to down in the R G B order in one array.
  52472. *
  52473. * More information on this format are available here:
  52474. * https://en.wikipedia.org/wiki/RGBE_image_format
  52475. *
  52476. * @param uint8array The binary file stored in an array buffer.
  52477. * @param hdrInfo The header information of the file.
  52478. * @return The pixels data in RGB right to left up to down order.
  52479. */
  52480. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52481. private static RGBE_ReadPixels_RLE;
  52482. }
  52483. }
  52484. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52485. import { Nullable } from "babylonjs/types";
  52486. import { Scene } from "babylonjs/scene";
  52487. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52488. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52489. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52490. /**
  52491. * This represents a texture coming from an HDR input.
  52492. *
  52493. * The only supported format is currently panorama picture stored in RGBE format.
  52494. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52495. */
  52496. export class HDRCubeTexture extends BaseTexture {
  52497. private static _facesMapping;
  52498. private _generateHarmonics;
  52499. private _noMipmap;
  52500. private _textureMatrix;
  52501. private _size;
  52502. private _onLoad;
  52503. private _onError;
  52504. /**
  52505. * The texture URL.
  52506. */
  52507. url: string;
  52508. /**
  52509. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52510. */
  52511. coordinatesMode: number;
  52512. protected _isBlocking: boolean;
  52513. /**
  52514. * Sets wether or not the texture is blocking during loading.
  52515. */
  52516. /**
  52517. * Gets wether or not the texture is blocking during loading.
  52518. */
  52519. isBlocking: boolean;
  52520. protected _rotationY: number;
  52521. /**
  52522. * Sets texture matrix rotation angle around Y axis in radians.
  52523. */
  52524. /**
  52525. * Gets texture matrix rotation angle around Y axis radians.
  52526. */
  52527. rotationY: number;
  52528. /**
  52529. * Gets or sets the center of the bounding box associated with the cube texture
  52530. * It must define where the camera used to render the texture was set
  52531. */
  52532. boundingBoxPosition: Vector3;
  52533. private _boundingBoxSize;
  52534. /**
  52535. * Gets or sets the size of the bounding box associated with the cube texture
  52536. * When defined, the cubemap will switch to local mode
  52537. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52538. * @example https://www.babylonjs-playground.com/#RNASML
  52539. */
  52540. boundingBoxSize: Vector3;
  52541. /**
  52542. * Instantiates an HDRTexture from the following parameters.
  52543. *
  52544. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52545. * @param scene The scene the texture will be used in
  52546. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52547. * @param noMipmap Forces to not generate the mipmap if true
  52548. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52549. * @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)
  52550. * @param reserved Reserved flag for internal use.
  52551. */
  52552. 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>);
  52553. /**
  52554. * Get the current class name of the texture useful for serialization or dynamic coding.
  52555. * @returns "HDRCubeTexture"
  52556. */
  52557. getClassName(): string;
  52558. /**
  52559. * Occurs when the file is raw .hdr file.
  52560. */
  52561. private loadTexture;
  52562. clone(): HDRCubeTexture;
  52563. delayLoad(): void;
  52564. /**
  52565. * Get the texture reflection matrix used to rotate/transform the reflection.
  52566. * @returns the reflection matrix
  52567. */
  52568. getReflectionTextureMatrix(): Matrix;
  52569. /**
  52570. * Set the texture reflection matrix used to rotate/transform the reflection.
  52571. * @param value Define the reflection matrix to set
  52572. */
  52573. setReflectionTextureMatrix(value: Matrix): void;
  52574. /**
  52575. * Parses a JSON representation of an HDR Texture in order to create the texture
  52576. * @param parsedTexture Define the JSON representation
  52577. * @param scene Define the scene the texture should be created in
  52578. * @param rootUrl Define the root url in case we need to load relative dependencies
  52579. * @returns the newly created texture after parsing
  52580. */
  52581. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52582. serialize(): any;
  52583. }
  52584. }
  52585. declare module "babylonjs/Physics/physicsEngine" {
  52586. import { Nullable } from "babylonjs/types";
  52587. import { Vector3 } from "babylonjs/Maths/math.vector";
  52588. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52589. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  52590. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  52591. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52592. /**
  52593. * Class used to control physics engine
  52594. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52595. */
  52596. export class PhysicsEngine implements IPhysicsEngine {
  52597. private _physicsPlugin;
  52598. /**
  52599. * Global value used to control the smallest number supported by the simulation
  52600. */
  52601. static Epsilon: number;
  52602. private _impostors;
  52603. private _joints;
  52604. /**
  52605. * Gets the gravity vector used by the simulation
  52606. */
  52607. gravity: Vector3;
  52608. /**
  52609. * Factory used to create the default physics plugin.
  52610. * @returns The default physics plugin
  52611. */
  52612. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52613. /**
  52614. * Creates a new Physics Engine
  52615. * @param gravity defines the gravity vector used by the simulation
  52616. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52617. */
  52618. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52619. /**
  52620. * Sets the gravity vector used by the simulation
  52621. * @param gravity defines the gravity vector to use
  52622. */
  52623. setGravity(gravity: Vector3): void;
  52624. /**
  52625. * Set the time step of the physics engine.
  52626. * Default is 1/60.
  52627. * To slow it down, enter 1/600 for example.
  52628. * To speed it up, 1/30
  52629. * @param newTimeStep defines the new timestep to apply to this world.
  52630. */
  52631. setTimeStep(newTimeStep?: number): void;
  52632. /**
  52633. * Get the time step of the physics engine.
  52634. * @returns the current time step
  52635. */
  52636. getTimeStep(): number;
  52637. /**
  52638. * Release all resources
  52639. */
  52640. dispose(): void;
  52641. /**
  52642. * Gets the name of the current physics plugin
  52643. * @returns the name of the plugin
  52644. */
  52645. getPhysicsPluginName(): string;
  52646. /**
  52647. * Adding a new impostor for the impostor tracking.
  52648. * This will be done by the impostor itself.
  52649. * @param impostor the impostor to add
  52650. */
  52651. addImpostor(impostor: PhysicsImpostor): void;
  52652. /**
  52653. * Remove an impostor from the engine.
  52654. * This impostor and its mesh will not longer be updated by the physics engine.
  52655. * @param impostor the impostor to remove
  52656. */
  52657. removeImpostor(impostor: PhysicsImpostor): void;
  52658. /**
  52659. * Add a joint to the physics engine
  52660. * @param mainImpostor defines the main impostor to which the joint is added.
  52661. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52662. * @param joint defines the joint that will connect both impostors.
  52663. */
  52664. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52665. /**
  52666. * Removes a joint from the simulation
  52667. * @param mainImpostor defines the impostor used with the joint
  52668. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52669. * @param joint defines the joint to remove
  52670. */
  52671. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52672. /**
  52673. * Called by the scene. No need to call it.
  52674. * @param delta defines the timespam between frames
  52675. */
  52676. _step(delta: number): void;
  52677. /**
  52678. * Gets the current plugin used to run the simulation
  52679. * @returns current plugin
  52680. */
  52681. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52682. /**
  52683. * Gets the list of physic impostors
  52684. * @returns an array of PhysicsImpostor
  52685. */
  52686. getImpostors(): Array<PhysicsImpostor>;
  52687. /**
  52688. * Gets the impostor for a physics enabled object
  52689. * @param object defines the object impersonated by the impostor
  52690. * @returns the PhysicsImpostor or null if not found
  52691. */
  52692. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52693. /**
  52694. * Gets the impostor for a physics body object
  52695. * @param body defines physics body used by the impostor
  52696. * @returns the PhysicsImpostor or null if not found
  52697. */
  52698. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52699. /**
  52700. * Does a raycast in the physics world
  52701. * @param from when should the ray start?
  52702. * @param to when should the ray end?
  52703. * @returns PhysicsRaycastResult
  52704. */
  52705. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52706. }
  52707. }
  52708. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52709. import { Nullable } from "babylonjs/types";
  52710. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52712. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52713. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52714. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52715. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52716. /** @hidden */
  52717. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52718. private _useDeltaForWorldStep;
  52719. world: any;
  52720. name: string;
  52721. private _physicsMaterials;
  52722. private _fixedTimeStep;
  52723. private _cannonRaycastResult;
  52724. private _raycastResult;
  52725. private _physicsBodysToRemoveAfterStep;
  52726. BJSCANNON: any;
  52727. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52728. setGravity(gravity: Vector3): void;
  52729. setTimeStep(timeStep: number): void;
  52730. getTimeStep(): number;
  52731. executeStep(delta: number): void;
  52732. private _removeMarkedPhysicsBodiesFromWorld;
  52733. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52734. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52735. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52736. private _processChildMeshes;
  52737. removePhysicsBody(impostor: PhysicsImpostor): void;
  52738. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52739. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52740. private _addMaterial;
  52741. private _checkWithEpsilon;
  52742. private _createShape;
  52743. private _createHeightmap;
  52744. private _minus90X;
  52745. private _plus90X;
  52746. private _tmpPosition;
  52747. private _tmpDeltaPosition;
  52748. private _tmpUnityRotation;
  52749. private _updatePhysicsBodyTransformation;
  52750. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52751. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52752. isSupported(): boolean;
  52753. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52754. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52755. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52756. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52757. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52758. getBodyMass(impostor: PhysicsImpostor): number;
  52759. getBodyFriction(impostor: PhysicsImpostor): number;
  52760. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52761. getBodyRestitution(impostor: PhysicsImpostor): number;
  52762. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52763. sleepBody(impostor: PhysicsImpostor): void;
  52764. wakeUpBody(impostor: PhysicsImpostor): void;
  52765. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52766. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52767. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52768. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52769. getRadius(impostor: PhysicsImpostor): number;
  52770. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52771. dispose(): void;
  52772. private _extendNamespace;
  52773. /**
  52774. * Does a raycast in the physics world
  52775. * @param from when should the ray start?
  52776. * @param to when should the ray end?
  52777. * @returns PhysicsRaycastResult
  52778. */
  52779. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52780. }
  52781. }
  52782. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52783. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52784. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52785. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52786. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52787. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52788. import { Nullable } from "babylonjs/types";
  52789. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52790. /** @hidden */
  52791. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52792. world: any;
  52793. name: string;
  52794. BJSOIMO: any;
  52795. private _raycastResult;
  52796. constructor(iterations?: number, oimoInjection?: any);
  52797. setGravity(gravity: Vector3): void;
  52798. setTimeStep(timeStep: number): void;
  52799. getTimeStep(): number;
  52800. private _tmpImpostorsArray;
  52801. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52802. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52803. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52804. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52805. private _tmpPositionVector;
  52806. removePhysicsBody(impostor: PhysicsImpostor): void;
  52807. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52808. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52809. isSupported(): boolean;
  52810. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52811. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52812. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52813. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52814. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52815. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52816. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52817. getBodyMass(impostor: PhysicsImpostor): number;
  52818. getBodyFriction(impostor: PhysicsImpostor): number;
  52819. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52820. getBodyRestitution(impostor: PhysicsImpostor): number;
  52821. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52822. sleepBody(impostor: PhysicsImpostor): void;
  52823. wakeUpBody(impostor: PhysicsImpostor): void;
  52824. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52825. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52826. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52827. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52828. getRadius(impostor: PhysicsImpostor): number;
  52829. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52830. dispose(): void;
  52831. /**
  52832. * Does a raycast in the physics world
  52833. * @param from when should the ray start?
  52834. * @param to when should the ray end?
  52835. * @returns PhysicsRaycastResult
  52836. */
  52837. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52838. }
  52839. }
  52840. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52841. import { Nullable } from "babylonjs/types";
  52842. import { Scene } from "babylonjs/scene";
  52843. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52844. import { Color4 } from "babylonjs/Maths/math.color";
  52845. import { Mesh } from "babylonjs/Meshes/mesh";
  52846. /**
  52847. * Class containing static functions to help procedurally build meshes
  52848. */
  52849. export class RibbonBuilder {
  52850. /**
  52851. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52852. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52853. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52854. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52855. * * 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
  52856. * * 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
  52857. * * 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
  52858. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52859. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52860. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52861. * * 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
  52862. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52863. * * 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
  52864. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52866. * @param name defines the name of the mesh
  52867. * @param options defines the options used to create the mesh
  52868. * @param scene defines the hosting scene
  52869. * @returns the ribbon mesh
  52870. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52871. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52872. */
  52873. static CreateRibbon(name: string, options: {
  52874. pathArray: Vector3[][];
  52875. closeArray?: boolean;
  52876. closePath?: boolean;
  52877. offset?: number;
  52878. updatable?: boolean;
  52879. sideOrientation?: number;
  52880. frontUVs?: Vector4;
  52881. backUVs?: Vector4;
  52882. instance?: Mesh;
  52883. invertUV?: boolean;
  52884. uvs?: Vector2[];
  52885. colors?: Color4[];
  52886. }, scene?: Nullable<Scene>): Mesh;
  52887. }
  52888. }
  52889. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52890. import { Nullable } from "babylonjs/types";
  52891. import { Scene } from "babylonjs/scene";
  52892. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52893. import { Mesh } from "babylonjs/Meshes/mesh";
  52894. /**
  52895. * Class containing static functions to help procedurally build meshes
  52896. */
  52897. export class ShapeBuilder {
  52898. /**
  52899. * 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.
  52900. * * 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.
  52901. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52902. * * 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.
  52903. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52904. * * 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
  52905. * * 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
  52906. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52908. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52909. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52911. * @param name defines the name of the mesh
  52912. * @param options defines the options used to create the mesh
  52913. * @param scene defines the hosting scene
  52914. * @returns the extruded shape mesh
  52915. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52916. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52917. */
  52918. static ExtrudeShape(name: string, options: {
  52919. shape: Vector3[];
  52920. path: Vector3[];
  52921. scale?: number;
  52922. rotation?: number;
  52923. cap?: number;
  52924. updatable?: boolean;
  52925. sideOrientation?: number;
  52926. frontUVs?: Vector4;
  52927. backUVs?: Vector4;
  52928. instance?: Mesh;
  52929. invertUV?: boolean;
  52930. }, scene?: Nullable<Scene>): Mesh;
  52931. /**
  52932. * Creates an custom extruded shape mesh.
  52933. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52934. * * 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.
  52935. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52936. * * 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
  52937. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52938. * * 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
  52939. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52940. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52941. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52942. * * 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
  52943. * * 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
  52944. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52947. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52949. * @param name defines the name of the mesh
  52950. * @param options defines the options used to create the mesh
  52951. * @param scene defines the hosting scene
  52952. * @returns the custom extruded shape mesh
  52953. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52954. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52955. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52956. */
  52957. static ExtrudeShapeCustom(name: string, options: {
  52958. shape: Vector3[];
  52959. path: Vector3[];
  52960. scaleFunction?: any;
  52961. rotationFunction?: any;
  52962. ribbonCloseArray?: boolean;
  52963. ribbonClosePath?: boolean;
  52964. cap?: number;
  52965. updatable?: boolean;
  52966. sideOrientation?: number;
  52967. frontUVs?: Vector4;
  52968. backUVs?: Vector4;
  52969. instance?: Mesh;
  52970. invertUV?: boolean;
  52971. }, scene?: Nullable<Scene>): Mesh;
  52972. private static _ExtrudeShapeGeneric;
  52973. }
  52974. }
  52975. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52976. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52977. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52978. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52979. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52980. import { Nullable } from "babylonjs/types";
  52981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52982. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52983. /**
  52984. * AmmoJS Physics plugin
  52985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52986. * @see https://github.com/kripken/ammo.js/
  52987. */
  52988. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52989. private _useDeltaForWorldStep;
  52990. /**
  52991. * Reference to the Ammo library
  52992. */
  52993. bjsAMMO: any;
  52994. /**
  52995. * Created ammoJS world which physics bodies are added to
  52996. */
  52997. world: any;
  52998. /**
  52999. * Name of the plugin
  53000. */
  53001. name: string;
  53002. private _timeStep;
  53003. private _fixedTimeStep;
  53004. private _maxSteps;
  53005. private _tmpQuaternion;
  53006. private _tmpAmmoTransform;
  53007. private _tmpAmmoQuaternion;
  53008. private _tmpAmmoConcreteContactResultCallback;
  53009. private _collisionConfiguration;
  53010. private _dispatcher;
  53011. private _overlappingPairCache;
  53012. private _solver;
  53013. private _softBodySolver;
  53014. private _tmpAmmoVectorA;
  53015. private _tmpAmmoVectorB;
  53016. private _tmpAmmoVectorC;
  53017. private _tmpAmmoVectorD;
  53018. private _tmpContactCallbackResult;
  53019. private _tmpAmmoVectorRCA;
  53020. private _tmpAmmoVectorRCB;
  53021. private _raycastResult;
  53022. private static readonly DISABLE_COLLISION_FLAG;
  53023. private static readonly KINEMATIC_FLAG;
  53024. private static readonly DISABLE_DEACTIVATION_FLAG;
  53025. /**
  53026. * Initializes the ammoJS plugin
  53027. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53028. * @param ammoInjection can be used to inject your own ammo reference
  53029. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53030. */
  53031. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53032. /**
  53033. * Sets the gravity of the physics world (m/(s^2))
  53034. * @param gravity Gravity to set
  53035. */
  53036. setGravity(gravity: Vector3): void;
  53037. /**
  53038. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53039. * @param timeStep timestep to use in seconds
  53040. */
  53041. setTimeStep(timeStep: number): void;
  53042. /**
  53043. * 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)
  53044. * @param fixedTimeStep fixedTimeStep to use in seconds
  53045. */
  53046. setFixedTimeStep(fixedTimeStep: number): void;
  53047. /**
  53048. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53049. * @param maxSteps the maximum number of steps by the physics engine per frame
  53050. */
  53051. setMaxSteps(maxSteps: number): void;
  53052. /**
  53053. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53054. * @returns the current timestep in seconds
  53055. */
  53056. getTimeStep(): number;
  53057. private _isImpostorInContact;
  53058. private _isImpostorPairInContact;
  53059. private _stepSimulation;
  53060. /**
  53061. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53062. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53063. * After the step the babylon meshes are set to the position of the physics imposters
  53064. * @param delta amount of time to step forward
  53065. * @param impostors array of imposters to update before/after the step
  53066. */
  53067. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53068. /**
  53069. * Update babylon mesh to match physics world object
  53070. * @param impostor imposter to match
  53071. */
  53072. private _afterSoftStep;
  53073. /**
  53074. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53075. * @param impostor imposter to match
  53076. */
  53077. private _ropeStep;
  53078. /**
  53079. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53080. * @param impostor imposter to match
  53081. */
  53082. private _softbodyOrClothStep;
  53083. private _tmpVector;
  53084. private _tmpMatrix;
  53085. /**
  53086. * Applies an impulse on the imposter
  53087. * @param impostor imposter to apply impulse to
  53088. * @param force amount of force to be applied to the imposter
  53089. * @param contactPoint the location to apply the impulse on the imposter
  53090. */
  53091. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53092. /**
  53093. * Applies a force on the imposter
  53094. * @param impostor imposter to apply force
  53095. * @param force amount of force to be applied to the imposter
  53096. * @param contactPoint the location to apply the force on the imposter
  53097. */
  53098. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53099. /**
  53100. * Creates a physics body using the plugin
  53101. * @param impostor the imposter to create the physics body on
  53102. */
  53103. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53104. /**
  53105. * Removes the physics body from the imposter and disposes of the body's memory
  53106. * @param impostor imposter to remove the physics body from
  53107. */
  53108. removePhysicsBody(impostor: PhysicsImpostor): void;
  53109. /**
  53110. * Generates a joint
  53111. * @param impostorJoint the imposter joint to create the joint with
  53112. */
  53113. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53114. /**
  53115. * Removes a joint
  53116. * @param impostorJoint the imposter joint to remove the joint from
  53117. */
  53118. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53119. private _addMeshVerts;
  53120. /**
  53121. * Initialise the soft body vertices to match its object's (mesh) vertices
  53122. * Softbody vertices (nodes) are in world space and to match this
  53123. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53124. * @param impostor to create the softbody for
  53125. */
  53126. private _softVertexData;
  53127. /**
  53128. * Create an impostor's soft body
  53129. * @param impostor to create the softbody for
  53130. */
  53131. private _createSoftbody;
  53132. /**
  53133. * Create cloth for an impostor
  53134. * @param impostor to create the softbody for
  53135. */
  53136. private _createCloth;
  53137. /**
  53138. * Create rope for an impostor
  53139. * @param impostor to create the softbody for
  53140. */
  53141. private _createRope;
  53142. private _addHullVerts;
  53143. private _createShape;
  53144. /**
  53145. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53146. * @param impostor imposter containing the physics body and babylon object
  53147. */
  53148. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53149. /**
  53150. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53151. * @param impostor imposter containing the physics body and babylon object
  53152. * @param newPosition new position
  53153. * @param newRotation new rotation
  53154. */
  53155. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53156. /**
  53157. * If this plugin is supported
  53158. * @returns true if its supported
  53159. */
  53160. isSupported(): boolean;
  53161. /**
  53162. * Sets the linear velocity of the physics body
  53163. * @param impostor imposter to set the velocity on
  53164. * @param velocity velocity to set
  53165. */
  53166. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53167. /**
  53168. * Sets the angular velocity of the physics body
  53169. * @param impostor imposter to set the velocity on
  53170. * @param velocity velocity to set
  53171. */
  53172. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53173. /**
  53174. * gets the linear velocity
  53175. * @param impostor imposter to get linear velocity from
  53176. * @returns linear velocity
  53177. */
  53178. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53179. /**
  53180. * gets the angular velocity
  53181. * @param impostor imposter to get angular velocity from
  53182. * @returns angular velocity
  53183. */
  53184. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53185. /**
  53186. * Sets the mass of physics body
  53187. * @param impostor imposter to set the mass on
  53188. * @param mass mass to set
  53189. */
  53190. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53191. /**
  53192. * Gets the mass of the physics body
  53193. * @param impostor imposter to get the mass from
  53194. * @returns mass
  53195. */
  53196. getBodyMass(impostor: PhysicsImpostor): number;
  53197. /**
  53198. * Gets friction of the impostor
  53199. * @param impostor impostor to get friction from
  53200. * @returns friction value
  53201. */
  53202. getBodyFriction(impostor: PhysicsImpostor): number;
  53203. /**
  53204. * Sets friction of the impostor
  53205. * @param impostor impostor to set friction on
  53206. * @param friction friction value
  53207. */
  53208. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53209. /**
  53210. * Gets restitution of the impostor
  53211. * @param impostor impostor to get restitution from
  53212. * @returns restitution value
  53213. */
  53214. getBodyRestitution(impostor: PhysicsImpostor): number;
  53215. /**
  53216. * Sets resitution of the impostor
  53217. * @param impostor impostor to set resitution on
  53218. * @param restitution resitution value
  53219. */
  53220. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53221. /**
  53222. * Gets pressure inside the impostor
  53223. * @param impostor impostor to get pressure from
  53224. * @returns pressure value
  53225. */
  53226. getBodyPressure(impostor: PhysicsImpostor): number;
  53227. /**
  53228. * Sets pressure inside a soft body impostor
  53229. * Cloth and rope must remain 0 pressure
  53230. * @param impostor impostor to set pressure on
  53231. * @param pressure pressure value
  53232. */
  53233. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53234. /**
  53235. * Gets stiffness of the impostor
  53236. * @param impostor impostor to get stiffness from
  53237. * @returns pressure value
  53238. */
  53239. getBodyStiffness(impostor: PhysicsImpostor): number;
  53240. /**
  53241. * Sets stiffness of the impostor
  53242. * @param impostor impostor to set stiffness on
  53243. * @param stiffness stiffness value from 0 to 1
  53244. */
  53245. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53246. /**
  53247. * Gets velocityIterations of the impostor
  53248. * @param impostor impostor to get velocity iterations from
  53249. * @returns velocityIterations value
  53250. */
  53251. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53252. /**
  53253. * Sets velocityIterations of the impostor
  53254. * @param impostor impostor to set velocity iterations on
  53255. * @param velocityIterations velocityIterations value
  53256. */
  53257. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53258. /**
  53259. * Gets positionIterations of the impostor
  53260. * @param impostor impostor to get position iterations from
  53261. * @returns positionIterations value
  53262. */
  53263. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53264. /**
  53265. * Sets positionIterations of the impostor
  53266. * @param impostor impostor to set position on
  53267. * @param positionIterations positionIterations value
  53268. */
  53269. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53270. /**
  53271. * Append an anchor to a cloth object
  53272. * @param impostor is the cloth impostor to add anchor to
  53273. * @param otherImpostor is the rigid impostor to anchor to
  53274. * @param width ratio across width from 0 to 1
  53275. * @param height ratio up height from 0 to 1
  53276. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53277. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53278. */
  53279. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53280. /**
  53281. * Append an hook to a rope object
  53282. * @param impostor is the rope impostor to add hook to
  53283. * @param otherImpostor is the rigid impostor to hook to
  53284. * @param length ratio along the rope from 0 to 1
  53285. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53286. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53287. */
  53288. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53289. /**
  53290. * Sleeps the physics body and stops it from being active
  53291. * @param impostor impostor to sleep
  53292. */
  53293. sleepBody(impostor: PhysicsImpostor): void;
  53294. /**
  53295. * Activates the physics body
  53296. * @param impostor impostor to activate
  53297. */
  53298. wakeUpBody(impostor: PhysicsImpostor): void;
  53299. /**
  53300. * Updates the distance parameters of the joint
  53301. * @param joint joint to update
  53302. * @param maxDistance maximum distance of the joint
  53303. * @param minDistance minimum distance of the joint
  53304. */
  53305. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53306. /**
  53307. * Sets a motor on the joint
  53308. * @param joint joint to set motor on
  53309. * @param speed speed of the motor
  53310. * @param maxForce maximum force of the motor
  53311. * @param motorIndex index of the motor
  53312. */
  53313. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53314. /**
  53315. * Sets the motors limit
  53316. * @param joint joint to set limit on
  53317. * @param upperLimit upper limit
  53318. * @param lowerLimit lower limit
  53319. */
  53320. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53321. /**
  53322. * Syncs the position and rotation of a mesh with the impostor
  53323. * @param mesh mesh to sync
  53324. * @param impostor impostor to update the mesh with
  53325. */
  53326. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53327. /**
  53328. * Gets the radius of the impostor
  53329. * @param impostor impostor to get radius from
  53330. * @returns the radius
  53331. */
  53332. getRadius(impostor: PhysicsImpostor): number;
  53333. /**
  53334. * Gets the box size of the impostor
  53335. * @param impostor impostor to get box size from
  53336. * @param result the resulting box size
  53337. */
  53338. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53339. /**
  53340. * Disposes of the impostor
  53341. */
  53342. dispose(): void;
  53343. /**
  53344. * Does a raycast in the physics world
  53345. * @param from when should the ray start?
  53346. * @param to when should the ray end?
  53347. * @returns PhysicsRaycastResult
  53348. */
  53349. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53350. }
  53351. }
  53352. declare module "babylonjs/Probes/reflectionProbe" {
  53353. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53354. import { Vector3 } from "babylonjs/Maths/math.vector";
  53355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53356. import { Nullable } from "babylonjs/types";
  53357. import { Scene } from "babylonjs/scene";
  53358. module "babylonjs/abstractScene" {
  53359. interface AbstractScene {
  53360. /**
  53361. * The list of reflection probes added to the scene
  53362. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53363. */
  53364. reflectionProbes: Array<ReflectionProbe>;
  53365. /**
  53366. * Removes the given reflection probe from this scene.
  53367. * @param toRemove The reflection probe to remove
  53368. * @returns The index of the removed reflection probe
  53369. */
  53370. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53371. /**
  53372. * Adds the given reflection probe to this scene.
  53373. * @param newReflectionProbe The reflection probe to add
  53374. */
  53375. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53376. }
  53377. }
  53378. /**
  53379. * Class used to generate realtime reflection / refraction cube textures
  53380. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53381. */
  53382. export class ReflectionProbe {
  53383. /** defines the name of the probe */
  53384. name: string;
  53385. private _scene;
  53386. private _renderTargetTexture;
  53387. private _projectionMatrix;
  53388. private _viewMatrix;
  53389. private _target;
  53390. private _add;
  53391. private _attachedMesh;
  53392. private _invertYAxis;
  53393. /** Gets or sets probe position (center of the cube map) */
  53394. position: Vector3;
  53395. /**
  53396. * Creates a new reflection probe
  53397. * @param name defines the name of the probe
  53398. * @param size defines the texture resolution (for each face)
  53399. * @param scene defines the hosting scene
  53400. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53401. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53402. */
  53403. constructor(
  53404. /** defines the name of the probe */
  53405. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53406. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53407. samples: number;
  53408. /** Gets or sets the refresh rate to use (on every frame by default) */
  53409. refreshRate: number;
  53410. /**
  53411. * Gets the hosting scene
  53412. * @returns a Scene
  53413. */
  53414. getScene(): Scene;
  53415. /** Gets the internal CubeTexture used to render to */
  53416. readonly cubeTexture: RenderTargetTexture;
  53417. /** Gets the list of meshes to render */
  53418. readonly renderList: Nullable<AbstractMesh[]>;
  53419. /**
  53420. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53421. * @param mesh defines the mesh to attach to
  53422. */
  53423. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53424. /**
  53425. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53426. * @param renderingGroupId The rendering group id corresponding to its index
  53427. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53428. */
  53429. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53430. /**
  53431. * Clean all associated resources
  53432. */
  53433. dispose(): void;
  53434. /**
  53435. * Converts the reflection probe information to a readable string for debug purpose.
  53436. * @param fullDetails Supports for multiple levels of logging within scene loading
  53437. * @returns the human readable reflection probe info
  53438. */
  53439. toString(fullDetails?: boolean): string;
  53440. /**
  53441. * Get the class name of the relfection probe.
  53442. * @returns "ReflectionProbe"
  53443. */
  53444. getClassName(): string;
  53445. /**
  53446. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53447. * @returns The JSON representation of the texture
  53448. */
  53449. serialize(): any;
  53450. /**
  53451. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53452. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53453. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53454. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53455. * @returns The parsed reflection probe if successful
  53456. */
  53457. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53458. }
  53459. }
  53460. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53461. /** @hidden */
  53462. export var _BabylonLoaderRegistered: boolean;
  53463. }
  53464. declare module "babylonjs/Loading/Plugins/index" {
  53465. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53466. }
  53467. declare module "babylonjs/Loading/index" {
  53468. export * from "babylonjs/Loading/loadingScreen";
  53469. export * from "babylonjs/Loading/Plugins/index";
  53470. export * from "babylonjs/Loading/sceneLoader";
  53471. export * from "babylonjs/Loading/sceneLoaderFlags";
  53472. }
  53473. declare module "babylonjs/Materials/Background/index" {
  53474. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53475. }
  53476. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53477. import { Scene } from "babylonjs/scene";
  53478. import { Color3 } from "babylonjs/Maths/math.color";
  53479. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53481. /**
  53482. * The Physically based simple base material of BJS.
  53483. *
  53484. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53485. * It is used as the base class for both the specGloss and metalRough conventions.
  53486. */
  53487. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53488. /**
  53489. * Number of Simultaneous lights allowed on the material.
  53490. */
  53491. maxSimultaneousLights: number;
  53492. /**
  53493. * If sets to true, disables all the lights affecting the material.
  53494. */
  53495. disableLighting: boolean;
  53496. /**
  53497. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53498. */
  53499. environmentTexture: BaseTexture;
  53500. /**
  53501. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53502. */
  53503. invertNormalMapX: boolean;
  53504. /**
  53505. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53506. */
  53507. invertNormalMapY: boolean;
  53508. /**
  53509. * Normal map used in the model.
  53510. */
  53511. normalTexture: BaseTexture;
  53512. /**
  53513. * Emissivie color used to self-illuminate the model.
  53514. */
  53515. emissiveColor: Color3;
  53516. /**
  53517. * Emissivie texture used to self-illuminate the model.
  53518. */
  53519. emissiveTexture: BaseTexture;
  53520. /**
  53521. * Occlusion Channel Strenght.
  53522. */
  53523. occlusionStrength: number;
  53524. /**
  53525. * Occlusion Texture of the material (adding extra occlusion effects).
  53526. */
  53527. occlusionTexture: BaseTexture;
  53528. /**
  53529. * Defines the alpha limits in alpha test mode.
  53530. */
  53531. alphaCutOff: number;
  53532. /**
  53533. * Gets the current double sided mode.
  53534. */
  53535. /**
  53536. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53537. */
  53538. doubleSided: boolean;
  53539. /**
  53540. * Stores the pre-calculated light information of a mesh in a texture.
  53541. */
  53542. lightmapTexture: BaseTexture;
  53543. /**
  53544. * If true, the light map contains occlusion information instead of lighting info.
  53545. */
  53546. useLightmapAsShadowmap: boolean;
  53547. /**
  53548. * Instantiates a new PBRMaterial instance.
  53549. *
  53550. * @param name The material name
  53551. * @param scene The scene the material will be use in.
  53552. */
  53553. constructor(name: string, scene: Scene);
  53554. getClassName(): string;
  53555. }
  53556. }
  53557. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  53558. import { Scene } from "babylonjs/scene";
  53559. import { Color3 } from "babylonjs/Maths/math.color";
  53560. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53561. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53562. /**
  53563. * The PBR material of BJS following the metal roughness convention.
  53564. *
  53565. * This fits to the PBR convention in the GLTF definition:
  53566. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53567. */
  53568. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53569. /**
  53570. * The base color has two different interpretations depending on the value of metalness.
  53571. * When the material is a metal, the base color is the specific measured reflectance value
  53572. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53573. * of the material.
  53574. */
  53575. baseColor: Color3;
  53576. /**
  53577. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53578. * well as opacity information in the alpha channel.
  53579. */
  53580. baseTexture: BaseTexture;
  53581. /**
  53582. * Specifies the metallic scalar value of the material.
  53583. * Can also be used to scale the metalness values of the metallic texture.
  53584. */
  53585. metallic: number;
  53586. /**
  53587. * Specifies the roughness scalar value of the material.
  53588. * Can also be used to scale the roughness values of the metallic texture.
  53589. */
  53590. roughness: number;
  53591. /**
  53592. * Texture containing both the metallic value in the B channel and the
  53593. * roughness value in the G channel to keep better precision.
  53594. */
  53595. metallicRoughnessTexture: BaseTexture;
  53596. /**
  53597. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53598. *
  53599. * @param name The material name
  53600. * @param scene The scene the material will be use in.
  53601. */
  53602. constructor(name: string, scene: Scene);
  53603. /**
  53604. * Return the currrent class name of the material.
  53605. */
  53606. getClassName(): string;
  53607. /**
  53608. * Makes a duplicate of the current material.
  53609. * @param name - name to use for the new material.
  53610. */
  53611. clone(name: string): PBRMetallicRoughnessMaterial;
  53612. /**
  53613. * Serialize the material to a parsable JSON object.
  53614. */
  53615. serialize(): any;
  53616. /**
  53617. * Parses a JSON object correponding to the serialize function.
  53618. */
  53619. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53620. }
  53621. }
  53622. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53623. import { Scene } from "babylonjs/scene";
  53624. import { Color3 } from "babylonjs/Maths/math.color";
  53625. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53626. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53627. /**
  53628. * The PBR material of BJS following the specular glossiness convention.
  53629. *
  53630. * This fits to the PBR convention in the GLTF definition:
  53631. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53632. */
  53633. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53634. /**
  53635. * Specifies the diffuse color of the material.
  53636. */
  53637. diffuseColor: Color3;
  53638. /**
  53639. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53640. * channel.
  53641. */
  53642. diffuseTexture: BaseTexture;
  53643. /**
  53644. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53645. */
  53646. specularColor: Color3;
  53647. /**
  53648. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53649. */
  53650. glossiness: number;
  53651. /**
  53652. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53653. */
  53654. specularGlossinessTexture: BaseTexture;
  53655. /**
  53656. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53657. *
  53658. * @param name The material name
  53659. * @param scene The scene the material will be use in.
  53660. */
  53661. constructor(name: string, scene: Scene);
  53662. /**
  53663. * Return the currrent class name of the material.
  53664. */
  53665. getClassName(): string;
  53666. /**
  53667. * Makes a duplicate of the current material.
  53668. * @param name - name to use for the new material.
  53669. */
  53670. clone(name: string): PBRSpecularGlossinessMaterial;
  53671. /**
  53672. * Serialize the material to a parsable JSON object.
  53673. */
  53674. serialize(): any;
  53675. /**
  53676. * Parses a JSON object correponding to the serialize function.
  53677. */
  53678. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53679. }
  53680. }
  53681. declare module "babylonjs/Materials/PBR/index" {
  53682. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53683. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53684. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53685. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53686. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53687. }
  53688. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53689. import { Nullable } from "babylonjs/types";
  53690. import { Scene } from "babylonjs/scene";
  53691. import { Matrix } from "babylonjs/Maths/math.vector";
  53692. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53693. /**
  53694. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53695. * It can help converting any input color in a desired output one. This can then be used to create effects
  53696. * from sepia, black and white to sixties or futuristic rendering...
  53697. *
  53698. * The only supported format is currently 3dl.
  53699. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53700. */
  53701. export class ColorGradingTexture extends BaseTexture {
  53702. /**
  53703. * The current texture matrix. (will always be identity in color grading texture)
  53704. */
  53705. private _textureMatrix;
  53706. /**
  53707. * The texture URL.
  53708. */
  53709. url: string;
  53710. /**
  53711. * Empty line regex stored for GC.
  53712. */
  53713. private static _noneEmptyLineRegex;
  53714. private _engine;
  53715. /**
  53716. * Instantiates a ColorGradingTexture from the following parameters.
  53717. *
  53718. * @param url The location of the color gradind data (currently only supporting 3dl)
  53719. * @param scene The scene the texture will be used in
  53720. */
  53721. constructor(url: string, scene: Scene);
  53722. /**
  53723. * Returns the texture matrix used in most of the material.
  53724. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53725. */
  53726. getTextureMatrix(): Matrix;
  53727. /**
  53728. * Occurs when the file being loaded is a .3dl LUT file.
  53729. */
  53730. private load3dlTexture;
  53731. /**
  53732. * Starts the loading process of the texture.
  53733. */
  53734. private loadTexture;
  53735. /**
  53736. * Clones the color gradind texture.
  53737. */
  53738. clone(): ColorGradingTexture;
  53739. /**
  53740. * Called during delayed load for textures.
  53741. */
  53742. delayLoad(): void;
  53743. /**
  53744. * Parses a color grading texture serialized by Babylon.
  53745. * @param parsedTexture The texture information being parsedTexture
  53746. * @param scene The scene to load the texture in
  53747. * @param rootUrl The root url of the data assets to load
  53748. * @return A color gradind texture
  53749. */
  53750. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53751. /**
  53752. * Serializes the LUT texture to json format.
  53753. */
  53754. serialize(): any;
  53755. }
  53756. }
  53757. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53758. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53759. import { Scene } from "babylonjs/scene";
  53760. import { Nullable } from "babylonjs/types";
  53761. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53762. /**
  53763. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53764. */
  53765. export class EquiRectangularCubeTexture extends BaseTexture {
  53766. /** The six faces of the cube. */
  53767. private static _FacesMapping;
  53768. private _noMipmap;
  53769. private _onLoad;
  53770. private _onError;
  53771. /** The size of the cubemap. */
  53772. private _size;
  53773. /** The buffer of the image. */
  53774. private _buffer;
  53775. /** The width of the input image. */
  53776. private _width;
  53777. /** The height of the input image. */
  53778. private _height;
  53779. /** The URL to the image. */
  53780. url: string;
  53781. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53782. coordinatesMode: number;
  53783. /**
  53784. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53785. * @param url The location of the image
  53786. * @param scene The scene the texture will be used in
  53787. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53788. * @param noMipmap Forces to not generate the mipmap if true
  53789. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53790. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53791. * @param onLoad — defines a callback called when texture is loaded
  53792. * @param onError — defines a callback called if there is an error
  53793. */
  53794. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53795. /**
  53796. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53797. */
  53798. private loadImage;
  53799. /**
  53800. * Convert the image buffer into a cubemap and create a CubeTexture.
  53801. */
  53802. private loadTexture;
  53803. /**
  53804. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53805. * @param buffer The ArrayBuffer that should be converted.
  53806. * @returns The buffer as Float32Array.
  53807. */
  53808. private getFloat32ArrayFromArrayBuffer;
  53809. /**
  53810. * Get the current class name of the texture useful for serialization or dynamic coding.
  53811. * @returns "EquiRectangularCubeTexture"
  53812. */
  53813. getClassName(): string;
  53814. /**
  53815. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53816. * @returns A clone of the current EquiRectangularCubeTexture.
  53817. */
  53818. clone(): EquiRectangularCubeTexture;
  53819. }
  53820. }
  53821. declare module "babylonjs/Misc/tga" {
  53822. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53823. /**
  53824. * Based on jsTGALoader - Javascript loader for TGA file
  53825. * By Vincent Thibault
  53826. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53827. */
  53828. export class TGATools {
  53829. private static _TYPE_INDEXED;
  53830. private static _TYPE_RGB;
  53831. private static _TYPE_GREY;
  53832. private static _TYPE_RLE_INDEXED;
  53833. private static _TYPE_RLE_RGB;
  53834. private static _TYPE_RLE_GREY;
  53835. private static _ORIGIN_MASK;
  53836. private static _ORIGIN_SHIFT;
  53837. private static _ORIGIN_BL;
  53838. private static _ORIGIN_BR;
  53839. private static _ORIGIN_UL;
  53840. private static _ORIGIN_UR;
  53841. /**
  53842. * Gets the header of a TGA file
  53843. * @param data defines the TGA data
  53844. * @returns the header
  53845. */
  53846. static GetTGAHeader(data: Uint8Array): any;
  53847. /**
  53848. * Uploads TGA content to a Babylon Texture
  53849. * @hidden
  53850. */
  53851. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53852. /** @hidden */
  53853. 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;
  53854. /** @hidden */
  53855. 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;
  53856. /** @hidden */
  53857. 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;
  53858. /** @hidden */
  53859. 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;
  53860. /** @hidden */
  53861. 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;
  53862. /** @hidden */
  53863. 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;
  53864. }
  53865. }
  53866. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53867. import { Nullable } from "babylonjs/types";
  53868. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53869. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53870. /**
  53871. * Implementation of the TGA Texture Loader.
  53872. * @hidden
  53873. */
  53874. export class _TGATextureLoader implements IInternalTextureLoader {
  53875. /**
  53876. * Defines wether the loader supports cascade loading the different faces.
  53877. */
  53878. readonly supportCascades: boolean;
  53879. /**
  53880. * This returns if the loader support the current file information.
  53881. * @param extension defines the file extension of the file being loaded
  53882. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53883. * @param fallback defines the fallback internal texture if any
  53884. * @param isBase64 defines whether the texture is encoded as a base64
  53885. * @param isBuffer defines whether the texture data are stored as a buffer
  53886. * @returns true if the loader can load the specified file
  53887. */
  53888. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53889. /**
  53890. * Transform the url before loading if required.
  53891. * @param rootUrl the url of the texture
  53892. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53893. * @returns the transformed texture
  53894. */
  53895. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53896. /**
  53897. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53898. * @param rootUrl the url of the texture
  53899. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53900. * @returns the fallback texture
  53901. */
  53902. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53903. /**
  53904. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53905. * @param data contains the texture data
  53906. * @param texture defines the BabylonJS internal texture
  53907. * @param createPolynomials will be true if polynomials have been requested
  53908. * @param onLoad defines the callback to trigger once the texture is ready
  53909. * @param onError defines the callback to trigger in case of error
  53910. */
  53911. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53912. /**
  53913. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53914. * @param data contains the texture data
  53915. * @param texture defines the BabylonJS internal texture
  53916. * @param callback defines the method to call once ready to upload
  53917. */
  53918. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53919. }
  53920. }
  53921. declare module "babylonjs/Misc/basis" {
  53922. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53923. /**
  53924. * Info about the .basis files
  53925. */
  53926. class BasisFileInfo {
  53927. /**
  53928. * If the file has alpha
  53929. */
  53930. hasAlpha: boolean;
  53931. /**
  53932. * Info about each image of the basis file
  53933. */
  53934. images: Array<{
  53935. levels: Array<{
  53936. width: number;
  53937. height: number;
  53938. transcodedPixels: ArrayBufferView;
  53939. }>;
  53940. }>;
  53941. }
  53942. /**
  53943. * Result of transcoding a basis file
  53944. */
  53945. class TranscodeResult {
  53946. /**
  53947. * Info about the .basis file
  53948. */
  53949. fileInfo: BasisFileInfo;
  53950. /**
  53951. * Format to use when loading the file
  53952. */
  53953. format: number;
  53954. }
  53955. /**
  53956. * Configuration options for the Basis transcoder
  53957. */
  53958. export class BasisTranscodeConfiguration {
  53959. /**
  53960. * Supported compression formats used to determine the supported output format of the transcoder
  53961. */
  53962. supportedCompressionFormats?: {
  53963. /**
  53964. * etc1 compression format
  53965. */
  53966. etc1?: boolean;
  53967. /**
  53968. * s3tc compression format
  53969. */
  53970. s3tc?: boolean;
  53971. /**
  53972. * pvrtc compression format
  53973. */
  53974. pvrtc?: boolean;
  53975. /**
  53976. * etc2 compression format
  53977. */
  53978. etc2?: boolean;
  53979. };
  53980. /**
  53981. * If mipmap levels should be loaded for transcoded images (Default: true)
  53982. */
  53983. loadMipmapLevels?: boolean;
  53984. /**
  53985. * Index of a single image to load (Default: all images)
  53986. */
  53987. loadSingleImage?: number;
  53988. }
  53989. /**
  53990. * Used to load .Basis files
  53991. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53992. */
  53993. export class BasisTools {
  53994. private static _IgnoreSupportedFormats;
  53995. /**
  53996. * URL to use when loading the basis transcoder
  53997. */
  53998. static JSModuleURL: string;
  53999. /**
  54000. * URL to use when loading the wasm module for the transcoder
  54001. */
  54002. static WasmModuleURL: string;
  54003. /**
  54004. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54005. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54006. * @returns internal format corresponding to the Basis format
  54007. */
  54008. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54009. private static _WorkerPromise;
  54010. private static _Worker;
  54011. private static _actionId;
  54012. private static _CreateWorkerAsync;
  54013. /**
  54014. * Transcodes a loaded image file to compressed pixel data
  54015. * @param imageData image data to transcode
  54016. * @param config configuration options for the transcoding
  54017. * @returns a promise resulting in the transcoded image
  54018. */
  54019. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54020. /**
  54021. * Loads a texture from the transcode result
  54022. * @param texture texture load to
  54023. * @param transcodeResult the result of transcoding the basis file to load from
  54024. */
  54025. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54026. }
  54027. }
  54028. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54029. import { Nullable } from "babylonjs/types";
  54030. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54031. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54032. /**
  54033. * Loader for .basis file format
  54034. */
  54035. export class _BasisTextureLoader implements IInternalTextureLoader {
  54036. /**
  54037. * Defines whether the loader supports cascade loading the different faces.
  54038. */
  54039. readonly supportCascades: boolean;
  54040. /**
  54041. * This returns if the loader support the current file information.
  54042. * @param extension defines the file extension of the file being loaded
  54043. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54044. * @param fallback defines the fallback internal texture if any
  54045. * @param isBase64 defines whether the texture is encoded as a base64
  54046. * @param isBuffer defines whether the texture data are stored as a buffer
  54047. * @returns true if the loader can load the specified file
  54048. */
  54049. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54050. /**
  54051. * Transform the url before loading if required.
  54052. * @param rootUrl the url of the texture
  54053. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54054. * @returns the transformed texture
  54055. */
  54056. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54057. /**
  54058. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54059. * @param rootUrl the url of the texture
  54060. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54061. * @returns the fallback texture
  54062. */
  54063. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54064. /**
  54065. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54066. * @param data contains the texture data
  54067. * @param texture defines the BabylonJS internal texture
  54068. * @param createPolynomials will be true if polynomials have been requested
  54069. * @param onLoad defines the callback to trigger once the texture is ready
  54070. * @param onError defines the callback to trigger in case of error
  54071. */
  54072. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54073. /**
  54074. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54075. * @param data contains the texture data
  54076. * @param texture defines the BabylonJS internal texture
  54077. * @param callback defines the method to call once ready to upload
  54078. */
  54079. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54080. }
  54081. }
  54082. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54083. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54084. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54085. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54086. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54087. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54088. }
  54089. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54090. import { Scene } from "babylonjs/scene";
  54091. import { Texture } from "babylonjs/Materials/Textures/texture";
  54092. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54093. /**
  54094. * 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.
  54095. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54096. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54097. */
  54098. export class CustomProceduralTexture extends ProceduralTexture {
  54099. private _animate;
  54100. private _time;
  54101. private _config;
  54102. private _texturePath;
  54103. /**
  54104. * Instantiates a new Custom Procedural Texture.
  54105. * 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.
  54106. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54107. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54108. * @param name Define the name of the texture
  54109. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54110. * @param size Define the size of the texture to create
  54111. * @param scene Define the scene the texture belongs to
  54112. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54113. * @param generateMipMaps Define if the texture should creates mip maps or not
  54114. */
  54115. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54116. private _loadJson;
  54117. /**
  54118. * Is the texture ready to be used ? (rendered at least once)
  54119. * @returns true if ready, otherwise, false.
  54120. */
  54121. isReady(): boolean;
  54122. /**
  54123. * Render the texture to its associated render target.
  54124. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54125. */
  54126. render(useCameraPostProcess?: boolean): void;
  54127. /**
  54128. * Update the list of dependant textures samplers in the shader.
  54129. */
  54130. updateTextures(): void;
  54131. /**
  54132. * Update the uniform values of the procedural texture in the shader.
  54133. */
  54134. updateShaderUniforms(): void;
  54135. /**
  54136. * Define if the texture animates or not.
  54137. */
  54138. animate: boolean;
  54139. }
  54140. }
  54141. declare module "babylonjs/Shaders/noise.fragment" {
  54142. /** @hidden */
  54143. export var noisePixelShader: {
  54144. name: string;
  54145. shader: string;
  54146. };
  54147. }
  54148. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54149. import { Nullable } from "babylonjs/types";
  54150. import { Scene } from "babylonjs/scene";
  54151. import { Texture } from "babylonjs/Materials/Textures/texture";
  54152. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54153. import "babylonjs/Shaders/noise.fragment";
  54154. /**
  54155. * Class used to generate noise procedural textures
  54156. */
  54157. export class NoiseProceduralTexture extends ProceduralTexture {
  54158. private _time;
  54159. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54160. brightness: number;
  54161. /** Defines the number of octaves to process */
  54162. octaves: number;
  54163. /** Defines the level of persistence (0.8 by default) */
  54164. persistence: number;
  54165. /** Gets or sets animation speed factor (default is 1) */
  54166. animationSpeedFactor: number;
  54167. /**
  54168. * Creates a new NoiseProceduralTexture
  54169. * @param name defines the name fo the texture
  54170. * @param size defines the size of the texture (default is 256)
  54171. * @param scene defines the hosting scene
  54172. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54173. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54174. */
  54175. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54176. private _updateShaderUniforms;
  54177. protected _getDefines(): string;
  54178. /** Generate the current state of the procedural texture */
  54179. render(useCameraPostProcess?: boolean): void;
  54180. /**
  54181. * Serializes this noise procedural texture
  54182. * @returns a serialized noise procedural texture object
  54183. */
  54184. serialize(): any;
  54185. /**
  54186. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54187. * @param parsedTexture defines parsed texture data
  54188. * @param scene defines the current scene
  54189. * @param rootUrl defines the root URL containing noise procedural texture information
  54190. * @returns a parsed NoiseProceduralTexture
  54191. */
  54192. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54193. }
  54194. }
  54195. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54196. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54197. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54198. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54199. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54200. }
  54201. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54202. import { Nullable } from "babylonjs/types";
  54203. import { Scene } from "babylonjs/scene";
  54204. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54205. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54206. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54207. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54208. /**
  54209. * Raw cube texture where the raw buffers are passed in
  54210. */
  54211. export class RawCubeTexture extends CubeTexture {
  54212. /**
  54213. * Creates a cube texture where the raw buffers are passed in.
  54214. * @param scene defines the scene the texture is attached to
  54215. * @param data defines the array of data to use to create each face
  54216. * @param size defines the size of the textures
  54217. * @param format defines the format of the data
  54218. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54219. * @param generateMipMaps defines if the engine should generate the mip levels
  54220. * @param invertY defines if data must be stored with Y axis inverted
  54221. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54222. * @param compression defines the compression used (null by default)
  54223. */
  54224. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54225. /**
  54226. * Updates the raw cube texture.
  54227. * @param data defines the data to store
  54228. * @param format defines the data format
  54229. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54230. * @param invertY defines if data must be stored with Y axis inverted
  54231. * @param compression defines the compression used (null by default)
  54232. * @param level defines which level of the texture to update
  54233. */
  54234. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54235. /**
  54236. * Updates a raw cube texture with RGBD encoded data.
  54237. * @param data defines the array of data [mipmap][face] to use to create each face
  54238. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54239. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54240. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54241. * @returns a promsie that resolves when the operation is complete
  54242. */
  54243. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54244. /**
  54245. * Clones the raw cube texture.
  54246. * @return a new cube texture
  54247. */
  54248. clone(): CubeTexture;
  54249. /** @hidden */
  54250. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54251. }
  54252. }
  54253. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54254. import { Scene } from "babylonjs/scene";
  54255. import { Texture } from "babylonjs/Materials/Textures/texture";
  54256. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54257. /**
  54258. * Class used to store 3D textures containing user data
  54259. */
  54260. export class RawTexture3D extends Texture {
  54261. /** Gets or sets the texture format to use */
  54262. format: number;
  54263. private _engine;
  54264. /**
  54265. * Create a new RawTexture3D
  54266. * @param data defines the data of the texture
  54267. * @param width defines the width of the texture
  54268. * @param height defines the height of the texture
  54269. * @param depth defines the depth of the texture
  54270. * @param format defines the texture format to use
  54271. * @param scene defines the hosting scene
  54272. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54273. * @param invertY defines if texture must be stored with Y axis inverted
  54274. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54275. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54276. */
  54277. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54278. /** Gets or sets the texture format to use */
  54279. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54280. /**
  54281. * Update the texture with new data
  54282. * @param data defines the data to store in the texture
  54283. */
  54284. update(data: ArrayBufferView): void;
  54285. }
  54286. }
  54287. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54288. import { Scene } from "babylonjs/scene";
  54289. import { Plane } from "babylonjs/Maths/math.plane";
  54290. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54291. /**
  54292. * Creates a refraction texture used by refraction channel of the standard material.
  54293. * It is like a mirror but to see through a material.
  54294. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54295. */
  54296. export class RefractionTexture extends RenderTargetTexture {
  54297. /**
  54298. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54299. * 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.
  54300. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54301. */
  54302. refractionPlane: Plane;
  54303. /**
  54304. * Define how deep under the surface we should see.
  54305. */
  54306. depth: number;
  54307. /**
  54308. * Creates a refraction texture used by refraction channel of the standard material.
  54309. * It is like a mirror but to see through a material.
  54310. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54311. * @param name Define the texture name
  54312. * @param size Define the size of the underlying texture
  54313. * @param scene Define the scene the refraction belongs to
  54314. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54315. */
  54316. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54317. /**
  54318. * Clone the refraction texture.
  54319. * @returns the cloned texture
  54320. */
  54321. clone(): RefractionTexture;
  54322. /**
  54323. * Serialize the texture to a JSON representation you could use in Parse later on
  54324. * @returns the serialized JSON representation
  54325. */
  54326. serialize(): any;
  54327. }
  54328. }
  54329. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54330. import { Nullable } from "babylonjs/types";
  54331. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54332. import { Matrix } from "babylonjs/Maths/math.vector";
  54333. import { Engine } from "babylonjs/Engines/engine";
  54334. import { Scene } from "babylonjs/scene";
  54335. /**
  54336. * Defines the options related to the creation of an HtmlElementTexture
  54337. */
  54338. export interface IHtmlElementTextureOptions {
  54339. /**
  54340. * Defines wether mip maps should be created or not.
  54341. */
  54342. generateMipMaps?: boolean;
  54343. /**
  54344. * Defines the sampling mode of the texture.
  54345. */
  54346. samplingMode?: number;
  54347. /**
  54348. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54349. */
  54350. engine: Nullable<Engine>;
  54351. /**
  54352. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54353. */
  54354. scene: Nullable<Scene>;
  54355. }
  54356. /**
  54357. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54358. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54359. * is automatically managed.
  54360. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54361. * in your application.
  54362. *
  54363. * As the update is not automatic, you need to call them manually.
  54364. */
  54365. export class HtmlElementTexture extends BaseTexture {
  54366. /**
  54367. * The texture URL.
  54368. */
  54369. element: HTMLVideoElement | HTMLCanvasElement;
  54370. private static readonly DefaultOptions;
  54371. private _textureMatrix;
  54372. private _engine;
  54373. private _isVideo;
  54374. private _generateMipMaps;
  54375. private _samplingMode;
  54376. /**
  54377. * Instantiates a HtmlElementTexture from the following parameters.
  54378. *
  54379. * @param name Defines the name of the texture
  54380. * @param element Defines the video or canvas the texture is filled with
  54381. * @param options Defines the other none mandatory texture creation options
  54382. */
  54383. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54384. private _createInternalTexture;
  54385. /**
  54386. * Returns the texture matrix used in most of the material.
  54387. */
  54388. getTextureMatrix(): Matrix;
  54389. /**
  54390. * Updates the content of the texture.
  54391. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54392. */
  54393. update(invertY?: Nullable<boolean>): void;
  54394. }
  54395. }
  54396. declare module "babylonjs/Materials/Textures/index" {
  54397. export * from "babylonjs/Materials/Textures/baseTexture";
  54398. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54399. export * from "babylonjs/Materials/Textures/cubeTexture";
  54400. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54401. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54402. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54403. export * from "babylonjs/Materials/Textures/internalTexture";
  54404. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54405. export * from "babylonjs/Materials/Textures/Loaders/index";
  54406. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54407. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54408. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54409. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54410. export * from "babylonjs/Materials/Textures/rawTexture";
  54411. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54412. export * from "babylonjs/Materials/Textures/refractionTexture";
  54413. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54414. export * from "babylonjs/Materials/Textures/texture";
  54415. export * from "babylonjs/Materials/Textures/videoTexture";
  54416. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54417. }
  54418. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  54419. /**
  54420. * Enum used to define the target of a block
  54421. */
  54422. export enum NodeMaterialBlockTargets {
  54423. /** Vertex shader */
  54424. Vertex = 1,
  54425. /** Fragment shader */
  54426. Fragment = 2,
  54427. /** Neutral */
  54428. Neutral = 4,
  54429. /** Vertex and Fragment */
  54430. VertexAndFragment = 3
  54431. }
  54432. }
  54433. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  54434. /**
  54435. * Defines the kind of connection point for node based material
  54436. */
  54437. export enum NodeMaterialBlockConnectionPointTypes {
  54438. /** Float */
  54439. Float = 1,
  54440. /** Int */
  54441. Int = 2,
  54442. /** Vector2 */
  54443. Vector2 = 4,
  54444. /** Vector3 */
  54445. Vector3 = 8,
  54446. /** Vector4 */
  54447. Vector4 = 16,
  54448. /** Color3 */
  54449. Color3 = 32,
  54450. /** Color4 */
  54451. Color4 = 64,
  54452. /** Matrix */
  54453. Matrix = 128,
  54454. /** Detect type based on connection */
  54455. AutoDetect = 1024,
  54456. /** Output type that will be defined by input type */
  54457. BasedOnInput = 2048
  54458. }
  54459. }
  54460. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  54461. /**
  54462. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54463. */
  54464. export enum NodeMaterialBlockConnectionPointMode {
  54465. /** Value is an uniform */
  54466. Uniform = 0,
  54467. /** Value is a mesh attribute */
  54468. Attribute = 1,
  54469. /** Value is a varying between vertex and fragment shaders */
  54470. Varying = 2,
  54471. /** Mode is undefined */
  54472. Undefined = 3
  54473. }
  54474. }
  54475. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  54476. /**
  54477. * Enum used to define system values e.g. values automatically provided by the system
  54478. */
  54479. export enum NodeMaterialSystemValues {
  54480. /** World */
  54481. World = 1,
  54482. /** View */
  54483. View = 2,
  54484. /** Projection */
  54485. Projection = 3,
  54486. /** ViewProjection */
  54487. ViewProjection = 4,
  54488. /** WorldView */
  54489. WorldView = 5,
  54490. /** WorldViewProjection */
  54491. WorldViewProjection = 6,
  54492. /** CameraPosition */
  54493. CameraPosition = 7,
  54494. /** Fog Color */
  54495. FogColor = 8
  54496. }
  54497. }
  54498. declare module "babylonjs/Materials/Node/Enums/index" {
  54499. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  54500. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  54501. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  54502. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  54503. }
  54504. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  54505. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54506. /**
  54507. * Root class for all node material optimizers
  54508. */
  54509. export class NodeMaterialOptimizer {
  54510. /**
  54511. * Function used to optimize a NodeMaterial graph
  54512. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  54513. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  54514. */
  54515. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  54516. }
  54517. }
  54518. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  54519. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54520. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54521. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54522. import { Scene } from "babylonjs/scene";
  54523. /**
  54524. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  54525. */
  54526. export class TransformBlock extends NodeMaterialBlock {
  54527. /**
  54528. * Defines the value to use to complement W value to transform it to a Vector4
  54529. */
  54530. complementW: number;
  54531. /**
  54532. * Defines the value to use to complement z value to transform it to a Vector4
  54533. */
  54534. complementZ: number;
  54535. /**
  54536. * Creates a new TransformBlock
  54537. * @param name defines the block name
  54538. */
  54539. constructor(name: string);
  54540. /**
  54541. * Gets the current class name
  54542. * @returns the class name
  54543. */
  54544. getClassName(): string;
  54545. /**
  54546. * Gets the vector input
  54547. */
  54548. readonly vector: NodeMaterialConnectionPoint;
  54549. /**
  54550. * Gets the output component
  54551. */
  54552. readonly output: NodeMaterialConnectionPoint;
  54553. /**
  54554. * Gets the matrix transform input
  54555. */
  54556. readonly transform: NodeMaterialConnectionPoint;
  54557. protected _buildBlock(state: NodeMaterialBuildState): this;
  54558. serialize(): any;
  54559. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54560. protected _dumpPropertiesCode(): string;
  54561. }
  54562. }
  54563. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  54564. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54565. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54566. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54567. /**
  54568. * Block used to output the vertex position
  54569. */
  54570. export class VertexOutputBlock extends NodeMaterialBlock {
  54571. /**
  54572. * Creates a new VertexOutputBlock
  54573. * @param name defines the block name
  54574. */
  54575. constructor(name: string);
  54576. /**
  54577. * Gets the current class name
  54578. * @returns the class name
  54579. */
  54580. getClassName(): string;
  54581. /**
  54582. * Gets the vector input component
  54583. */
  54584. readonly vector: NodeMaterialConnectionPoint;
  54585. protected _buildBlock(state: NodeMaterialBuildState): this;
  54586. }
  54587. }
  54588. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  54589. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54590. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54591. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54592. /**
  54593. * Block used to output the final color
  54594. */
  54595. export class FragmentOutputBlock extends NodeMaterialBlock {
  54596. /**
  54597. * Create a new FragmentOutputBlock
  54598. * @param name defines the block name
  54599. */
  54600. constructor(name: string);
  54601. /**
  54602. * Gets the current class name
  54603. * @returns the class name
  54604. */
  54605. getClassName(): string;
  54606. /**
  54607. * Gets the rgba input component
  54608. */
  54609. readonly rgba: NodeMaterialConnectionPoint;
  54610. /**
  54611. * Gets the rgb input component
  54612. */
  54613. readonly rgb: NodeMaterialConnectionPoint;
  54614. /**
  54615. * Gets the a input component
  54616. */
  54617. readonly a: NodeMaterialConnectionPoint;
  54618. protected _buildBlock(state: NodeMaterialBuildState): this;
  54619. }
  54620. }
  54621. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  54622. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54623. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54624. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54625. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54627. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54628. import { Effect } from "babylonjs/Materials/effect";
  54629. import { Mesh } from "babylonjs/Meshes/mesh";
  54630. import { Nullable } from "babylonjs/types";
  54631. import { Scene } from "babylonjs/scene";
  54632. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  54633. /**
  54634. * Block used to read a reflection texture from a sampler
  54635. */
  54636. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54637. private _define3DName;
  54638. private _defineCubicName;
  54639. private _defineExplicitName;
  54640. private _defineProjectionName;
  54641. private _defineLocalCubicName;
  54642. private _defineSphericalName;
  54643. private _definePlanarName;
  54644. private _defineEquirectangularName;
  54645. private _defineMirroredEquirectangularFixedName;
  54646. private _defineEquirectangularFixedName;
  54647. private _defineSkyboxName;
  54648. private _cubeSamplerName;
  54649. private _2DSamplerName;
  54650. private _positionUVWName;
  54651. private _directionWName;
  54652. private _reflectionCoordsName;
  54653. private _reflection2DCoordsName;
  54654. private _reflectionColorName;
  54655. private _reflectionMatrixName;
  54656. /**
  54657. * Gets or sets the texture associated with the node
  54658. */
  54659. texture: Nullable<BaseTexture>;
  54660. /**
  54661. * Create a new TextureBlock
  54662. * @param name defines the block name
  54663. */
  54664. constructor(name: string);
  54665. /**
  54666. * Gets the current class name
  54667. * @returns the class name
  54668. */
  54669. getClassName(): string;
  54670. /**
  54671. * Gets the world position input component
  54672. */
  54673. readonly position: NodeMaterialConnectionPoint;
  54674. /**
  54675. * Gets the world position input component
  54676. */
  54677. readonly worldPosition: NodeMaterialConnectionPoint;
  54678. /**
  54679. * Gets the world normal input component
  54680. */
  54681. readonly worldNormal: NodeMaterialConnectionPoint;
  54682. /**
  54683. * Gets the world input component
  54684. */
  54685. readonly world: NodeMaterialConnectionPoint;
  54686. /**
  54687. * Gets the camera (or eye) position component
  54688. */
  54689. readonly cameraPosition: NodeMaterialConnectionPoint;
  54690. /**
  54691. * Gets the view input component
  54692. */
  54693. readonly view: NodeMaterialConnectionPoint;
  54694. /**
  54695. * Gets the rgb output component
  54696. */
  54697. readonly rgb: NodeMaterialConnectionPoint;
  54698. /**
  54699. * Gets the r output component
  54700. */
  54701. readonly r: NodeMaterialConnectionPoint;
  54702. /**
  54703. * Gets the g output component
  54704. */
  54705. readonly g: NodeMaterialConnectionPoint;
  54706. /**
  54707. * Gets the b output component
  54708. */
  54709. readonly b: NodeMaterialConnectionPoint;
  54710. autoConfigure(material: NodeMaterial): void;
  54711. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54712. isReady(): boolean;
  54713. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54714. private _injectVertexCode;
  54715. private _writeOutput;
  54716. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54717. serialize(): any;
  54718. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54719. }
  54720. }
  54721. declare module "babylonjs/Materials/Node/nodeMaterial" {
  54722. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54723. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54724. import { Scene } from "babylonjs/scene";
  54725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54726. import { Matrix } from "babylonjs/Maths/math.vector";
  54727. import { Mesh } from "babylonjs/Meshes/mesh";
  54728. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54729. import { Observable } from "babylonjs/Misc/observable";
  54730. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54731. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54732. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54733. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54734. import { Nullable } from "babylonjs/types";
  54735. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54736. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54737. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54738. /**
  54739. * Interface used to configure the node material editor
  54740. */
  54741. export interface INodeMaterialEditorOptions {
  54742. /** Define the URl to load node editor script */
  54743. editorURL?: string;
  54744. }
  54745. /** @hidden */
  54746. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54747. /** BONES */
  54748. NUM_BONE_INFLUENCERS: number;
  54749. BonesPerMesh: number;
  54750. BONETEXTURE: boolean;
  54751. /** MORPH TARGETS */
  54752. MORPHTARGETS: boolean;
  54753. MORPHTARGETS_NORMAL: boolean;
  54754. MORPHTARGETS_TANGENT: boolean;
  54755. MORPHTARGETS_UV: boolean;
  54756. NUM_MORPH_INFLUENCERS: number;
  54757. /** IMAGE PROCESSING */
  54758. IMAGEPROCESSING: boolean;
  54759. VIGNETTE: boolean;
  54760. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54761. VIGNETTEBLENDMODEOPAQUE: boolean;
  54762. TONEMAPPING: boolean;
  54763. TONEMAPPING_ACES: boolean;
  54764. CONTRAST: boolean;
  54765. EXPOSURE: boolean;
  54766. COLORCURVES: boolean;
  54767. COLORGRADING: boolean;
  54768. COLORGRADING3D: boolean;
  54769. SAMPLER3DGREENDEPTH: boolean;
  54770. SAMPLER3DBGRMAP: boolean;
  54771. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54772. /** MISC. */
  54773. BUMPDIRECTUV: number;
  54774. constructor();
  54775. setValue(name: string, value: boolean): void;
  54776. }
  54777. /**
  54778. * Class used to configure NodeMaterial
  54779. */
  54780. export interface INodeMaterialOptions {
  54781. /**
  54782. * Defines if blocks should emit comments
  54783. */
  54784. emitComments: boolean;
  54785. }
  54786. /**
  54787. * Class used to create a node based material built by assembling shader blocks
  54788. */
  54789. export class NodeMaterial extends PushMaterial {
  54790. private static _BuildIdGenerator;
  54791. private _options;
  54792. private _vertexCompilationState;
  54793. private _fragmentCompilationState;
  54794. private _sharedData;
  54795. private _buildId;
  54796. private _buildWasSuccessful;
  54797. private _cachedWorldViewMatrix;
  54798. private _cachedWorldViewProjectionMatrix;
  54799. private _optimizers;
  54800. private _animationFrame;
  54801. /** Define the URl to load node editor script */
  54802. static EditorURL: string;
  54803. private BJSNODEMATERIALEDITOR;
  54804. /** Get the inspector from bundle or global */
  54805. private _getGlobalNodeMaterialEditor;
  54806. /**
  54807. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  54808. */
  54809. ignoreAlpha: boolean;
  54810. /**
  54811. * Defines the maximum number of lights that can be used in the material
  54812. */
  54813. maxSimultaneousLights: number;
  54814. /**
  54815. * Observable raised when the material is built
  54816. */
  54817. onBuildObservable: Observable<NodeMaterial>;
  54818. /**
  54819. * Gets or sets the root nodes of the material vertex shader
  54820. */
  54821. _vertexOutputNodes: NodeMaterialBlock[];
  54822. /**
  54823. * Gets or sets the root nodes of the material fragment (pixel) shader
  54824. */
  54825. _fragmentOutputNodes: NodeMaterialBlock[];
  54826. /** Gets or sets options to control the node material overall behavior */
  54827. options: INodeMaterialOptions;
  54828. /**
  54829. * Default configuration related to image processing available in the standard Material.
  54830. */
  54831. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54832. /**
  54833. * Gets the image processing configuration used either in this material.
  54834. */
  54835. /**
  54836. * Sets the Default image processing configuration used either in the this material.
  54837. *
  54838. * If sets to null, the scene one is in use.
  54839. */
  54840. imageProcessingConfiguration: ImageProcessingConfiguration;
  54841. /**
  54842. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54843. */
  54844. attachedBlocks: NodeMaterialBlock[];
  54845. /**
  54846. * Create a new node based material
  54847. * @param name defines the material name
  54848. * @param scene defines the hosting scene
  54849. * @param options defines creation option
  54850. */
  54851. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54852. /**
  54853. * Gets the current class name of the material e.g. "NodeMaterial"
  54854. * @returns the class name
  54855. */
  54856. getClassName(): string;
  54857. /**
  54858. * Keep track of the image processing observer to allow dispose and replace.
  54859. */
  54860. private _imageProcessingObserver;
  54861. /**
  54862. * Attaches a new image processing configuration to the Standard Material.
  54863. * @param configuration
  54864. */
  54865. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54866. /**
  54867. * Get a block by its name
  54868. * @param name defines the name of the block to retrieve
  54869. * @returns the required block or null if not found
  54870. */
  54871. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54872. /**
  54873. * Get a block by its name
  54874. * @param predicate defines the predicate used to find the good candidate
  54875. * @returns the required block or null if not found
  54876. */
  54877. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  54878. /**
  54879. * Get an input block by its name
  54880. * @param predicate defines the predicate used to find the good candidate
  54881. * @returns the required input block or null if not found
  54882. */
  54883. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  54884. /**
  54885. * Gets the list of input blocks attached to this material
  54886. * @returns an array of InputBlocks
  54887. */
  54888. getInputBlocks(): InputBlock[];
  54889. /**
  54890. * Adds a new optimizer to the list of optimizers
  54891. * @param optimizer defines the optimizers to add
  54892. * @returns the current material
  54893. */
  54894. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54895. /**
  54896. * Remove an optimizer from the list of optimizers
  54897. * @param optimizer defines the optimizers to remove
  54898. * @returns the current material
  54899. */
  54900. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54901. /**
  54902. * Add a new block to the list of output nodes
  54903. * @param node defines the node to add
  54904. * @returns the current material
  54905. */
  54906. addOutputNode(node: NodeMaterialBlock): this;
  54907. /**
  54908. * Remove a block from the list of root nodes
  54909. * @param node defines the node to remove
  54910. * @returns the current material
  54911. */
  54912. removeOutputNode(node: NodeMaterialBlock): this;
  54913. private _addVertexOutputNode;
  54914. private _removeVertexOutputNode;
  54915. private _addFragmentOutputNode;
  54916. private _removeFragmentOutputNode;
  54917. /**
  54918. * Specifies if the material will require alpha blending
  54919. * @returns a boolean specifying if alpha blending is needed
  54920. */
  54921. needAlphaBlending(): boolean;
  54922. /**
  54923. * Specifies if this material should be rendered in alpha test mode
  54924. * @returns a boolean specifying if an alpha test is needed.
  54925. */
  54926. needAlphaTesting(): boolean;
  54927. private _initializeBlock;
  54928. private _resetDualBlocks;
  54929. /**
  54930. * Build the material and generates the inner effect
  54931. * @param verbose defines if the build should log activity
  54932. */
  54933. build(verbose?: boolean): void;
  54934. /**
  54935. * Runs an otpimization phase to try to improve the shader code
  54936. */
  54937. optimize(): void;
  54938. private _prepareDefinesForAttributes;
  54939. /**
  54940. * Get if the submesh is ready to be used and all its information available.
  54941. * Child classes can use it to update shaders
  54942. * @param mesh defines the mesh to check
  54943. * @param subMesh defines which submesh to check
  54944. * @param useInstances specifies that instances should be used
  54945. * @returns a boolean indicating that the submesh is ready or not
  54946. */
  54947. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54948. /**
  54949. * Get a string representing the shaders built by the current node graph
  54950. */
  54951. readonly compiledShaders: string;
  54952. /**
  54953. * Binds the world matrix to the material
  54954. * @param world defines the world transformation matrix
  54955. */
  54956. bindOnlyWorldMatrix(world: Matrix): void;
  54957. /**
  54958. * Binds the submesh to this material by preparing the effect and shader to draw
  54959. * @param world defines the world transformation matrix
  54960. * @param mesh defines the mesh containing the submesh
  54961. * @param subMesh defines the submesh to bind the material to
  54962. */
  54963. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54964. /**
  54965. * Gets the active textures from the material
  54966. * @returns an array of textures
  54967. */
  54968. getActiveTextures(): BaseTexture[];
  54969. /**
  54970. * Gets the list of texture blocks
  54971. * @returns an array of texture blocks
  54972. */
  54973. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  54974. /**
  54975. * Specifies if the material uses a texture
  54976. * @param texture defines the texture to check against the material
  54977. * @returns a boolean specifying if the material uses the texture
  54978. */
  54979. hasTexture(texture: BaseTexture): boolean;
  54980. /**
  54981. * Disposes the material
  54982. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54983. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54984. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54985. */
  54986. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54987. /** Creates the node editor window. */
  54988. private _createNodeEditor;
  54989. /**
  54990. * Launch the node material editor
  54991. * @param config Define the configuration of the editor
  54992. * @return a promise fulfilled when the node editor is visible
  54993. */
  54994. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54995. /**
  54996. * Clear the current material
  54997. */
  54998. clear(): void;
  54999. /**
  55000. * Clear the current material and set it to a default state
  55001. */
  55002. setToDefault(): void;
  55003. /**
  55004. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55005. * @param url defines the url to load from
  55006. * @returns a promise that will fullfil when the material is fully loaded
  55007. */
  55008. loadAsync(url: string): Promise<unknown>;
  55009. private _gatherBlocks;
  55010. /**
  55011. * Generate a string containing the code declaration required to create an equivalent of this material
  55012. * @returns a string
  55013. */
  55014. generateCode(): string;
  55015. /**
  55016. * Serializes this material in a JSON representation
  55017. * @returns the serialized material object
  55018. */
  55019. serialize(): any;
  55020. private _restoreConnections;
  55021. /**
  55022. * Clear the current graph and load a new one from a serialization object
  55023. * @param source defines the JSON representation of the material
  55024. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55025. */
  55026. loadFromSerialization(source: any, rootUrl?: string): void;
  55027. /**
  55028. * Creates a node material from parsed material data
  55029. * @param source defines the JSON representation of the material
  55030. * @param scene defines the hosting scene
  55031. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55032. * @returns a new node material
  55033. */
  55034. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55035. /**
  55036. * Creates a new node material set to default basic configuration
  55037. * @param name defines the name of the material
  55038. * @param scene defines the hosting scene
  55039. * @returns a new NodeMaterial
  55040. */
  55041. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55042. }
  55043. }
  55044. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55045. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55046. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55047. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55048. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55050. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55051. import { Effect } from "babylonjs/Materials/effect";
  55052. import { Mesh } from "babylonjs/Meshes/mesh";
  55053. import { Nullable } from "babylonjs/types";
  55054. import { Texture } from "babylonjs/Materials/Textures/texture";
  55055. import { Scene } from "babylonjs/scene";
  55056. /**
  55057. * Block used to read a texture from a sampler
  55058. */
  55059. export class TextureBlock extends NodeMaterialBlock {
  55060. private _defineName;
  55061. private _samplerName;
  55062. private _transformedUVName;
  55063. private _textureTransformName;
  55064. private _textureInfoName;
  55065. private _mainUVName;
  55066. private _mainUVDefineName;
  55067. /**
  55068. * Gets or sets the texture associated with the node
  55069. */
  55070. texture: Nullable<Texture>;
  55071. /**
  55072. * Create a new TextureBlock
  55073. * @param name defines the block name
  55074. */
  55075. constructor(name: string);
  55076. /**
  55077. * Gets the current class name
  55078. * @returns the class name
  55079. */
  55080. getClassName(): string;
  55081. /**
  55082. * Gets the uv input component
  55083. */
  55084. readonly uv: NodeMaterialConnectionPoint;
  55085. /**
  55086. * Gets the rgba output component
  55087. */
  55088. readonly rgba: NodeMaterialConnectionPoint;
  55089. /**
  55090. * Gets the rgb output component
  55091. */
  55092. readonly rgb: NodeMaterialConnectionPoint;
  55093. /**
  55094. * Gets the r output component
  55095. */
  55096. readonly r: NodeMaterialConnectionPoint;
  55097. /**
  55098. * Gets the g output component
  55099. */
  55100. readonly g: NodeMaterialConnectionPoint;
  55101. /**
  55102. * Gets the b output component
  55103. */
  55104. readonly b: NodeMaterialConnectionPoint;
  55105. /**
  55106. * Gets the a output component
  55107. */
  55108. readonly a: NodeMaterialConnectionPoint;
  55109. readonly target: NodeMaterialBlockTargets;
  55110. autoConfigure(material: NodeMaterial): void;
  55111. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55112. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55113. isReady(): boolean;
  55114. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55115. private readonly _isMixed;
  55116. private _injectVertexCode;
  55117. private _writeOutput;
  55118. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55119. protected _dumpPropertiesCode(): string;
  55120. serialize(): any;
  55121. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55122. }
  55123. }
  55124. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55125. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55126. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55127. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55128. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55129. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55130. import { Scene } from "babylonjs/scene";
  55131. /**
  55132. * Class used to store shared data between 2 NodeMaterialBuildState
  55133. */
  55134. export class NodeMaterialBuildStateSharedData {
  55135. /**
  55136. * Gets the list of emitted varyings
  55137. */
  55138. temps: string[];
  55139. /**
  55140. * Gets the list of emitted varyings
  55141. */
  55142. varyings: string[];
  55143. /**
  55144. * Gets the varying declaration string
  55145. */
  55146. varyingDeclaration: string;
  55147. /**
  55148. * Input blocks
  55149. */
  55150. inputBlocks: InputBlock[];
  55151. /**
  55152. * Input blocks
  55153. */
  55154. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55155. /**
  55156. * Bindable blocks (Blocks that need to set data to the effect)
  55157. */
  55158. bindableBlocks: NodeMaterialBlock[];
  55159. /**
  55160. * List of blocks that can provide a compilation fallback
  55161. */
  55162. blocksWithFallbacks: NodeMaterialBlock[];
  55163. /**
  55164. * List of blocks that can provide a define update
  55165. */
  55166. blocksWithDefines: NodeMaterialBlock[];
  55167. /**
  55168. * List of blocks that can provide a repeatable content
  55169. */
  55170. repeatableContentBlocks: NodeMaterialBlock[];
  55171. /**
  55172. * List of blocks that can provide a dynamic list of uniforms
  55173. */
  55174. dynamicUniformBlocks: NodeMaterialBlock[];
  55175. /**
  55176. * List of blocks that can block the isReady function for the material
  55177. */
  55178. blockingBlocks: NodeMaterialBlock[];
  55179. /**
  55180. * Gets the list of animated inputs
  55181. */
  55182. animatedInputs: InputBlock[];
  55183. /**
  55184. * Build Id used to avoid multiple recompilations
  55185. */
  55186. buildId: number;
  55187. /** List of emitted variables */
  55188. variableNames: {
  55189. [key: string]: number;
  55190. };
  55191. /** List of emitted defines */
  55192. defineNames: {
  55193. [key: string]: number;
  55194. };
  55195. /** Should emit comments? */
  55196. emitComments: boolean;
  55197. /** Emit build activity */
  55198. verbose: boolean;
  55199. /** Gets or sets the hosting scene */
  55200. scene: Scene;
  55201. /**
  55202. * Gets the compilation hints emitted at compilation time
  55203. */
  55204. hints: {
  55205. needWorldViewMatrix: boolean;
  55206. needWorldViewProjectionMatrix: boolean;
  55207. needAlphaBlending: boolean;
  55208. needAlphaTesting: boolean;
  55209. };
  55210. /**
  55211. * List of compilation checks
  55212. */
  55213. checks: {
  55214. emitVertex: boolean;
  55215. emitFragment: boolean;
  55216. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55217. };
  55218. /** Creates a new shared data */
  55219. constructor();
  55220. /**
  55221. * Emits console errors and exceptions if there is a failing check
  55222. */
  55223. emitErrors(): void;
  55224. }
  55225. }
  55226. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55227. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55228. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55229. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55230. /**
  55231. * Class used to store node based material build state
  55232. */
  55233. export class NodeMaterialBuildState {
  55234. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55235. supportUniformBuffers: boolean;
  55236. /**
  55237. * Gets the list of emitted attributes
  55238. */
  55239. attributes: string[];
  55240. /**
  55241. * Gets the list of emitted uniforms
  55242. */
  55243. uniforms: string[];
  55244. /**
  55245. * Gets the list of emitted constants
  55246. */
  55247. constants: string[];
  55248. /**
  55249. * Gets the list of emitted uniform buffers
  55250. */
  55251. uniformBuffers: string[];
  55252. /**
  55253. * Gets the list of emitted samplers
  55254. */
  55255. samplers: string[];
  55256. /**
  55257. * Gets the list of emitted functions
  55258. */
  55259. functions: {
  55260. [key: string]: string;
  55261. };
  55262. /**
  55263. * Gets the list of emitted extensions
  55264. */
  55265. extensions: {
  55266. [key: string]: string;
  55267. };
  55268. /**
  55269. * Gets the target of the compilation state
  55270. */
  55271. target: NodeMaterialBlockTargets;
  55272. /**
  55273. * Gets the list of emitted counters
  55274. */
  55275. counters: {
  55276. [key: string]: number;
  55277. };
  55278. /**
  55279. * Shared data between multiple NodeMaterialBuildState instances
  55280. */
  55281. sharedData: NodeMaterialBuildStateSharedData;
  55282. /** @hidden */
  55283. _vertexState: NodeMaterialBuildState;
  55284. /** @hidden */
  55285. _attributeDeclaration: string;
  55286. /** @hidden */
  55287. _uniformDeclaration: string;
  55288. /** @hidden */
  55289. _constantDeclaration: string;
  55290. /** @hidden */
  55291. _samplerDeclaration: string;
  55292. /** @hidden */
  55293. _varyingTransfer: string;
  55294. private _repeatableContentAnchorIndex;
  55295. /** @hidden */
  55296. _builtCompilationString: string;
  55297. /**
  55298. * Gets the emitted compilation strings
  55299. */
  55300. compilationString: string;
  55301. /**
  55302. * Finalize the compilation strings
  55303. * @param state defines the current compilation state
  55304. */
  55305. finalize(state: NodeMaterialBuildState): void;
  55306. /** @hidden */
  55307. readonly _repeatableContentAnchor: string;
  55308. /** @hidden */
  55309. _getFreeVariableName(prefix: string): string;
  55310. /** @hidden */
  55311. _getFreeDefineName(prefix: string): string;
  55312. /** @hidden */
  55313. _excludeVariableName(name: string): void;
  55314. /** @hidden */
  55315. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55316. /** @hidden */
  55317. _emitExtension(name: string, extension: string): void;
  55318. /** @hidden */
  55319. _emitFunction(name: string, code: string, comments: string): void;
  55320. /** @hidden */
  55321. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55322. replaceStrings?: {
  55323. search: RegExp;
  55324. replace: string;
  55325. }[];
  55326. repeatKey?: string;
  55327. }): string;
  55328. /** @hidden */
  55329. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55330. repeatKey?: string;
  55331. removeAttributes?: boolean;
  55332. removeUniforms?: boolean;
  55333. removeVaryings?: boolean;
  55334. removeIfDef?: boolean;
  55335. replaceStrings?: {
  55336. search: RegExp;
  55337. replace: string;
  55338. }[];
  55339. }, storeKey?: string): void;
  55340. /** @hidden */
  55341. _registerTempVariable(name: string): boolean;
  55342. /** @hidden */
  55343. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55344. /** @hidden */
  55345. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55346. }
  55347. }
  55348. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55349. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55350. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55351. import { Nullable } from "babylonjs/types";
  55352. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55353. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55354. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55356. import { Mesh } from "babylonjs/Meshes/mesh";
  55357. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55358. import { Scene } from "babylonjs/scene";
  55359. /**
  55360. * Defines a block that can be used inside a node based material
  55361. */
  55362. export class NodeMaterialBlock {
  55363. private _buildId;
  55364. private _buildTarget;
  55365. private _target;
  55366. private _isFinalMerger;
  55367. private _isInput;
  55368. /** @hidden */
  55369. _codeVariableName: string;
  55370. /** @hidden */
  55371. _inputs: NodeMaterialConnectionPoint[];
  55372. /** @hidden */
  55373. _outputs: NodeMaterialConnectionPoint[];
  55374. /** @hidden */
  55375. _preparationId: number;
  55376. /**
  55377. * Gets or sets the name of the block
  55378. */
  55379. name: string;
  55380. /**
  55381. * Gets or sets the unique id of the node
  55382. */
  55383. uniqueId: number;
  55384. /**
  55385. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55386. */
  55387. readonly isFinalMerger: boolean;
  55388. /**
  55389. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55390. */
  55391. readonly isInput: boolean;
  55392. /**
  55393. * Gets or sets the build Id
  55394. */
  55395. buildId: number;
  55396. /**
  55397. * Gets or sets the target of the block
  55398. */
  55399. target: NodeMaterialBlockTargets;
  55400. /**
  55401. * Gets the list of input points
  55402. */
  55403. readonly inputs: NodeMaterialConnectionPoint[];
  55404. /** Gets the list of output points */
  55405. readonly outputs: NodeMaterialConnectionPoint[];
  55406. /**
  55407. * Find an input by its name
  55408. * @param name defines the name of the input to look for
  55409. * @returns the input or null if not found
  55410. */
  55411. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55412. /**
  55413. * Find an output by its name
  55414. * @param name defines the name of the outputto look for
  55415. * @returns the output or null if not found
  55416. */
  55417. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55418. /**
  55419. * Creates a new NodeMaterialBlock
  55420. * @param name defines the block name
  55421. * @param target defines the target of that block (Vertex by default)
  55422. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55423. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55424. */
  55425. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55426. /**
  55427. * Initialize the block and prepare the context for build
  55428. * @param state defines the state that will be used for the build
  55429. */
  55430. initialize(state: NodeMaterialBuildState): void;
  55431. /**
  55432. * Bind data to effect. Will only be called for blocks with isBindable === true
  55433. * @param effect defines the effect to bind data to
  55434. * @param nodeMaterial defines the hosting NodeMaterial
  55435. * @param mesh defines the mesh that will be rendered
  55436. */
  55437. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55438. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55439. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55440. protected _writeFloat(value: number): string;
  55441. /**
  55442. * Gets the current class name e.g. "NodeMaterialBlock"
  55443. * @returns the class name
  55444. */
  55445. getClassName(): string;
  55446. /**
  55447. * Register a new input. Must be called inside a block constructor
  55448. * @param name defines the connection point name
  55449. * @param type defines the connection point type
  55450. * @param isOptional defines a boolean indicating that this input can be omitted
  55451. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55452. * @returns the current block
  55453. */
  55454. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55455. /**
  55456. * Register a new output. Must be called inside a block constructor
  55457. * @param name defines the connection point name
  55458. * @param type defines the connection point type
  55459. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55460. * @returns the current block
  55461. */
  55462. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55463. /**
  55464. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55465. * @param forOutput defines an optional connection point to check compatibility with
  55466. * @returns the first available input or null
  55467. */
  55468. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55469. /**
  55470. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55471. * @param forBlock defines an optional block to check compatibility with
  55472. * @returns the first available input or null
  55473. */
  55474. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55475. /**
  55476. * Gets the sibling of the given output
  55477. * @param current defines the current output
  55478. * @returns the next output in the list or null
  55479. */
  55480. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55481. /**
  55482. * Connect current block with another block
  55483. * @param other defines the block to connect with
  55484. * @param options define the various options to help pick the right connections
  55485. * @returns the current block
  55486. */
  55487. connectTo(other: NodeMaterialBlock, options?: {
  55488. input?: string;
  55489. output?: string;
  55490. outputSwizzle?: string;
  55491. }): this | undefined;
  55492. protected _buildBlock(state: NodeMaterialBuildState): void;
  55493. /**
  55494. * Add uniforms, samplers and uniform buffers at compilation time
  55495. * @param state defines the state to update
  55496. * @param nodeMaterial defines the node material requesting the update
  55497. * @param defines defines the material defines to update
  55498. */
  55499. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55500. /**
  55501. * Add potential fallbacks if shader compilation fails
  55502. * @param mesh defines the mesh to be rendered
  55503. * @param fallbacks defines the current prioritized list of fallbacks
  55504. */
  55505. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55506. /**
  55507. * Initialize defines for shader compilation
  55508. * @param mesh defines the mesh to be rendered
  55509. * @param nodeMaterial defines the node material requesting the update
  55510. * @param defines defines the material defines to update
  55511. * @param useInstances specifies that instances should be used
  55512. */
  55513. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55514. /**
  55515. * Update defines for shader compilation
  55516. * @param mesh defines the mesh to be rendered
  55517. * @param nodeMaterial defines the node material requesting the update
  55518. * @param defines defines the material defines to update
  55519. * @param useInstances specifies that instances should be used
  55520. */
  55521. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55522. /**
  55523. * Lets the block try to connect some inputs automatically
  55524. * @param material defines the hosting NodeMaterial
  55525. */
  55526. autoConfigure(material: NodeMaterial): void;
  55527. /**
  55528. * Function called when a block is declared as repeatable content generator
  55529. * @param vertexShaderState defines the current compilation state for the vertex shader
  55530. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55531. * @param mesh defines the mesh to be rendered
  55532. * @param defines defines the material defines to update
  55533. */
  55534. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55535. /**
  55536. * Checks if the block is ready
  55537. * @param mesh defines the mesh to be rendered
  55538. * @param nodeMaterial defines the node material requesting the update
  55539. * @param defines defines the material defines to update
  55540. * @param useInstances specifies that instances should be used
  55541. * @returns true if the block is ready
  55542. */
  55543. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  55544. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  55545. private _processBuild;
  55546. /**
  55547. * Compile the current node and generate the shader code
  55548. * @param state defines the current compilation state (uniforms, samplers, current string)
  55549. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  55550. * @returns true if already built
  55551. */
  55552. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  55553. protected _inputRename(name: string): string;
  55554. protected _outputRename(name: string): string;
  55555. protected _dumpPropertiesCode(): string;
  55556. /** @hidden */
  55557. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  55558. /**
  55559. * Clone the current block to a new identical block
  55560. * @param scene defines the hosting scene
  55561. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55562. * @returns a copy of the current block
  55563. */
  55564. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  55565. /**
  55566. * Serializes this block in a JSON representation
  55567. * @returns the serialized block object
  55568. */
  55569. serialize(): any;
  55570. /** @hidden */
  55571. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55572. }
  55573. }
  55574. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  55575. /**
  55576. * Enum defining the type of animations supported by InputBlock
  55577. */
  55578. export enum AnimatedInputBlockTypes {
  55579. /** No animation */
  55580. None = 0,
  55581. /** Time based animation. Will only work for floats */
  55582. Time = 1
  55583. }
  55584. }
  55585. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  55586. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55587. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55588. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55589. import { Nullable } from "babylonjs/types";
  55590. import { Effect } from "babylonjs/Materials/effect";
  55591. import { Matrix } from "babylonjs/Maths/math.vector";
  55592. import { Scene } from "babylonjs/scene";
  55593. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55594. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55595. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55596. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55597. /**
  55598. * Block used to expose an input value
  55599. */
  55600. export class InputBlock extends NodeMaterialBlock {
  55601. private _mode;
  55602. private _associatedVariableName;
  55603. private _storedValue;
  55604. private _valueCallback;
  55605. private _type;
  55606. private _animationType;
  55607. /** Gets or set a value used to limit the range of float values */
  55608. min: number;
  55609. /** Gets or set a value used to limit the range of float values */
  55610. max: number;
  55611. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  55612. matrixMode: number;
  55613. /** @hidden */
  55614. _systemValue: Nullable<NodeMaterialSystemValues>;
  55615. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  55616. visibleInInspector: boolean;
  55617. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  55618. isConstant: boolean;
  55619. /**
  55620. * Gets or sets the connection point type (default is float)
  55621. */
  55622. readonly type: NodeMaterialBlockConnectionPointTypes;
  55623. /**
  55624. * Creates a new InputBlock
  55625. * @param name defines the block name
  55626. * @param target defines the target of that block (Vertex by default)
  55627. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55628. */
  55629. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55630. /**
  55631. * Gets the output component
  55632. */
  55633. readonly output: NodeMaterialConnectionPoint;
  55634. /**
  55635. * Set the source of this connection point to a vertex attribute
  55636. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55637. * @returns the current connection point
  55638. */
  55639. setAsAttribute(attributeName?: string): InputBlock;
  55640. /**
  55641. * Set the source of this connection point to a system value
  55642. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  55643. * @returns the current connection point
  55644. */
  55645. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  55646. /**
  55647. * Gets or sets the value of that point.
  55648. * Please note that this value will be ignored if valueCallback is defined
  55649. */
  55650. value: any;
  55651. /**
  55652. * Gets or sets a callback used to get the value of that point.
  55653. * Please note that setting this value will force the connection point to ignore the value property
  55654. */
  55655. valueCallback: () => any;
  55656. /**
  55657. * Gets or sets the associated variable name in the shader
  55658. */
  55659. associatedVariableName: string;
  55660. /** Gets or sets the type of animation applied to the input */
  55661. animationType: AnimatedInputBlockTypes;
  55662. /**
  55663. * Gets a boolean indicating that this connection point not defined yet
  55664. */
  55665. readonly isUndefined: boolean;
  55666. /**
  55667. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55668. * In this case the connection point name must be the name of the uniform to use.
  55669. * Can only be set on inputs
  55670. */
  55671. isUniform: boolean;
  55672. /**
  55673. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55674. * In this case the connection point name must be the name of the attribute to use
  55675. * Can only be set on inputs
  55676. */
  55677. isAttribute: boolean;
  55678. /**
  55679. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55680. * Can only be set on exit points
  55681. */
  55682. isVarying: boolean;
  55683. /**
  55684. * Gets a boolean indicating that the current connection point is a system value
  55685. */
  55686. readonly isSystemValue: boolean;
  55687. /**
  55688. * Gets or sets the current well known value or null if not defined as a system value
  55689. */
  55690. systemValue: Nullable<NodeMaterialSystemValues>;
  55691. /**
  55692. * Gets the current class name
  55693. * @returns the class name
  55694. */
  55695. getClassName(): string;
  55696. /**
  55697. * Animate the input if animationType !== None
  55698. * @param scene defines the rendering scene
  55699. */
  55700. animate(scene: Scene): void;
  55701. private _emitDefine;
  55702. initialize(state: NodeMaterialBuildState): void;
  55703. /**
  55704. * Set the input block to its default value (based on its type)
  55705. */
  55706. setDefaultValue(): void;
  55707. private _emitConstant;
  55708. private _emit;
  55709. /** @hidden */
  55710. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55711. /** @hidden */
  55712. _transmit(effect: Effect, scene: Scene): void;
  55713. protected _buildBlock(state: NodeMaterialBuildState): void;
  55714. protected _dumpPropertiesCode(): string;
  55715. serialize(): any;
  55716. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55717. }
  55718. }
  55719. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  55720. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55721. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55722. import { Nullable } from "babylonjs/types";
  55723. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55724. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55725. /**
  55726. * Defines a connection point for a block
  55727. */
  55728. export class NodeMaterialConnectionPoint {
  55729. /** @hidden */
  55730. _ownerBlock: NodeMaterialBlock;
  55731. /** @hidden */
  55732. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55733. private _endpoints;
  55734. private _associatedVariableName;
  55735. /** @hidden */
  55736. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55737. /** @hidden */
  55738. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55739. private _type;
  55740. /** @hidden */
  55741. _enforceAssociatedVariableName: boolean;
  55742. /**
  55743. * Gets or sets the additional types supported by this connection point
  55744. */
  55745. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55746. /**
  55747. * Gets or sets the additional types excluded by this connection point
  55748. */
  55749. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55750. /**
  55751. * Gets or sets the associated variable name in the shader
  55752. */
  55753. associatedVariableName: string;
  55754. /**
  55755. * Gets or sets the connection point type (default is float)
  55756. */
  55757. type: NodeMaterialBlockConnectionPointTypes;
  55758. /**
  55759. * Gets or sets the connection point name
  55760. */
  55761. name: string;
  55762. /**
  55763. * Gets or sets a boolean indicating that this connection point can be omitted
  55764. */
  55765. isOptional: boolean;
  55766. /**
  55767. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55768. */
  55769. define: string;
  55770. /** Gets or sets the target of that connection point */
  55771. target: NodeMaterialBlockTargets;
  55772. /**
  55773. * Gets a boolean indicating that the current point is connected
  55774. */
  55775. readonly isConnected: boolean;
  55776. /**
  55777. * Gets a boolean indicating that the current point is connected to an input block
  55778. */
  55779. readonly isConnectedToInputBlock: boolean;
  55780. /**
  55781. * Gets a the connected input block (if any)
  55782. */
  55783. readonly connectInputBlock: Nullable<InputBlock>;
  55784. /** Get the other side of the connection (if any) */
  55785. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55786. /** Get the block that owns this connection point */
  55787. readonly ownerBlock: NodeMaterialBlock;
  55788. /** Get the block connected on the other side of this connection (if any) */
  55789. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55790. /** Get the block connected on the endpoints of this connection (if any) */
  55791. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55792. /** Gets the list of connected endpoints */
  55793. readonly endpoints: NodeMaterialConnectionPoint[];
  55794. /** Gets a boolean indicating if that output point is connected to at least one input */
  55795. readonly hasEndpoints: boolean;
  55796. /**
  55797. * Creates a new connection point
  55798. * @param name defines the connection point name
  55799. * @param ownerBlock defines the block hosting this connection point
  55800. */
  55801. constructor(name: string, ownerBlock: NodeMaterialBlock);
  55802. /**
  55803. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55804. * @returns the class name
  55805. */
  55806. getClassName(): string;
  55807. /**
  55808. * Gets an boolean indicating if the current point can be connected to another point
  55809. * @param connectionPoint defines the other connection point
  55810. * @returns true if the connection is possible
  55811. */
  55812. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55813. /**
  55814. * Connect this point to another connection point
  55815. * @param connectionPoint defines the other connection point
  55816. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55817. * @returns the current connection point
  55818. */
  55819. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55820. /**
  55821. * Disconnect this point from one of his endpoint
  55822. * @param endpoint defines the other connection point
  55823. * @returns the current connection point
  55824. */
  55825. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55826. /**
  55827. * Serializes this point in a JSON representation
  55828. * @returns the serialized point object
  55829. */
  55830. serialize(): any;
  55831. }
  55832. }
  55833. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55834. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55835. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55837. import { Mesh } from "babylonjs/Meshes/mesh";
  55838. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55839. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55840. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55841. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55842. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55843. /**
  55844. * Block used to add support for vertex skinning (bones)
  55845. */
  55846. export class BonesBlock extends NodeMaterialBlock {
  55847. /**
  55848. * Creates a new BonesBlock
  55849. * @param name defines the block name
  55850. */
  55851. constructor(name: string);
  55852. /**
  55853. * Initialize the block and prepare the context for build
  55854. * @param state defines the state that will be used for the build
  55855. */
  55856. initialize(state: NodeMaterialBuildState): void;
  55857. /**
  55858. * Gets the current class name
  55859. * @returns the class name
  55860. */
  55861. getClassName(): string;
  55862. /**
  55863. * Gets the matrix indices input component
  55864. */
  55865. readonly matricesIndices: NodeMaterialConnectionPoint;
  55866. /**
  55867. * Gets the matrix weights input component
  55868. */
  55869. readonly matricesWeights: NodeMaterialConnectionPoint;
  55870. /**
  55871. * Gets the extra matrix indices input component
  55872. */
  55873. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55874. /**
  55875. * Gets the extra matrix weights input component
  55876. */
  55877. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55878. /**
  55879. * Gets the world input component
  55880. */
  55881. readonly world: NodeMaterialConnectionPoint;
  55882. /**
  55883. * Gets the output component
  55884. */
  55885. readonly output: NodeMaterialConnectionPoint;
  55886. autoConfigure(material: NodeMaterial): void;
  55887. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55888. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55889. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55890. protected _buildBlock(state: NodeMaterialBuildState): this;
  55891. }
  55892. }
  55893. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55894. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55895. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55896. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55898. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55899. /**
  55900. * Block used to add support for instances
  55901. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55902. */
  55903. export class InstancesBlock extends NodeMaterialBlock {
  55904. /**
  55905. * Creates a new InstancesBlock
  55906. * @param name defines the block name
  55907. */
  55908. constructor(name: string);
  55909. /**
  55910. * Gets the current class name
  55911. * @returns the class name
  55912. */
  55913. getClassName(): string;
  55914. /**
  55915. * Gets the first world row input component
  55916. */
  55917. readonly world0: NodeMaterialConnectionPoint;
  55918. /**
  55919. * Gets the second world row input component
  55920. */
  55921. readonly world1: NodeMaterialConnectionPoint;
  55922. /**
  55923. * Gets the third world row input component
  55924. */
  55925. readonly world2: NodeMaterialConnectionPoint;
  55926. /**
  55927. * Gets the forth world row input component
  55928. */
  55929. readonly world3: NodeMaterialConnectionPoint;
  55930. /**
  55931. * Gets the world input component
  55932. */
  55933. readonly world: NodeMaterialConnectionPoint;
  55934. /**
  55935. * Gets the output component
  55936. */
  55937. readonly output: NodeMaterialConnectionPoint;
  55938. autoConfigure(material: NodeMaterial): void;
  55939. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55940. protected _buildBlock(state: NodeMaterialBuildState): this;
  55941. }
  55942. }
  55943. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55944. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55945. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55946. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55948. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55949. import { Effect } from "babylonjs/Materials/effect";
  55950. import { Mesh } from "babylonjs/Meshes/mesh";
  55951. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55952. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55953. /**
  55954. * Block used to add morph targets support to vertex shader
  55955. */
  55956. export class MorphTargetsBlock extends NodeMaterialBlock {
  55957. private _repeatableContentAnchor;
  55958. private _repeatebleContentGenerated;
  55959. /**
  55960. * Create a new MorphTargetsBlock
  55961. * @param name defines the block name
  55962. */
  55963. constructor(name: string);
  55964. /**
  55965. * Gets the current class name
  55966. * @returns the class name
  55967. */
  55968. getClassName(): string;
  55969. /**
  55970. * Gets the position input component
  55971. */
  55972. readonly position: NodeMaterialConnectionPoint;
  55973. /**
  55974. * Gets the normal input component
  55975. */
  55976. readonly normal: NodeMaterialConnectionPoint;
  55977. /**
  55978. * Gets the tangent input component
  55979. */
  55980. readonly tangent: NodeMaterialConnectionPoint;
  55981. /**
  55982. * Gets the tangent input component
  55983. */
  55984. readonly uv: NodeMaterialConnectionPoint;
  55985. /**
  55986. * Gets the position output component
  55987. */
  55988. readonly positionOutput: NodeMaterialConnectionPoint;
  55989. /**
  55990. * Gets the normal output component
  55991. */
  55992. readonly normalOutput: NodeMaterialConnectionPoint;
  55993. /**
  55994. * Gets the tangent output component
  55995. */
  55996. readonly tangentOutput: NodeMaterialConnectionPoint;
  55997. /**
  55998. * Gets the tangent output component
  55999. */
  56000. readonly uvOutput: NodeMaterialConnectionPoint;
  56001. initialize(state: NodeMaterialBuildState): void;
  56002. autoConfigure(material: NodeMaterial): void;
  56003. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56004. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56005. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56006. protected _buildBlock(state: NodeMaterialBuildState): this;
  56007. }
  56008. }
  56009. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56010. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56011. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56012. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56013. import { Nullable } from "babylonjs/types";
  56014. import { Scene } from "babylonjs/scene";
  56015. import { Effect } from "babylonjs/Materials/effect";
  56016. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56017. import { Mesh } from "babylonjs/Meshes/mesh";
  56018. import { Light } from "babylonjs/Lights/light";
  56019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56020. /**
  56021. * Block used to get data information from a light
  56022. */
  56023. export class LightInformationBlock extends NodeMaterialBlock {
  56024. private _lightDataUniformName;
  56025. private _lightColorUniformName;
  56026. private _lightTypeDefineName;
  56027. /**
  56028. * Gets or sets the light associated with this block
  56029. */
  56030. light: Nullable<Light>;
  56031. /**
  56032. * Creates a new LightInformationBlock
  56033. * @param name defines the block name
  56034. */
  56035. constructor(name: string);
  56036. /**
  56037. * Gets the current class name
  56038. * @returns the class name
  56039. */
  56040. getClassName(): string;
  56041. /**
  56042. * Gets the world position input component
  56043. */
  56044. readonly worldPosition: NodeMaterialConnectionPoint;
  56045. /**
  56046. * Gets the direction output component
  56047. */
  56048. readonly direction: NodeMaterialConnectionPoint;
  56049. /**
  56050. * Gets the direction output component
  56051. */
  56052. readonly color: NodeMaterialConnectionPoint;
  56053. /**
  56054. * Gets the direction output component
  56055. */
  56056. readonly intensity: NodeMaterialConnectionPoint;
  56057. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56058. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56059. protected _buildBlock(state: NodeMaterialBuildState): this;
  56060. serialize(): any;
  56061. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56062. }
  56063. }
  56064. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56065. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56066. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56067. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56068. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56069. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56070. }
  56071. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56072. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56073. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56074. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56076. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56077. import { Effect } from "babylonjs/Materials/effect";
  56078. import { Mesh } from "babylonjs/Meshes/mesh";
  56079. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56080. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56081. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56082. /**
  56083. * Block used to add image processing support to fragment shader
  56084. */
  56085. export class ImageProcessingBlock extends NodeMaterialBlock {
  56086. /**
  56087. * Create a new ImageProcessingBlock
  56088. * @param name defines the block name
  56089. */
  56090. constructor(name: string);
  56091. /**
  56092. * Gets the current class name
  56093. * @returns the class name
  56094. */
  56095. getClassName(): string;
  56096. /**
  56097. * Gets the color input component
  56098. */
  56099. readonly color: NodeMaterialConnectionPoint;
  56100. /**
  56101. * Gets the output component
  56102. */
  56103. readonly output: NodeMaterialConnectionPoint;
  56104. /**
  56105. * Initialize the block and prepare the context for build
  56106. * @param state defines the state that will be used for the build
  56107. */
  56108. initialize(state: NodeMaterialBuildState): void;
  56109. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56110. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56111. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56112. protected _buildBlock(state: NodeMaterialBuildState): this;
  56113. }
  56114. }
  56115. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56116. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56117. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56118. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56119. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56121. import { Effect } from "babylonjs/Materials/effect";
  56122. import { Mesh } from "babylonjs/Meshes/mesh";
  56123. import { Scene } from "babylonjs/scene";
  56124. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56125. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56126. /**
  56127. * Block used to pertub normals based on a normal map
  56128. */
  56129. export class PerturbNormalBlock extends NodeMaterialBlock {
  56130. private _tangentSpaceParameterName;
  56131. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56132. invertX: boolean;
  56133. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56134. invertY: boolean;
  56135. /**
  56136. * Create a new PerturbNormalBlock
  56137. * @param name defines the block name
  56138. */
  56139. constructor(name: string);
  56140. /**
  56141. * Gets the current class name
  56142. * @returns the class name
  56143. */
  56144. getClassName(): string;
  56145. /**
  56146. * Gets the world position input component
  56147. */
  56148. readonly worldPosition: NodeMaterialConnectionPoint;
  56149. /**
  56150. * Gets the world normal input component
  56151. */
  56152. readonly worldNormal: NodeMaterialConnectionPoint;
  56153. /**
  56154. * Gets the uv input component
  56155. */
  56156. readonly uv: NodeMaterialConnectionPoint;
  56157. /**
  56158. * Gets the normal map color input component
  56159. */
  56160. readonly normalMapColor: NodeMaterialConnectionPoint;
  56161. /**
  56162. * Gets the strength input component
  56163. */
  56164. readonly strength: NodeMaterialConnectionPoint;
  56165. /**
  56166. * Gets the output component
  56167. */
  56168. readonly output: NodeMaterialConnectionPoint;
  56169. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56170. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56171. autoConfigure(material: NodeMaterial): void;
  56172. protected _buildBlock(state: NodeMaterialBuildState): this;
  56173. protected _dumpPropertiesCode(): string;
  56174. serialize(): any;
  56175. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56176. }
  56177. }
  56178. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56179. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56180. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56181. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56182. /**
  56183. * Block used to discard a pixel if a value is smaller than a cutoff
  56184. */
  56185. export class DiscardBlock extends NodeMaterialBlock {
  56186. /**
  56187. * Create a new DiscardBlock
  56188. * @param name defines the block name
  56189. */
  56190. constructor(name: string);
  56191. /**
  56192. * Gets the current class name
  56193. * @returns the class name
  56194. */
  56195. getClassName(): string;
  56196. /**
  56197. * Gets the color input component
  56198. */
  56199. readonly value: NodeMaterialConnectionPoint;
  56200. /**
  56201. * Gets the cutoff input component
  56202. */
  56203. readonly cutoff: NodeMaterialConnectionPoint;
  56204. protected _buildBlock(state: NodeMaterialBuildState): this;
  56205. }
  56206. }
  56207. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56208. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56209. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56210. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56211. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56212. }
  56213. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56214. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56215. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56216. import { Mesh } from "babylonjs/Meshes/mesh";
  56217. import { Effect } from "babylonjs/Materials/effect";
  56218. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56220. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56221. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56222. /**
  56223. * Block used to add support for scene fog
  56224. */
  56225. export class FogBlock extends NodeMaterialBlock {
  56226. private _fogDistanceName;
  56227. private _fogParameters;
  56228. /**
  56229. * Create a new FogBlock
  56230. * @param name defines the block name
  56231. */
  56232. constructor(name: string);
  56233. /**
  56234. * Gets the current class name
  56235. * @returns the class name
  56236. */
  56237. getClassName(): string;
  56238. /**
  56239. * Gets the world position input component
  56240. */
  56241. readonly worldPosition: NodeMaterialConnectionPoint;
  56242. /**
  56243. * Gets the view input component
  56244. */
  56245. readonly view: NodeMaterialConnectionPoint;
  56246. /**
  56247. * Gets the color input component
  56248. */
  56249. readonly input: NodeMaterialConnectionPoint;
  56250. /**
  56251. * Gets the fog color input component
  56252. */
  56253. readonly fogColor: NodeMaterialConnectionPoint;
  56254. /**
  56255. * Gets the output component
  56256. */
  56257. readonly output: NodeMaterialConnectionPoint;
  56258. autoConfigure(material: NodeMaterial): void;
  56259. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56260. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56261. protected _buildBlock(state: NodeMaterialBuildState): this;
  56262. }
  56263. }
  56264. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56265. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56266. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56267. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56269. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56270. import { Effect } from "babylonjs/Materials/effect";
  56271. import { Mesh } from "babylonjs/Meshes/mesh";
  56272. import { Light } from "babylonjs/Lights/light";
  56273. import { Nullable } from "babylonjs/types";
  56274. import { Scene } from "babylonjs/scene";
  56275. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56276. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56277. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56278. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56279. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56280. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56281. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56282. /**
  56283. * Block used to add light in the fragment shader
  56284. */
  56285. export class LightBlock extends NodeMaterialBlock {
  56286. private _lightId;
  56287. /**
  56288. * Gets or sets the light associated with this block
  56289. */
  56290. light: Nullable<Light>;
  56291. /**
  56292. * Create a new LightBlock
  56293. * @param name defines the block name
  56294. */
  56295. constructor(name: string);
  56296. /**
  56297. * Gets the current class name
  56298. * @returns the class name
  56299. */
  56300. getClassName(): string;
  56301. /**
  56302. * Gets the world position input component
  56303. */
  56304. readonly worldPosition: NodeMaterialConnectionPoint;
  56305. /**
  56306. * Gets the world normal input component
  56307. */
  56308. readonly worldNormal: NodeMaterialConnectionPoint;
  56309. /**
  56310. * Gets the camera (or eye) position component
  56311. */
  56312. readonly cameraPosition: NodeMaterialConnectionPoint;
  56313. /**
  56314. * Gets the glossiness component
  56315. */
  56316. readonly glossiness: NodeMaterialConnectionPoint;
  56317. /**
  56318. * Gets the diffuse output component
  56319. */
  56320. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56321. /**
  56322. * Gets the specular output component
  56323. */
  56324. readonly specularOutput: NodeMaterialConnectionPoint;
  56325. autoConfigure(material: NodeMaterial): void;
  56326. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56327. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56328. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56329. private _injectVertexCode;
  56330. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56331. serialize(): any;
  56332. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56333. }
  56334. }
  56335. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56336. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56337. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56338. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56339. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56340. }
  56341. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56342. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56343. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56344. }
  56345. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56346. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56347. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56348. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56349. /**
  56350. * Block used to multiply 2 values
  56351. */
  56352. export class MultiplyBlock extends NodeMaterialBlock {
  56353. /**
  56354. * Creates a new MultiplyBlock
  56355. * @param name defines the block name
  56356. */
  56357. constructor(name: string);
  56358. /**
  56359. * Gets the current class name
  56360. * @returns the class name
  56361. */
  56362. getClassName(): string;
  56363. /**
  56364. * Gets the left operand input component
  56365. */
  56366. readonly left: NodeMaterialConnectionPoint;
  56367. /**
  56368. * Gets the right operand input component
  56369. */
  56370. readonly right: NodeMaterialConnectionPoint;
  56371. /**
  56372. * Gets the output component
  56373. */
  56374. readonly output: NodeMaterialConnectionPoint;
  56375. protected _buildBlock(state: NodeMaterialBuildState): this;
  56376. }
  56377. }
  56378. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56379. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56380. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56381. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56382. /**
  56383. * Block used to add 2 vectors
  56384. */
  56385. export class AddBlock extends NodeMaterialBlock {
  56386. /**
  56387. * Creates a new AddBlock
  56388. * @param name defines the block name
  56389. */
  56390. constructor(name: string);
  56391. /**
  56392. * Gets the current class name
  56393. * @returns the class name
  56394. */
  56395. getClassName(): string;
  56396. /**
  56397. * Gets the left operand input component
  56398. */
  56399. readonly left: NodeMaterialConnectionPoint;
  56400. /**
  56401. * Gets the right operand input component
  56402. */
  56403. readonly right: NodeMaterialConnectionPoint;
  56404. /**
  56405. * Gets the output component
  56406. */
  56407. readonly output: NodeMaterialConnectionPoint;
  56408. protected _buildBlock(state: NodeMaterialBuildState): this;
  56409. }
  56410. }
  56411. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  56412. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56413. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56414. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56415. /**
  56416. * Block used to scale a vector by a float
  56417. */
  56418. export class ScaleBlock extends NodeMaterialBlock {
  56419. /**
  56420. * Creates a new ScaleBlock
  56421. * @param name defines the block name
  56422. */
  56423. constructor(name: string);
  56424. /**
  56425. * Gets the current class name
  56426. * @returns the class name
  56427. */
  56428. getClassName(): string;
  56429. /**
  56430. * Gets the input component
  56431. */
  56432. readonly input: NodeMaterialConnectionPoint;
  56433. /**
  56434. * Gets the factor input component
  56435. */
  56436. readonly factor: NodeMaterialConnectionPoint;
  56437. /**
  56438. * Gets the output component
  56439. */
  56440. readonly output: NodeMaterialConnectionPoint;
  56441. protected _buildBlock(state: NodeMaterialBuildState): this;
  56442. }
  56443. }
  56444. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  56445. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56446. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56447. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56448. import { Scene } from "babylonjs/scene";
  56449. /**
  56450. * Block used to clamp a float
  56451. */
  56452. export class ClampBlock extends NodeMaterialBlock {
  56453. /** Gets or sets the minimum range */
  56454. minimum: number;
  56455. /** Gets or sets the maximum range */
  56456. maximum: number;
  56457. /**
  56458. * Creates a new ClampBlock
  56459. * @param name defines the block name
  56460. */
  56461. constructor(name: string);
  56462. /**
  56463. * Gets the current class name
  56464. * @returns the class name
  56465. */
  56466. getClassName(): string;
  56467. /**
  56468. * Gets the value input component
  56469. */
  56470. readonly value: NodeMaterialConnectionPoint;
  56471. /**
  56472. * Gets the output component
  56473. */
  56474. readonly output: NodeMaterialConnectionPoint;
  56475. protected _buildBlock(state: NodeMaterialBuildState): this;
  56476. protected _dumpPropertiesCode(): string;
  56477. serialize(): any;
  56478. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56479. }
  56480. }
  56481. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  56482. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56484. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56485. /**
  56486. * Block used to apply a cross product between 2 vectors
  56487. */
  56488. export class CrossBlock extends NodeMaterialBlock {
  56489. /**
  56490. * Creates a new CrossBlock
  56491. * @param name defines the block name
  56492. */
  56493. constructor(name: string);
  56494. /**
  56495. * Gets the current class name
  56496. * @returns the class name
  56497. */
  56498. getClassName(): string;
  56499. /**
  56500. * Gets the left operand input component
  56501. */
  56502. readonly left: NodeMaterialConnectionPoint;
  56503. /**
  56504. * Gets the right operand input component
  56505. */
  56506. readonly right: NodeMaterialConnectionPoint;
  56507. /**
  56508. * Gets the output component
  56509. */
  56510. readonly output: NodeMaterialConnectionPoint;
  56511. protected _buildBlock(state: NodeMaterialBuildState): this;
  56512. }
  56513. }
  56514. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  56515. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56516. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56517. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56518. /**
  56519. * Block used to apply a dot product between 2 vectors
  56520. */
  56521. export class DotBlock extends NodeMaterialBlock {
  56522. /**
  56523. * Creates a new DotBlock
  56524. * @param name defines the block name
  56525. */
  56526. constructor(name: string);
  56527. /**
  56528. * Gets the current class name
  56529. * @returns the class name
  56530. */
  56531. getClassName(): string;
  56532. /**
  56533. * Gets the left operand input component
  56534. */
  56535. readonly left: NodeMaterialConnectionPoint;
  56536. /**
  56537. * Gets the right operand input component
  56538. */
  56539. readonly right: NodeMaterialConnectionPoint;
  56540. /**
  56541. * Gets the output component
  56542. */
  56543. readonly output: NodeMaterialConnectionPoint;
  56544. protected _buildBlock(state: NodeMaterialBuildState): this;
  56545. }
  56546. }
  56547. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  56548. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56549. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56550. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56551. import { Vector2 } from "babylonjs/Maths/math.vector";
  56552. import { Scene } from "babylonjs/scene";
  56553. /**
  56554. * Block used to remap a float from a range to a new one
  56555. */
  56556. export class RemapBlock extends NodeMaterialBlock {
  56557. /**
  56558. * Gets or sets the source range
  56559. */
  56560. sourceRange: Vector2;
  56561. /**
  56562. * Gets or sets the target range
  56563. */
  56564. targetRange: Vector2;
  56565. /**
  56566. * Creates a new RemapBlock
  56567. * @param name defines the block name
  56568. */
  56569. constructor(name: string);
  56570. /**
  56571. * Gets the current class name
  56572. * @returns the class name
  56573. */
  56574. getClassName(): string;
  56575. /**
  56576. * Gets the input component
  56577. */
  56578. readonly input: NodeMaterialConnectionPoint;
  56579. /**
  56580. * Gets the source min input component
  56581. */
  56582. readonly sourceMin: NodeMaterialConnectionPoint;
  56583. /**
  56584. * Gets the source max input component
  56585. */
  56586. readonly sourceMax: NodeMaterialConnectionPoint;
  56587. /**
  56588. * Gets the target min input component
  56589. */
  56590. readonly targetMin: NodeMaterialConnectionPoint;
  56591. /**
  56592. * Gets the target max input component
  56593. */
  56594. readonly targetMax: NodeMaterialConnectionPoint;
  56595. /**
  56596. * Gets the output component
  56597. */
  56598. readonly output: NodeMaterialConnectionPoint;
  56599. protected _buildBlock(state: NodeMaterialBuildState): this;
  56600. protected _dumpPropertiesCode(): string;
  56601. serialize(): any;
  56602. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56603. }
  56604. }
  56605. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  56606. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56607. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56608. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56609. /**
  56610. * Block used to normalize a vector
  56611. */
  56612. export class NormalizeBlock extends NodeMaterialBlock {
  56613. /**
  56614. * Creates a new NormalizeBlock
  56615. * @param name defines the block name
  56616. */
  56617. constructor(name: string);
  56618. /**
  56619. * Gets the current class name
  56620. * @returns the class name
  56621. */
  56622. getClassName(): string;
  56623. /**
  56624. * Gets the input component
  56625. */
  56626. readonly input: NodeMaterialConnectionPoint;
  56627. /**
  56628. * Gets the output component
  56629. */
  56630. readonly output: NodeMaterialConnectionPoint;
  56631. protected _buildBlock(state: NodeMaterialBuildState): this;
  56632. }
  56633. }
  56634. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  56635. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56636. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56637. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56638. import { Scene } from "babylonjs/scene";
  56639. /**
  56640. * Operations supported by the Trigonometry block
  56641. */
  56642. export enum TrigonometryBlockOperations {
  56643. /** Cos */
  56644. Cos = 0,
  56645. /** Sin */
  56646. Sin = 1,
  56647. /** Abs */
  56648. Abs = 2,
  56649. /** Exp */
  56650. Exp = 3,
  56651. /** Exp2 */
  56652. Exp2 = 4,
  56653. /** Round */
  56654. Round = 5,
  56655. /** Floor */
  56656. Floor = 6,
  56657. /** Ceiling */
  56658. Ceiling = 7,
  56659. /** Square root */
  56660. Sqrt = 8
  56661. }
  56662. /**
  56663. * Block used to apply trigonometry operation to floats
  56664. */
  56665. export class TrigonometryBlock extends NodeMaterialBlock {
  56666. /**
  56667. * Gets or sets the operation applied by the block
  56668. */
  56669. operation: TrigonometryBlockOperations;
  56670. /**
  56671. * Creates a new TrigonometryBlock
  56672. * @param name defines the block name
  56673. */
  56674. constructor(name: string);
  56675. /**
  56676. * Gets the current class name
  56677. * @returns the class name
  56678. */
  56679. getClassName(): string;
  56680. /**
  56681. * Gets the input component
  56682. */
  56683. readonly input: NodeMaterialConnectionPoint;
  56684. /**
  56685. * Gets the output component
  56686. */
  56687. readonly output: NodeMaterialConnectionPoint;
  56688. protected _buildBlock(state: NodeMaterialBuildState): this;
  56689. serialize(): any;
  56690. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56691. }
  56692. }
  56693. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  56694. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56695. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56696. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56697. /**
  56698. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56699. */
  56700. export class ColorMergerBlock extends NodeMaterialBlock {
  56701. /**
  56702. * Create a new ColorMergerBlock
  56703. * @param name defines the block name
  56704. */
  56705. constructor(name: string);
  56706. /**
  56707. * Gets the current class name
  56708. * @returns the class name
  56709. */
  56710. getClassName(): string;
  56711. /**
  56712. * Gets the r component (input)
  56713. */
  56714. readonly r: NodeMaterialConnectionPoint;
  56715. /**
  56716. * Gets the g component (input)
  56717. */
  56718. readonly g: NodeMaterialConnectionPoint;
  56719. /**
  56720. * Gets the b component (input)
  56721. */
  56722. readonly b: NodeMaterialConnectionPoint;
  56723. /**
  56724. * Gets the a component (input)
  56725. */
  56726. readonly a: NodeMaterialConnectionPoint;
  56727. /**
  56728. * Gets the rgba component (output)
  56729. */
  56730. readonly rgba: NodeMaterialConnectionPoint;
  56731. /**
  56732. * Gets the rgb component (output)
  56733. */
  56734. readonly rgb: NodeMaterialConnectionPoint;
  56735. protected _buildBlock(state: NodeMaterialBuildState): this;
  56736. }
  56737. }
  56738. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  56739. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56740. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56741. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56742. /**
  56743. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56744. */
  56745. export class VectorMergerBlock extends NodeMaterialBlock {
  56746. /**
  56747. * Create a new VectorMergerBlock
  56748. * @param name defines the block name
  56749. */
  56750. constructor(name: string);
  56751. /**
  56752. * Gets the current class name
  56753. * @returns the class name
  56754. */
  56755. getClassName(): string;
  56756. /**
  56757. * Gets the x component (input)
  56758. */
  56759. readonly x: NodeMaterialConnectionPoint;
  56760. /**
  56761. * Gets the y component (input)
  56762. */
  56763. readonly y: NodeMaterialConnectionPoint;
  56764. /**
  56765. * Gets the z component (input)
  56766. */
  56767. readonly z: NodeMaterialConnectionPoint;
  56768. /**
  56769. * Gets the w component (input)
  56770. */
  56771. readonly w: NodeMaterialConnectionPoint;
  56772. /**
  56773. * Gets the xyzw component (output)
  56774. */
  56775. readonly xyzw: NodeMaterialConnectionPoint;
  56776. /**
  56777. * Gets the xyz component (output)
  56778. */
  56779. readonly xyz: NodeMaterialConnectionPoint;
  56780. /**
  56781. * Gets the xy component (output)
  56782. */
  56783. readonly xy: NodeMaterialConnectionPoint;
  56784. protected _buildBlock(state: NodeMaterialBuildState): this;
  56785. }
  56786. }
  56787. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  56788. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56789. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56790. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56791. /**
  56792. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56793. */
  56794. export class ColorSplitterBlock extends NodeMaterialBlock {
  56795. /**
  56796. * Create a new ColorSplitterBlock
  56797. * @param name defines the block name
  56798. */
  56799. constructor(name: string);
  56800. /**
  56801. * Gets the current class name
  56802. * @returns the class name
  56803. */
  56804. getClassName(): string;
  56805. /**
  56806. * Gets the rgba component (input)
  56807. */
  56808. readonly rgba: NodeMaterialConnectionPoint;
  56809. /**
  56810. * Gets the rgb component (input)
  56811. */
  56812. readonly rgbIn: NodeMaterialConnectionPoint;
  56813. /**
  56814. * Gets the rgb component (output)
  56815. */
  56816. readonly rgbOut: NodeMaterialConnectionPoint;
  56817. /**
  56818. * Gets the r component (output)
  56819. */
  56820. readonly r: NodeMaterialConnectionPoint;
  56821. /**
  56822. * Gets the g component (output)
  56823. */
  56824. readonly g: NodeMaterialConnectionPoint;
  56825. /**
  56826. * Gets the b component (output)
  56827. */
  56828. readonly b: NodeMaterialConnectionPoint;
  56829. /**
  56830. * Gets the a component (output)
  56831. */
  56832. readonly a: NodeMaterialConnectionPoint;
  56833. protected _inputRename(name: string): string;
  56834. protected _outputRename(name: string): string;
  56835. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56836. }
  56837. }
  56838. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  56839. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56840. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56841. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56842. /**
  56843. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56844. */
  56845. export class VectorSplitterBlock extends NodeMaterialBlock {
  56846. /**
  56847. * Create a new VectorSplitterBlock
  56848. * @param name defines the block name
  56849. */
  56850. constructor(name: string);
  56851. /**
  56852. * Gets the current class name
  56853. * @returns the class name
  56854. */
  56855. getClassName(): string;
  56856. /**
  56857. * Gets the xyzw component (input)
  56858. */
  56859. readonly xyzw: NodeMaterialConnectionPoint;
  56860. /**
  56861. * Gets the xyz component (input)
  56862. */
  56863. readonly xyzIn: NodeMaterialConnectionPoint;
  56864. /**
  56865. * Gets the xy component (input)
  56866. */
  56867. readonly xyIn: NodeMaterialConnectionPoint;
  56868. /**
  56869. * Gets the xyz component (output)
  56870. */
  56871. readonly xyzOut: NodeMaterialConnectionPoint;
  56872. /**
  56873. * Gets the xy component (output)
  56874. */
  56875. readonly xyOut: NodeMaterialConnectionPoint;
  56876. /**
  56877. * Gets the x component (output)
  56878. */
  56879. readonly x: NodeMaterialConnectionPoint;
  56880. /**
  56881. * Gets the y component (output)
  56882. */
  56883. readonly y: NodeMaterialConnectionPoint;
  56884. /**
  56885. * Gets the z component (output)
  56886. */
  56887. readonly z: NodeMaterialConnectionPoint;
  56888. /**
  56889. * Gets the w component (output)
  56890. */
  56891. readonly w: NodeMaterialConnectionPoint;
  56892. protected _inputRename(name: string): string;
  56893. protected _outputRename(name: string): string;
  56894. protected _buildBlock(state: NodeMaterialBuildState): this;
  56895. }
  56896. }
  56897. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  56898. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56899. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56900. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56901. /**
  56902. * Block used to lerp 2 values
  56903. */
  56904. export class LerpBlock extends NodeMaterialBlock {
  56905. /**
  56906. * Creates a new LerpBlock
  56907. * @param name defines the block name
  56908. */
  56909. constructor(name: string);
  56910. /**
  56911. * Gets the current class name
  56912. * @returns the class name
  56913. */
  56914. getClassName(): string;
  56915. /**
  56916. * Gets the left operand input component
  56917. */
  56918. readonly left: NodeMaterialConnectionPoint;
  56919. /**
  56920. * Gets the right operand input component
  56921. */
  56922. readonly right: NodeMaterialConnectionPoint;
  56923. /**
  56924. * Gets the gradient operand input component
  56925. */
  56926. readonly gradient: NodeMaterialConnectionPoint;
  56927. /**
  56928. * Gets the output component
  56929. */
  56930. readonly output: NodeMaterialConnectionPoint;
  56931. protected _buildBlock(state: NodeMaterialBuildState): this;
  56932. }
  56933. }
  56934. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  56935. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56936. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56937. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56938. /**
  56939. * Block used to divide 2 vectors
  56940. */
  56941. export class DivideBlock extends NodeMaterialBlock {
  56942. /**
  56943. * Creates a new DivideBlock
  56944. * @param name defines the block name
  56945. */
  56946. constructor(name: string);
  56947. /**
  56948. * Gets the current class name
  56949. * @returns the class name
  56950. */
  56951. getClassName(): string;
  56952. /**
  56953. * Gets the left operand input component
  56954. */
  56955. readonly left: NodeMaterialConnectionPoint;
  56956. /**
  56957. * Gets the right operand input component
  56958. */
  56959. readonly right: NodeMaterialConnectionPoint;
  56960. /**
  56961. * Gets the output component
  56962. */
  56963. readonly output: NodeMaterialConnectionPoint;
  56964. protected _buildBlock(state: NodeMaterialBuildState): this;
  56965. }
  56966. }
  56967. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  56968. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56969. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56970. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56971. /**
  56972. * Block used to subtract 2 vectors
  56973. */
  56974. export class SubtractBlock extends NodeMaterialBlock {
  56975. /**
  56976. * Creates a new SubtractBlock
  56977. * @param name defines the block name
  56978. */
  56979. constructor(name: string);
  56980. /**
  56981. * Gets the current class name
  56982. * @returns the class name
  56983. */
  56984. getClassName(): string;
  56985. /**
  56986. * Gets the left operand input component
  56987. */
  56988. readonly left: NodeMaterialConnectionPoint;
  56989. /**
  56990. * Gets the right operand input component
  56991. */
  56992. readonly right: NodeMaterialConnectionPoint;
  56993. /**
  56994. * Gets the output component
  56995. */
  56996. readonly output: NodeMaterialConnectionPoint;
  56997. protected _buildBlock(state: NodeMaterialBuildState): this;
  56998. }
  56999. }
  57000. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57002. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57003. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57004. /**
  57005. * Block used to step a value
  57006. */
  57007. export class StepBlock extends NodeMaterialBlock {
  57008. /**
  57009. * Creates a new AddBlock
  57010. * @param name defines the block name
  57011. */
  57012. constructor(name: string);
  57013. /**
  57014. * Gets the current class name
  57015. * @returns the class name
  57016. */
  57017. getClassName(): string;
  57018. /**
  57019. * Gets the value operand input component
  57020. */
  57021. readonly value: NodeMaterialConnectionPoint;
  57022. /**
  57023. * Gets the edge operand input component
  57024. */
  57025. readonly edge: NodeMaterialConnectionPoint;
  57026. /**
  57027. * Gets the output component
  57028. */
  57029. readonly output: NodeMaterialConnectionPoint;
  57030. protected _buildBlock(state: NodeMaterialBuildState): this;
  57031. }
  57032. }
  57033. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57034. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57035. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57036. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57037. /**
  57038. * Block used to get the opposite (1 - x) of a value
  57039. */
  57040. export class OneMinusBlock extends NodeMaterialBlock {
  57041. /**
  57042. * Creates a new OneMinusBlock
  57043. * @param name defines the block name
  57044. */
  57045. constructor(name: string);
  57046. /**
  57047. * Gets the current class name
  57048. * @returns the class name
  57049. */
  57050. getClassName(): string;
  57051. /**
  57052. * Gets the input component
  57053. */
  57054. readonly input: NodeMaterialConnectionPoint;
  57055. /**
  57056. * Gets the output component
  57057. */
  57058. readonly output: NodeMaterialConnectionPoint;
  57059. protected _buildBlock(state: NodeMaterialBuildState): this;
  57060. }
  57061. }
  57062. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57063. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57064. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57065. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57066. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57067. /**
  57068. * Block used to get the view direction
  57069. */
  57070. export class ViewDirectionBlock extends NodeMaterialBlock {
  57071. /**
  57072. * Creates a new ViewDirectionBlock
  57073. * @param name defines the block name
  57074. */
  57075. constructor(name: string);
  57076. /**
  57077. * Gets the current class name
  57078. * @returns the class name
  57079. */
  57080. getClassName(): string;
  57081. /**
  57082. * Gets the world position component
  57083. */
  57084. readonly worldPosition: NodeMaterialConnectionPoint;
  57085. /**
  57086. * Gets the camera position component
  57087. */
  57088. readonly cameraPosition: NodeMaterialConnectionPoint;
  57089. /**
  57090. * Gets the output component
  57091. */
  57092. readonly output: NodeMaterialConnectionPoint;
  57093. autoConfigure(material: NodeMaterial): void;
  57094. protected _buildBlock(state: NodeMaterialBuildState): this;
  57095. }
  57096. }
  57097. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57098. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57099. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57100. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57101. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57102. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57103. /**
  57104. * Block used to compute fresnel value
  57105. */
  57106. export class FresnelBlock extends NodeMaterialBlock {
  57107. /**
  57108. * Create a new FresnelBlock
  57109. * @param name defines the block name
  57110. */
  57111. constructor(name: string);
  57112. /**
  57113. * Gets the current class name
  57114. * @returns the class name
  57115. */
  57116. getClassName(): string;
  57117. /**
  57118. * Gets the world normal input component
  57119. */
  57120. readonly worldNormal: NodeMaterialConnectionPoint;
  57121. /**
  57122. * Gets the view direction input component
  57123. */
  57124. readonly viewDirection: NodeMaterialConnectionPoint;
  57125. /**
  57126. * Gets the bias input component
  57127. */
  57128. readonly bias: NodeMaterialConnectionPoint;
  57129. /**
  57130. * Gets the camera (or eye) position component
  57131. */
  57132. readonly power: NodeMaterialConnectionPoint;
  57133. /**
  57134. * Gets the fresnel output component
  57135. */
  57136. readonly fresnel: NodeMaterialConnectionPoint;
  57137. autoConfigure(material: NodeMaterial): void;
  57138. protected _buildBlock(state: NodeMaterialBuildState): this;
  57139. }
  57140. }
  57141. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57142. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57143. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57144. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57145. /**
  57146. * Block used to get the max of 2 values
  57147. */
  57148. export class MaxBlock extends NodeMaterialBlock {
  57149. /**
  57150. * Creates a new MaxBlock
  57151. * @param name defines the block name
  57152. */
  57153. constructor(name: string);
  57154. /**
  57155. * Gets the current class name
  57156. * @returns the class name
  57157. */
  57158. getClassName(): string;
  57159. /**
  57160. * Gets the left operand input component
  57161. */
  57162. readonly left: NodeMaterialConnectionPoint;
  57163. /**
  57164. * Gets the right operand input component
  57165. */
  57166. readonly right: NodeMaterialConnectionPoint;
  57167. /**
  57168. * Gets the output component
  57169. */
  57170. readonly output: NodeMaterialConnectionPoint;
  57171. protected _buildBlock(state: NodeMaterialBuildState): this;
  57172. }
  57173. }
  57174. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57175. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57176. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57177. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57178. /**
  57179. * Block used to get the min of 2 values
  57180. */
  57181. export class MinBlock extends NodeMaterialBlock {
  57182. /**
  57183. * Creates a new MinBlock
  57184. * @param name defines the block name
  57185. */
  57186. constructor(name: string);
  57187. /**
  57188. * Gets the current class name
  57189. * @returns the class name
  57190. */
  57191. getClassName(): string;
  57192. /**
  57193. * Gets the left operand input component
  57194. */
  57195. readonly left: NodeMaterialConnectionPoint;
  57196. /**
  57197. * Gets the right operand input component
  57198. */
  57199. readonly right: NodeMaterialConnectionPoint;
  57200. /**
  57201. * Gets the output component
  57202. */
  57203. readonly output: NodeMaterialConnectionPoint;
  57204. protected _buildBlock(state: NodeMaterialBuildState): this;
  57205. }
  57206. }
  57207. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57208. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57209. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57210. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57211. /**
  57212. * Block used to get the distance between 2 values
  57213. */
  57214. export class DistanceBlock extends NodeMaterialBlock {
  57215. /**
  57216. * Creates a new DistanceBlock
  57217. * @param name defines the block name
  57218. */
  57219. constructor(name: string);
  57220. /**
  57221. * Gets the current class name
  57222. * @returns the class name
  57223. */
  57224. getClassName(): string;
  57225. /**
  57226. * Gets the left operand input component
  57227. */
  57228. readonly left: NodeMaterialConnectionPoint;
  57229. /**
  57230. * Gets the right operand input component
  57231. */
  57232. readonly right: NodeMaterialConnectionPoint;
  57233. /**
  57234. * Gets the output component
  57235. */
  57236. readonly output: NodeMaterialConnectionPoint;
  57237. protected _buildBlock(state: NodeMaterialBuildState): this;
  57238. }
  57239. }
  57240. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57241. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57242. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57243. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57244. /**
  57245. * Block used to get the length of a vector
  57246. */
  57247. export class LengthBlock extends NodeMaterialBlock {
  57248. /**
  57249. * Creates a new LengthBlock
  57250. * @param name defines the block name
  57251. */
  57252. constructor(name: string);
  57253. /**
  57254. * Gets the current class name
  57255. * @returns the class name
  57256. */
  57257. getClassName(): string;
  57258. /**
  57259. * Gets the value input component
  57260. */
  57261. readonly value: NodeMaterialConnectionPoint;
  57262. /**
  57263. * Gets the output component
  57264. */
  57265. readonly output: NodeMaterialConnectionPoint;
  57266. protected _buildBlock(state: NodeMaterialBuildState): this;
  57267. }
  57268. }
  57269. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57270. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57271. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57272. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57273. /**
  57274. * Block used to get negative version of a value (i.e. x * -1)
  57275. */
  57276. export class NegateBlock extends NodeMaterialBlock {
  57277. /**
  57278. * Creates a new NegateBlock
  57279. * @param name defines the block name
  57280. */
  57281. constructor(name: string);
  57282. /**
  57283. * Gets the current class name
  57284. * @returns the class name
  57285. */
  57286. getClassName(): string;
  57287. /**
  57288. * Gets the value input component
  57289. */
  57290. readonly value: NodeMaterialConnectionPoint;
  57291. /**
  57292. * Gets the output component
  57293. */
  57294. readonly output: NodeMaterialConnectionPoint;
  57295. protected _buildBlock(state: NodeMaterialBuildState): this;
  57296. }
  57297. }
  57298. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57299. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57300. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57301. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57302. /**
  57303. * Block used to get the value of the first parameter raised to the power of the second
  57304. */
  57305. export class PowBlock extends NodeMaterialBlock {
  57306. /**
  57307. * Creates a new PowBlock
  57308. * @param name defines the block name
  57309. */
  57310. constructor(name: string);
  57311. /**
  57312. * Gets the current class name
  57313. * @returns the class name
  57314. */
  57315. getClassName(): string;
  57316. /**
  57317. * Gets the value operand input component
  57318. */
  57319. readonly value: NodeMaterialConnectionPoint;
  57320. /**
  57321. * Gets the power operand input component
  57322. */
  57323. readonly power: NodeMaterialConnectionPoint;
  57324. /**
  57325. * Gets the output component
  57326. */
  57327. readonly output: NodeMaterialConnectionPoint;
  57328. protected _buildBlock(state: NodeMaterialBuildState): this;
  57329. }
  57330. }
  57331. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  57332. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57333. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57334. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57335. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57336. /**
  57337. * Block used to get a random number
  57338. */
  57339. export class RandomNumberBlock extends NodeMaterialBlock {
  57340. /**
  57341. * Creates a new RandomNumberBlock
  57342. * @param name defines the block name
  57343. */
  57344. constructor(name: string);
  57345. /**
  57346. * Gets the current class name
  57347. * @returns the class name
  57348. */
  57349. getClassName(): string;
  57350. /**
  57351. * Gets the seed input component
  57352. */
  57353. readonly seed: NodeMaterialConnectionPoint;
  57354. /**
  57355. * Gets the output component
  57356. */
  57357. readonly output: NodeMaterialConnectionPoint;
  57358. protected _buildBlock(state: NodeMaterialBuildState): this;
  57359. }
  57360. }
  57361. declare module "babylonjs/Materials/Node/Blocks/index" {
  57362. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  57363. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  57364. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  57365. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  57366. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  57367. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  57368. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  57369. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  57370. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  57371. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  57372. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  57373. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  57374. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  57375. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  57376. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  57377. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  57378. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  57379. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  57380. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  57381. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  57382. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  57383. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  57384. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  57385. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  57386. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  57387. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  57388. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  57389. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  57390. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  57391. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  57392. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  57393. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  57394. }
  57395. declare module "babylonjs/Materials/Node/Optimizers/index" {
  57396. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57397. }
  57398. declare module "babylonjs/Materials/Node/index" {
  57399. export * from "babylonjs/Materials/Node/Enums/index";
  57400. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57401. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  57402. export * from "babylonjs/Materials/Node/nodeMaterial";
  57403. export * from "babylonjs/Materials/Node/Blocks/index";
  57404. export * from "babylonjs/Materials/Node/Optimizers/index";
  57405. }
  57406. declare module "babylonjs/Materials/effectRenderer" {
  57407. import { Nullable } from "babylonjs/types";
  57408. import { Texture } from "babylonjs/Materials/Textures/texture";
  57409. import { Engine } from "babylonjs/Engines/engine";
  57410. import { Viewport } from "babylonjs/Maths/math.viewport";
  57411. import { Observable } from "babylonjs/Misc/observable";
  57412. import { Effect } from "babylonjs/Materials/effect";
  57413. import "babylonjs/Shaders/postprocess.vertex";
  57414. /**
  57415. * Effect Render Options
  57416. */
  57417. export interface IEffectRendererOptions {
  57418. /**
  57419. * Defines the vertices positions.
  57420. */
  57421. positions?: number[];
  57422. /**
  57423. * Defines the indices.
  57424. */
  57425. indices?: number[];
  57426. }
  57427. /**
  57428. * Helper class to render one or more effects
  57429. */
  57430. export class EffectRenderer {
  57431. private engine;
  57432. private static _DefaultOptions;
  57433. private _vertexBuffers;
  57434. private _indexBuffer;
  57435. private _ringBufferIndex;
  57436. private _ringScreenBuffer;
  57437. private _fullscreenViewport;
  57438. private _getNextFrameBuffer;
  57439. /**
  57440. * Creates an effect renderer
  57441. * @param engine the engine to use for rendering
  57442. * @param options defines the options of the effect renderer
  57443. */
  57444. constructor(engine: Engine, options?: IEffectRendererOptions);
  57445. /**
  57446. * Sets the current viewport in normalized coordinates 0-1
  57447. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57448. */
  57449. setViewport(viewport?: Viewport): void;
  57450. /**
  57451. * Binds the embedded attributes buffer to the effect.
  57452. * @param effect Defines the effect to bind the attributes for
  57453. */
  57454. bindBuffers(effect: Effect): void;
  57455. /**
  57456. * Sets the current effect wrapper to use during draw.
  57457. * The effect needs to be ready before calling this api.
  57458. * This also sets the default full screen position attribute.
  57459. * @param effectWrapper Defines the effect to draw with
  57460. */
  57461. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57462. /**
  57463. * Draws a full screen quad.
  57464. */
  57465. draw(): void;
  57466. /**
  57467. * renders one or more effects to a specified texture
  57468. * @param effectWrappers list of effects to renderer
  57469. * @param outputTexture texture to draw to, if null it will render to the screen
  57470. */
  57471. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57472. /**
  57473. * Disposes of the effect renderer
  57474. */
  57475. dispose(): void;
  57476. }
  57477. /**
  57478. * Options to create an EffectWrapper
  57479. */
  57480. interface EffectWrapperCreationOptions {
  57481. /**
  57482. * Engine to use to create the effect
  57483. */
  57484. engine: Engine;
  57485. /**
  57486. * Fragment shader for the effect
  57487. */
  57488. fragmentShader: string;
  57489. /**
  57490. * Vertex shader for the effect
  57491. */
  57492. vertexShader?: string;
  57493. /**
  57494. * Attributes to use in the shader
  57495. */
  57496. attributeNames?: Array<string>;
  57497. /**
  57498. * Uniforms to use in the shader
  57499. */
  57500. uniformNames?: Array<string>;
  57501. /**
  57502. * Texture sampler names to use in the shader
  57503. */
  57504. samplerNames?: Array<string>;
  57505. /**
  57506. * The friendly name of the effect displayed in Spector.
  57507. */
  57508. name?: string;
  57509. }
  57510. /**
  57511. * Wraps an effect to be used for rendering
  57512. */
  57513. export class EffectWrapper {
  57514. /**
  57515. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  57516. */
  57517. onApplyObservable: Observable<{}>;
  57518. /**
  57519. * The underlying effect
  57520. */
  57521. effect: Effect;
  57522. /**
  57523. * Creates an effect to be renderer
  57524. * @param creationOptions options to create the effect
  57525. */
  57526. constructor(creationOptions: EffectWrapperCreationOptions);
  57527. /**
  57528. * Disposes of the effect wrapper
  57529. */
  57530. dispose(): void;
  57531. }
  57532. }
  57533. declare module "babylonjs/Materials/index" {
  57534. export * from "babylonjs/Materials/Background/index";
  57535. export * from "babylonjs/Materials/colorCurves";
  57536. export * from "babylonjs/Materials/effect";
  57537. export * from "babylonjs/Materials/fresnelParameters";
  57538. export * from "babylonjs/Materials/imageProcessingConfiguration";
  57539. export * from "babylonjs/Materials/material";
  57540. export * from "babylonjs/Materials/materialDefines";
  57541. export * from "babylonjs/Materials/materialHelper";
  57542. export * from "babylonjs/Materials/multiMaterial";
  57543. export * from "babylonjs/Materials/PBR/index";
  57544. export * from "babylonjs/Materials/pushMaterial";
  57545. export * from "babylonjs/Materials/shaderMaterial";
  57546. export * from "babylonjs/Materials/standardMaterial";
  57547. export * from "babylonjs/Materials/Textures/index";
  57548. export * from "babylonjs/Materials/uniformBuffer";
  57549. export * from "babylonjs/Materials/materialFlags";
  57550. export * from "babylonjs/Materials/Node/index";
  57551. export * from "babylonjs/Materials/effectRenderer";
  57552. }
  57553. declare module "babylonjs/Maths/index" {
  57554. export * from "babylonjs/Maths/math.scalar";
  57555. export * from "babylonjs/Maths/math";
  57556. export * from "babylonjs/Maths/sphericalPolynomial";
  57557. }
  57558. declare module "babylonjs/Misc/workerPool" {
  57559. import { IDisposable } from "babylonjs/scene";
  57560. /**
  57561. * Helper class to push actions to a pool of workers.
  57562. */
  57563. export class WorkerPool implements IDisposable {
  57564. private _workerInfos;
  57565. private _pendingActions;
  57566. /**
  57567. * Constructor
  57568. * @param workers Array of workers to use for actions
  57569. */
  57570. constructor(workers: Array<Worker>);
  57571. /**
  57572. * Terminates all workers and clears any pending actions.
  57573. */
  57574. dispose(): void;
  57575. /**
  57576. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57577. * pended until a worker has completed its action.
  57578. * @param action The action to perform. Call onComplete when the action is complete.
  57579. */
  57580. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57581. private _execute;
  57582. }
  57583. }
  57584. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  57585. import { IDisposable } from "babylonjs/scene";
  57586. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57587. /**
  57588. * Configuration for Draco compression
  57589. */
  57590. export interface IDracoCompressionConfiguration {
  57591. /**
  57592. * Configuration for the decoder.
  57593. */
  57594. decoder: {
  57595. /**
  57596. * The url to the WebAssembly module.
  57597. */
  57598. wasmUrl?: string;
  57599. /**
  57600. * The url to the WebAssembly binary.
  57601. */
  57602. wasmBinaryUrl?: string;
  57603. /**
  57604. * The url to the fallback JavaScript module.
  57605. */
  57606. fallbackUrl?: string;
  57607. };
  57608. }
  57609. /**
  57610. * Draco compression (https://google.github.io/draco/)
  57611. *
  57612. * This class wraps the Draco module.
  57613. *
  57614. * **Encoder**
  57615. *
  57616. * The encoder is not currently implemented.
  57617. *
  57618. * **Decoder**
  57619. *
  57620. * 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.
  57621. *
  57622. * To update the configuration, use the following code:
  57623. * ```javascript
  57624. * DracoCompression.Configuration = {
  57625. * decoder: {
  57626. * wasmUrl: "<url to the WebAssembly library>",
  57627. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  57628. * fallbackUrl: "<url to the fallback JavaScript library>",
  57629. * }
  57630. * };
  57631. * ```
  57632. *
  57633. * 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.
  57634. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  57635. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  57636. *
  57637. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  57638. * ```javascript
  57639. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  57640. * ```
  57641. *
  57642. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  57643. */
  57644. export class DracoCompression implements IDisposable {
  57645. private _workerPoolPromise?;
  57646. private _decoderModulePromise?;
  57647. /**
  57648. * The configuration. Defaults to the following urls:
  57649. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  57650. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  57651. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  57652. */
  57653. static Configuration: IDracoCompressionConfiguration;
  57654. /**
  57655. * Returns true if the decoder configuration is available.
  57656. */
  57657. static readonly DecoderAvailable: boolean;
  57658. /**
  57659. * Default number of workers to create when creating the draco compression object.
  57660. */
  57661. static DefaultNumWorkers: number;
  57662. private static GetDefaultNumWorkers;
  57663. private static _Default;
  57664. /**
  57665. * Default instance for the draco compression object.
  57666. */
  57667. static readonly Default: DracoCompression;
  57668. /**
  57669. * Constructor
  57670. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57671. */
  57672. constructor(numWorkers?: number);
  57673. /**
  57674. * Stop all async operations and release resources.
  57675. */
  57676. dispose(): void;
  57677. /**
  57678. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  57679. * @returns a promise that resolves when ready
  57680. */
  57681. whenReadyAsync(): Promise<void>;
  57682. /**
  57683. * Decode Draco compressed mesh data to vertex data.
  57684. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  57685. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  57686. * @returns A promise that resolves with the decoded vertex data
  57687. */
  57688. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  57689. [kind: string]: number;
  57690. }): Promise<VertexData>;
  57691. }
  57692. }
  57693. declare module "babylonjs/Meshes/Compression/index" {
  57694. export * from "babylonjs/Meshes/Compression/dracoCompression";
  57695. }
  57696. declare module "babylonjs/Meshes/csg" {
  57697. import { Nullable } from "babylonjs/types";
  57698. import { Scene } from "babylonjs/scene";
  57699. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57700. import { Mesh } from "babylonjs/Meshes/mesh";
  57701. import { Material } from "babylonjs/Materials/material";
  57702. /**
  57703. * Class for building Constructive Solid Geometry
  57704. */
  57705. export class CSG {
  57706. private polygons;
  57707. /**
  57708. * The world matrix
  57709. */
  57710. matrix: Matrix;
  57711. /**
  57712. * Stores the position
  57713. */
  57714. position: Vector3;
  57715. /**
  57716. * Stores the rotation
  57717. */
  57718. rotation: Vector3;
  57719. /**
  57720. * Stores the rotation quaternion
  57721. */
  57722. rotationQuaternion: Nullable<Quaternion>;
  57723. /**
  57724. * Stores the scaling vector
  57725. */
  57726. scaling: Vector3;
  57727. /**
  57728. * Convert the Mesh to CSG
  57729. * @param mesh The Mesh to convert to CSG
  57730. * @returns A new CSG from the Mesh
  57731. */
  57732. static FromMesh(mesh: Mesh): CSG;
  57733. /**
  57734. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  57735. * @param polygons Polygons used to construct a CSG solid
  57736. */
  57737. private static FromPolygons;
  57738. /**
  57739. * Clones, or makes a deep copy, of the CSG
  57740. * @returns A new CSG
  57741. */
  57742. clone(): CSG;
  57743. /**
  57744. * Unions this CSG with another CSG
  57745. * @param csg The CSG to union against this CSG
  57746. * @returns The unioned CSG
  57747. */
  57748. union(csg: CSG): CSG;
  57749. /**
  57750. * Unions this CSG with another CSG in place
  57751. * @param csg The CSG to union against this CSG
  57752. */
  57753. unionInPlace(csg: CSG): void;
  57754. /**
  57755. * Subtracts this CSG with another CSG
  57756. * @param csg The CSG to subtract against this CSG
  57757. * @returns A new CSG
  57758. */
  57759. subtract(csg: CSG): CSG;
  57760. /**
  57761. * Subtracts this CSG with another CSG in place
  57762. * @param csg The CSG to subtact against this CSG
  57763. */
  57764. subtractInPlace(csg: CSG): void;
  57765. /**
  57766. * Intersect this CSG with another CSG
  57767. * @param csg The CSG to intersect against this CSG
  57768. * @returns A new CSG
  57769. */
  57770. intersect(csg: CSG): CSG;
  57771. /**
  57772. * Intersects this CSG with another CSG in place
  57773. * @param csg The CSG to intersect against this CSG
  57774. */
  57775. intersectInPlace(csg: CSG): void;
  57776. /**
  57777. * Return a new CSG solid with solid and empty space switched. This solid is
  57778. * not modified.
  57779. * @returns A new CSG solid with solid and empty space switched
  57780. */
  57781. inverse(): CSG;
  57782. /**
  57783. * Inverses the CSG in place
  57784. */
  57785. inverseInPlace(): void;
  57786. /**
  57787. * This is used to keep meshes transformations so they can be restored
  57788. * when we build back a Babylon Mesh
  57789. * NB : All CSG operations are performed in world coordinates
  57790. * @param csg The CSG to copy the transform attributes from
  57791. * @returns This CSG
  57792. */
  57793. copyTransformAttributes(csg: CSG): CSG;
  57794. /**
  57795. * Build Raw mesh from CSG
  57796. * Coordinates here are in world space
  57797. * @param name The name of the mesh geometry
  57798. * @param scene The Scene
  57799. * @param keepSubMeshes Specifies if the submeshes should be kept
  57800. * @returns A new Mesh
  57801. */
  57802. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57803. /**
  57804. * Build Mesh from CSG taking material and transforms into account
  57805. * @param name The name of the Mesh
  57806. * @param material The material of the Mesh
  57807. * @param scene The Scene
  57808. * @param keepSubMeshes Specifies if submeshes should be kept
  57809. * @returns The new Mesh
  57810. */
  57811. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57812. }
  57813. }
  57814. declare module "babylonjs/Meshes/trailMesh" {
  57815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57816. import { Mesh } from "babylonjs/Meshes/mesh";
  57817. import { Scene } from "babylonjs/scene";
  57818. /**
  57819. * Class used to create a trail following a mesh
  57820. */
  57821. export class TrailMesh extends Mesh {
  57822. private _generator;
  57823. private _autoStart;
  57824. private _running;
  57825. private _diameter;
  57826. private _length;
  57827. private _sectionPolygonPointsCount;
  57828. private _sectionVectors;
  57829. private _sectionNormalVectors;
  57830. private _beforeRenderObserver;
  57831. /**
  57832. * @constructor
  57833. * @param name The value used by scene.getMeshByName() to do a lookup.
  57834. * @param generator The mesh to generate a trail.
  57835. * @param scene The scene to add this mesh to.
  57836. * @param diameter Diameter of trailing mesh. Default is 1.
  57837. * @param length Length of trailing mesh. Default is 60.
  57838. * @param autoStart Automatically start trailing mesh. Default true.
  57839. */
  57840. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  57841. /**
  57842. * "TrailMesh"
  57843. * @returns "TrailMesh"
  57844. */
  57845. getClassName(): string;
  57846. private _createMesh;
  57847. /**
  57848. * Start trailing mesh.
  57849. */
  57850. start(): void;
  57851. /**
  57852. * Stop trailing mesh.
  57853. */
  57854. stop(): void;
  57855. /**
  57856. * Update trailing mesh geometry.
  57857. */
  57858. update(): void;
  57859. /**
  57860. * Returns a new TrailMesh object.
  57861. * @param name is a string, the name given to the new mesh
  57862. * @param newGenerator use new generator object for cloned trail mesh
  57863. * @returns a new mesh
  57864. */
  57865. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  57866. /**
  57867. * Serializes this trail mesh
  57868. * @param serializationObject object to write serialization to
  57869. */
  57870. serialize(serializationObject: any): void;
  57871. /**
  57872. * Parses a serialized trail mesh
  57873. * @param parsedMesh the serialized mesh
  57874. * @param scene the scene to create the trail mesh in
  57875. * @returns the created trail mesh
  57876. */
  57877. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  57878. }
  57879. }
  57880. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  57881. import { Nullable } from "babylonjs/types";
  57882. import { Scene } from "babylonjs/scene";
  57883. import { Vector4 } from "babylonjs/Maths/math.vector";
  57884. import { Color4 } from "babylonjs/Maths/math.color";
  57885. import { Mesh } from "babylonjs/Meshes/mesh";
  57886. /**
  57887. * Class containing static functions to help procedurally build meshes
  57888. */
  57889. export class TiledBoxBuilder {
  57890. /**
  57891. * Creates a box mesh
  57892. * 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)
  57893. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57894. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57895. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57897. * @param name defines the name of the mesh
  57898. * @param options defines the options used to create the mesh
  57899. * @param scene defines the hosting scene
  57900. * @returns the box mesh
  57901. */
  57902. static CreateTiledBox(name: string, options: {
  57903. pattern?: number;
  57904. width?: number;
  57905. height?: number;
  57906. depth?: number;
  57907. tileSize?: number;
  57908. tileWidth?: number;
  57909. tileHeight?: number;
  57910. alignHorizontal?: number;
  57911. alignVertical?: number;
  57912. faceUV?: Vector4[];
  57913. faceColors?: Color4[];
  57914. sideOrientation?: number;
  57915. updatable?: boolean;
  57916. }, scene?: Nullable<Scene>): Mesh;
  57917. }
  57918. }
  57919. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  57920. import { Vector4 } from "babylonjs/Maths/math.vector";
  57921. import { Mesh } from "babylonjs/Meshes/mesh";
  57922. /**
  57923. * Class containing static functions to help procedurally build meshes
  57924. */
  57925. export class TorusKnotBuilder {
  57926. /**
  57927. * Creates a torus knot mesh
  57928. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57929. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57930. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57931. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57933. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57935. * @param name defines the name of the mesh
  57936. * @param options defines the options used to create the mesh
  57937. * @param scene defines the hosting scene
  57938. * @returns the torus knot mesh
  57939. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57940. */
  57941. static CreateTorusKnot(name: string, options: {
  57942. radius?: number;
  57943. tube?: number;
  57944. radialSegments?: number;
  57945. tubularSegments?: number;
  57946. p?: number;
  57947. q?: number;
  57948. updatable?: boolean;
  57949. sideOrientation?: number;
  57950. frontUVs?: Vector4;
  57951. backUVs?: Vector4;
  57952. }, scene: any): Mesh;
  57953. }
  57954. }
  57955. declare module "babylonjs/Meshes/polygonMesh" {
  57956. import { Scene } from "babylonjs/scene";
  57957. import { Vector2 } from "babylonjs/Maths/math.vector";
  57958. import { Mesh } from "babylonjs/Meshes/mesh";
  57959. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57960. import { Path2 } from "babylonjs/Maths/math.path";
  57961. /**
  57962. * Polygon
  57963. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  57964. */
  57965. export class Polygon {
  57966. /**
  57967. * Creates a rectangle
  57968. * @param xmin bottom X coord
  57969. * @param ymin bottom Y coord
  57970. * @param xmax top X coord
  57971. * @param ymax top Y coord
  57972. * @returns points that make the resulting rectation
  57973. */
  57974. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  57975. /**
  57976. * Creates a circle
  57977. * @param radius radius of circle
  57978. * @param cx scale in x
  57979. * @param cy scale in y
  57980. * @param numberOfSides number of sides that make up the circle
  57981. * @returns points that make the resulting circle
  57982. */
  57983. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  57984. /**
  57985. * Creates a polygon from input string
  57986. * @param input Input polygon data
  57987. * @returns the parsed points
  57988. */
  57989. static Parse(input: string): Vector2[];
  57990. /**
  57991. * Starts building a polygon from x and y coordinates
  57992. * @param x x coordinate
  57993. * @param y y coordinate
  57994. * @returns the started path2
  57995. */
  57996. static StartingAt(x: number, y: number): Path2;
  57997. }
  57998. /**
  57999. * Builds a polygon
  58000. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58001. */
  58002. export class PolygonMeshBuilder {
  58003. private _points;
  58004. private _outlinepoints;
  58005. private _holes;
  58006. private _name;
  58007. private _scene;
  58008. private _epoints;
  58009. private _eholes;
  58010. private _addToepoint;
  58011. /**
  58012. * Babylon reference to the earcut plugin.
  58013. */
  58014. bjsEarcut: any;
  58015. /**
  58016. * Creates a PolygonMeshBuilder
  58017. * @param name name of the builder
  58018. * @param contours Path of the polygon
  58019. * @param scene scene to add to when creating the mesh
  58020. * @param earcutInjection can be used to inject your own earcut reference
  58021. */
  58022. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58023. /**
  58024. * Adds a whole within the polygon
  58025. * @param hole Array of points defining the hole
  58026. * @returns this
  58027. */
  58028. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58029. /**
  58030. * Creates the polygon
  58031. * @param updatable If the mesh should be updatable
  58032. * @param depth The depth of the mesh created
  58033. * @returns the created mesh
  58034. */
  58035. build(updatable?: boolean, depth?: number): Mesh;
  58036. /**
  58037. * Creates the polygon
  58038. * @param depth The depth of the mesh created
  58039. * @returns the created VertexData
  58040. */
  58041. buildVertexData(depth?: number): VertexData;
  58042. /**
  58043. * Adds a side to the polygon
  58044. * @param positions points that make the polygon
  58045. * @param normals normals of the polygon
  58046. * @param uvs uvs of the polygon
  58047. * @param indices indices of the polygon
  58048. * @param bounds bounds of the polygon
  58049. * @param points points of the polygon
  58050. * @param depth depth of the polygon
  58051. * @param flip flip of the polygon
  58052. */
  58053. private addSide;
  58054. }
  58055. }
  58056. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  58057. import { Scene } from "babylonjs/scene";
  58058. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58059. import { Color4 } from "babylonjs/Maths/math.color";
  58060. import { Mesh } from "babylonjs/Meshes/mesh";
  58061. import { Nullable } from "babylonjs/types";
  58062. /**
  58063. * Class containing static functions to help procedurally build meshes
  58064. */
  58065. export class PolygonBuilder {
  58066. /**
  58067. * Creates a polygon mesh
  58068. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58069. * * 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
  58070. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58072. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58073. * * Remember you can only change the shape positions, not their number when updating a polygon
  58074. * @param name defines the name of the mesh
  58075. * @param options defines the options used to create the mesh
  58076. * @param scene defines the hosting scene
  58077. * @param earcutInjection can be used to inject your own earcut reference
  58078. * @returns the polygon mesh
  58079. */
  58080. static CreatePolygon(name: string, options: {
  58081. shape: Vector3[];
  58082. holes?: Vector3[][];
  58083. depth?: number;
  58084. faceUV?: Vector4[];
  58085. faceColors?: Color4[];
  58086. updatable?: boolean;
  58087. sideOrientation?: number;
  58088. frontUVs?: Vector4;
  58089. backUVs?: Vector4;
  58090. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58091. /**
  58092. * Creates an extruded polygon mesh, with depth in the Y direction.
  58093. * * 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)
  58094. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58095. * @param name defines the name of the mesh
  58096. * @param options defines the options used to create the mesh
  58097. * @param scene defines the hosting scene
  58098. * @param earcutInjection can be used to inject your own earcut reference
  58099. * @returns the polygon mesh
  58100. */
  58101. static ExtrudePolygon(name: string, options: {
  58102. shape: Vector3[];
  58103. holes?: Vector3[][];
  58104. depth?: number;
  58105. faceUV?: Vector4[];
  58106. faceColors?: Color4[];
  58107. updatable?: boolean;
  58108. sideOrientation?: number;
  58109. frontUVs?: Vector4;
  58110. backUVs?: Vector4;
  58111. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58112. }
  58113. }
  58114. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  58115. import { Scene } from "babylonjs/scene";
  58116. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58117. import { Mesh } from "babylonjs/Meshes/mesh";
  58118. import { Nullable } from "babylonjs/types";
  58119. /**
  58120. * Class containing static functions to help procedurally build meshes
  58121. */
  58122. export class LatheBuilder {
  58123. /**
  58124. * Creates lathe mesh.
  58125. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58126. * * 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
  58127. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58128. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58129. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58130. * * 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
  58131. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58132. * * 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
  58133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58134. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58135. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58137. * @param name defines the name of the mesh
  58138. * @param options defines the options used to create the mesh
  58139. * @param scene defines the hosting scene
  58140. * @returns the lathe mesh
  58141. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58142. */
  58143. static CreateLathe(name: string, options: {
  58144. shape: Vector3[];
  58145. radius?: number;
  58146. tessellation?: number;
  58147. clip?: number;
  58148. arc?: number;
  58149. closed?: boolean;
  58150. updatable?: boolean;
  58151. sideOrientation?: number;
  58152. frontUVs?: Vector4;
  58153. backUVs?: Vector4;
  58154. cap?: number;
  58155. invertUV?: boolean;
  58156. }, scene?: Nullable<Scene>): Mesh;
  58157. }
  58158. }
  58159. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  58160. import { Nullable } from "babylonjs/types";
  58161. import { Scene } from "babylonjs/scene";
  58162. import { Vector4 } from "babylonjs/Maths/math.vector";
  58163. import { Mesh } from "babylonjs/Meshes/mesh";
  58164. /**
  58165. * Class containing static functions to help procedurally build meshes
  58166. */
  58167. export class TiledPlaneBuilder {
  58168. /**
  58169. * Creates a tiled plane mesh
  58170. * * The parameter `pattern` will, depending on value, do nothing or
  58171. * * * flip (reflect about central vertical) alternate tiles across and up
  58172. * * * flip every tile on alternate rows
  58173. * * * rotate (180 degs) alternate tiles across and up
  58174. * * * rotate every tile on alternate rows
  58175. * * * flip and rotate alternate tiles across and up
  58176. * * * flip and rotate every tile on alternate rows
  58177. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  58178. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  58179. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58180. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58181. * * 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)
  58182. * * 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)
  58183. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58184. * @param name defines the name of the mesh
  58185. * @param options defines the options used to create the mesh
  58186. * @param scene defines the hosting scene
  58187. * @returns the box mesh
  58188. */
  58189. static CreateTiledPlane(name: string, options: {
  58190. pattern?: number;
  58191. tileSize?: number;
  58192. tileWidth?: number;
  58193. tileHeight?: number;
  58194. size?: number;
  58195. width?: number;
  58196. height?: number;
  58197. alignHorizontal?: number;
  58198. alignVertical?: number;
  58199. sideOrientation?: number;
  58200. frontUVs?: Vector4;
  58201. backUVs?: Vector4;
  58202. updatable?: boolean;
  58203. }, scene?: Nullable<Scene>): Mesh;
  58204. }
  58205. }
  58206. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  58207. import { Nullable } from "babylonjs/types";
  58208. import { Scene } from "babylonjs/scene";
  58209. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58210. import { Mesh } from "babylonjs/Meshes/mesh";
  58211. /**
  58212. * Class containing static functions to help procedurally build meshes
  58213. */
  58214. export class TubeBuilder {
  58215. /**
  58216. * Creates a tube mesh.
  58217. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58218. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58219. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58220. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58221. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58222. * * 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)
  58223. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58224. * * 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
  58225. * * 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
  58226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58227. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58228. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58230. * @param name defines the name of the mesh
  58231. * @param options defines the options used to create the mesh
  58232. * @param scene defines the hosting scene
  58233. * @returns the tube mesh
  58234. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58235. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58236. */
  58237. static CreateTube(name: string, options: {
  58238. path: Vector3[];
  58239. radius?: number;
  58240. tessellation?: number;
  58241. radiusFunction?: {
  58242. (i: number, distance: number): number;
  58243. };
  58244. cap?: number;
  58245. arc?: number;
  58246. updatable?: boolean;
  58247. sideOrientation?: number;
  58248. frontUVs?: Vector4;
  58249. backUVs?: Vector4;
  58250. instance?: Mesh;
  58251. invertUV?: boolean;
  58252. }, scene?: Nullable<Scene>): Mesh;
  58253. }
  58254. }
  58255. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  58256. import { Scene } from "babylonjs/scene";
  58257. import { Vector4 } from "babylonjs/Maths/math.vector";
  58258. import { Mesh } from "babylonjs/Meshes/mesh";
  58259. import { Nullable } from "babylonjs/types";
  58260. /**
  58261. * Class containing static functions to help procedurally build meshes
  58262. */
  58263. export class IcoSphereBuilder {
  58264. /**
  58265. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58266. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58267. * * 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`)
  58268. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58269. * * 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
  58270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58271. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58273. * @param name defines the name of the mesh
  58274. * @param options defines the options used to create the mesh
  58275. * @param scene defines the hosting scene
  58276. * @returns the icosahedron mesh
  58277. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58278. */
  58279. static CreateIcoSphere(name: string, options: {
  58280. radius?: number;
  58281. radiusX?: number;
  58282. radiusY?: number;
  58283. radiusZ?: number;
  58284. flat?: boolean;
  58285. subdivisions?: number;
  58286. sideOrientation?: number;
  58287. frontUVs?: Vector4;
  58288. backUVs?: Vector4;
  58289. updatable?: boolean;
  58290. }, scene?: Nullable<Scene>): Mesh;
  58291. }
  58292. }
  58293. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  58294. import { Vector3 } from "babylonjs/Maths/math.vector";
  58295. import { Mesh } from "babylonjs/Meshes/mesh";
  58296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58297. /**
  58298. * Class containing static functions to help procedurally build meshes
  58299. */
  58300. export class DecalBuilder {
  58301. /**
  58302. * Creates a decal mesh.
  58303. * 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
  58304. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58305. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58306. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58307. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58308. * @param name defines the name of the mesh
  58309. * @param sourceMesh defines the mesh where the decal must be applied
  58310. * @param options defines the options used to create the mesh
  58311. * @param scene defines the hosting scene
  58312. * @returns the decal mesh
  58313. * @see https://doc.babylonjs.com/how_to/decals
  58314. */
  58315. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58316. position?: Vector3;
  58317. normal?: Vector3;
  58318. size?: Vector3;
  58319. angle?: number;
  58320. }): Mesh;
  58321. }
  58322. }
  58323. declare module "babylonjs/Meshes/meshBuilder" {
  58324. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  58325. import { Nullable } from "babylonjs/types";
  58326. import { Scene } from "babylonjs/scene";
  58327. import { Mesh } from "babylonjs/Meshes/mesh";
  58328. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  58329. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  58330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58331. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58332. import { Plane } from "babylonjs/Maths/math.plane";
  58333. /**
  58334. * Class containing static functions to help procedurally build meshes
  58335. */
  58336. export class MeshBuilder {
  58337. /**
  58338. * Creates a box mesh
  58339. * * The parameter `size` sets the size (float) of each box side (default 1)
  58340. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  58341. * * 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)
  58342. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58346. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58347. * @param name defines the name of the mesh
  58348. * @param options defines the options used to create the mesh
  58349. * @param scene defines the hosting scene
  58350. * @returns the box mesh
  58351. */
  58352. static CreateBox(name: string, options: {
  58353. size?: number;
  58354. width?: number;
  58355. height?: number;
  58356. depth?: number;
  58357. faceUV?: Vector4[];
  58358. faceColors?: Color4[];
  58359. sideOrientation?: number;
  58360. frontUVs?: Vector4;
  58361. backUVs?: Vector4;
  58362. updatable?: boolean;
  58363. }, scene?: Nullable<Scene>): Mesh;
  58364. /**
  58365. * Creates a tiled box mesh
  58366. * * faceTiles sets the pattern, tile size and number of tiles for a face
  58367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58368. * @param name defines the name of the mesh
  58369. * @param options defines the options used to create the mesh
  58370. * @param scene defines the hosting scene
  58371. * @returns the tiled box mesh
  58372. */
  58373. static CreateTiledBox(name: string, options: {
  58374. pattern?: number;
  58375. size?: number;
  58376. width?: number;
  58377. height?: number;
  58378. depth: number;
  58379. tileSize?: number;
  58380. tileWidth?: number;
  58381. tileHeight?: number;
  58382. faceUV?: Vector4[];
  58383. faceColors?: Color4[];
  58384. alignHorizontal?: number;
  58385. alignVertical?: number;
  58386. sideOrientation?: number;
  58387. updatable?: boolean;
  58388. }, scene?: Nullable<Scene>): Mesh;
  58389. /**
  58390. * Creates a sphere mesh
  58391. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  58392. * * 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`)
  58393. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  58394. * * 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
  58395. * * 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)
  58396. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58397. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58399. * @param name defines the name of the mesh
  58400. * @param options defines the options used to create the mesh
  58401. * @param scene defines the hosting scene
  58402. * @returns the sphere mesh
  58403. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  58404. */
  58405. static CreateSphere(name: string, options: {
  58406. segments?: number;
  58407. diameter?: number;
  58408. diameterX?: number;
  58409. diameterY?: number;
  58410. diameterZ?: number;
  58411. arc?: number;
  58412. slice?: number;
  58413. sideOrientation?: number;
  58414. frontUVs?: Vector4;
  58415. backUVs?: Vector4;
  58416. updatable?: boolean;
  58417. }, scene?: Nullable<Scene>): Mesh;
  58418. /**
  58419. * Creates a plane polygonal mesh. By default, this is a disc
  58420. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  58421. * * 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
  58422. * * 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
  58423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58424. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58426. * @param name defines the name of the mesh
  58427. * @param options defines the options used to create the mesh
  58428. * @param scene defines the hosting scene
  58429. * @returns the plane polygonal mesh
  58430. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  58431. */
  58432. static CreateDisc(name: string, options: {
  58433. radius?: number;
  58434. tessellation?: number;
  58435. arc?: number;
  58436. updatable?: boolean;
  58437. sideOrientation?: number;
  58438. frontUVs?: Vector4;
  58439. backUVs?: Vector4;
  58440. }, scene?: Nullable<Scene>): Mesh;
  58441. /**
  58442. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58443. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58444. * * 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`)
  58445. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58446. * * 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
  58447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58450. * @param name defines the name of the mesh
  58451. * @param options defines the options used to create the mesh
  58452. * @param scene defines the hosting scene
  58453. * @returns the icosahedron mesh
  58454. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58455. */
  58456. static CreateIcoSphere(name: string, options: {
  58457. radius?: number;
  58458. radiusX?: number;
  58459. radiusY?: number;
  58460. radiusZ?: number;
  58461. flat?: boolean;
  58462. subdivisions?: number;
  58463. sideOrientation?: number;
  58464. frontUVs?: Vector4;
  58465. backUVs?: Vector4;
  58466. updatable?: boolean;
  58467. }, scene?: Nullable<Scene>): Mesh;
  58468. /**
  58469. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58470. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58471. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58472. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58473. * * 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
  58474. * * 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
  58475. * * 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
  58476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58477. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58478. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58479. * * 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
  58480. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58481. * * 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
  58482. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58484. * @param name defines the name of the mesh
  58485. * @param options defines the options used to create the mesh
  58486. * @param scene defines the hosting scene
  58487. * @returns the ribbon mesh
  58488. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58489. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58490. */
  58491. static CreateRibbon(name: string, options: {
  58492. pathArray: Vector3[][];
  58493. closeArray?: boolean;
  58494. closePath?: boolean;
  58495. offset?: number;
  58496. updatable?: boolean;
  58497. sideOrientation?: number;
  58498. frontUVs?: Vector4;
  58499. backUVs?: Vector4;
  58500. instance?: Mesh;
  58501. invertUV?: boolean;
  58502. uvs?: Vector2[];
  58503. colors?: Color4[];
  58504. }, scene?: Nullable<Scene>): Mesh;
  58505. /**
  58506. * Creates a cylinder or a cone mesh
  58507. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  58508. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  58509. * * 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.
  58510. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  58511. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  58512. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  58513. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  58514. * * 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).
  58515. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  58516. * * 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).
  58517. * * 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
  58518. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  58519. * * 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
  58520. * * 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.
  58521. * * If `enclose` is false, a ring surface is one element.
  58522. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  58523. * * 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
  58524. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58525. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58527. * @param name defines the name of the mesh
  58528. * @param options defines the options used to create the mesh
  58529. * @param scene defines the hosting scene
  58530. * @returns the cylinder mesh
  58531. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  58532. */
  58533. static CreateCylinder(name: string, options: {
  58534. height?: number;
  58535. diameterTop?: number;
  58536. diameterBottom?: number;
  58537. diameter?: number;
  58538. tessellation?: number;
  58539. subdivisions?: number;
  58540. arc?: number;
  58541. faceColors?: Color4[];
  58542. faceUV?: Vector4[];
  58543. updatable?: boolean;
  58544. hasRings?: boolean;
  58545. enclose?: boolean;
  58546. cap?: number;
  58547. sideOrientation?: number;
  58548. frontUVs?: Vector4;
  58549. backUVs?: Vector4;
  58550. }, scene?: Nullable<Scene>): Mesh;
  58551. /**
  58552. * Creates a torus mesh
  58553. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  58554. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  58555. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  58556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58557. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58559. * @param name defines the name of the mesh
  58560. * @param options defines the options used to create the mesh
  58561. * @param scene defines the hosting scene
  58562. * @returns the torus mesh
  58563. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  58564. */
  58565. static CreateTorus(name: string, options: {
  58566. diameter?: number;
  58567. thickness?: number;
  58568. tessellation?: number;
  58569. updatable?: boolean;
  58570. sideOrientation?: number;
  58571. frontUVs?: Vector4;
  58572. backUVs?: Vector4;
  58573. }, scene?: Nullable<Scene>): Mesh;
  58574. /**
  58575. * Creates a torus knot mesh
  58576. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58577. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58578. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58579. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58581. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58583. * @param name defines the name of the mesh
  58584. * @param options defines the options used to create the mesh
  58585. * @param scene defines the hosting scene
  58586. * @returns the torus knot mesh
  58587. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58588. */
  58589. static CreateTorusKnot(name: string, options: {
  58590. radius?: number;
  58591. tube?: number;
  58592. radialSegments?: number;
  58593. tubularSegments?: number;
  58594. p?: number;
  58595. q?: number;
  58596. updatable?: boolean;
  58597. sideOrientation?: number;
  58598. frontUVs?: Vector4;
  58599. backUVs?: Vector4;
  58600. }, scene?: Nullable<Scene>): Mesh;
  58601. /**
  58602. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58603. * * 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
  58604. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58605. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58606. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58607. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58608. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58609. * * 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
  58610. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58612. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58613. * @param name defines the name of the new line system
  58614. * @param options defines the options used to create the line system
  58615. * @param scene defines the hosting scene
  58616. * @returns a new line system mesh
  58617. */
  58618. static CreateLineSystem(name: string, options: {
  58619. lines: Vector3[][];
  58620. updatable?: boolean;
  58621. instance?: Nullable<LinesMesh>;
  58622. colors?: Nullable<Color4[][]>;
  58623. useVertexAlpha?: boolean;
  58624. }, scene: Nullable<Scene>): LinesMesh;
  58625. /**
  58626. * Creates a line mesh
  58627. * 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
  58628. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58629. * * The parameter `points` is an array successive Vector3
  58630. * * 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
  58631. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58632. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58633. * * When updating an instance, remember that only point positions can change, not the number of points
  58634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58635. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58636. * @param name defines the name of the new line system
  58637. * @param options defines the options used to create the line system
  58638. * @param scene defines the hosting scene
  58639. * @returns a new line mesh
  58640. */
  58641. static CreateLines(name: string, options: {
  58642. points: Vector3[];
  58643. updatable?: boolean;
  58644. instance?: Nullable<LinesMesh>;
  58645. colors?: Color4[];
  58646. useVertexAlpha?: boolean;
  58647. }, scene?: Nullable<Scene>): LinesMesh;
  58648. /**
  58649. * Creates a dashed line mesh
  58650. * * 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
  58651. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58652. * * The parameter `points` is an array successive Vector3
  58653. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58654. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58655. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58656. * * 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
  58657. * * When updating an instance, remember that only point positions can change, not the number of points
  58658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58659. * @param name defines the name of the mesh
  58660. * @param options defines the options used to create the mesh
  58661. * @param scene defines the hosting scene
  58662. * @returns the dashed line mesh
  58663. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58664. */
  58665. static CreateDashedLines(name: string, options: {
  58666. points: Vector3[];
  58667. dashSize?: number;
  58668. gapSize?: number;
  58669. dashNb?: number;
  58670. updatable?: boolean;
  58671. instance?: LinesMesh;
  58672. }, scene?: Nullable<Scene>): LinesMesh;
  58673. /**
  58674. * 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.
  58675. * * 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.
  58676. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58677. * * 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.
  58678. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58679. * * 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
  58680. * * 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
  58681. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58682. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58683. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58684. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58686. * @param name defines the name of the mesh
  58687. * @param options defines the options used to create the mesh
  58688. * @param scene defines the hosting scene
  58689. * @returns the extruded shape mesh
  58690. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58691. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58692. */
  58693. static ExtrudeShape(name: string, options: {
  58694. shape: Vector3[];
  58695. path: Vector3[];
  58696. scale?: number;
  58697. rotation?: number;
  58698. cap?: number;
  58699. updatable?: boolean;
  58700. sideOrientation?: number;
  58701. frontUVs?: Vector4;
  58702. backUVs?: Vector4;
  58703. instance?: Mesh;
  58704. invertUV?: boolean;
  58705. }, scene?: Nullable<Scene>): Mesh;
  58706. /**
  58707. * Creates an custom extruded shape mesh.
  58708. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58709. * * 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.
  58710. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58711. * * 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
  58712. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58713. * * 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
  58714. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58715. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58716. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58717. * * 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
  58718. * * 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
  58719. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58720. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58721. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58722. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58724. * @param name defines the name of the mesh
  58725. * @param options defines the options used to create the mesh
  58726. * @param scene defines the hosting scene
  58727. * @returns the custom extruded shape mesh
  58728. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58729. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58730. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58731. */
  58732. static ExtrudeShapeCustom(name: string, options: {
  58733. shape: Vector3[];
  58734. path: Vector3[];
  58735. scaleFunction?: any;
  58736. rotationFunction?: any;
  58737. ribbonCloseArray?: boolean;
  58738. ribbonClosePath?: boolean;
  58739. cap?: number;
  58740. updatable?: boolean;
  58741. sideOrientation?: number;
  58742. frontUVs?: Vector4;
  58743. backUVs?: Vector4;
  58744. instance?: Mesh;
  58745. invertUV?: boolean;
  58746. }, scene?: Nullable<Scene>): Mesh;
  58747. /**
  58748. * Creates lathe mesh.
  58749. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58750. * * 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
  58751. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58752. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58753. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58754. * * 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
  58755. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58756. * * 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
  58757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58758. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58759. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58761. * @param name defines the name of the mesh
  58762. * @param options defines the options used to create the mesh
  58763. * @param scene defines the hosting scene
  58764. * @returns the lathe mesh
  58765. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58766. */
  58767. static CreateLathe(name: string, options: {
  58768. shape: Vector3[];
  58769. radius?: number;
  58770. tessellation?: number;
  58771. clip?: number;
  58772. arc?: number;
  58773. closed?: boolean;
  58774. updatable?: boolean;
  58775. sideOrientation?: number;
  58776. frontUVs?: Vector4;
  58777. backUVs?: Vector4;
  58778. cap?: number;
  58779. invertUV?: boolean;
  58780. }, scene?: Nullable<Scene>): Mesh;
  58781. /**
  58782. * Creates a tiled plane mesh
  58783. * * You can set a limited pattern arrangement with the tiles
  58784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58787. * @param name defines the name of the mesh
  58788. * @param options defines the options used to create the mesh
  58789. * @param scene defines the hosting scene
  58790. * @returns the plane mesh
  58791. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58792. */
  58793. static CreateTiledPlane(name: string, options: {
  58794. pattern?: number;
  58795. tileSize?: number;
  58796. tileWidth?: number;
  58797. tileHeight?: number;
  58798. size?: number;
  58799. width?: number;
  58800. height?: number;
  58801. alignHorizontal?: number;
  58802. alignVertical?: number;
  58803. sideOrientation?: number;
  58804. frontUVs?: Vector4;
  58805. backUVs?: Vector4;
  58806. updatable?: boolean;
  58807. }, scene?: Nullable<Scene>): Mesh;
  58808. /**
  58809. * Creates a plane mesh
  58810. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  58811. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  58812. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  58813. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58814. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58816. * @param name defines the name of the mesh
  58817. * @param options defines the options used to create the mesh
  58818. * @param scene defines the hosting scene
  58819. * @returns the plane mesh
  58820. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58821. */
  58822. static CreatePlane(name: string, options: {
  58823. size?: number;
  58824. width?: number;
  58825. height?: number;
  58826. sideOrientation?: number;
  58827. frontUVs?: Vector4;
  58828. backUVs?: Vector4;
  58829. updatable?: boolean;
  58830. sourcePlane?: Plane;
  58831. }, scene?: Nullable<Scene>): Mesh;
  58832. /**
  58833. * Creates a ground mesh
  58834. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  58835. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  58836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58837. * @param name defines the name of the mesh
  58838. * @param options defines the options used to create the mesh
  58839. * @param scene defines the hosting scene
  58840. * @returns the ground mesh
  58841. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  58842. */
  58843. static CreateGround(name: string, options: {
  58844. width?: number;
  58845. height?: number;
  58846. subdivisions?: number;
  58847. subdivisionsX?: number;
  58848. subdivisionsY?: number;
  58849. updatable?: boolean;
  58850. }, scene?: Nullable<Scene>): Mesh;
  58851. /**
  58852. * Creates a tiled ground mesh
  58853. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  58854. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  58855. * * 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
  58856. * * 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
  58857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58858. * @param name defines the name of the mesh
  58859. * @param options defines the options used to create the mesh
  58860. * @param scene defines the hosting scene
  58861. * @returns the tiled ground mesh
  58862. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  58863. */
  58864. static CreateTiledGround(name: string, options: {
  58865. xmin: number;
  58866. zmin: number;
  58867. xmax: number;
  58868. zmax: number;
  58869. subdivisions?: {
  58870. w: number;
  58871. h: number;
  58872. };
  58873. precision?: {
  58874. w: number;
  58875. h: number;
  58876. };
  58877. updatable?: boolean;
  58878. }, scene?: Nullable<Scene>): Mesh;
  58879. /**
  58880. * Creates a ground mesh from a height map
  58881. * * The parameter `url` sets the URL of the height map image resource.
  58882. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  58883. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  58884. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  58885. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  58886. * * 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.
  58887. * * 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).
  58888. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  58889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58890. * @param name defines the name of the mesh
  58891. * @param url defines the url to the height map
  58892. * @param options defines the options used to create the mesh
  58893. * @param scene defines the hosting scene
  58894. * @returns the ground mesh
  58895. * @see https://doc.babylonjs.com/babylon101/height_map
  58896. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  58897. */
  58898. static CreateGroundFromHeightMap(name: string, url: string, options: {
  58899. width?: number;
  58900. height?: number;
  58901. subdivisions?: number;
  58902. minHeight?: number;
  58903. maxHeight?: number;
  58904. colorFilter?: Color3;
  58905. alphaFilter?: number;
  58906. updatable?: boolean;
  58907. onReady?: (mesh: GroundMesh) => void;
  58908. }, scene?: Nullable<Scene>): GroundMesh;
  58909. /**
  58910. * Creates a polygon mesh
  58911. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58912. * * 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
  58913. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58915. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58916. * * Remember you can only change the shape positions, not their number when updating a polygon
  58917. * @param name defines the name of the mesh
  58918. * @param options defines the options used to create the mesh
  58919. * @param scene defines the hosting scene
  58920. * @param earcutInjection can be used to inject your own earcut reference
  58921. * @returns the polygon mesh
  58922. */
  58923. static CreatePolygon(name: string, options: {
  58924. shape: Vector3[];
  58925. holes?: Vector3[][];
  58926. depth?: number;
  58927. faceUV?: Vector4[];
  58928. faceColors?: Color4[];
  58929. updatable?: boolean;
  58930. sideOrientation?: number;
  58931. frontUVs?: Vector4;
  58932. backUVs?: Vector4;
  58933. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58934. /**
  58935. * Creates an extruded polygon mesh, with depth in the Y direction.
  58936. * * 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)
  58937. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58938. * @param name defines the name of the mesh
  58939. * @param options defines the options used to create the mesh
  58940. * @param scene defines the hosting scene
  58941. * @param earcutInjection can be used to inject your own earcut reference
  58942. * @returns the polygon mesh
  58943. */
  58944. static ExtrudePolygon(name: string, options: {
  58945. shape: Vector3[];
  58946. holes?: Vector3[][];
  58947. depth?: number;
  58948. faceUV?: Vector4[];
  58949. faceColors?: Color4[];
  58950. updatable?: boolean;
  58951. sideOrientation?: number;
  58952. frontUVs?: Vector4;
  58953. backUVs?: Vector4;
  58954. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58955. /**
  58956. * Creates a tube mesh.
  58957. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58958. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58959. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58960. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58961. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58962. * * 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)
  58963. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58964. * * 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
  58965. * * 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
  58966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58967. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58968. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58970. * @param name defines the name of the mesh
  58971. * @param options defines the options used to create the mesh
  58972. * @param scene defines the hosting scene
  58973. * @returns the tube mesh
  58974. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58975. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58976. */
  58977. static CreateTube(name: string, options: {
  58978. path: Vector3[];
  58979. radius?: number;
  58980. tessellation?: number;
  58981. radiusFunction?: {
  58982. (i: number, distance: number): number;
  58983. };
  58984. cap?: number;
  58985. arc?: number;
  58986. updatable?: boolean;
  58987. sideOrientation?: number;
  58988. frontUVs?: Vector4;
  58989. backUVs?: Vector4;
  58990. instance?: Mesh;
  58991. invertUV?: boolean;
  58992. }, scene?: Nullable<Scene>): Mesh;
  58993. /**
  58994. * Creates a polyhedron mesh
  58995. * * 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
  58996. * * The parameter `size` (positive float, default 1) sets the polygon size
  58997. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58998. * * 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`
  58999. * * 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
  59000. * * 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)`)
  59001. * * 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
  59002. * * 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
  59003. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59004. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59006. * @param name defines the name of the mesh
  59007. * @param options defines the options used to create the mesh
  59008. * @param scene defines the hosting scene
  59009. * @returns the polyhedron mesh
  59010. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59011. */
  59012. static CreatePolyhedron(name: string, options: {
  59013. type?: number;
  59014. size?: number;
  59015. sizeX?: number;
  59016. sizeY?: number;
  59017. sizeZ?: number;
  59018. custom?: any;
  59019. faceUV?: Vector4[];
  59020. faceColors?: Color4[];
  59021. flat?: boolean;
  59022. updatable?: boolean;
  59023. sideOrientation?: number;
  59024. frontUVs?: Vector4;
  59025. backUVs?: Vector4;
  59026. }, scene?: Nullable<Scene>): Mesh;
  59027. /**
  59028. * Creates a decal mesh.
  59029. * 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
  59030. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59031. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59032. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59033. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59034. * @param name defines the name of the mesh
  59035. * @param sourceMesh defines the mesh where the decal must be applied
  59036. * @param options defines the options used to create the mesh
  59037. * @param scene defines the hosting scene
  59038. * @returns the decal mesh
  59039. * @see https://doc.babylonjs.com/how_to/decals
  59040. */
  59041. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59042. position?: Vector3;
  59043. normal?: Vector3;
  59044. size?: Vector3;
  59045. angle?: number;
  59046. }): Mesh;
  59047. }
  59048. }
  59049. declare module "babylonjs/Meshes/meshSimplification" {
  59050. import { Mesh } from "babylonjs/Meshes/mesh";
  59051. /**
  59052. * A simplifier interface for future simplification implementations
  59053. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59054. */
  59055. export interface ISimplifier {
  59056. /**
  59057. * Simplification of a given mesh according to the given settings.
  59058. * Since this requires computation, it is assumed that the function runs async.
  59059. * @param settings The settings of the simplification, including quality and distance
  59060. * @param successCallback A callback that will be called after the mesh was simplified.
  59061. * @param errorCallback in case of an error, this callback will be called. optional.
  59062. */
  59063. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59064. }
  59065. /**
  59066. * Expected simplification settings.
  59067. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59068. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59069. */
  59070. export interface ISimplificationSettings {
  59071. /**
  59072. * Gets or sets the expected quality
  59073. */
  59074. quality: number;
  59075. /**
  59076. * Gets or sets the distance when this optimized version should be used
  59077. */
  59078. distance: number;
  59079. /**
  59080. * Gets an already optimized mesh
  59081. */
  59082. optimizeMesh?: boolean;
  59083. }
  59084. /**
  59085. * Class used to specify simplification options
  59086. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59087. */
  59088. export class SimplificationSettings implements ISimplificationSettings {
  59089. /** expected quality */
  59090. quality: number;
  59091. /** distance when this optimized version should be used */
  59092. distance: number;
  59093. /** already optimized mesh */
  59094. optimizeMesh?: boolean | undefined;
  59095. /**
  59096. * Creates a SimplificationSettings
  59097. * @param quality expected quality
  59098. * @param distance distance when this optimized version should be used
  59099. * @param optimizeMesh already optimized mesh
  59100. */
  59101. constructor(
  59102. /** expected quality */
  59103. quality: number,
  59104. /** distance when this optimized version should be used */
  59105. distance: number,
  59106. /** already optimized mesh */
  59107. optimizeMesh?: boolean | undefined);
  59108. }
  59109. /**
  59110. * Interface used to define a simplification task
  59111. */
  59112. export interface ISimplificationTask {
  59113. /**
  59114. * Array of settings
  59115. */
  59116. settings: Array<ISimplificationSettings>;
  59117. /**
  59118. * Simplification type
  59119. */
  59120. simplificationType: SimplificationType;
  59121. /**
  59122. * Mesh to simplify
  59123. */
  59124. mesh: Mesh;
  59125. /**
  59126. * Callback called on success
  59127. */
  59128. successCallback?: () => void;
  59129. /**
  59130. * Defines if parallel processing can be used
  59131. */
  59132. parallelProcessing: boolean;
  59133. }
  59134. /**
  59135. * Queue used to order the simplification tasks
  59136. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59137. */
  59138. export class SimplificationQueue {
  59139. private _simplificationArray;
  59140. /**
  59141. * Gets a boolean indicating that the process is still running
  59142. */
  59143. running: boolean;
  59144. /**
  59145. * Creates a new queue
  59146. */
  59147. constructor();
  59148. /**
  59149. * Adds a new simplification task
  59150. * @param task defines a task to add
  59151. */
  59152. addTask(task: ISimplificationTask): void;
  59153. /**
  59154. * Execute next task
  59155. */
  59156. executeNext(): void;
  59157. /**
  59158. * Execute a simplification task
  59159. * @param task defines the task to run
  59160. */
  59161. runSimplification(task: ISimplificationTask): void;
  59162. private getSimplifier;
  59163. }
  59164. /**
  59165. * The implemented types of simplification
  59166. * At the moment only Quadratic Error Decimation is implemented
  59167. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59168. */
  59169. export enum SimplificationType {
  59170. /** Quadratic error decimation */
  59171. QUADRATIC = 0
  59172. }
  59173. }
  59174. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  59175. import { Scene } from "babylonjs/scene";
  59176. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  59177. import { ISceneComponent } from "babylonjs/sceneComponent";
  59178. module "babylonjs/scene" {
  59179. interface Scene {
  59180. /** @hidden (Backing field) */
  59181. _simplificationQueue: SimplificationQueue;
  59182. /**
  59183. * Gets or sets the simplification queue attached to the scene
  59184. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59185. */
  59186. simplificationQueue: SimplificationQueue;
  59187. }
  59188. }
  59189. module "babylonjs/Meshes/mesh" {
  59190. interface Mesh {
  59191. /**
  59192. * Simplify the mesh according to the given array of settings.
  59193. * Function will return immediately and will simplify async
  59194. * @param settings a collection of simplification settings
  59195. * @param parallelProcessing should all levels calculate parallel or one after the other
  59196. * @param simplificationType the type of simplification to run
  59197. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  59198. * @returns the current mesh
  59199. */
  59200. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  59201. }
  59202. }
  59203. /**
  59204. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  59205. * created in a scene
  59206. */
  59207. export class SimplicationQueueSceneComponent implements ISceneComponent {
  59208. /**
  59209. * The component name helpfull to identify the component in the list of scene components.
  59210. */
  59211. readonly name: string;
  59212. /**
  59213. * The scene the component belongs to.
  59214. */
  59215. scene: Scene;
  59216. /**
  59217. * Creates a new instance of the component for the given scene
  59218. * @param scene Defines the scene to register the component in
  59219. */
  59220. constructor(scene: Scene);
  59221. /**
  59222. * Registers the component in a given scene
  59223. */
  59224. register(): void;
  59225. /**
  59226. * Rebuilds the elements related to this component in case of
  59227. * context lost for instance.
  59228. */
  59229. rebuild(): void;
  59230. /**
  59231. * Disposes the component and the associated ressources
  59232. */
  59233. dispose(): void;
  59234. private _beforeCameraUpdate;
  59235. }
  59236. }
  59237. declare module "babylonjs/Meshes/Builders/index" {
  59238. export * from "babylonjs/Meshes/Builders/boxBuilder";
  59239. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  59240. export * from "babylonjs/Meshes/Builders/discBuilder";
  59241. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  59242. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  59243. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  59244. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  59245. export * from "babylonjs/Meshes/Builders/torusBuilder";
  59246. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  59247. export * from "babylonjs/Meshes/Builders/linesBuilder";
  59248. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  59249. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  59250. export * from "babylonjs/Meshes/Builders/latheBuilder";
  59251. export * from "babylonjs/Meshes/Builders/planeBuilder";
  59252. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  59253. export * from "babylonjs/Meshes/Builders/groundBuilder";
  59254. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  59255. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  59256. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  59257. export * from "babylonjs/Meshes/Builders/decalBuilder";
  59258. }
  59259. declare module "babylonjs/Meshes/index" {
  59260. export * from "babylonjs/Meshes/abstractMesh";
  59261. export * from "babylonjs/Meshes/buffer";
  59262. export * from "babylonjs/Meshes/Compression/index";
  59263. export * from "babylonjs/Meshes/csg";
  59264. export * from "babylonjs/Meshes/geometry";
  59265. export * from "babylonjs/Meshes/groundMesh";
  59266. export * from "babylonjs/Meshes/trailMesh";
  59267. export * from "babylonjs/Meshes/instancedMesh";
  59268. export * from "babylonjs/Meshes/linesMesh";
  59269. export * from "babylonjs/Meshes/mesh";
  59270. export * from "babylonjs/Meshes/mesh.vertexData";
  59271. export * from "babylonjs/Meshes/meshBuilder";
  59272. export * from "babylonjs/Meshes/meshSimplification";
  59273. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  59274. export * from "babylonjs/Meshes/polygonMesh";
  59275. export * from "babylonjs/Meshes/subMesh";
  59276. export * from "babylonjs/Meshes/meshLODLevel";
  59277. export * from "babylonjs/Meshes/transformNode";
  59278. export * from "babylonjs/Meshes/Builders/index";
  59279. export * from "babylonjs/Meshes/dataBuffer";
  59280. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  59281. }
  59282. declare module "babylonjs/Morph/index" {
  59283. export * from "babylonjs/Morph/morphTarget";
  59284. export * from "babylonjs/Morph/morphTargetManager";
  59285. }
  59286. declare module "babylonjs/Navigation/INavigationEngine" {
  59287. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59288. import { Vector3 } from "babylonjs/Maths/math";
  59289. import { Mesh } from "babylonjs/Meshes/mesh";
  59290. import { Scene } from "babylonjs/scene";
  59291. /**
  59292. * Navigation plugin interface to add navigation constrained by a navigation mesh
  59293. */
  59294. export interface INavigationEnginePlugin {
  59295. /**
  59296. * plugin name
  59297. */
  59298. name: string;
  59299. /**
  59300. * Creates a navigation mesh
  59301. * @param meshes array of all the geometry used to compute the navigatio mesh
  59302. * @param parameters bunch of parameters used to filter geometry
  59303. */
  59304. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59305. /**
  59306. * Create a navigation mesh debug mesh
  59307. * @param scene is where the mesh will be added
  59308. * @returns debug display mesh
  59309. */
  59310. createDebugNavMesh(scene: Scene): Mesh;
  59311. /**
  59312. * Get a navigation mesh constrained position, closest to the parameter position
  59313. * @param position world position
  59314. * @returns the closest point to position constrained by the navigation mesh
  59315. */
  59316. getClosestPoint(position: Vector3): Vector3;
  59317. /**
  59318. * Get a navigation mesh constrained position, within a particular radius
  59319. * @param position world position
  59320. * @param maxRadius the maximum distance to the constrained world position
  59321. * @returns the closest point to position constrained by the navigation mesh
  59322. */
  59323. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59324. /**
  59325. * Compute the final position from a segment made of destination-position
  59326. * @param position world position
  59327. * @param destination world position
  59328. * @returns the resulting point along the navmesh
  59329. */
  59330. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59331. /**
  59332. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59333. * @param start world position
  59334. * @param end world position
  59335. * @returns array containing world position composing the path
  59336. */
  59337. computePath(start: Vector3, end: Vector3): Vector3[];
  59338. /**
  59339. * If this plugin is supported
  59340. * @returns true if plugin is supported
  59341. */
  59342. isSupported(): boolean;
  59343. /**
  59344. * Create a new Crowd so you can add agents
  59345. * @param maxAgents the maximum agent count in the crowd
  59346. * @param maxAgentRadius the maximum radius an agent can have
  59347. * @param scene to attach the crowd to
  59348. * @returns the crowd you can add agents to
  59349. */
  59350. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59351. /**
  59352. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59353. * The queries will try to find a solution within those bounds
  59354. * default is (1,1,1)
  59355. * @param extent x,y,z value that define the extent around the queries point of reference
  59356. */
  59357. setDefaultQueryExtent(extent: Vector3): void;
  59358. /**
  59359. * Get the Bounding box extent specified by setDefaultQueryExtent
  59360. * @returns the box extent values
  59361. */
  59362. getDefaultQueryExtent(): Vector3;
  59363. /**
  59364. * Release all resources
  59365. */
  59366. dispose(): void;
  59367. }
  59368. /**
  59369. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  59370. */
  59371. export interface ICrowd {
  59372. /**
  59373. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59374. * You can attach anything to that node. The node position is updated in the scene update tick.
  59375. * @param pos world position that will be constrained by the navigation mesh
  59376. * @param parameters agent parameters
  59377. * @param transform hooked to the agent that will be update by the scene
  59378. * @returns agent index
  59379. */
  59380. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59381. /**
  59382. * Returns the agent position in world space
  59383. * @param index agent index returned by addAgent
  59384. * @returns world space position
  59385. */
  59386. getAgentPosition(index: number): Vector3;
  59387. /**
  59388. * Gets the agent velocity in world space
  59389. * @param index agent index returned by addAgent
  59390. * @returns world space velocity
  59391. */
  59392. getAgentVelocity(index: number): Vector3;
  59393. /**
  59394. * remove a particular agent previously created
  59395. * @param index agent index returned by addAgent
  59396. */
  59397. removeAgent(index: number): void;
  59398. /**
  59399. * get the list of all agents attached to this crowd
  59400. * @returns list of agent indices
  59401. */
  59402. getAgents(): number[];
  59403. /**
  59404. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59405. * @param deltaTime in seconds
  59406. */
  59407. update(deltaTime: number): void;
  59408. /**
  59409. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59410. * @param index agent index returned by addAgent
  59411. * @param destination targeted world position
  59412. */
  59413. agentGoto(index: number, destination: Vector3): void;
  59414. /**
  59415. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59416. * The queries will try to find a solution within those bounds
  59417. * default is (1,1,1)
  59418. * @param extent x,y,z value that define the extent around the queries point of reference
  59419. */
  59420. setDefaultQueryExtent(extent: Vector3): void;
  59421. /**
  59422. * Get the Bounding box extent specified by setDefaultQueryExtent
  59423. * @returns the box extent values
  59424. */
  59425. getDefaultQueryExtent(): Vector3;
  59426. /**
  59427. * Release all resources
  59428. */
  59429. dispose(): void;
  59430. }
  59431. /**
  59432. * Configures an agent
  59433. */
  59434. export interface IAgentParameters {
  59435. /**
  59436. * Agent radius. [Limit: >= 0]
  59437. */
  59438. radius: number;
  59439. /**
  59440. * Agent height. [Limit: > 0]
  59441. */
  59442. height: number;
  59443. /**
  59444. * Maximum allowed acceleration. [Limit: >= 0]
  59445. */
  59446. maxAcceleration: number;
  59447. /**
  59448. * Maximum allowed speed. [Limit: >= 0]
  59449. */
  59450. maxSpeed: number;
  59451. /**
  59452. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  59453. */
  59454. collisionQueryRange: number;
  59455. /**
  59456. * The path visibility optimization range. [Limit: > 0]
  59457. */
  59458. pathOptimizationRange: number;
  59459. /**
  59460. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  59461. */
  59462. separationWeight: number;
  59463. }
  59464. /**
  59465. * Configures the navigation mesh creation
  59466. */
  59467. export interface INavMeshParameters {
  59468. /**
  59469. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  59470. */
  59471. cs: number;
  59472. /**
  59473. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  59474. */
  59475. ch: number;
  59476. /**
  59477. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  59478. */
  59479. walkableSlopeAngle: number;
  59480. /**
  59481. * Minimum floor to 'ceiling' height that will still allow the floor area to
  59482. * be considered walkable. [Limit: >= 3] [Units: vx]
  59483. */
  59484. walkableHeight: number;
  59485. /**
  59486. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  59487. */
  59488. walkableClimb: number;
  59489. /**
  59490. * The distance to erode/shrink the walkable area of the heightfield away from
  59491. * obstructions. [Limit: >=0] [Units: vx]
  59492. */
  59493. walkableRadius: number;
  59494. /**
  59495. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  59496. */
  59497. maxEdgeLen: number;
  59498. /**
  59499. * The maximum distance a simplfied contour's border edges should deviate
  59500. * the original raw contour. [Limit: >=0] [Units: vx]
  59501. */
  59502. maxSimplificationError: number;
  59503. /**
  59504. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  59505. */
  59506. minRegionArea: number;
  59507. /**
  59508. * Any regions with a span count smaller than this value will, if possible,
  59509. * be merged with larger regions. [Limit: >=0] [Units: vx]
  59510. */
  59511. mergeRegionArea: number;
  59512. /**
  59513. * The maximum number of vertices allowed for polygons generated during the
  59514. * contour to polygon conversion process. [Limit: >= 3]
  59515. */
  59516. maxVertsPerPoly: number;
  59517. /**
  59518. * Sets the sampling distance to use when generating the detail mesh.
  59519. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  59520. */
  59521. detailSampleDist: number;
  59522. /**
  59523. * The maximum distance the detail mesh surface should deviate from heightfield
  59524. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  59525. */
  59526. detailSampleMaxError: number;
  59527. }
  59528. }
  59529. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  59530. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  59531. import { Mesh } from "babylonjs/Meshes/mesh";
  59532. import { Scene } from "babylonjs/scene";
  59533. import { Vector3 } from "babylonjs/Maths/math";
  59534. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59535. /**
  59536. * RecastJS navigation plugin
  59537. */
  59538. export class RecastJSPlugin implements INavigationEnginePlugin {
  59539. /**
  59540. * Reference to the Recast library
  59541. */
  59542. bjsRECAST: any;
  59543. /**
  59544. * plugin name
  59545. */
  59546. name: string;
  59547. /**
  59548. * the first navmesh created. We might extend this to support multiple navmeshes
  59549. */
  59550. navMesh: any;
  59551. /**
  59552. * Initializes the recastJS plugin
  59553. * @param recastInjection can be used to inject your own recast reference
  59554. */
  59555. constructor(recastInjection?: any);
  59556. /**
  59557. * Creates a navigation mesh
  59558. * @param meshes array of all the geometry used to compute the navigatio mesh
  59559. * @param parameters bunch of parameters used to filter geometry
  59560. */
  59561. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59562. /**
  59563. * Create a navigation mesh debug mesh
  59564. * @param scene is where the mesh will be added
  59565. * @returns debug display mesh
  59566. */
  59567. createDebugNavMesh(scene: Scene): Mesh;
  59568. /**
  59569. * Get a navigation mesh constrained position, closest to the parameter position
  59570. * @param position world position
  59571. * @returns the closest point to position constrained by the navigation mesh
  59572. */
  59573. getClosestPoint(position: Vector3): Vector3;
  59574. /**
  59575. * Get a navigation mesh constrained position, within a particular radius
  59576. * @param position world position
  59577. * @param maxRadius the maximum distance to the constrained world position
  59578. * @returns the closest point to position constrained by the navigation mesh
  59579. */
  59580. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59581. /**
  59582. * Compute the final position from a segment made of destination-position
  59583. * @param position world position
  59584. * @param destination world position
  59585. * @returns the resulting point along the navmesh
  59586. */
  59587. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59588. /**
  59589. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59590. * @param start world position
  59591. * @param end world position
  59592. * @returns array containing world position composing the path
  59593. */
  59594. computePath(start: Vector3, end: Vector3): Vector3[];
  59595. /**
  59596. * Create a new Crowd so you can add agents
  59597. * @param maxAgents the maximum agent count in the crowd
  59598. * @param maxAgentRadius the maximum radius an agent can have
  59599. * @param scene to attach the crowd to
  59600. * @returns the crowd you can add agents to
  59601. */
  59602. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59603. /**
  59604. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59605. * The queries will try to find a solution within those bounds
  59606. * default is (1,1,1)
  59607. * @param extent x,y,z value that define the extent around the queries point of reference
  59608. */
  59609. setDefaultQueryExtent(extent: Vector3): void;
  59610. /**
  59611. * Get the Bounding box extent specified by setDefaultQueryExtent
  59612. * @returns the box extent values
  59613. */
  59614. getDefaultQueryExtent(): Vector3;
  59615. /**
  59616. * Disposes
  59617. */
  59618. dispose(): void;
  59619. /**
  59620. * If this plugin is supported
  59621. * @returns true if plugin is supported
  59622. */
  59623. isSupported(): boolean;
  59624. }
  59625. /**
  59626. * Recast detour crowd implementation
  59627. */
  59628. export class RecastJSCrowd implements ICrowd {
  59629. /**
  59630. * Recast/detour plugin
  59631. */
  59632. bjsRECASTPlugin: RecastJSPlugin;
  59633. /**
  59634. * Link to the detour crowd
  59635. */
  59636. recastCrowd: any;
  59637. /**
  59638. * One transform per agent
  59639. */
  59640. transforms: TransformNode[];
  59641. /**
  59642. * All agents created
  59643. */
  59644. agents: number[];
  59645. /**
  59646. * Link to the scene is kept to unregister the crowd from the scene
  59647. */
  59648. private _scene;
  59649. /**
  59650. * Observer for crowd updates
  59651. */
  59652. private _onBeforeAnimationsObserver;
  59653. /**
  59654. * Constructor
  59655. * @param plugin recastJS plugin
  59656. * @param maxAgents the maximum agent count in the crowd
  59657. * @param maxAgentRadius the maximum radius an agent can have
  59658. * @param scene to attach the crowd to
  59659. * @returns the crowd you can add agents to
  59660. */
  59661. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  59662. /**
  59663. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59664. * You can attach anything to that node. The node position is updated in the scene update tick.
  59665. * @param pos world position that will be constrained by the navigation mesh
  59666. * @param parameters agent parameters
  59667. * @param transform hooked to the agent that will be update by the scene
  59668. * @returns agent index
  59669. */
  59670. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59671. /**
  59672. * Returns the agent position in world space
  59673. * @param index agent index returned by addAgent
  59674. * @returns world space position
  59675. */
  59676. getAgentPosition(index: number): Vector3;
  59677. /**
  59678. * Returns the agent velocity in world space
  59679. * @param index agent index returned by addAgent
  59680. * @returns world space velocity
  59681. */
  59682. getAgentVelocity(index: number): Vector3;
  59683. /**
  59684. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59685. * @param index agent index returned by addAgent
  59686. * @param destination targeted world position
  59687. */
  59688. agentGoto(index: number, destination: Vector3): void;
  59689. /**
  59690. * remove a particular agent previously created
  59691. * @param index agent index returned by addAgent
  59692. */
  59693. removeAgent(index: number): void;
  59694. /**
  59695. * get the list of all agents attached to this crowd
  59696. * @returns list of agent indices
  59697. */
  59698. getAgents(): number[];
  59699. /**
  59700. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59701. * @param deltaTime in seconds
  59702. */
  59703. update(deltaTime: number): void;
  59704. /**
  59705. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59706. * The queries will try to find a solution within those bounds
  59707. * default is (1,1,1)
  59708. * @param extent x,y,z value that define the extent around the queries point of reference
  59709. */
  59710. setDefaultQueryExtent(extent: Vector3): void;
  59711. /**
  59712. * Get the Bounding box extent specified by setDefaultQueryExtent
  59713. * @returns the box extent values
  59714. */
  59715. getDefaultQueryExtent(): Vector3;
  59716. /**
  59717. * Release all resources
  59718. */
  59719. dispose(): void;
  59720. }
  59721. }
  59722. declare module "babylonjs/Navigation/Plugins/index" {
  59723. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  59724. }
  59725. declare module "babylonjs/Navigation/index" {
  59726. export * from "babylonjs/Navigation/INavigationEngine";
  59727. export * from "babylonjs/Navigation/Plugins/index";
  59728. }
  59729. declare module "babylonjs/Offline/database" {
  59730. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  59731. /**
  59732. * Class used to enable access to IndexedDB
  59733. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  59734. */
  59735. export class Database implements IOfflineProvider {
  59736. private _callbackManifestChecked;
  59737. private _currentSceneUrl;
  59738. private _db;
  59739. private _enableSceneOffline;
  59740. private _enableTexturesOffline;
  59741. private _manifestVersionFound;
  59742. private _mustUpdateRessources;
  59743. private _hasReachedQuota;
  59744. private _isSupported;
  59745. private _idbFactory;
  59746. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  59747. private static IsUASupportingBlobStorage;
  59748. /**
  59749. * Gets a boolean indicating if Database storate is enabled (off by default)
  59750. */
  59751. static IDBStorageEnabled: boolean;
  59752. /**
  59753. * Gets a boolean indicating if scene must be saved in the database
  59754. */
  59755. readonly enableSceneOffline: boolean;
  59756. /**
  59757. * Gets a boolean indicating if textures must be saved in the database
  59758. */
  59759. readonly enableTexturesOffline: boolean;
  59760. /**
  59761. * Creates a new Database
  59762. * @param urlToScene defines the url to load the scene
  59763. * @param callbackManifestChecked defines the callback to use when manifest is checked
  59764. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  59765. */
  59766. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  59767. private static _ParseURL;
  59768. private static _ReturnFullUrlLocation;
  59769. private _checkManifestFile;
  59770. /**
  59771. * Open the database and make it available
  59772. * @param successCallback defines the callback to call on success
  59773. * @param errorCallback defines the callback to call on error
  59774. */
  59775. open(successCallback: () => void, errorCallback: () => void): void;
  59776. /**
  59777. * Loads an image from the database
  59778. * @param url defines the url to load from
  59779. * @param image defines the target DOM image
  59780. */
  59781. loadImage(url: string, image: HTMLImageElement): void;
  59782. private _loadImageFromDBAsync;
  59783. private _saveImageIntoDBAsync;
  59784. private _checkVersionFromDB;
  59785. private _loadVersionFromDBAsync;
  59786. private _saveVersionIntoDBAsync;
  59787. /**
  59788. * Loads a file from database
  59789. * @param url defines the URL to load from
  59790. * @param sceneLoaded defines a callback to call on success
  59791. * @param progressCallBack defines a callback to call when progress changed
  59792. * @param errorCallback defines a callback to call on error
  59793. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  59794. */
  59795. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  59796. private _loadFileAsync;
  59797. private _saveFileAsync;
  59798. /**
  59799. * Validates if xhr data is correct
  59800. * @param xhr defines the request to validate
  59801. * @param dataType defines the expected data type
  59802. * @returns true if data is correct
  59803. */
  59804. private static _ValidateXHRData;
  59805. }
  59806. }
  59807. declare module "babylonjs/Offline/index" {
  59808. export * from "babylonjs/Offline/database";
  59809. export * from "babylonjs/Offline/IOfflineProvider";
  59810. }
  59811. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  59812. /** @hidden */
  59813. export var gpuUpdateParticlesPixelShader: {
  59814. name: string;
  59815. shader: string;
  59816. };
  59817. }
  59818. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  59819. /** @hidden */
  59820. export var gpuUpdateParticlesVertexShader: {
  59821. name: string;
  59822. shader: string;
  59823. };
  59824. }
  59825. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  59826. /** @hidden */
  59827. export var clipPlaneFragmentDeclaration2: {
  59828. name: string;
  59829. shader: string;
  59830. };
  59831. }
  59832. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  59833. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  59834. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59835. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59836. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59837. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59838. /** @hidden */
  59839. export var gpuRenderParticlesPixelShader: {
  59840. name: string;
  59841. shader: string;
  59842. };
  59843. }
  59844. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  59845. /** @hidden */
  59846. export var clipPlaneVertexDeclaration2: {
  59847. name: string;
  59848. shader: string;
  59849. };
  59850. }
  59851. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  59852. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  59853. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59854. /** @hidden */
  59855. export var gpuRenderParticlesVertexShader: {
  59856. name: string;
  59857. shader: string;
  59858. };
  59859. }
  59860. declare module "babylonjs/Particles/gpuParticleSystem" {
  59861. import { Nullable } from "babylonjs/types";
  59862. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  59863. import { Observable } from "babylonjs/Misc/observable";
  59864. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59865. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59866. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  59867. import { Scene, IDisposable } from "babylonjs/scene";
  59868. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  59869. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59870. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  59871. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  59872. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  59873. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  59874. /**
  59875. * This represents a GPU particle system in Babylon
  59876. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  59877. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  59878. */
  59879. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  59880. /**
  59881. * The layer mask we are rendering the particles through.
  59882. */
  59883. layerMask: number;
  59884. private _capacity;
  59885. private _activeCount;
  59886. private _currentActiveCount;
  59887. private _accumulatedCount;
  59888. private _renderEffect;
  59889. private _updateEffect;
  59890. private _buffer0;
  59891. private _buffer1;
  59892. private _spriteBuffer;
  59893. private _updateVAO;
  59894. private _renderVAO;
  59895. private _targetIndex;
  59896. private _sourceBuffer;
  59897. private _targetBuffer;
  59898. private _engine;
  59899. private _currentRenderId;
  59900. private _started;
  59901. private _stopped;
  59902. private _timeDelta;
  59903. private _randomTexture;
  59904. private _randomTexture2;
  59905. private _attributesStrideSize;
  59906. private _updateEffectOptions;
  59907. private _randomTextureSize;
  59908. private _actualFrame;
  59909. private readonly _rawTextureWidth;
  59910. /**
  59911. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  59912. */
  59913. static readonly IsSupported: boolean;
  59914. /**
  59915. * An event triggered when the system is disposed.
  59916. */
  59917. onDisposeObservable: Observable<GPUParticleSystem>;
  59918. /**
  59919. * Gets the maximum number of particles active at the same time.
  59920. * @returns The max number of active particles.
  59921. */
  59922. getCapacity(): number;
  59923. /**
  59924. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  59925. * to override the particles.
  59926. */
  59927. forceDepthWrite: boolean;
  59928. /**
  59929. * Gets or set the number of active particles
  59930. */
  59931. activeParticleCount: number;
  59932. private _preWarmDone;
  59933. /**
  59934. * Is this system ready to be used/rendered
  59935. * @return true if the system is ready
  59936. */
  59937. isReady(): boolean;
  59938. /**
  59939. * Gets if the system has been started. (Note: this will still be true after stop is called)
  59940. * @returns True if it has been started, otherwise false.
  59941. */
  59942. isStarted(): boolean;
  59943. /**
  59944. * Starts the particle system and begins to emit
  59945. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  59946. */
  59947. start(delay?: number): void;
  59948. /**
  59949. * Stops the particle system.
  59950. */
  59951. stop(): void;
  59952. /**
  59953. * Remove all active particles
  59954. */
  59955. reset(): void;
  59956. /**
  59957. * Returns the string "GPUParticleSystem"
  59958. * @returns a string containing the class name
  59959. */
  59960. getClassName(): string;
  59961. private _colorGradientsTexture;
  59962. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  59963. /**
  59964. * Adds a new color gradient
  59965. * @param gradient defines the gradient to use (between 0 and 1)
  59966. * @param color1 defines the color to affect to the specified gradient
  59967. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  59968. * @returns the current particle system
  59969. */
  59970. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  59971. /**
  59972. * Remove a specific color gradient
  59973. * @param gradient defines the gradient to remove
  59974. * @returns the current particle system
  59975. */
  59976. removeColorGradient(gradient: number): GPUParticleSystem;
  59977. private _angularSpeedGradientsTexture;
  59978. private _sizeGradientsTexture;
  59979. private _velocityGradientsTexture;
  59980. private _limitVelocityGradientsTexture;
  59981. private _dragGradientsTexture;
  59982. private _addFactorGradient;
  59983. /**
  59984. * Adds a new size gradient
  59985. * @param gradient defines the gradient to use (between 0 and 1)
  59986. * @param factor defines the size factor to affect to the specified gradient
  59987. * @returns the current particle system
  59988. */
  59989. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  59990. /**
  59991. * Remove a specific size gradient
  59992. * @param gradient defines the gradient to remove
  59993. * @returns the current particle system
  59994. */
  59995. removeSizeGradient(gradient: number): GPUParticleSystem;
  59996. /**
  59997. * Adds a new angular speed gradient
  59998. * @param gradient defines the gradient to use (between 0 and 1)
  59999. * @param factor defines the angular speed to affect to the specified gradient
  60000. * @returns the current particle system
  60001. */
  60002. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60003. /**
  60004. * Remove a specific angular speed gradient
  60005. * @param gradient defines the gradient to remove
  60006. * @returns the current particle system
  60007. */
  60008. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60009. /**
  60010. * Adds a new velocity gradient
  60011. * @param gradient defines the gradient to use (between 0 and 1)
  60012. * @param factor defines the velocity to affect to the specified gradient
  60013. * @returns the current particle system
  60014. */
  60015. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60016. /**
  60017. * Remove a specific velocity gradient
  60018. * @param gradient defines the gradient to remove
  60019. * @returns the current particle system
  60020. */
  60021. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60022. /**
  60023. * Adds a new limit velocity gradient
  60024. * @param gradient defines the gradient to use (between 0 and 1)
  60025. * @param factor defines the limit velocity value to affect to the specified gradient
  60026. * @returns the current particle system
  60027. */
  60028. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60029. /**
  60030. * Remove a specific limit velocity gradient
  60031. * @param gradient defines the gradient to remove
  60032. * @returns the current particle system
  60033. */
  60034. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60035. /**
  60036. * Adds a new drag gradient
  60037. * @param gradient defines the gradient to use (between 0 and 1)
  60038. * @param factor defines the drag value to affect to the specified gradient
  60039. * @returns the current particle system
  60040. */
  60041. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60042. /**
  60043. * Remove a specific drag gradient
  60044. * @param gradient defines the gradient to remove
  60045. * @returns the current particle system
  60046. */
  60047. removeDragGradient(gradient: number): GPUParticleSystem;
  60048. /**
  60049. * Not supported by GPUParticleSystem
  60050. * @param gradient defines the gradient to use (between 0 and 1)
  60051. * @param factor defines the emit rate value to affect to the specified gradient
  60052. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60053. * @returns the current particle system
  60054. */
  60055. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60056. /**
  60057. * Not supported by GPUParticleSystem
  60058. * @param gradient defines the gradient to remove
  60059. * @returns the current particle system
  60060. */
  60061. removeEmitRateGradient(gradient: number): IParticleSystem;
  60062. /**
  60063. * Not supported by GPUParticleSystem
  60064. * @param gradient defines the gradient to use (between 0 and 1)
  60065. * @param factor defines the start size value to affect to the specified gradient
  60066. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60067. * @returns the current particle system
  60068. */
  60069. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60070. /**
  60071. * Not supported by GPUParticleSystem
  60072. * @param gradient defines the gradient to remove
  60073. * @returns the current particle system
  60074. */
  60075. removeStartSizeGradient(gradient: number): IParticleSystem;
  60076. /**
  60077. * Not supported by GPUParticleSystem
  60078. * @param gradient defines the gradient to use (between 0 and 1)
  60079. * @param min defines the color remap minimal range
  60080. * @param max defines the color remap maximal range
  60081. * @returns the current particle system
  60082. */
  60083. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60084. /**
  60085. * Not supported by GPUParticleSystem
  60086. * @param gradient defines the gradient to remove
  60087. * @returns the current particle system
  60088. */
  60089. removeColorRemapGradient(): IParticleSystem;
  60090. /**
  60091. * Not supported by GPUParticleSystem
  60092. * @param gradient defines the gradient to use (between 0 and 1)
  60093. * @param min defines the alpha remap minimal range
  60094. * @param max defines the alpha remap maximal range
  60095. * @returns the current particle system
  60096. */
  60097. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60098. /**
  60099. * Not supported by GPUParticleSystem
  60100. * @param gradient defines the gradient to remove
  60101. * @returns the current particle system
  60102. */
  60103. removeAlphaRemapGradient(): IParticleSystem;
  60104. /**
  60105. * Not supported by GPUParticleSystem
  60106. * @param gradient defines the gradient to use (between 0 and 1)
  60107. * @param color defines the color to affect to the specified gradient
  60108. * @returns the current particle system
  60109. */
  60110. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60111. /**
  60112. * Not supported by GPUParticleSystem
  60113. * @param gradient defines the gradient to remove
  60114. * @returns the current particle system
  60115. */
  60116. removeRampGradient(): IParticleSystem;
  60117. /**
  60118. * Not supported by GPUParticleSystem
  60119. * @returns the list of ramp gradients
  60120. */
  60121. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60122. /**
  60123. * Not supported by GPUParticleSystem
  60124. * Gets or sets a boolean indicating that ramp gradients must be used
  60125. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60126. */
  60127. useRampGradients: boolean;
  60128. /**
  60129. * Not supported by GPUParticleSystem
  60130. * @param gradient defines the gradient to use (between 0 and 1)
  60131. * @param factor defines the life time factor to affect to the specified gradient
  60132. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60133. * @returns the current particle system
  60134. */
  60135. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60136. /**
  60137. * Not supported by GPUParticleSystem
  60138. * @param gradient defines the gradient to remove
  60139. * @returns the current particle system
  60140. */
  60141. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60142. /**
  60143. * Instantiates a GPU particle system.
  60144. * 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.
  60145. * @param name The name of the particle system
  60146. * @param options The options used to create the system
  60147. * @param scene The scene the particle system belongs to
  60148. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60149. */
  60150. constructor(name: string, options: Partial<{
  60151. capacity: number;
  60152. randomTextureSize: number;
  60153. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60154. protected _reset(): void;
  60155. private _createUpdateVAO;
  60156. private _createRenderVAO;
  60157. private _initialize;
  60158. /** @hidden */
  60159. _recreateUpdateEffect(): void;
  60160. /** @hidden */
  60161. _recreateRenderEffect(): void;
  60162. /**
  60163. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60164. * @param preWarm defines if we are in the pre-warmimg phase
  60165. */
  60166. animate(preWarm?: boolean): void;
  60167. private _createFactorGradientTexture;
  60168. private _createSizeGradientTexture;
  60169. private _createAngularSpeedGradientTexture;
  60170. private _createVelocityGradientTexture;
  60171. private _createLimitVelocityGradientTexture;
  60172. private _createDragGradientTexture;
  60173. private _createColorGradientTexture;
  60174. /**
  60175. * Renders the particle system in its current state
  60176. * @param preWarm defines if the system should only update the particles but not render them
  60177. * @returns the current number of particles
  60178. */
  60179. render(preWarm?: boolean): number;
  60180. /**
  60181. * Rebuilds the particle system
  60182. */
  60183. rebuild(): void;
  60184. private _releaseBuffers;
  60185. private _releaseVAOs;
  60186. /**
  60187. * Disposes the particle system and free the associated resources
  60188. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  60189. */
  60190. dispose(disposeTexture?: boolean): void;
  60191. /**
  60192. * Clones the particle system.
  60193. * @param name The name of the cloned object
  60194. * @param newEmitter The new emitter to use
  60195. * @returns the cloned particle system
  60196. */
  60197. clone(name: string, newEmitter: any): GPUParticleSystem;
  60198. /**
  60199. * Serializes the particle system to a JSON object.
  60200. * @returns the JSON object
  60201. */
  60202. serialize(): any;
  60203. /**
  60204. * Parses a JSON object to create a GPU particle system.
  60205. * @param parsedParticleSystem The JSON object to parse
  60206. * @param scene The scene to create the particle system in
  60207. * @param rootUrl The root url to use to load external dependencies like texture
  60208. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  60209. * @returns the parsed GPU particle system
  60210. */
  60211. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  60212. }
  60213. }
  60214. declare module "babylonjs/Particles/particleSystemSet" {
  60215. import { Nullable } from "babylonjs/types";
  60216. import { Color3 } from "babylonjs/Maths/math.color";
  60217. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60218. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60219. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60220. import { Scene, IDisposable } from "babylonjs/scene";
  60221. /**
  60222. * Represents a set of particle systems working together to create a specific effect
  60223. */
  60224. export class ParticleSystemSet implements IDisposable {
  60225. private _emitterCreationOptions;
  60226. private _emitterNode;
  60227. /**
  60228. * Gets the particle system list
  60229. */
  60230. systems: IParticleSystem[];
  60231. /**
  60232. * Gets the emitter node used with this set
  60233. */
  60234. readonly emitterNode: Nullable<TransformNode>;
  60235. /**
  60236. * Creates a new emitter mesh as a sphere
  60237. * @param options defines the options used to create the sphere
  60238. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  60239. * @param scene defines the hosting scene
  60240. */
  60241. setEmitterAsSphere(options: {
  60242. diameter: number;
  60243. segments: number;
  60244. color: Color3;
  60245. }, renderingGroupId: number, scene: Scene): void;
  60246. /**
  60247. * Starts all particle systems of the set
  60248. * @param emitter defines an optional mesh to use as emitter for the particle systems
  60249. */
  60250. start(emitter?: AbstractMesh): void;
  60251. /**
  60252. * Release all associated resources
  60253. */
  60254. dispose(): void;
  60255. /**
  60256. * Serialize the set into a JSON compatible object
  60257. * @returns a JSON compatible representation of the set
  60258. */
  60259. serialize(): any;
  60260. /**
  60261. * Parse a new ParticleSystemSet from a serialized source
  60262. * @param data defines a JSON compatible representation of the set
  60263. * @param scene defines the hosting scene
  60264. * @param gpu defines if we want GPU particles or CPU particles
  60265. * @returns a new ParticleSystemSet
  60266. */
  60267. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  60268. }
  60269. }
  60270. declare module "babylonjs/Particles/particleHelper" {
  60271. import { Nullable } from "babylonjs/types";
  60272. import { Scene } from "babylonjs/scene";
  60273. import { Vector3 } from "babylonjs/Maths/math.vector";
  60274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60275. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60276. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  60277. /**
  60278. * This class is made for on one-liner static method to help creating particle system set.
  60279. */
  60280. export class ParticleHelper {
  60281. /**
  60282. * Gets or sets base Assets URL
  60283. */
  60284. static BaseAssetsUrl: string;
  60285. /**
  60286. * Create a default particle system that you can tweak
  60287. * @param emitter defines the emitter to use
  60288. * @param capacity defines the system capacity (default is 500 particles)
  60289. * @param scene defines the hosting scene
  60290. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  60291. * @returns the new Particle system
  60292. */
  60293. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  60294. /**
  60295. * This is the main static method (one-liner) of this helper to create different particle systems
  60296. * @param type This string represents the type to the particle system to create
  60297. * @param scene The scene where the particle system should live
  60298. * @param gpu If the system will use gpu
  60299. * @returns the ParticleSystemSet created
  60300. */
  60301. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  60302. /**
  60303. * Static function used to export a particle system to a ParticleSystemSet variable.
  60304. * Please note that the emitter shape is not exported
  60305. * @param systems defines the particle systems to export
  60306. * @returns the created particle system set
  60307. */
  60308. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  60309. }
  60310. }
  60311. declare module "babylonjs/Particles/particleSystemComponent" {
  60312. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60313. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  60314. import "babylonjs/Shaders/particles.vertex";
  60315. module "babylonjs/Engines/engine" {
  60316. interface Engine {
  60317. /**
  60318. * Create an effect to use with particle systems.
  60319. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  60320. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  60321. * @param uniformsNames defines a list of attribute names
  60322. * @param samplers defines an array of string used to represent textures
  60323. * @param defines defines the string containing the defines to use to compile the shaders
  60324. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  60325. * @param onCompiled defines a function to call when the effect creation is successful
  60326. * @param onError defines a function to call when the effect creation has failed
  60327. * @returns the new Effect
  60328. */
  60329. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  60330. }
  60331. }
  60332. module "babylonjs/Meshes/mesh" {
  60333. interface Mesh {
  60334. /**
  60335. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  60336. * @returns an array of IParticleSystem
  60337. */
  60338. getEmittedParticleSystems(): IParticleSystem[];
  60339. /**
  60340. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  60341. * @returns an array of IParticleSystem
  60342. */
  60343. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  60344. }
  60345. }
  60346. /**
  60347. * @hidden
  60348. */
  60349. export var _IDoNeedToBeInTheBuild: number;
  60350. }
  60351. declare module "babylonjs/Particles/index" {
  60352. export * from "babylonjs/Particles/baseParticleSystem";
  60353. export * from "babylonjs/Particles/EmitterTypes/index";
  60354. export * from "babylonjs/Particles/gpuParticleSystem";
  60355. export * from "babylonjs/Particles/IParticleSystem";
  60356. export * from "babylonjs/Particles/particle";
  60357. export * from "babylonjs/Particles/particleHelper";
  60358. export * from "babylonjs/Particles/particleSystem";
  60359. export * from "babylonjs/Particles/particleSystemComponent";
  60360. export * from "babylonjs/Particles/particleSystemSet";
  60361. export * from "babylonjs/Particles/solidParticle";
  60362. export * from "babylonjs/Particles/solidParticleSystem";
  60363. export * from "babylonjs/Particles/subEmitter";
  60364. }
  60365. declare module "babylonjs/Physics/physicsEngineComponent" {
  60366. import { Nullable } from "babylonjs/types";
  60367. import { Observable, Observer } from "babylonjs/Misc/observable";
  60368. import { Vector3 } from "babylonjs/Maths/math.vector";
  60369. import { Mesh } from "babylonjs/Meshes/mesh";
  60370. import { ISceneComponent } from "babylonjs/sceneComponent";
  60371. import { Scene } from "babylonjs/scene";
  60372. import { Node } from "babylonjs/node";
  60373. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  60374. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60375. module "babylonjs/scene" {
  60376. interface Scene {
  60377. /** @hidden (Backing field) */
  60378. _physicsEngine: Nullable<IPhysicsEngine>;
  60379. /**
  60380. * Gets the current physics engine
  60381. * @returns a IPhysicsEngine or null if none attached
  60382. */
  60383. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60384. /**
  60385. * Enables physics to the current scene
  60386. * @param gravity defines the scene's gravity for the physics engine
  60387. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60388. * @return a boolean indicating if the physics engine was initialized
  60389. */
  60390. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60391. /**
  60392. * Disables and disposes the physics engine associated with the scene
  60393. */
  60394. disablePhysicsEngine(): void;
  60395. /**
  60396. * Gets a boolean indicating if there is an active physics engine
  60397. * @returns a boolean indicating if there is an active physics engine
  60398. */
  60399. isPhysicsEnabled(): boolean;
  60400. /**
  60401. * Deletes a physics compound impostor
  60402. * @param compound defines the compound to delete
  60403. */
  60404. deleteCompoundImpostor(compound: any): void;
  60405. /**
  60406. * An event triggered when physic simulation is about to be run
  60407. */
  60408. onBeforePhysicsObservable: Observable<Scene>;
  60409. /**
  60410. * An event triggered when physic simulation has been done
  60411. */
  60412. onAfterPhysicsObservable: Observable<Scene>;
  60413. }
  60414. }
  60415. module "babylonjs/Meshes/abstractMesh" {
  60416. interface AbstractMesh {
  60417. /** @hidden */
  60418. _physicsImpostor: Nullable<PhysicsImpostor>;
  60419. /**
  60420. * Gets or sets impostor used for physic simulation
  60421. * @see http://doc.babylonjs.com/features/physics_engine
  60422. */
  60423. physicsImpostor: Nullable<PhysicsImpostor>;
  60424. /**
  60425. * Gets the current physics impostor
  60426. * @see http://doc.babylonjs.com/features/physics_engine
  60427. * @returns a physics impostor or null
  60428. */
  60429. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60430. /** Apply a physic impulse to the mesh
  60431. * @param force defines the force to apply
  60432. * @param contactPoint defines where to apply the force
  60433. * @returns the current mesh
  60434. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60435. */
  60436. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  60437. /**
  60438. * Creates a physic joint between two meshes
  60439. * @param otherMesh defines the other mesh to use
  60440. * @param pivot1 defines the pivot to use on this mesh
  60441. * @param pivot2 defines the pivot to use on the other mesh
  60442. * @param options defines additional options (can be plugin dependent)
  60443. * @returns the current mesh
  60444. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  60445. */
  60446. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  60447. /** @hidden */
  60448. _disposePhysicsObserver: Nullable<Observer<Node>>;
  60449. }
  60450. }
  60451. /**
  60452. * Defines the physics engine scene component responsible to manage a physics engine
  60453. */
  60454. export class PhysicsEngineSceneComponent implements ISceneComponent {
  60455. /**
  60456. * The component name helpful to identify the component in the list of scene components.
  60457. */
  60458. readonly name: string;
  60459. /**
  60460. * The scene the component belongs to.
  60461. */
  60462. scene: Scene;
  60463. /**
  60464. * Creates a new instance of the component for the given scene
  60465. * @param scene Defines the scene to register the component in
  60466. */
  60467. constructor(scene: Scene);
  60468. /**
  60469. * Registers the component in a given scene
  60470. */
  60471. register(): void;
  60472. /**
  60473. * Rebuilds the elements related to this component in case of
  60474. * context lost for instance.
  60475. */
  60476. rebuild(): void;
  60477. /**
  60478. * Disposes the component and the associated ressources
  60479. */
  60480. dispose(): void;
  60481. }
  60482. }
  60483. declare module "babylonjs/Physics/physicsHelper" {
  60484. import { Nullable } from "babylonjs/types";
  60485. import { Vector3 } from "babylonjs/Maths/math.vector";
  60486. import { Mesh } from "babylonjs/Meshes/mesh";
  60487. import { Scene } from "babylonjs/scene";
  60488. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60489. /**
  60490. * A helper for physics simulations
  60491. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60492. */
  60493. export class PhysicsHelper {
  60494. private _scene;
  60495. private _physicsEngine;
  60496. /**
  60497. * Initializes the Physics helper
  60498. * @param scene Babylon.js scene
  60499. */
  60500. constructor(scene: Scene);
  60501. /**
  60502. * Applies a radial explosion impulse
  60503. * @param origin the origin of the explosion
  60504. * @param radiusOrEventOptions the radius or the options of radial explosion
  60505. * @param strength the explosion strength
  60506. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60507. * @returns A physics radial explosion event, or null
  60508. */
  60509. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60510. /**
  60511. * Applies a radial explosion force
  60512. * @param origin the origin of the explosion
  60513. * @param radiusOrEventOptions the radius or the options of radial explosion
  60514. * @param strength the explosion strength
  60515. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60516. * @returns A physics radial explosion event, or null
  60517. */
  60518. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60519. /**
  60520. * Creates a gravitational field
  60521. * @param origin the origin of the explosion
  60522. * @param radiusOrEventOptions the radius or the options of radial explosion
  60523. * @param strength the explosion strength
  60524. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60525. * @returns A physics gravitational field event, or null
  60526. */
  60527. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  60528. /**
  60529. * Creates a physics updraft event
  60530. * @param origin the origin of the updraft
  60531. * @param radiusOrEventOptions the radius or the options of the updraft
  60532. * @param strength the strength of the updraft
  60533. * @param height the height of the updraft
  60534. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  60535. * @returns A physics updraft event, or null
  60536. */
  60537. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  60538. /**
  60539. * Creates a physics vortex event
  60540. * @param origin the of the vortex
  60541. * @param radiusOrEventOptions the radius or the options of the vortex
  60542. * @param strength the strength of the vortex
  60543. * @param height the height of the vortex
  60544. * @returns a Physics vortex event, or null
  60545. * A physics vortex event or null
  60546. */
  60547. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  60548. }
  60549. /**
  60550. * Represents a physics radial explosion event
  60551. */
  60552. class PhysicsRadialExplosionEvent {
  60553. private _scene;
  60554. private _options;
  60555. private _sphere;
  60556. private _dataFetched;
  60557. /**
  60558. * Initializes a radial explosioin event
  60559. * @param _scene BabylonJS scene
  60560. * @param _options The options for the vortex event
  60561. */
  60562. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  60563. /**
  60564. * Returns the data related to the radial explosion event (sphere).
  60565. * @returns The radial explosion event data
  60566. */
  60567. getData(): PhysicsRadialExplosionEventData;
  60568. /**
  60569. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  60570. * @param impostor A physics imposter
  60571. * @param origin the origin of the explosion
  60572. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  60573. */
  60574. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  60575. /**
  60576. * Triggers affecterd impostors callbacks
  60577. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  60578. */
  60579. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  60580. /**
  60581. * Disposes the sphere.
  60582. * @param force Specifies if the sphere should be disposed by force
  60583. */
  60584. dispose(force?: boolean): void;
  60585. /*** Helpers ***/
  60586. private _prepareSphere;
  60587. private _intersectsWithSphere;
  60588. }
  60589. /**
  60590. * Represents a gravitational field event
  60591. */
  60592. class PhysicsGravitationalFieldEvent {
  60593. private _physicsHelper;
  60594. private _scene;
  60595. private _origin;
  60596. private _options;
  60597. private _tickCallback;
  60598. private _sphere;
  60599. private _dataFetched;
  60600. /**
  60601. * Initializes the physics gravitational field event
  60602. * @param _physicsHelper A physics helper
  60603. * @param _scene BabylonJS scene
  60604. * @param _origin The origin position of the gravitational field event
  60605. * @param _options The options for the vortex event
  60606. */
  60607. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  60608. /**
  60609. * Returns the data related to the gravitational field event (sphere).
  60610. * @returns A gravitational field event
  60611. */
  60612. getData(): PhysicsGravitationalFieldEventData;
  60613. /**
  60614. * Enables the gravitational field.
  60615. */
  60616. enable(): void;
  60617. /**
  60618. * Disables the gravitational field.
  60619. */
  60620. disable(): void;
  60621. /**
  60622. * Disposes the sphere.
  60623. * @param force The force to dispose from the gravitational field event
  60624. */
  60625. dispose(force?: boolean): void;
  60626. private _tick;
  60627. }
  60628. /**
  60629. * Represents a physics updraft event
  60630. */
  60631. class PhysicsUpdraftEvent {
  60632. private _scene;
  60633. private _origin;
  60634. private _options;
  60635. private _physicsEngine;
  60636. private _originTop;
  60637. private _originDirection;
  60638. private _tickCallback;
  60639. private _cylinder;
  60640. private _cylinderPosition;
  60641. private _dataFetched;
  60642. /**
  60643. * Initializes the physics updraft event
  60644. * @param _scene BabylonJS scene
  60645. * @param _origin The origin position of the updraft
  60646. * @param _options The options for the updraft event
  60647. */
  60648. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  60649. /**
  60650. * Returns the data related to the updraft event (cylinder).
  60651. * @returns A physics updraft event
  60652. */
  60653. getData(): PhysicsUpdraftEventData;
  60654. /**
  60655. * Enables the updraft.
  60656. */
  60657. enable(): void;
  60658. /**
  60659. * Disables the updraft.
  60660. */
  60661. disable(): void;
  60662. /**
  60663. * Disposes the cylinder.
  60664. * @param force Specifies if the updraft should be disposed by force
  60665. */
  60666. dispose(force?: boolean): void;
  60667. private getImpostorHitData;
  60668. private _tick;
  60669. /*** Helpers ***/
  60670. private _prepareCylinder;
  60671. private _intersectsWithCylinder;
  60672. }
  60673. /**
  60674. * Represents a physics vortex event
  60675. */
  60676. class PhysicsVortexEvent {
  60677. private _scene;
  60678. private _origin;
  60679. private _options;
  60680. private _physicsEngine;
  60681. private _originTop;
  60682. private _tickCallback;
  60683. private _cylinder;
  60684. private _cylinderPosition;
  60685. private _dataFetched;
  60686. /**
  60687. * Initializes the physics vortex event
  60688. * @param _scene The BabylonJS scene
  60689. * @param _origin The origin position of the vortex
  60690. * @param _options The options for the vortex event
  60691. */
  60692. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  60693. /**
  60694. * Returns the data related to the vortex event (cylinder).
  60695. * @returns The physics vortex event data
  60696. */
  60697. getData(): PhysicsVortexEventData;
  60698. /**
  60699. * Enables the vortex.
  60700. */
  60701. enable(): void;
  60702. /**
  60703. * Disables the cortex.
  60704. */
  60705. disable(): void;
  60706. /**
  60707. * Disposes the sphere.
  60708. * @param force
  60709. */
  60710. dispose(force?: boolean): void;
  60711. private getImpostorHitData;
  60712. private _tick;
  60713. /*** Helpers ***/
  60714. private _prepareCylinder;
  60715. private _intersectsWithCylinder;
  60716. }
  60717. /**
  60718. * Options fot the radial explosion event
  60719. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60720. */
  60721. export class PhysicsRadialExplosionEventOptions {
  60722. /**
  60723. * The radius of the sphere for the radial explosion.
  60724. */
  60725. radius: number;
  60726. /**
  60727. * The strenth of the explosion.
  60728. */
  60729. strength: number;
  60730. /**
  60731. * The strenght of the force in correspondence to the distance of the affected object
  60732. */
  60733. falloff: PhysicsRadialImpulseFalloff;
  60734. /**
  60735. * Sphere options for the radial explosion.
  60736. */
  60737. sphere: {
  60738. segments: number;
  60739. diameter: number;
  60740. };
  60741. /**
  60742. * Sphere options for the radial explosion.
  60743. */
  60744. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  60745. }
  60746. /**
  60747. * Options fot the updraft event
  60748. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60749. */
  60750. export class PhysicsUpdraftEventOptions {
  60751. /**
  60752. * The radius of the cylinder for the vortex
  60753. */
  60754. radius: number;
  60755. /**
  60756. * The strenth of the updraft.
  60757. */
  60758. strength: number;
  60759. /**
  60760. * The height of the cylinder for the updraft.
  60761. */
  60762. height: number;
  60763. /**
  60764. * The mode for the the updraft.
  60765. */
  60766. updraftMode: PhysicsUpdraftMode;
  60767. }
  60768. /**
  60769. * Options fot the vortex event
  60770. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60771. */
  60772. export class PhysicsVortexEventOptions {
  60773. /**
  60774. * The radius of the cylinder for the vortex
  60775. */
  60776. radius: number;
  60777. /**
  60778. * The strenth of the vortex.
  60779. */
  60780. strength: number;
  60781. /**
  60782. * The height of the cylinder for the vortex.
  60783. */
  60784. height: number;
  60785. /**
  60786. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  60787. */
  60788. centripetalForceThreshold: number;
  60789. /**
  60790. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  60791. */
  60792. centripetalForceMultiplier: number;
  60793. /**
  60794. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  60795. */
  60796. centrifugalForceMultiplier: number;
  60797. /**
  60798. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  60799. */
  60800. updraftForceMultiplier: number;
  60801. }
  60802. /**
  60803. * The strenght of the force in correspondence to the distance of the affected object
  60804. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60805. */
  60806. export enum PhysicsRadialImpulseFalloff {
  60807. /** Defines that impulse is constant in strength across it's whole radius */
  60808. Constant = 0,
  60809. /** Defines that impulse gets weaker if it's further from the origin */
  60810. Linear = 1
  60811. }
  60812. /**
  60813. * The strength of the force in correspondence to the distance of the affected object
  60814. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60815. */
  60816. export enum PhysicsUpdraftMode {
  60817. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  60818. Center = 0,
  60819. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  60820. Perpendicular = 1
  60821. }
  60822. /**
  60823. * Interface for a physics hit data
  60824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60825. */
  60826. export interface PhysicsHitData {
  60827. /**
  60828. * The force applied at the contact point
  60829. */
  60830. force: Vector3;
  60831. /**
  60832. * The contact point
  60833. */
  60834. contactPoint: Vector3;
  60835. /**
  60836. * The distance from the origin to the contact point
  60837. */
  60838. distanceFromOrigin: number;
  60839. }
  60840. /**
  60841. * Interface for radial explosion event data
  60842. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60843. */
  60844. export interface PhysicsRadialExplosionEventData {
  60845. /**
  60846. * A sphere used for the radial explosion event
  60847. */
  60848. sphere: Mesh;
  60849. }
  60850. /**
  60851. * Interface for gravitational field event data
  60852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60853. */
  60854. export interface PhysicsGravitationalFieldEventData {
  60855. /**
  60856. * A sphere mesh used for the gravitational field event
  60857. */
  60858. sphere: Mesh;
  60859. }
  60860. /**
  60861. * Interface for updraft event data
  60862. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60863. */
  60864. export interface PhysicsUpdraftEventData {
  60865. /**
  60866. * A cylinder used for the updraft event
  60867. */
  60868. cylinder: Mesh;
  60869. }
  60870. /**
  60871. * Interface for vortex event data
  60872. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60873. */
  60874. export interface PhysicsVortexEventData {
  60875. /**
  60876. * A cylinder used for the vortex event
  60877. */
  60878. cylinder: Mesh;
  60879. }
  60880. /**
  60881. * Interface for an affected physics impostor
  60882. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60883. */
  60884. export interface PhysicsAffectedImpostorWithData {
  60885. /**
  60886. * The impostor affected by the effect
  60887. */
  60888. impostor: PhysicsImpostor;
  60889. /**
  60890. * The data about the hit/horce from the explosion
  60891. */
  60892. hitData: PhysicsHitData;
  60893. }
  60894. }
  60895. declare module "babylonjs/Physics/Plugins/index" {
  60896. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  60897. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  60898. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  60899. }
  60900. declare module "babylonjs/Physics/index" {
  60901. export * from "babylonjs/Physics/IPhysicsEngine";
  60902. export * from "babylonjs/Physics/physicsEngine";
  60903. export * from "babylonjs/Physics/physicsEngineComponent";
  60904. export * from "babylonjs/Physics/physicsHelper";
  60905. export * from "babylonjs/Physics/physicsImpostor";
  60906. export * from "babylonjs/Physics/physicsJoint";
  60907. export * from "babylonjs/Physics/Plugins/index";
  60908. }
  60909. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  60910. /** @hidden */
  60911. export var blackAndWhitePixelShader: {
  60912. name: string;
  60913. shader: string;
  60914. };
  60915. }
  60916. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  60917. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60918. import { Camera } from "babylonjs/Cameras/camera";
  60919. import { Engine } from "babylonjs/Engines/engine";
  60920. import "babylonjs/Shaders/blackAndWhite.fragment";
  60921. /**
  60922. * Post process used to render in black and white
  60923. */
  60924. export class BlackAndWhitePostProcess extends PostProcess {
  60925. /**
  60926. * Linear about to convert he result to black and white (default: 1)
  60927. */
  60928. degree: number;
  60929. /**
  60930. * Creates a black and white post process
  60931. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  60932. * @param name The name of the effect.
  60933. * @param options The required width/height ratio to downsize to before computing the render pass.
  60934. * @param camera The camera to apply the render pass to.
  60935. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60936. * @param engine The engine which the post process will be applied. (default: current engine)
  60937. * @param reusable If the post process can be reused on the same frame. (default: false)
  60938. */
  60939. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60940. }
  60941. }
  60942. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  60943. import { Nullable } from "babylonjs/types";
  60944. import { Camera } from "babylonjs/Cameras/camera";
  60945. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60946. import { Engine } from "babylonjs/Engines/engine";
  60947. /**
  60948. * This represents a set of one or more post processes in Babylon.
  60949. * A post process can be used to apply a shader to a texture after it is rendered.
  60950. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60951. */
  60952. export class PostProcessRenderEffect {
  60953. private _postProcesses;
  60954. private _getPostProcesses;
  60955. private _singleInstance;
  60956. private _cameras;
  60957. private _indicesForCamera;
  60958. /**
  60959. * Name of the effect
  60960. * @hidden
  60961. */
  60962. _name: string;
  60963. /**
  60964. * Instantiates a post process render effect.
  60965. * A post process can be used to apply a shader to a texture after it is rendered.
  60966. * @param engine The engine the effect is tied to
  60967. * @param name The name of the effect
  60968. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60969. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60970. */
  60971. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60972. /**
  60973. * Checks if all the post processes in the effect are supported.
  60974. */
  60975. readonly isSupported: boolean;
  60976. /**
  60977. * Updates the current state of the effect
  60978. * @hidden
  60979. */
  60980. _update(): void;
  60981. /**
  60982. * Attaches the effect on cameras
  60983. * @param cameras The camera to attach to.
  60984. * @hidden
  60985. */
  60986. _attachCameras(cameras: Camera): void;
  60987. /**
  60988. * Attaches the effect on cameras
  60989. * @param cameras The camera to attach to.
  60990. * @hidden
  60991. */
  60992. _attachCameras(cameras: Camera[]): void;
  60993. /**
  60994. * Detaches the effect on cameras
  60995. * @param cameras The camera to detatch from.
  60996. * @hidden
  60997. */
  60998. _detachCameras(cameras: Camera): void;
  60999. /**
  61000. * Detatches the effect on cameras
  61001. * @param cameras The camera to detatch from.
  61002. * @hidden
  61003. */
  61004. _detachCameras(cameras: Camera[]): void;
  61005. /**
  61006. * Enables the effect on given cameras
  61007. * @param cameras The camera to enable.
  61008. * @hidden
  61009. */
  61010. _enable(cameras: Camera): void;
  61011. /**
  61012. * Enables the effect on given cameras
  61013. * @param cameras The camera to enable.
  61014. * @hidden
  61015. */
  61016. _enable(cameras: Nullable<Camera[]>): void;
  61017. /**
  61018. * Disables the effect on the given cameras
  61019. * @param cameras The camera to disable.
  61020. * @hidden
  61021. */
  61022. _disable(cameras: Camera): void;
  61023. /**
  61024. * Disables the effect on the given cameras
  61025. * @param cameras The camera to disable.
  61026. * @hidden
  61027. */
  61028. _disable(cameras: Nullable<Camera[]>): void;
  61029. /**
  61030. * Gets a list of the post processes contained in the effect.
  61031. * @param camera The camera to get the post processes on.
  61032. * @returns The list of the post processes in the effect.
  61033. */
  61034. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61035. }
  61036. }
  61037. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  61038. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61039. /** @hidden */
  61040. export var extractHighlightsPixelShader: {
  61041. name: string;
  61042. shader: string;
  61043. };
  61044. }
  61045. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  61046. import { Nullable } from "babylonjs/types";
  61047. import { Camera } from "babylonjs/Cameras/camera";
  61048. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61049. import { Engine } from "babylonjs/Engines/engine";
  61050. import "babylonjs/Shaders/extractHighlights.fragment";
  61051. /**
  61052. * 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.
  61053. */
  61054. export class ExtractHighlightsPostProcess extends PostProcess {
  61055. /**
  61056. * The luminance threshold, pixels below this value will be set to black.
  61057. */
  61058. threshold: number;
  61059. /** @hidden */
  61060. _exposure: number;
  61061. /**
  61062. * Post process which has the input texture to be used when performing highlight extraction
  61063. * @hidden
  61064. */
  61065. _inputPostProcess: Nullable<PostProcess>;
  61066. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61067. }
  61068. }
  61069. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  61070. /** @hidden */
  61071. export var bloomMergePixelShader: {
  61072. name: string;
  61073. shader: string;
  61074. };
  61075. }
  61076. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  61077. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61078. import { Nullable } from "babylonjs/types";
  61079. import { Engine } from "babylonjs/Engines/engine";
  61080. import { Camera } from "babylonjs/Cameras/camera";
  61081. import "babylonjs/Shaders/bloomMerge.fragment";
  61082. /**
  61083. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61084. */
  61085. export class BloomMergePostProcess extends PostProcess {
  61086. /** Weight of the bloom to be added to the original input. */
  61087. weight: number;
  61088. /**
  61089. * Creates a new instance of @see BloomMergePostProcess
  61090. * @param name The name of the effect.
  61091. * @param originalFromInput Post process which's input will be used for the merge.
  61092. * @param blurred Blurred highlights post process which's output will be used.
  61093. * @param weight Weight of the bloom to be added to the original input.
  61094. * @param options The required width/height ratio to downsize to before computing the render pass.
  61095. * @param camera The camera to apply the render pass to.
  61096. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61097. * @param engine The engine which the post process will be applied. (default: current engine)
  61098. * @param reusable If the post process can be reused on the same frame. (default: false)
  61099. * @param textureType Type of textures used when performing the post process. (default: 0)
  61100. * @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)
  61101. */
  61102. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  61103. /** Weight of the bloom to be added to the original input. */
  61104. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61105. }
  61106. }
  61107. declare module "babylonjs/PostProcesses/bloomEffect" {
  61108. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61109. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61110. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61111. import { Camera } from "babylonjs/Cameras/camera";
  61112. import { Scene } from "babylonjs/scene";
  61113. /**
  61114. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  61115. */
  61116. export class BloomEffect extends PostProcessRenderEffect {
  61117. private bloomScale;
  61118. /**
  61119. * @hidden Internal
  61120. */
  61121. _effects: Array<PostProcess>;
  61122. /**
  61123. * @hidden Internal
  61124. */
  61125. _downscale: ExtractHighlightsPostProcess;
  61126. private _blurX;
  61127. private _blurY;
  61128. private _merge;
  61129. /**
  61130. * The luminance threshold to find bright areas of the image to bloom.
  61131. */
  61132. threshold: number;
  61133. /**
  61134. * The strength of the bloom.
  61135. */
  61136. weight: number;
  61137. /**
  61138. * Specifies the size of the bloom blur kernel, relative to the final output size
  61139. */
  61140. kernel: number;
  61141. /**
  61142. * Creates a new instance of @see BloomEffect
  61143. * @param scene The scene the effect belongs to.
  61144. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  61145. * @param bloomKernel The size of the kernel to be used when applying the blur.
  61146. * @param bloomWeight The the strength of bloom.
  61147. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61148. * @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)
  61149. */
  61150. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  61151. /**
  61152. * Disposes each of the internal effects for a given camera.
  61153. * @param camera The camera to dispose the effect on.
  61154. */
  61155. disposeEffects(camera: Camera): void;
  61156. /**
  61157. * @hidden Internal
  61158. */
  61159. _updateEffects(): void;
  61160. /**
  61161. * Internal
  61162. * @returns if all the contained post processes are ready.
  61163. * @hidden
  61164. */
  61165. _isReady(): boolean;
  61166. }
  61167. }
  61168. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  61169. /** @hidden */
  61170. export var chromaticAberrationPixelShader: {
  61171. name: string;
  61172. shader: string;
  61173. };
  61174. }
  61175. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  61176. import { Vector2 } from "babylonjs/Maths/math.vector";
  61177. import { Nullable } from "babylonjs/types";
  61178. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61179. import { Camera } from "babylonjs/Cameras/camera";
  61180. import { Engine } from "babylonjs/Engines/engine";
  61181. import "babylonjs/Shaders/chromaticAberration.fragment";
  61182. /**
  61183. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  61184. */
  61185. export class ChromaticAberrationPostProcess extends PostProcess {
  61186. /**
  61187. * The amount of seperation of rgb channels (default: 30)
  61188. */
  61189. aberrationAmount: number;
  61190. /**
  61191. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  61192. */
  61193. radialIntensity: number;
  61194. /**
  61195. * 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))
  61196. */
  61197. direction: Vector2;
  61198. /**
  61199. * 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))
  61200. */
  61201. centerPosition: Vector2;
  61202. /**
  61203. * Creates a new instance ChromaticAberrationPostProcess
  61204. * @param name The name of the effect.
  61205. * @param screenWidth The width of the screen to apply the effect on.
  61206. * @param screenHeight The height of the screen to apply the effect on.
  61207. * @param options The required width/height ratio to downsize to before computing the render pass.
  61208. * @param camera The camera to apply the render pass to.
  61209. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61210. * @param engine The engine which the post process will be applied. (default: current engine)
  61211. * @param reusable If the post process can be reused on the same frame. (default: false)
  61212. * @param textureType Type of textures used when performing the post process. (default: 0)
  61213. * @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)
  61214. */
  61215. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61216. }
  61217. }
  61218. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  61219. /** @hidden */
  61220. export var circleOfConfusionPixelShader: {
  61221. name: string;
  61222. shader: string;
  61223. };
  61224. }
  61225. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  61226. import { Nullable } from "babylonjs/types";
  61227. import { Engine } from "babylonjs/Engines/engine";
  61228. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61229. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61230. import { Camera } from "babylonjs/Cameras/camera";
  61231. import "babylonjs/Shaders/circleOfConfusion.fragment";
  61232. /**
  61233. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  61234. */
  61235. export class CircleOfConfusionPostProcess extends PostProcess {
  61236. /**
  61237. * 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.
  61238. */
  61239. lensSize: number;
  61240. /**
  61241. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61242. */
  61243. fStop: number;
  61244. /**
  61245. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61246. */
  61247. focusDistance: number;
  61248. /**
  61249. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  61250. */
  61251. focalLength: number;
  61252. private _depthTexture;
  61253. /**
  61254. * Creates a new instance CircleOfConfusionPostProcess
  61255. * @param name The name of the effect.
  61256. * @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.
  61257. * @param options The required width/height ratio to downsize to before computing the render pass.
  61258. * @param camera The camera to apply the render pass to.
  61259. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61260. * @param engine The engine which the post process will be applied. (default: current engine)
  61261. * @param reusable If the post process can be reused on the same frame. (default: false)
  61262. * @param textureType Type of textures used when performing the post process. (default: 0)
  61263. * @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)
  61264. */
  61265. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61266. /**
  61267. * 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.
  61268. */
  61269. depthTexture: RenderTargetTexture;
  61270. }
  61271. }
  61272. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  61273. /** @hidden */
  61274. export var colorCorrectionPixelShader: {
  61275. name: string;
  61276. shader: string;
  61277. };
  61278. }
  61279. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  61280. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61281. import { Engine } from "babylonjs/Engines/engine";
  61282. import { Camera } from "babylonjs/Cameras/camera";
  61283. import "babylonjs/Shaders/colorCorrection.fragment";
  61284. /**
  61285. *
  61286. * This post-process allows the modification of rendered colors by using
  61287. * a 'look-up table' (LUT). This effect is also called Color Grading.
  61288. *
  61289. * The object needs to be provided an url to a texture containing the color
  61290. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  61291. * Use an image editing software to tweak the LUT to match your needs.
  61292. *
  61293. * For an example of a color LUT, see here:
  61294. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  61295. * For explanations on color grading, see here:
  61296. * @see http://udn.epicgames.com/Three/ColorGrading.html
  61297. *
  61298. */
  61299. export class ColorCorrectionPostProcess extends PostProcess {
  61300. private _colorTableTexture;
  61301. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61302. }
  61303. }
  61304. declare module "babylonjs/Shaders/convolution.fragment" {
  61305. /** @hidden */
  61306. export var convolutionPixelShader: {
  61307. name: string;
  61308. shader: string;
  61309. };
  61310. }
  61311. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  61312. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61313. import { Nullable } from "babylonjs/types";
  61314. import { Camera } from "babylonjs/Cameras/camera";
  61315. import { Engine } from "babylonjs/Engines/engine";
  61316. import "babylonjs/Shaders/convolution.fragment";
  61317. /**
  61318. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  61319. * input texture to perform effects such as edge detection or sharpening
  61320. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61321. */
  61322. export class ConvolutionPostProcess extends PostProcess {
  61323. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61324. kernel: number[];
  61325. /**
  61326. * Creates a new instance ConvolutionPostProcess
  61327. * @param name The name of the effect.
  61328. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  61329. * @param options The required width/height ratio to downsize to before computing the render pass.
  61330. * @param camera The camera to apply the render pass to.
  61331. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61332. * @param engine The engine which the post process will be applied. (default: current engine)
  61333. * @param reusable If the post process can be reused on the same frame. (default: false)
  61334. * @param textureType Type of textures used when performing the post process. (default: 0)
  61335. */
  61336. constructor(name: string,
  61337. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61338. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61339. /**
  61340. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61341. */
  61342. static EdgeDetect0Kernel: number[];
  61343. /**
  61344. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61345. */
  61346. static EdgeDetect1Kernel: number[];
  61347. /**
  61348. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61349. */
  61350. static EdgeDetect2Kernel: number[];
  61351. /**
  61352. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61353. */
  61354. static SharpenKernel: number[];
  61355. /**
  61356. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61357. */
  61358. static EmbossKernel: number[];
  61359. /**
  61360. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61361. */
  61362. static GaussianKernel: number[];
  61363. }
  61364. }
  61365. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  61366. import { Nullable } from "babylonjs/types";
  61367. import { Vector2 } from "babylonjs/Maths/math.vector";
  61368. import { Camera } from "babylonjs/Cameras/camera";
  61369. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61370. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61371. import { Engine } from "babylonjs/Engines/engine";
  61372. import { Scene } from "babylonjs/scene";
  61373. /**
  61374. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  61375. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  61376. * based on samples that have a large difference in distance than the center pixel.
  61377. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  61378. */
  61379. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  61380. direction: Vector2;
  61381. /**
  61382. * Creates a new instance CircleOfConfusionPostProcess
  61383. * @param name The name of the effect.
  61384. * @param scene The scene the effect belongs to.
  61385. * @param direction The direction the blur should be applied.
  61386. * @param kernel The size of the kernel used to blur.
  61387. * @param options The required width/height ratio to downsize to before computing the render pass.
  61388. * @param camera The camera to apply the render pass to.
  61389. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61390. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61391. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61392. * @param engine The engine which the post process will be applied. (default: current engine)
  61393. * @param reusable If the post process can be reused on the same frame. (default: false)
  61394. * @param textureType Type of textures used when performing the post process. (default: 0)
  61395. * @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)
  61396. */
  61397. 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);
  61398. }
  61399. }
  61400. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  61401. /** @hidden */
  61402. export var depthOfFieldMergePixelShader: {
  61403. name: string;
  61404. shader: string;
  61405. };
  61406. }
  61407. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  61408. import { Nullable } from "babylonjs/types";
  61409. import { Camera } from "babylonjs/Cameras/camera";
  61410. import { Effect } from "babylonjs/Materials/effect";
  61411. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61412. import { Engine } from "babylonjs/Engines/engine";
  61413. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  61414. /**
  61415. * Options to be set when merging outputs from the default pipeline.
  61416. */
  61417. export class DepthOfFieldMergePostProcessOptions {
  61418. /**
  61419. * The original image to merge on top of
  61420. */
  61421. originalFromInput: PostProcess;
  61422. /**
  61423. * Parameters to perform the merge of the depth of field effect
  61424. */
  61425. depthOfField?: {
  61426. circleOfConfusion: PostProcess;
  61427. blurSteps: Array<PostProcess>;
  61428. };
  61429. /**
  61430. * Parameters to perform the merge of bloom effect
  61431. */
  61432. bloom?: {
  61433. blurred: PostProcess;
  61434. weight: number;
  61435. };
  61436. }
  61437. /**
  61438. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61439. */
  61440. export class DepthOfFieldMergePostProcess extends PostProcess {
  61441. private blurSteps;
  61442. /**
  61443. * Creates a new instance of DepthOfFieldMergePostProcess
  61444. * @param name The name of the effect.
  61445. * @param originalFromInput Post process which's input will be used for the merge.
  61446. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61447. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61448. * @param options The required width/height ratio to downsize to before computing the render pass.
  61449. * @param camera The camera to apply the render pass to.
  61450. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61451. * @param engine The engine which the post process will be applied. (default: current engine)
  61452. * @param reusable If the post process can be reused on the same frame. (default: false)
  61453. * @param textureType Type of textures used when performing the post process. (default: 0)
  61454. * @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)
  61455. */
  61456. 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);
  61457. /**
  61458. * Updates the effect with the current post process compile time values and recompiles the shader.
  61459. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61460. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61461. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61462. * @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
  61463. * @param onCompiled Called when the shader has been compiled.
  61464. * @param onError Called if there is an error when compiling a shader.
  61465. */
  61466. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61467. }
  61468. }
  61469. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  61470. import { Nullable } from "babylonjs/types";
  61471. import { Camera } from "babylonjs/Cameras/camera";
  61472. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61473. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61474. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61475. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61476. import { Scene } from "babylonjs/scene";
  61477. /**
  61478. * Specifies the level of max blur that should be applied when using the depth of field effect
  61479. */
  61480. export enum DepthOfFieldEffectBlurLevel {
  61481. /**
  61482. * Subtle blur
  61483. */
  61484. Low = 0,
  61485. /**
  61486. * Medium blur
  61487. */
  61488. Medium = 1,
  61489. /**
  61490. * Large blur
  61491. */
  61492. High = 2
  61493. }
  61494. /**
  61495. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  61496. */
  61497. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  61498. private _circleOfConfusion;
  61499. /**
  61500. * @hidden Internal, blurs from high to low
  61501. */
  61502. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  61503. private _depthOfFieldBlurY;
  61504. private _dofMerge;
  61505. /**
  61506. * @hidden Internal post processes in depth of field effect
  61507. */
  61508. _effects: Array<PostProcess>;
  61509. /**
  61510. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  61511. */
  61512. focalLength: number;
  61513. /**
  61514. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61515. */
  61516. fStop: number;
  61517. /**
  61518. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61519. */
  61520. focusDistance: number;
  61521. /**
  61522. * 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.
  61523. */
  61524. lensSize: number;
  61525. /**
  61526. * Creates a new instance DepthOfFieldEffect
  61527. * @param scene The scene the effect belongs to.
  61528. * @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.
  61529. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61530. * @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)
  61531. */
  61532. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  61533. /**
  61534. * Get the current class name of the current effet
  61535. * @returns "DepthOfFieldEffect"
  61536. */
  61537. getClassName(): string;
  61538. /**
  61539. * 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.
  61540. */
  61541. depthTexture: RenderTargetTexture;
  61542. /**
  61543. * Disposes each of the internal effects for a given camera.
  61544. * @param camera The camera to dispose the effect on.
  61545. */
  61546. disposeEffects(camera: Camera): void;
  61547. /**
  61548. * @hidden Internal
  61549. */
  61550. _updateEffects(): void;
  61551. /**
  61552. * Internal
  61553. * @returns if all the contained post processes are ready.
  61554. * @hidden
  61555. */
  61556. _isReady(): boolean;
  61557. }
  61558. }
  61559. declare module "babylonjs/Shaders/displayPass.fragment" {
  61560. /** @hidden */
  61561. export var displayPassPixelShader: {
  61562. name: string;
  61563. shader: string;
  61564. };
  61565. }
  61566. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  61567. import { Nullable } from "babylonjs/types";
  61568. import { Camera } from "babylonjs/Cameras/camera";
  61569. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61570. import { Engine } from "babylonjs/Engines/engine";
  61571. import "babylonjs/Shaders/displayPass.fragment";
  61572. /**
  61573. * DisplayPassPostProcess which produces an output the same as it's input
  61574. */
  61575. export class DisplayPassPostProcess extends PostProcess {
  61576. /**
  61577. * Creates the DisplayPassPostProcess
  61578. * @param name The name of the effect.
  61579. * @param options The required width/height ratio to downsize to before computing the render pass.
  61580. * @param camera The camera to apply the render pass to.
  61581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61582. * @param engine The engine which the post process will be applied. (default: current engine)
  61583. * @param reusable If the post process can be reused on the same frame. (default: false)
  61584. */
  61585. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61586. }
  61587. }
  61588. declare module "babylonjs/Shaders/filter.fragment" {
  61589. /** @hidden */
  61590. export var filterPixelShader: {
  61591. name: string;
  61592. shader: string;
  61593. };
  61594. }
  61595. declare module "babylonjs/PostProcesses/filterPostProcess" {
  61596. import { Nullable } from "babylonjs/types";
  61597. import { Matrix } from "babylonjs/Maths/math.vector";
  61598. import { Camera } from "babylonjs/Cameras/camera";
  61599. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61600. import { Engine } from "babylonjs/Engines/engine";
  61601. import "babylonjs/Shaders/filter.fragment";
  61602. /**
  61603. * Applies a kernel filter to the image
  61604. */
  61605. export class FilterPostProcess extends PostProcess {
  61606. /** The matrix to be applied to the image */
  61607. kernelMatrix: Matrix;
  61608. /**
  61609. *
  61610. * @param name The name of the effect.
  61611. * @param kernelMatrix The matrix to be applied to the image
  61612. * @param options The required width/height ratio to downsize to before computing the render pass.
  61613. * @param camera The camera to apply the render pass to.
  61614. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61615. * @param engine The engine which the post process will be applied. (default: current engine)
  61616. * @param reusable If the post process can be reused on the same frame. (default: false)
  61617. */
  61618. constructor(name: string,
  61619. /** The matrix to be applied to the image */
  61620. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61621. }
  61622. }
  61623. declare module "babylonjs/Shaders/fxaa.fragment" {
  61624. /** @hidden */
  61625. export var fxaaPixelShader: {
  61626. name: string;
  61627. shader: string;
  61628. };
  61629. }
  61630. declare module "babylonjs/Shaders/fxaa.vertex" {
  61631. /** @hidden */
  61632. export var fxaaVertexShader: {
  61633. name: string;
  61634. shader: string;
  61635. };
  61636. }
  61637. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  61638. import { Nullable } from "babylonjs/types";
  61639. import { Camera } from "babylonjs/Cameras/camera";
  61640. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61641. import { Engine } from "babylonjs/Engines/engine";
  61642. import "babylonjs/Shaders/fxaa.fragment";
  61643. import "babylonjs/Shaders/fxaa.vertex";
  61644. /**
  61645. * Fxaa post process
  61646. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  61647. */
  61648. export class FxaaPostProcess extends PostProcess {
  61649. /** @hidden */
  61650. texelWidth: number;
  61651. /** @hidden */
  61652. texelHeight: number;
  61653. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61654. private _getDefines;
  61655. }
  61656. }
  61657. declare module "babylonjs/Shaders/grain.fragment" {
  61658. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61659. /** @hidden */
  61660. export var grainPixelShader: {
  61661. name: string;
  61662. shader: string;
  61663. };
  61664. }
  61665. declare module "babylonjs/PostProcesses/grainPostProcess" {
  61666. import { Nullable } from "babylonjs/types";
  61667. import { Camera } from "babylonjs/Cameras/camera";
  61668. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61669. import { Engine } from "babylonjs/Engines/engine";
  61670. import "babylonjs/Shaders/grain.fragment";
  61671. /**
  61672. * The GrainPostProcess adds noise to the image at mid luminance levels
  61673. */
  61674. export class GrainPostProcess extends PostProcess {
  61675. /**
  61676. * The intensity of the grain added (default: 30)
  61677. */
  61678. intensity: number;
  61679. /**
  61680. * If the grain should be randomized on every frame
  61681. */
  61682. animated: boolean;
  61683. /**
  61684. * Creates a new instance of @see GrainPostProcess
  61685. * @param name The name of the effect.
  61686. * @param options The required width/height ratio to downsize to before computing the render pass.
  61687. * @param camera The camera to apply the render pass to.
  61688. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61689. * @param engine The engine which the post process will be applied. (default: current engine)
  61690. * @param reusable If the post process can be reused on the same frame. (default: false)
  61691. * @param textureType Type of textures used when performing the post process. (default: 0)
  61692. * @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)
  61693. */
  61694. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61695. }
  61696. }
  61697. declare module "babylonjs/Shaders/highlights.fragment" {
  61698. /** @hidden */
  61699. export var highlightsPixelShader: {
  61700. name: string;
  61701. shader: string;
  61702. };
  61703. }
  61704. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  61705. import { Nullable } from "babylonjs/types";
  61706. import { Camera } from "babylonjs/Cameras/camera";
  61707. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61708. import { Engine } from "babylonjs/Engines/engine";
  61709. import "babylonjs/Shaders/highlights.fragment";
  61710. /**
  61711. * Extracts highlights from the image
  61712. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61713. */
  61714. export class HighlightsPostProcess extends PostProcess {
  61715. /**
  61716. * Extracts highlights from the image
  61717. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61718. * @param name The name of the effect.
  61719. * @param options The required width/height ratio to downsize to before computing the render pass.
  61720. * @param camera The camera to apply the render pass to.
  61721. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61722. * @param engine The engine which the post process will be applied. (default: current engine)
  61723. * @param reusable If the post process can be reused on the same frame. (default: false)
  61724. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  61725. */
  61726. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61727. }
  61728. }
  61729. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  61730. /** @hidden */
  61731. export var mrtFragmentDeclaration: {
  61732. name: string;
  61733. shader: string;
  61734. };
  61735. }
  61736. declare module "babylonjs/Shaders/geometry.fragment" {
  61737. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  61738. /** @hidden */
  61739. export var geometryPixelShader: {
  61740. name: string;
  61741. shader: string;
  61742. };
  61743. }
  61744. declare module "babylonjs/Shaders/geometry.vertex" {
  61745. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61746. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61747. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61748. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61749. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61750. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61751. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61752. /** @hidden */
  61753. export var geometryVertexShader: {
  61754. name: string;
  61755. shader: string;
  61756. };
  61757. }
  61758. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  61759. import { Matrix } from "babylonjs/Maths/math.vector";
  61760. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61761. import { Mesh } from "babylonjs/Meshes/mesh";
  61762. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  61763. import { Effect } from "babylonjs/Materials/effect";
  61764. import { Scene } from "babylonjs/scene";
  61765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61766. import "babylonjs/Shaders/geometry.fragment";
  61767. import "babylonjs/Shaders/geometry.vertex";
  61768. /** @hidden */
  61769. interface ISavedTransformationMatrix {
  61770. world: Matrix;
  61771. viewProjection: Matrix;
  61772. }
  61773. /**
  61774. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  61775. */
  61776. export class GeometryBufferRenderer {
  61777. /**
  61778. * Constant used to retrieve the position texture index in the G-Buffer textures array
  61779. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  61780. */
  61781. static readonly POSITION_TEXTURE_TYPE: number;
  61782. /**
  61783. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  61784. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  61785. */
  61786. static readonly VELOCITY_TEXTURE_TYPE: number;
  61787. /**
  61788. * Dictionary used to store the previous transformation matrices of each rendered mesh
  61789. * in order to compute objects velocities when enableVelocity is set to "true"
  61790. * @hidden
  61791. */
  61792. _previousTransformationMatrices: {
  61793. [index: number]: ISavedTransformationMatrix;
  61794. };
  61795. /**
  61796. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  61797. * in order to compute objects velocities when enableVelocity is set to "true"
  61798. * @hidden
  61799. */
  61800. _previousBonesTransformationMatrices: {
  61801. [index: number]: Float32Array;
  61802. };
  61803. /**
  61804. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  61805. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  61806. */
  61807. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  61808. private _scene;
  61809. private _multiRenderTarget;
  61810. private _ratio;
  61811. private _enablePosition;
  61812. private _enableVelocity;
  61813. private _positionIndex;
  61814. private _velocityIndex;
  61815. protected _effect: Effect;
  61816. protected _cachedDefines: string;
  61817. /**
  61818. * Set the render list (meshes to be rendered) used in the G buffer.
  61819. */
  61820. renderList: Mesh[];
  61821. /**
  61822. * Gets wether or not G buffer are supported by the running hardware.
  61823. * This requires draw buffer supports
  61824. */
  61825. readonly isSupported: boolean;
  61826. /**
  61827. * Returns the index of the given texture type in the G-Buffer textures array
  61828. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  61829. * @returns the index of the given texture type in the G-Buffer textures array
  61830. */
  61831. getTextureIndex(textureType: number): number;
  61832. /**
  61833. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  61834. */
  61835. /**
  61836. * Sets whether or not objects positions are enabled for the G buffer.
  61837. */
  61838. enablePosition: boolean;
  61839. /**
  61840. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  61841. */
  61842. /**
  61843. * Sets wether or not objects velocities are enabled for the G buffer.
  61844. */
  61845. enableVelocity: boolean;
  61846. /**
  61847. * Gets the scene associated with the buffer.
  61848. */
  61849. readonly scene: Scene;
  61850. /**
  61851. * Gets the ratio used by the buffer during its creation.
  61852. * How big is the buffer related to the main canvas.
  61853. */
  61854. readonly ratio: number;
  61855. /** @hidden */
  61856. static _SceneComponentInitialization: (scene: Scene) => void;
  61857. /**
  61858. * Creates a new G Buffer for the scene
  61859. * @param scene The scene the buffer belongs to
  61860. * @param ratio How big is the buffer related to the main canvas.
  61861. */
  61862. constructor(scene: Scene, ratio?: number);
  61863. /**
  61864. * Checks wether everything is ready to render a submesh to the G buffer.
  61865. * @param subMesh the submesh to check readiness for
  61866. * @param useInstances is the mesh drawn using instance or not
  61867. * @returns true if ready otherwise false
  61868. */
  61869. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61870. /**
  61871. * Gets the current underlying G Buffer.
  61872. * @returns the buffer
  61873. */
  61874. getGBuffer(): MultiRenderTarget;
  61875. /**
  61876. * Gets the number of samples used to render the buffer (anti aliasing).
  61877. */
  61878. /**
  61879. * Sets the number of samples used to render the buffer (anti aliasing).
  61880. */
  61881. samples: number;
  61882. /**
  61883. * Disposes the renderer and frees up associated resources.
  61884. */
  61885. dispose(): void;
  61886. protected _createRenderTargets(): void;
  61887. private _copyBonesTransformationMatrices;
  61888. }
  61889. }
  61890. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  61891. import { Nullable } from "babylonjs/types";
  61892. import { Scene } from "babylonjs/scene";
  61893. import { ISceneComponent } from "babylonjs/sceneComponent";
  61894. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  61895. module "babylonjs/scene" {
  61896. interface Scene {
  61897. /** @hidden (Backing field) */
  61898. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61899. /**
  61900. * Gets or Sets the current geometry buffer associated to the scene.
  61901. */
  61902. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61903. /**
  61904. * Enables a GeometryBufferRender and associates it with the scene
  61905. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  61906. * @returns the GeometryBufferRenderer
  61907. */
  61908. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  61909. /**
  61910. * Disables the GeometryBufferRender associated with the scene
  61911. */
  61912. disableGeometryBufferRenderer(): void;
  61913. }
  61914. }
  61915. /**
  61916. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  61917. * in several rendering techniques.
  61918. */
  61919. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  61920. /**
  61921. * The component name helpful to identify the component in the list of scene components.
  61922. */
  61923. readonly name: string;
  61924. /**
  61925. * The scene the component belongs to.
  61926. */
  61927. scene: Scene;
  61928. /**
  61929. * Creates a new instance of the component for the given scene
  61930. * @param scene Defines the scene to register the component in
  61931. */
  61932. constructor(scene: Scene);
  61933. /**
  61934. * Registers the component in a given scene
  61935. */
  61936. register(): void;
  61937. /**
  61938. * Rebuilds the elements related to this component in case of
  61939. * context lost for instance.
  61940. */
  61941. rebuild(): void;
  61942. /**
  61943. * Disposes the component and the associated ressources
  61944. */
  61945. dispose(): void;
  61946. private _gatherRenderTargets;
  61947. }
  61948. }
  61949. declare module "babylonjs/Shaders/motionBlur.fragment" {
  61950. /** @hidden */
  61951. export var motionBlurPixelShader: {
  61952. name: string;
  61953. shader: string;
  61954. };
  61955. }
  61956. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  61957. import { Nullable } from "babylonjs/types";
  61958. import { Camera } from "babylonjs/Cameras/camera";
  61959. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61960. import { Scene } from "babylonjs/scene";
  61961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61962. import "babylonjs/Animations/animatable";
  61963. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  61964. import "babylonjs/Shaders/motionBlur.fragment";
  61965. import { Engine } from "babylonjs/Engines/engine";
  61966. /**
  61967. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  61968. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  61969. * As an example, all you have to do is to create the post-process:
  61970. * var mb = new BABYLON.MotionBlurPostProcess(
  61971. * 'mb', // The name of the effect.
  61972. * scene, // The scene containing the objects to blur according to their velocity.
  61973. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  61974. * camera // The camera to apply the render pass to.
  61975. * );
  61976. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  61977. */
  61978. export class MotionBlurPostProcess extends PostProcess {
  61979. /**
  61980. * Defines how much the image is blurred by the movement. Default value is equal to 1
  61981. */
  61982. motionStrength: number;
  61983. /**
  61984. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  61985. */
  61986. /**
  61987. * Sets the number of iterations to be used for motion blur quality
  61988. */
  61989. motionBlurSamples: number;
  61990. private _motionBlurSamples;
  61991. private _geometryBufferRenderer;
  61992. /**
  61993. * Creates a new instance MotionBlurPostProcess
  61994. * @param name The name of the effect.
  61995. * @param scene The scene containing the objects to blur according to their velocity.
  61996. * @param options The required width/height ratio to downsize to before computing the render pass.
  61997. * @param camera The camera to apply the render pass to.
  61998. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61999. * @param engine The engine which the post process will be applied. (default: current engine)
  62000. * @param reusable If the post process can be reused on the same frame. (default: false)
  62001. * @param textureType Type of textures used when performing the post process. (default: 0)
  62002. * @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)
  62003. */
  62004. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62005. /**
  62006. * Excludes the given skinned mesh from computing bones velocities.
  62007. * 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.
  62008. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62009. */
  62010. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62011. /**
  62012. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62013. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62014. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62015. */
  62016. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62017. /**
  62018. * Disposes the post process.
  62019. * @param camera The camera to dispose the post process on.
  62020. */
  62021. dispose(camera?: Camera): void;
  62022. }
  62023. }
  62024. declare module "babylonjs/Shaders/refraction.fragment" {
  62025. /** @hidden */
  62026. export var refractionPixelShader: {
  62027. name: string;
  62028. shader: string;
  62029. };
  62030. }
  62031. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  62032. import { Color3 } from "babylonjs/Maths/math.color";
  62033. import { Camera } from "babylonjs/Cameras/camera";
  62034. import { Texture } from "babylonjs/Materials/Textures/texture";
  62035. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62036. import { Engine } from "babylonjs/Engines/engine";
  62037. import "babylonjs/Shaders/refraction.fragment";
  62038. /**
  62039. * Post process which applies a refractin texture
  62040. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62041. */
  62042. export class RefractionPostProcess extends PostProcess {
  62043. /** the base color of the refraction (used to taint the rendering) */
  62044. color: Color3;
  62045. /** simulated refraction depth */
  62046. depth: number;
  62047. /** the coefficient of the base color (0 to remove base color tainting) */
  62048. colorLevel: number;
  62049. private _refTexture;
  62050. private _ownRefractionTexture;
  62051. /**
  62052. * Gets or sets the refraction texture
  62053. * Please note that you are responsible for disposing the texture if you set it manually
  62054. */
  62055. refractionTexture: Texture;
  62056. /**
  62057. * Initializes the RefractionPostProcess
  62058. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62059. * @param name The name of the effect.
  62060. * @param refractionTextureUrl Url of the refraction texture to use
  62061. * @param color the base color of the refraction (used to taint the rendering)
  62062. * @param depth simulated refraction depth
  62063. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  62064. * @param camera The camera to apply the render pass to.
  62065. * @param options The required width/height ratio to downsize to before computing the render pass.
  62066. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62067. * @param engine The engine which the post process will be applied. (default: current engine)
  62068. * @param reusable If the post process can be reused on the same frame. (default: false)
  62069. */
  62070. constructor(name: string, refractionTextureUrl: string,
  62071. /** the base color of the refraction (used to taint the rendering) */
  62072. color: Color3,
  62073. /** simulated refraction depth */
  62074. depth: number,
  62075. /** the coefficient of the base color (0 to remove base color tainting) */
  62076. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62077. /**
  62078. * Disposes of the post process
  62079. * @param camera Camera to dispose post process on
  62080. */
  62081. dispose(camera: Camera): void;
  62082. }
  62083. }
  62084. declare module "babylonjs/Shaders/sharpen.fragment" {
  62085. /** @hidden */
  62086. export var sharpenPixelShader: {
  62087. name: string;
  62088. shader: string;
  62089. };
  62090. }
  62091. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  62092. import { Nullable } from "babylonjs/types";
  62093. import { Camera } from "babylonjs/Cameras/camera";
  62094. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62095. import "babylonjs/Shaders/sharpen.fragment";
  62096. import { Engine } from "babylonjs/Engines/engine";
  62097. /**
  62098. * The SharpenPostProcess applies a sharpen kernel to every pixel
  62099. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62100. */
  62101. export class SharpenPostProcess extends PostProcess {
  62102. /**
  62103. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  62104. */
  62105. colorAmount: number;
  62106. /**
  62107. * How much sharpness should be applied (default: 0.3)
  62108. */
  62109. edgeAmount: number;
  62110. /**
  62111. * Creates a new instance ConvolutionPostProcess
  62112. * @param name The name of the effect.
  62113. * @param options The required width/height ratio to downsize to before computing the render pass.
  62114. * @param camera The camera to apply the render pass to.
  62115. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62116. * @param engine The engine which the post process will be applied. (default: current engine)
  62117. * @param reusable If the post process can be reused on the same frame. (default: false)
  62118. * @param textureType Type of textures used when performing the post process. (default: 0)
  62119. * @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)
  62120. */
  62121. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62122. }
  62123. }
  62124. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  62125. import { Nullable } from "babylonjs/types";
  62126. import { Camera } from "babylonjs/Cameras/camera";
  62127. import { Engine } from "babylonjs/Engines/engine";
  62128. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62129. import { IInspectable } from "babylonjs/Misc/iInspectable";
  62130. /**
  62131. * PostProcessRenderPipeline
  62132. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62133. */
  62134. export class PostProcessRenderPipeline {
  62135. private engine;
  62136. private _renderEffects;
  62137. private _renderEffectsForIsolatedPass;
  62138. /**
  62139. * List of inspectable custom properties (used by the Inspector)
  62140. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  62141. */
  62142. inspectableCustomProperties: IInspectable[];
  62143. /**
  62144. * @hidden
  62145. */
  62146. protected _cameras: Camera[];
  62147. /** @hidden */
  62148. _name: string;
  62149. /**
  62150. * Gets pipeline name
  62151. */
  62152. readonly name: string;
  62153. /**
  62154. * Initializes a PostProcessRenderPipeline
  62155. * @param engine engine to add the pipeline to
  62156. * @param name name of the pipeline
  62157. */
  62158. constructor(engine: Engine, name: string);
  62159. /**
  62160. * Gets the class name
  62161. * @returns "PostProcessRenderPipeline"
  62162. */
  62163. getClassName(): string;
  62164. /**
  62165. * If all the render effects in the pipeline are supported
  62166. */
  62167. readonly isSupported: boolean;
  62168. /**
  62169. * Adds an effect to the pipeline
  62170. * @param renderEffect the effect to add
  62171. */
  62172. addEffect(renderEffect: PostProcessRenderEffect): void;
  62173. /** @hidden */
  62174. _rebuild(): void;
  62175. /** @hidden */
  62176. _enableEffect(renderEffectName: string, cameras: Camera): void;
  62177. /** @hidden */
  62178. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  62179. /** @hidden */
  62180. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62181. /** @hidden */
  62182. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62183. /** @hidden */
  62184. _attachCameras(cameras: Camera, unique: boolean): void;
  62185. /** @hidden */
  62186. _attachCameras(cameras: Camera[], unique: boolean): void;
  62187. /** @hidden */
  62188. _detachCameras(cameras: Camera): void;
  62189. /** @hidden */
  62190. _detachCameras(cameras: Nullable<Camera[]>): void;
  62191. /** @hidden */
  62192. _update(): void;
  62193. /** @hidden */
  62194. _reset(): void;
  62195. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  62196. /**
  62197. * Disposes of the pipeline
  62198. */
  62199. dispose(): void;
  62200. }
  62201. }
  62202. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  62203. import { Camera } from "babylonjs/Cameras/camera";
  62204. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62205. /**
  62206. * PostProcessRenderPipelineManager class
  62207. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62208. */
  62209. export class PostProcessRenderPipelineManager {
  62210. private _renderPipelines;
  62211. /**
  62212. * Initializes a PostProcessRenderPipelineManager
  62213. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62214. */
  62215. constructor();
  62216. /**
  62217. * Gets the list of supported render pipelines
  62218. */
  62219. readonly supportedPipelines: PostProcessRenderPipeline[];
  62220. /**
  62221. * Adds a pipeline to the manager
  62222. * @param renderPipeline The pipeline to add
  62223. */
  62224. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  62225. /**
  62226. * Attaches a camera to the pipeline
  62227. * @param renderPipelineName The name of the pipeline to attach to
  62228. * @param cameras the camera to attach
  62229. * @param unique if the camera can be attached multiple times to the pipeline
  62230. */
  62231. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  62232. /**
  62233. * Detaches a camera from the pipeline
  62234. * @param renderPipelineName The name of the pipeline to detach from
  62235. * @param cameras the camera to detach
  62236. */
  62237. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  62238. /**
  62239. * Enables an effect by name on a pipeline
  62240. * @param renderPipelineName the name of the pipeline to enable the effect in
  62241. * @param renderEffectName the name of the effect to enable
  62242. * @param cameras the cameras that the effect should be enabled on
  62243. */
  62244. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62245. /**
  62246. * Disables an effect by name on a pipeline
  62247. * @param renderPipelineName the name of the pipeline to disable the effect in
  62248. * @param renderEffectName the name of the effect to disable
  62249. * @param cameras the cameras that the effect should be disabled on
  62250. */
  62251. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62252. /**
  62253. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  62254. */
  62255. update(): void;
  62256. /** @hidden */
  62257. _rebuild(): void;
  62258. /**
  62259. * Disposes of the manager and pipelines
  62260. */
  62261. dispose(): void;
  62262. }
  62263. }
  62264. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  62265. import { ISceneComponent } from "babylonjs/sceneComponent";
  62266. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  62267. import { Scene } from "babylonjs/scene";
  62268. module "babylonjs/scene" {
  62269. interface Scene {
  62270. /** @hidden (Backing field) */
  62271. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62272. /**
  62273. * Gets the postprocess render pipeline manager
  62274. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62275. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62276. */
  62277. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62278. }
  62279. }
  62280. /**
  62281. * Defines the Render Pipeline scene component responsible to rendering pipelines
  62282. */
  62283. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  62284. /**
  62285. * The component name helpfull to identify the component in the list of scene components.
  62286. */
  62287. readonly name: string;
  62288. /**
  62289. * The scene the component belongs to.
  62290. */
  62291. scene: Scene;
  62292. /**
  62293. * Creates a new instance of the component for the given scene
  62294. * @param scene Defines the scene to register the component in
  62295. */
  62296. constructor(scene: Scene);
  62297. /**
  62298. * Registers the component in a given scene
  62299. */
  62300. register(): void;
  62301. /**
  62302. * Rebuilds the elements related to this component in case of
  62303. * context lost for instance.
  62304. */
  62305. rebuild(): void;
  62306. /**
  62307. * Disposes the component and the associated ressources
  62308. */
  62309. dispose(): void;
  62310. private _gatherRenderTargets;
  62311. }
  62312. }
  62313. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  62314. import { Nullable } from "babylonjs/types";
  62315. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62316. import { Camera } from "babylonjs/Cameras/camera";
  62317. import { IDisposable } from "babylonjs/scene";
  62318. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  62319. import { Scene } from "babylonjs/scene";
  62320. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  62321. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62322. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62323. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  62324. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62325. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62326. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  62327. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62328. import { Animation } from "babylonjs/Animations/animation";
  62329. /**
  62330. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  62331. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62332. */
  62333. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62334. private _scene;
  62335. private _camerasToBeAttached;
  62336. /**
  62337. * ID of the sharpen post process,
  62338. */
  62339. private readonly SharpenPostProcessId;
  62340. /**
  62341. * @ignore
  62342. * ID of the image processing post process;
  62343. */
  62344. readonly ImageProcessingPostProcessId: string;
  62345. /**
  62346. * @ignore
  62347. * ID of the Fast Approximate Anti-Aliasing post process;
  62348. */
  62349. readonly FxaaPostProcessId: string;
  62350. /**
  62351. * ID of the chromatic aberration post process,
  62352. */
  62353. private readonly ChromaticAberrationPostProcessId;
  62354. /**
  62355. * ID of the grain post process
  62356. */
  62357. private readonly GrainPostProcessId;
  62358. /**
  62359. * Sharpen post process which will apply a sharpen convolution to enhance edges
  62360. */
  62361. sharpen: SharpenPostProcess;
  62362. private _sharpenEffect;
  62363. private bloom;
  62364. /**
  62365. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  62366. */
  62367. depthOfField: DepthOfFieldEffect;
  62368. /**
  62369. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62370. */
  62371. fxaa: FxaaPostProcess;
  62372. /**
  62373. * Image post processing pass used to perform operations such as tone mapping or color grading.
  62374. */
  62375. imageProcessing: ImageProcessingPostProcess;
  62376. /**
  62377. * Chromatic aberration post process which will shift rgb colors in the image
  62378. */
  62379. chromaticAberration: ChromaticAberrationPostProcess;
  62380. private _chromaticAberrationEffect;
  62381. /**
  62382. * Grain post process which add noise to the image
  62383. */
  62384. grain: GrainPostProcess;
  62385. private _grainEffect;
  62386. /**
  62387. * Glow post process which adds a glow to emissive areas of the image
  62388. */
  62389. private _glowLayer;
  62390. /**
  62391. * Animations which can be used to tweak settings over a period of time
  62392. */
  62393. animations: Animation[];
  62394. private _imageProcessingConfigurationObserver;
  62395. private _sharpenEnabled;
  62396. private _bloomEnabled;
  62397. private _depthOfFieldEnabled;
  62398. private _depthOfFieldBlurLevel;
  62399. private _fxaaEnabled;
  62400. private _imageProcessingEnabled;
  62401. private _defaultPipelineTextureType;
  62402. private _bloomScale;
  62403. private _chromaticAberrationEnabled;
  62404. private _grainEnabled;
  62405. private _buildAllowed;
  62406. /**
  62407. * Gets active scene
  62408. */
  62409. readonly scene: Scene;
  62410. /**
  62411. * Enable or disable the sharpen process from the pipeline
  62412. */
  62413. sharpenEnabled: boolean;
  62414. private _resizeObserver;
  62415. private _hardwareScaleLevel;
  62416. private _bloomKernel;
  62417. /**
  62418. * Specifies the size of the bloom blur kernel, relative to the final output size
  62419. */
  62420. bloomKernel: number;
  62421. /**
  62422. * Specifies the weight of the bloom in the final rendering
  62423. */
  62424. private _bloomWeight;
  62425. /**
  62426. * Specifies the luma threshold for the area that will be blurred by the bloom
  62427. */
  62428. private _bloomThreshold;
  62429. private _hdr;
  62430. /**
  62431. * The strength of the bloom.
  62432. */
  62433. bloomWeight: number;
  62434. /**
  62435. * The strength of the bloom.
  62436. */
  62437. bloomThreshold: number;
  62438. /**
  62439. * The scale of the bloom, lower value will provide better performance.
  62440. */
  62441. bloomScale: number;
  62442. /**
  62443. * Enable or disable the bloom from the pipeline
  62444. */
  62445. bloomEnabled: boolean;
  62446. private _rebuildBloom;
  62447. /**
  62448. * If the depth of field is enabled.
  62449. */
  62450. depthOfFieldEnabled: boolean;
  62451. /**
  62452. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62453. */
  62454. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62455. /**
  62456. * If the anti aliasing is enabled.
  62457. */
  62458. fxaaEnabled: boolean;
  62459. private _samples;
  62460. /**
  62461. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62462. */
  62463. samples: number;
  62464. /**
  62465. * If image processing is enabled.
  62466. */
  62467. imageProcessingEnabled: boolean;
  62468. /**
  62469. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62470. */
  62471. glowLayerEnabled: boolean;
  62472. /**
  62473. * Gets the glow layer (or null if not defined)
  62474. */
  62475. readonly glowLayer: Nullable<GlowLayer>;
  62476. /**
  62477. * Enable or disable the chromaticAberration process from the pipeline
  62478. */
  62479. chromaticAberrationEnabled: boolean;
  62480. /**
  62481. * Enable or disable the grain process from the pipeline
  62482. */
  62483. grainEnabled: boolean;
  62484. /**
  62485. * @constructor
  62486. * @param name - The rendering pipeline name (default: "")
  62487. * @param hdr - If high dynamic range textures should be used (default: true)
  62488. * @param scene - The scene linked to this pipeline (default: the last created scene)
  62489. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  62490. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  62491. */
  62492. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  62493. /**
  62494. * Get the class name
  62495. * @returns "DefaultRenderingPipeline"
  62496. */
  62497. getClassName(): string;
  62498. /**
  62499. * Force the compilation of the entire pipeline.
  62500. */
  62501. prepare(): void;
  62502. private _hasCleared;
  62503. private _prevPostProcess;
  62504. private _prevPrevPostProcess;
  62505. private _setAutoClearAndTextureSharing;
  62506. private _depthOfFieldSceneObserver;
  62507. private _buildPipeline;
  62508. private _disposePostProcesses;
  62509. /**
  62510. * Adds a camera to the pipeline
  62511. * @param camera the camera to be added
  62512. */
  62513. addCamera(camera: Camera): void;
  62514. /**
  62515. * Removes a camera from the pipeline
  62516. * @param camera the camera to remove
  62517. */
  62518. removeCamera(camera: Camera): void;
  62519. /**
  62520. * Dispose of the pipeline and stop all post processes
  62521. */
  62522. dispose(): void;
  62523. /**
  62524. * Serialize the rendering pipeline (Used when exporting)
  62525. * @returns the serialized object
  62526. */
  62527. serialize(): any;
  62528. /**
  62529. * Parse the serialized pipeline
  62530. * @param source Source pipeline.
  62531. * @param scene The scene to load the pipeline to.
  62532. * @param rootUrl The URL of the serialized pipeline.
  62533. * @returns An instantiated pipeline from the serialized object.
  62534. */
  62535. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  62536. }
  62537. }
  62538. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  62539. /** @hidden */
  62540. export var lensHighlightsPixelShader: {
  62541. name: string;
  62542. shader: string;
  62543. };
  62544. }
  62545. declare module "babylonjs/Shaders/depthOfField.fragment" {
  62546. /** @hidden */
  62547. export var depthOfFieldPixelShader: {
  62548. name: string;
  62549. shader: string;
  62550. };
  62551. }
  62552. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  62553. import { Camera } from "babylonjs/Cameras/camera";
  62554. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62555. import { Scene } from "babylonjs/scene";
  62556. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62557. import "babylonjs/Shaders/chromaticAberration.fragment";
  62558. import "babylonjs/Shaders/lensHighlights.fragment";
  62559. import "babylonjs/Shaders/depthOfField.fragment";
  62560. /**
  62561. * BABYLON.JS Chromatic Aberration GLSL Shader
  62562. * Author: Olivier Guyot
  62563. * Separates very slightly R, G and B colors on the edges of the screen
  62564. * Inspired by Francois Tarlier & Martins Upitis
  62565. */
  62566. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  62567. /**
  62568. * @ignore
  62569. * The chromatic aberration PostProcess id in the pipeline
  62570. */
  62571. LensChromaticAberrationEffect: string;
  62572. /**
  62573. * @ignore
  62574. * The highlights enhancing PostProcess id in the pipeline
  62575. */
  62576. HighlightsEnhancingEffect: string;
  62577. /**
  62578. * @ignore
  62579. * The depth-of-field PostProcess id in the pipeline
  62580. */
  62581. LensDepthOfFieldEffect: string;
  62582. private _scene;
  62583. private _depthTexture;
  62584. private _grainTexture;
  62585. private _chromaticAberrationPostProcess;
  62586. private _highlightsPostProcess;
  62587. private _depthOfFieldPostProcess;
  62588. private _edgeBlur;
  62589. private _grainAmount;
  62590. private _chromaticAberration;
  62591. private _distortion;
  62592. private _highlightsGain;
  62593. private _highlightsThreshold;
  62594. private _dofDistance;
  62595. private _dofAperture;
  62596. private _dofDarken;
  62597. private _dofPentagon;
  62598. private _blurNoise;
  62599. /**
  62600. * @constructor
  62601. *
  62602. * Effect parameters are as follow:
  62603. * {
  62604. * chromatic_aberration: number; // from 0 to x (1 for realism)
  62605. * edge_blur: number; // from 0 to x (1 for realism)
  62606. * distortion: number; // from 0 to x (1 for realism)
  62607. * grain_amount: number; // from 0 to 1
  62608. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  62609. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  62610. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  62611. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  62612. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  62613. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  62614. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  62615. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  62616. * }
  62617. * Note: if an effect parameter is unset, effect is disabled
  62618. *
  62619. * @param name The rendering pipeline name
  62620. * @param parameters - An object containing all parameters (see above)
  62621. * @param scene The scene linked to this pipeline
  62622. * @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)
  62623. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62624. */
  62625. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  62626. /**
  62627. * Get the class name
  62628. * @returns "LensRenderingPipeline"
  62629. */
  62630. getClassName(): string;
  62631. /**
  62632. * Gets associated scene
  62633. */
  62634. readonly scene: Scene;
  62635. /**
  62636. * Gets or sets the edge blur
  62637. */
  62638. edgeBlur: number;
  62639. /**
  62640. * Gets or sets the grain amount
  62641. */
  62642. grainAmount: number;
  62643. /**
  62644. * Gets or sets the chromatic aberration amount
  62645. */
  62646. chromaticAberration: number;
  62647. /**
  62648. * Gets or sets the depth of field aperture
  62649. */
  62650. dofAperture: number;
  62651. /**
  62652. * Gets or sets the edge distortion
  62653. */
  62654. edgeDistortion: number;
  62655. /**
  62656. * Gets or sets the depth of field distortion
  62657. */
  62658. dofDistortion: number;
  62659. /**
  62660. * Gets or sets the darken out of focus amount
  62661. */
  62662. darkenOutOfFocus: number;
  62663. /**
  62664. * Gets or sets a boolean indicating if blur noise is enabled
  62665. */
  62666. blurNoise: boolean;
  62667. /**
  62668. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  62669. */
  62670. pentagonBokeh: boolean;
  62671. /**
  62672. * Gets or sets the highlight grain amount
  62673. */
  62674. highlightsGain: number;
  62675. /**
  62676. * Gets or sets the highlight threshold
  62677. */
  62678. highlightsThreshold: number;
  62679. /**
  62680. * Sets the amount of blur at the edges
  62681. * @param amount blur amount
  62682. */
  62683. setEdgeBlur(amount: number): void;
  62684. /**
  62685. * Sets edge blur to 0
  62686. */
  62687. disableEdgeBlur(): void;
  62688. /**
  62689. * Sets the amout of grain
  62690. * @param amount Amount of grain
  62691. */
  62692. setGrainAmount(amount: number): void;
  62693. /**
  62694. * Set grain amount to 0
  62695. */
  62696. disableGrain(): void;
  62697. /**
  62698. * Sets the chromatic aberration amount
  62699. * @param amount amount of chromatic aberration
  62700. */
  62701. setChromaticAberration(amount: number): void;
  62702. /**
  62703. * Sets chromatic aberration amount to 0
  62704. */
  62705. disableChromaticAberration(): void;
  62706. /**
  62707. * Sets the EdgeDistortion amount
  62708. * @param amount amount of EdgeDistortion
  62709. */
  62710. setEdgeDistortion(amount: number): void;
  62711. /**
  62712. * Sets edge distortion to 0
  62713. */
  62714. disableEdgeDistortion(): void;
  62715. /**
  62716. * Sets the FocusDistance amount
  62717. * @param amount amount of FocusDistance
  62718. */
  62719. setFocusDistance(amount: number): void;
  62720. /**
  62721. * Disables depth of field
  62722. */
  62723. disableDepthOfField(): void;
  62724. /**
  62725. * Sets the Aperture amount
  62726. * @param amount amount of Aperture
  62727. */
  62728. setAperture(amount: number): void;
  62729. /**
  62730. * Sets the DarkenOutOfFocus amount
  62731. * @param amount amount of DarkenOutOfFocus
  62732. */
  62733. setDarkenOutOfFocus(amount: number): void;
  62734. private _pentagonBokehIsEnabled;
  62735. /**
  62736. * Creates a pentagon bokeh effect
  62737. */
  62738. enablePentagonBokeh(): void;
  62739. /**
  62740. * Disables the pentagon bokeh effect
  62741. */
  62742. disablePentagonBokeh(): void;
  62743. /**
  62744. * Enables noise blur
  62745. */
  62746. enableNoiseBlur(): void;
  62747. /**
  62748. * Disables noise blur
  62749. */
  62750. disableNoiseBlur(): void;
  62751. /**
  62752. * Sets the HighlightsGain amount
  62753. * @param amount amount of HighlightsGain
  62754. */
  62755. setHighlightsGain(amount: number): void;
  62756. /**
  62757. * Sets the HighlightsThreshold amount
  62758. * @param amount amount of HighlightsThreshold
  62759. */
  62760. setHighlightsThreshold(amount: number): void;
  62761. /**
  62762. * Disables highlights
  62763. */
  62764. disableHighlights(): void;
  62765. /**
  62766. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  62767. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  62768. */
  62769. dispose(disableDepthRender?: boolean): void;
  62770. private _createChromaticAberrationPostProcess;
  62771. private _createHighlightsPostProcess;
  62772. private _createDepthOfFieldPostProcess;
  62773. private _createGrainTexture;
  62774. }
  62775. }
  62776. declare module "babylonjs/Shaders/ssao2.fragment" {
  62777. /** @hidden */
  62778. export var ssao2PixelShader: {
  62779. name: string;
  62780. shader: string;
  62781. };
  62782. }
  62783. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  62784. /** @hidden */
  62785. export var ssaoCombinePixelShader: {
  62786. name: string;
  62787. shader: string;
  62788. };
  62789. }
  62790. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  62791. import { Camera } from "babylonjs/Cameras/camera";
  62792. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62793. import { Scene } from "babylonjs/scene";
  62794. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62795. import "babylonjs/Shaders/ssao2.fragment";
  62796. import "babylonjs/Shaders/ssaoCombine.fragment";
  62797. /**
  62798. * Render pipeline to produce ssao effect
  62799. */
  62800. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  62801. /**
  62802. * @ignore
  62803. * The PassPostProcess id in the pipeline that contains the original scene color
  62804. */
  62805. SSAOOriginalSceneColorEffect: string;
  62806. /**
  62807. * @ignore
  62808. * The SSAO PostProcess id in the pipeline
  62809. */
  62810. SSAORenderEffect: string;
  62811. /**
  62812. * @ignore
  62813. * The horizontal blur PostProcess id in the pipeline
  62814. */
  62815. SSAOBlurHRenderEffect: string;
  62816. /**
  62817. * @ignore
  62818. * The vertical blur PostProcess id in the pipeline
  62819. */
  62820. SSAOBlurVRenderEffect: string;
  62821. /**
  62822. * @ignore
  62823. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62824. */
  62825. SSAOCombineRenderEffect: string;
  62826. /**
  62827. * The output strength of the SSAO post-process. Default value is 1.0.
  62828. */
  62829. totalStrength: number;
  62830. /**
  62831. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  62832. */
  62833. maxZ: number;
  62834. /**
  62835. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  62836. */
  62837. minZAspect: number;
  62838. private _samples;
  62839. /**
  62840. * Number of samples used for the SSAO calculations. Default value is 8
  62841. */
  62842. samples: number;
  62843. private _textureSamples;
  62844. /**
  62845. * Number of samples to use for antialiasing
  62846. */
  62847. textureSamples: number;
  62848. /**
  62849. * Ratio object used for SSAO ratio and blur ratio
  62850. */
  62851. private _ratio;
  62852. /**
  62853. * Dynamically generated sphere sampler.
  62854. */
  62855. private _sampleSphere;
  62856. /**
  62857. * Blur filter offsets
  62858. */
  62859. private _samplerOffsets;
  62860. private _expensiveBlur;
  62861. /**
  62862. * If bilateral blur should be used
  62863. */
  62864. expensiveBlur: boolean;
  62865. /**
  62866. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  62867. */
  62868. radius: number;
  62869. /**
  62870. * The base color of the SSAO post-process
  62871. * The final result is "base + ssao" between [0, 1]
  62872. */
  62873. base: number;
  62874. /**
  62875. * Support test.
  62876. */
  62877. static readonly IsSupported: boolean;
  62878. private _scene;
  62879. private _depthTexture;
  62880. private _normalTexture;
  62881. private _randomTexture;
  62882. private _originalColorPostProcess;
  62883. private _ssaoPostProcess;
  62884. private _blurHPostProcess;
  62885. private _blurVPostProcess;
  62886. private _ssaoCombinePostProcess;
  62887. private _firstUpdate;
  62888. /**
  62889. * Gets active scene
  62890. */
  62891. readonly scene: Scene;
  62892. /**
  62893. * @constructor
  62894. * @param name The rendering pipeline name
  62895. * @param scene The scene linked to this pipeline
  62896. * @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 }
  62897. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62898. */
  62899. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62900. /**
  62901. * Get the class name
  62902. * @returns "SSAO2RenderingPipeline"
  62903. */
  62904. getClassName(): string;
  62905. /**
  62906. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62907. */
  62908. dispose(disableGeometryBufferRenderer?: boolean): void;
  62909. private _createBlurPostProcess;
  62910. /** @hidden */
  62911. _rebuild(): void;
  62912. private _bits;
  62913. private _radicalInverse_VdC;
  62914. private _hammersley;
  62915. private _hemisphereSample_uniform;
  62916. private _generateHemisphere;
  62917. private _createSSAOPostProcess;
  62918. private _createSSAOCombinePostProcess;
  62919. private _createRandomTexture;
  62920. /**
  62921. * Serialize the rendering pipeline (Used when exporting)
  62922. * @returns the serialized object
  62923. */
  62924. serialize(): any;
  62925. /**
  62926. * Parse the serialized pipeline
  62927. * @param source Source pipeline.
  62928. * @param scene The scene to load the pipeline to.
  62929. * @param rootUrl The URL of the serialized pipeline.
  62930. * @returns An instantiated pipeline from the serialized object.
  62931. */
  62932. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  62933. }
  62934. }
  62935. declare module "babylonjs/Shaders/ssao.fragment" {
  62936. /** @hidden */
  62937. export var ssaoPixelShader: {
  62938. name: string;
  62939. shader: string;
  62940. };
  62941. }
  62942. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  62943. import { Camera } from "babylonjs/Cameras/camera";
  62944. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62945. import { Scene } from "babylonjs/scene";
  62946. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62947. import "babylonjs/Shaders/ssao.fragment";
  62948. import "babylonjs/Shaders/ssaoCombine.fragment";
  62949. /**
  62950. * Render pipeline to produce ssao effect
  62951. */
  62952. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  62953. /**
  62954. * @ignore
  62955. * The PassPostProcess id in the pipeline that contains the original scene color
  62956. */
  62957. SSAOOriginalSceneColorEffect: string;
  62958. /**
  62959. * @ignore
  62960. * The SSAO PostProcess id in the pipeline
  62961. */
  62962. SSAORenderEffect: string;
  62963. /**
  62964. * @ignore
  62965. * The horizontal blur PostProcess id in the pipeline
  62966. */
  62967. SSAOBlurHRenderEffect: string;
  62968. /**
  62969. * @ignore
  62970. * The vertical blur PostProcess id in the pipeline
  62971. */
  62972. SSAOBlurVRenderEffect: string;
  62973. /**
  62974. * @ignore
  62975. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62976. */
  62977. SSAOCombineRenderEffect: string;
  62978. /**
  62979. * The output strength of the SSAO post-process. Default value is 1.0.
  62980. */
  62981. totalStrength: number;
  62982. /**
  62983. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  62984. */
  62985. radius: number;
  62986. /**
  62987. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  62988. * Must not be equal to fallOff and superior to fallOff.
  62989. * Default value is 0.0075
  62990. */
  62991. area: number;
  62992. /**
  62993. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  62994. * Must not be equal to area and inferior to area.
  62995. * Default value is 0.000001
  62996. */
  62997. fallOff: number;
  62998. /**
  62999. * The base color of the SSAO post-process
  63000. * The final result is "base + ssao" between [0, 1]
  63001. */
  63002. base: number;
  63003. private _scene;
  63004. private _depthTexture;
  63005. private _randomTexture;
  63006. private _originalColorPostProcess;
  63007. private _ssaoPostProcess;
  63008. private _blurHPostProcess;
  63009. private _blurVPostProcess;
  63010. private _ssaoCombinePostProcess;
  63011. private _firstUpdate;
  63012. /**
  63013. * Gets active scene
  63014. */
  63015. readonly scene: Scene;
  63016. /**
  63017. * @constructor
  63018. * @param name - The rendering pipeline name
  63019. * @param scene - The scene linked to this pipeline
  63020. * @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 }
  63021. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63022. */
  63023. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63024. /**
  63025. * Get the class name
  63026. * @returns "SSAORenderingPipeline"
  63027. */
  63028. getClassName(): string;
  63029. /**
  63030. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63031. */
  63032. dispose(disableDepthRender?: boolean): void;
  63033. private _createBlurPostProcess;
  63034. /** @hidden */
  63035. _rebuild(): void;
  63036. private _createSSAOPostProcess;
  63037. private _createSSAOCombinePostProcess;
  63038. private _createRandomTexture;
  63039. }
  63040. }
  63041. declare module "babylonjs/Shaders/standard.fragment" {
  63042. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63043. /** @hidden */
  63044. export var standardPixelShader: {
  63045. name: string;
  63046. shader: string;
  63047. };
  63048. }
  63049. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  63050. import { Nullable } from "babylonjs/types";
  63051. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63052. import { Camera } from "babylonjs/Cameras/camera";
  63053. import { Texture } from "babylonjs/Materials/Textures/texture";
  63054. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63055. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63056. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63057. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63058. import { IDisposable } from "babylonjs/scene";
  63059. import { SpotLight } from "babylonjs/Lights/spotLight";
  63060. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63061. import { Scene } from "babylonjs/scene";
  63062. import { Animation } from "babylonjs/Animations/animation";
  63063. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63064. import "babylonjs/Shaders/standard.fragment";
  63065. /**
  63066. * Standard rendering pipeline
  63067. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63068. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  63069. */
  63070. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63071. /**
  63072. * Public members
  63073. */
  63074. /**
  63075. * Post-process which contains the original scene color before the pipeline applies all the effects
  63076. */
  63077. originalPostProcess: Nullable<PostProcess>;
  63078. /**
  63079. * Post-process used to down scale an image x4
  63080. */
  63081. downSampleX4PostProcess: Nullable<PostProcess>;
  63082. /**
  63083. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  63084. */
  63085. brightPassPostProcess: Nullable<PostProcess>;
  63086. /**
  63087. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  63088. */
  63089. blurHPostProcesses: PostProcess[];
  63090. /**
  63091. * Post-process array storing all the vertical blur post-processes used by the pipeline
  63092. */
  63093. blurVPostProcesses: PostProcess[];
  63094. /**
  63095. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  63096. */
  63097. textureAdderPostProcess: Nullable<PostProcess>;
  63098. /**
  63099. * Post-process used to create volumetric lighting effect
  63100. */
  63101. volumetricLightPostProcess: Nullable<PostProcess>;
  63102. /**
  63103. * Post-process used to smooth the previous volumetric light post-process on the X axis
  63104. */
  63105. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  63106. /**
  63107. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  63108. */
  63109. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  63110. /**
  63111. * Post-process used to merge the volumetric light effect and the real scene color
  63112. */
  63113. volumetricLightMergePostProces: Nullable<PostProcess>;
  63114. /**
  63115. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  63116. */
  63117. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  63118. /**
  63119. * Base post-process used to calculate the average luminance of the final image for HDR
  63120. */
  63121. luminancePostProcess: Nullable<PostProcess>;
  63122. /**
  63123. * Post-processes used to create down sample post-processes in order to get
  63124. * the average luminance of the final image for HDR
  63125. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  63126. */
  63127. luminanceDownSamplePostProcesses: PostProcess[];
  63128. /**
  63129. * Post-process used to create a HDR effect (light adaptation)
  63130. */
  63131. hdrPostProcess: Nullable<PostProcess>;
  63132. /**
  63133. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  63134. */
  63135. textureAdderFinalPostProcess: Nullable<PostProcess>;
  63136. /**
  63137. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  63138. */
  63139. lensFlareFinalPostProcess: Nullable<PostProcess>;
  63140. /**
  63141. * Post-process used to merge the final HDR post-process and the real scene color
  63142. */
  63143. hdrFinalPostProcess: Nullable<PostProcess>;
  63144. /**
  63145. * Post-process used to create a lens flare effect
  63146. */
  63147. lensFlarePostProcess: Nullable<PostProcess>;
  63148. /**
  63149. * Post-process that merges the result of the lens flare post-process and the real scene color
  63150. */
  63151. lensFlareComposePostProcess: Nullable<PostProcess>;
  63152. /**
  63153. * Post-process used to create a motion blur effect
  63154. */
  63155. motionBlurPostProcess: Nullable<PostProcess>;
  63156. /**
  63157. * Post-process used to create a depth of field effect
  63158. */
  63159. depthOfFieldPostProcess: Nullable<PostProcess>;
  63160. /**
  63161. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63162. */
  63163. fxaaPostProcess: Nullable<FxaaPostProcess>;
  63164. /**
  63165. * Represents the brightness threshold in order to configure the illuminated surfaces
  63166. */
  63167. brightThreshold: number;
  63168. /**
  63169. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  63170. */
  63171. blurWidth: number;
  63172. /**
  63173. * Sets if the blur for highlighted surfaces must be only horizontal
  63174. */
  63175. horizontalBlur: boolean;
  63176. /**
  63177. * Gets the overall exposure used by the pipeline
  63178. */
  63179. /**
  63180. * Sets the overall exposure used by the pipeline
  63181. */
  63182. exposure: number;
  63183. /**
  63184. * Texture used typically to simulate "dirty" on camera lens
  63185. */
  63186. lensTexture: Nullable<Texture>;
  63187. /**
  63188. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  63189. */
  63190. volumetricLightCoefficient: number;
  63191. /**
  63192. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  63193. */
  63194. volumetricLightPower: number;
  63195. /**
  63196. * Used the set the blur intensity to smooth the volumetric lights
  63197. */
  63198. volumetricLightBlurScale: number;
  63199. /**
  63200. * Light (spot or directional) used to generate the volumetric lights rays
  63201. * The source light must have a shadow generate so the pipeline can get its
  63202. * depth map
  63203. */
  63204. sourceLight: Nullable<SpotLight | DirectionalLight>;
  63205. /**
  63206. * For eye adaptation, represents the minimum luminance the eye can see
  63207. */
  63208. hdrMinimumLuminance: number;
  63209. /**
  63210. * For eye adaptation, represents the decrease luminance speed
  63211. */
  63212. hdrDecreaseRate: number;
  63213. /**
  63214. * For eye adaptation, represents the increase luminance speed
  63215. */
  63216. hdrIncreaseRate: number;
  63217. /**
  63218. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63219. */
  63220. /**
  63221. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63222. */
  63223. hdrAutoExposure: boolean;
  63224. /**
  63225. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  63226. */
  63227. lensColorTexture: Nullable<Texture>;
  63228. /**
  63229. * The overall strengh for the lens flare effect
  63230. */
  63231. lensFlareStrength: number;
  63232. /**
  63233. * Dispersion coefficient for lens flare ghosts
  63234. */
  63235. lensFlareGhostDispersal: number;
  63236. /**
  63237. * Main lens flare halo width
  63238. */
  63239. lensFlareHaloWidth: number;
  63240. /**
  63241. * Based on the lens distortion effect, defines how much the lens flare result
  63242. * is distorted
  63243. */
  63244. lensFlareDistortionStrength: number;
  63245. /**
  63246. * Configures the blur intensity used for for lens flare (halo)
  63247. */
  63248. lensFlareBlurWidth: number;
  63249. /**
  63250. * Lens star texture must be used to simulate rays on the flares and is available
  63251. * in the documentation
  63252. */
  63253. lensStarTexture: Nullable<Texture>;
  63254. /**
  63255. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  63256. * flare effect by taking account of the dirt texture
  63257. */
  63258. lensFlareDirtTexture: Nullable<Texture>;
  63259. /**
  63260. * Represents the focal length for the depth of field effect
  63261. */
  63262. depthOfFieldDistance: number;
  63263. /**
  63264. * Represents the blur intensity for the blurred part of the depth of field effect
  63265. */
  63266. depthOfFieldBlurWidth: number;
  63267. /**
  63268. * Gets how much the image is blurred by the movement while using the motion blur post-process
  63269. */
  63270. /**
  63271. * Sets how much the image is blurred by the movement while using the motion blur post-process
  63272. */
  63273. motionStrength: number;
  63274. /**
  63275. * Gets wether or not the motion blur post-process is object based or screen based.
  63276. */
  63277. /**
  63278. * Sets wether or not the motion blur post-process should be object based or screen based
  63279. */
  63280. objectBasedMotionBlur: boolean;
  63281. /**
  63282. * List of animations for the pipeline (IAnimatable implementation)
  63283. */
  63284. animations: Animation[];
  63285. /**
  63286. * Private members
  63287. */
  63288. private _scene;
  63289. private _currentDepthOfFieldSource;
  63290. private _basePostProcess;
  63291. private _fixedExposure;
  63292. private _currentExposure;
  63293. private _hdrAutoExposure;
  63294. private _hdrCurrentLuminance;
  63295. private _motionStrength;
  63296. private _isObjectBasedMotionBlur;
  63297. private _floatTextureType;
  63298. private _camerasToBeAttached;
  63299. private _ratio;
  63300. private _bloomEnabled;
  63301. private _depthOfFieldEnabled;
  63302. private _vlsEnabled;
  63303. private _lensFlareEnabled;
  63304. private _hdrEnabled;
  63305. private _motionBlurEnabled;
  63306. private _fxaaEnabled;
  63307. private _motionBlurSamples;
  63308. private _volumetricLightStepsCount;
  63309. private _samples;
  63310. /**
  63311. * @ignore
  63312. * Specifies if the bloom pipeline is enabled
  63313. */
  63314. BloomEnabled: boolean;
  63315. /**
  63316. * @ignore
  63317. * Specifies if the depth of field pipeline is enabed
  63318. */
  63319. DepthOfFieldEnabled: boolean;
  63320. /**
  63321. * @ignore
  63322. * Specifies if the lens flare pipeline is enabed
  63323. */
  63324. LensFlareEnabled: boolean;
  63325. /**
  63326. * @ignore
  63327. * Specifies if the HDR pipeline is enabled
  63328. */
  63329. HDREnabled: boolean;
  63330. /**
  63331. * @ignore
  63332. * Specifies if the volumetric lights scattering effect is enabled
  63333. */
  63334. VLSEnabled: boolean;
  63335. /**
  63336. * @ignore
  63337. * Specifies if the motion blur effect is enabled
  63338. */
  63339. MotionBlurEnabled: boolean;
  63340. /**
  63341. * Specifies if anti-aliasing is enabled
  63342. */
  63343. fxaaEnabled: boolean;
  63344. /**
  63345. * Specifies the number of steps used to calculate the volumetric lights
  63346. * Typically in interval [50, 200]
  63347. */
  63348. volumetricLightStepsCount: number;
  63349. /**
  63350. * Specifies the number of samples used for the motion blur effect
  63351. * Typically in interval [16, 64]
  63352. */
  63353. motionBlurSamples: number;
  63354. /**
  63355. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63356. */
  63357. samples: number;
  63358. /**
  63359. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63360. * @constructor
  63361. * @param name The rendering pipeline name
  63362. * @param scene The scene linked to this pipeline
  63363. * @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)
  63364. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  63365. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63366. */
  63367. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  63368. private _buildPipeline;
  63369. private _createDownSampleX4PostProcess;
  63370. private _createBrightPassPostProcess;
  63371. private _createBlurPostProcesses;
  63372. private _createTextureAdderPostProcess;
  63373. private _createVolumetricLightPostProcess;
  63374. private _createLuminancePostProcesses;
  63375. private _createHdrPostProcess;
  63376. private _createLensFlarePostProcess;
  63377. private _createDepthOfFieldPostProcess;
  63378. private _createMotionBlurPostProcess;
  63379. private _getDepthTexture;
  63380. private _disposePostProcesses;
  63381. /**
  63382. * Dispose of the pipeline and stop all post processes
  63383. */
  63384. dispose(): void;
  63385. /**
  63386. * Serialize the rendering pipeline (Used when exporting)
  63387. * @returns the serialized object
  63388. */
  63389. serialize(): any;
  63390. /**
  63391. * Parse the serialized pipeline
  63392. * @param source Source pipeline.
  63393. * @param scene The scene to load the pipeline to.
  63394. * @param rootUrl The URL of the serialized pipeline.
  63395. * @returns An instantiated pipeline from the serialized object.
  63396. */
  63397. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  63398. /**
  63399. * Luminance steps
  63400. */
  63401. static LuminanceSteps: number;
  63402. }
  63403. }
  63404. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  63405. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  63406. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  63407. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  63408. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  63409. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  63410. }
  63411. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  63412. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  63413. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63414. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63415. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63416. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63417. }
  63418. declare module "babylonjs/Shaders/tonemap.fragment" {
  63419. /** @hidden */
  63420. export var tonemapPixelShader: {
  63421. name: string;
  63422. shader: string;
  63423. };
  63424. }
  63425. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  63426. import { Camera } from "babylonjs/Cameras/camera";
  63427. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63428. import "babylonjs/Shaders/tonemap.fragment";
  63429. import { Engine } from "babylonjs/Engines/engine";
  63430. /** Defines operator used for tonemapping */
  63431. export enum TonemappingOperator {
  63432. /** Hable */
  63433. Hable = 0,
  63434. /** Reinhard */
  63435. Reinhard = 1,
  63436. /** HejiDawson */
  63437. HejiDawson = 2,
  63438. /** Photographic */
  63439. Photographic = 3
  63440. }
  63441. /**
  63442. * Defines a post process to apply tone mapping
  63443. */
  63444. export class TonemapPostProcess extends PostProcess {
  63445. private _operator;
  63446. /** Defines the required exposure adjustement */
  63447. exposureAdjustment: number;
  63448. /**
  63449. * Creates a new TonemapPostProcess
  63450. * @param name defines the name of the postprocess
  63451. * @param _operator defines the operator to use
  63452. * @param exposureAdjustment defines the required exposure adjustement
  63453. * @param camera defines the camera to use (can be null)
  63454. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63455. * @param engine defines the hosting engine (can be ignore if camera is set)
  63456. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63457. */
  63458. constructor(name: string, _operator: TonemappingOperator,
  63459. /** Defines the required exposure adjustement */
  63460. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63461. }
  63462. }
  63463. declare module "babylonjs/Shaders/depth.vertex" {
  63464. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63465. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63466. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63467. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63468. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63469. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63470. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63471. /** @hidden */
  63472. export var depthVertexShader: {
  63473. name: string;
  63474. shader: string;
  63475. };
  63476. }
  63477. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  63478. /** @hidden */
  63479. export var volumetricLightScatteringPixelShader: {
  63480. name: string;
  63481. shader: string;
  63482. };
  63483. }
  63484. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  63485. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63486. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63487. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63488. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63489. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63490. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63491. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63492. /** @hidden */
  63493. export var volumetricLightScatteringPassVertexShader: {
  63494. name: string;
  63495. shader: string;
  63496. };
  63497. }
  63498. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  63499. /** @hidden */
  63500. export var volumetricLightScatteringPassPixelShader: {
  63501. name: string;
  63502. shader: string;
  63503. };
  63504. }
  63505. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  63506. import { Vector3 } from "babylonjs/Maths/math.vector";
  63507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63508. import { Mesh } from "babylonjs/Meshes/mesh";
  63509. import { Camera } from "babylonjs/Cameras/camera";
  63510. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63511. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63512. import { Scene } from "babylonjs/scene";
  63513. import "babylonjs/Meshes/Builders/planeBuilder";
  63514. import "babylonjs/Shaders/depth.vertex";
  63515. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  63516. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  63517. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  63518. import { Engine } from "babylonjs/Engines/engine";
  63519. /**
  63520. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  63521. */
  63522. export class VolumetricLightScatteringPostProcess extends PostProcess {
  63523. private _volumetricLightScatteringPass;
  63524. private _volumetricLightScatteringRTT;
  63525. private _viewPort;
  63526. private _screenCoordinates;
  63527. private _cachedDefines;
  63528. /**
  63529. * If not undefined, the mesh position is computed from the attached node position
  63530. */
  63531. attachedNode: {
  63532. position: Vector3;
  63533. };
  63534. /**
  63535. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  63536. */
  63537. customMeshPosition: Vector3;
  63538. /**
  63539. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  63540. */
  63541. useCustomMeshPosition: boolean;
  63542. /**
  63543. * If the post-process should inverse the light scattering direction
  63544. */
  63545. invert: boolean;
  63546. /**
  63547. * The internal mesh used by the post-process
  63548. */
  63549. mesh: Mesh;
  63550. /**
  63551. * @hidden
  63552. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  63553. */
  63554. useDiffuseColor: boolean;
  63555. /**
  63556. * Array containing the excluded meshes not rendered in the internal pass
  63557. */
  63558. excludedMeshes: AbstractMesh[];
  63559. /**
  63560. * Controls the overall intensity of the post-process
  63561. */
  63562. exposure: number;
  63563. /**
  63564. * Dissipates each sample's contribution in range [0, 1]
  63565. */
  63566. decay: number;
  63567. /**
  63568. * Controls the overall intensity of each sample
  63569. */
  63570. weight: number;
  63571. /**
  63572. * Controls the density of each sample
  63573. */
  63574. density: number;
  63575. /**
  63576. * @constructor
  63577. * @param name The post-process name
  63578. * @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)
  63579. * @param camera The camera that the post-process will be attached to
  63580. * @param mesh The mesh used to create the light scattering
  63581. * @param samples The post-process quality, default 100
  63582. * @param samplingModeThe post-process filtering mode
  63583. * @param engine The babylon engine
  63584. * @param reusable If the post-process is reusable
  63585. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  63586. */
  63587. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  63588. /**
  63589. * Returns the string "VolumetricLightScatteringPostProcess"
  63590. * @returns "VolumetricLightScatteringPostProcess"
  63591. */
  63592. getClassName(): string;
  63593. private _isReady;
  63594. /**
  63595. * Sets the new light position for light scattering effect
  63596. * @param position The new custom light position
  63597. */
  63598. setCustomMeshPosition(position: Vector3): void;
  63599. /**
  63600. * Returns the light position for light scattering effect
  63601. * @return Vector3 The custom light position
  63602. */
  63603. getCustomMeshPosition(): Vector3;
  63604. /**
  63605. * Disposes the internal assets and detaches the post-process from the camera
  63606. */
  63607. dispose(camera: Camera): void;
  63608. /**
  63609. * Returns the render target texture used by the post-process
  63610. * @return the render target texture used by the post-process
  63611. */
  63612. getPass(): RenderTargetTexture;
  63613. private _meshExcluded;
  63614. private _createPass;
  63615. private _updateMeshScreenCoordinates;
  63616. /**
  63617. * Creates a default mesh for the Volumeric Light Scattering post-process
  63618. * @param name The mesh name
  63619. * @param scene The scene where to create the mesh
  63620. * @return the default mesh
  63621. */
  63622. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  63623. }
  63624. }
  63625. declare module "babylonjs/PostProcesses/index" {
  63626. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  63627. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  63628. export * from "babylonjs/PostProcesses/bloomEffect";
  63629. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  63630. export * from "babylonjs/PostProcesses/blurPostProcess";
  63631. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63632. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  63633. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  63634. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  63635. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63636. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  63637. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  63638. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  63639. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63640. export * from "babylonjs/PostProcesses/filterPostProcess";
  63641. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  63642. export * from "babylonjs/PostProcesses/grainPostProcess";
  63643. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  63644. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63645. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  63646. export * from "babylonjs/PostProcesses/passPostProcess";
  63647. export * from "babylonjs/PostProcesses/postProcess";
  63648. export * from "babylonjs/PostProcesses/postProcessManager";
  63649. export * from "babylonjs/PostProcesses/refractionPostProcess";
  63650. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  63651. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  63652. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  63653. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  63654. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  63655. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  63656. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  63657. }
  63658. declare module "babylonjs/Probes/index" {
  63659. export * from "babylonjs/Probes/reflectionProbe";
  63660. }
  63661. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  63662. import { Scene } from "babylonjs/scene";
  63663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63664. import { SmartArray } from "babylonjs/Misc/smartArray";
  63665. import { ISceneComponent } from "babylonjs/sceneComponent";
  63666. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  63667. import "babylonjs/Meshes/Builders/boxBuilder";
  63668. import "babylonjs/Shaders/color.fragment";
  63669. import "babylonjs/Shaders/color.vertex";
  63670. import { Color3 } from "babylonjs/Maths/math.color";
  63671. module "babylonjs/scene" {
  63672. interface Scene {
  63673. /** @hidden (Backing field) */
  63674. _boundingBoxRenderer: BoundingBoxRenderer;
  63675. /** @hidden (Backing field) */
  63676. _forceShowBoundingBoxes: boolean;
  63677. /**
  63678. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  63679. */
  63680. forceShowBoundingBoxes: boolean;
  63681. /**
  63682. * Gets the bounding box renderer associated with the scene
  63683. * @returns a BoundingBoxRenderer
  63684. */
  63685. getBoundingBoxRenderer(): BoundingBoxRenderer;
  63686. }
  63687. }
  63688. module "babylonjs/Meshes/abstractMesh" {
  63689. interface AbstractMesh {
  63690. /** @hidden (Backing field) */
  63691. _showBoundingBox: boolean;
  63692. /**
  63693. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  63694. */
  63695. showBoundingBox: boolean;
  63696. }
  63697. }
  63698. /**
  63699. * Component responsible of rendering the bounding box of the meshes in a scene.
  63700. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  63701. */
  63702. export class BoundingBoxRenderer implements ISceneComponent {
  63703. /**
  63704. * The component name helpfull to identify the component in the list of scene components.
  63705. */
  63706. readonly name: string;
  63707. /**
  63708. * The scene the component belongs to.
  63709. */
  63710. scene: Scene;
  63711. /**
  63712. * Color of the bounding box lines placed in front of an object
  63713. */
  63714. frontColor: Color3;
  63715. /**
  63716. * Color of the bounding box lines placed behind an object
  63717. */
  63718. backColor: Color3;
  63719. /**
  63720. * Defines if the renderer should show the back lines or not
  63721. */
  63722. showBackLines: boolean;
  63723. /**
  63724. * @hidden
  63725. */
  63726. renderList: SmartArray<BoundingBox>;
  63727. private _colorShader;
  63728. private _vertexBuffers;
  63729. private _indexBuffer;
  63730. private _fillIndexBuffer;
  63731. private _fillIndexData;
  63732. /**
  63733. * Instantiates a new bounding box renderer in a scene.
  63734. * @param scene the scene the renderer renders in
  63735. */
  63736. constructor(scene: Scene);
  63737. /**
  63738. * Registers the component in a given scene
  63739. */
  63740. register(): void;
  63741. private _evaluateSubMesh;
  63742. private _activeMesh;
  63743. private _prepareRessources;
  63744. private _createIndexBuffer;
  63745. /**
  63746. * Rebuilds the elements related to this component in case of
  63747. * context lost for instance.
  63748. */
  63749. rebuild(): void;
  63750. /**
  63751. * @hidden
  63752. */
  63753. reset(): void;
  63754. /**
  63755. * Render the bounding boxes of a specific rendering group
  63756. * @param renderingGroupId defines the rendering group to render
  63757. */
  63758. render(renderingGroupId: number): void;
  63759. /**
  63760. * In case of occlusion queries, we can render the occlusion bounding box through this method
  63761. * @param mesh Define the mesh to render the occlusion bounding box for
  63762. */
  63763. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  63764. /**
  63765. * Dispose and release the resources attached to this renderer.
  63766. */
  63767. dispose(): void;
  63768. }
  63769. }
  63770. declare module "babylonjs/Shaders/depth.fragment" {
  63771. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63772. /** @hidden */
  63773. export var depthPixelShader: {
  63774. name: string;
  63775. shader: string;
  63776. };
  63777. }
  63778. declare module "babylonjs/Rendering/depthRenderer" {
  63779. import { Nullable } from "babylonjs/types";
  63780. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63781. import { Scene } from "babylonjs/scene";
  63782. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63783. import { Camera } from "babylonjs/Cameras/camera";
  63784. import "babylonjs/Shaders/depth.fragment";
  63785. import "babylonjs/Shaders/depth.vertex";
  63786. /**
  63787. * This represents a depth renderer in Babylon.
  63788. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63789. */
  63790. export class DepthRenderer {
  63791. private _scene;
  63792. private _depthMap;
  63793. private _effect;
  63794. private readonly _storeNonLinearDepth;
  63795. private readonly _clearColor;
  63796. /** Get if the depth renderer is using packed depth or not */
  63797. readonly isPacked: boolean;
  63798. private _cachedDefines;
  63799. private _camera;
  63800. /**
  63801. * Specifiess that the depth renderer will only be used within
  63802. * the camera it is created for.
  63803. * This can help forcing its rendering during the camera processing.
  63804. */
  63805. useOnlyInActiveCamera: boolean;
  63806. /** @hidden */
  63807. static _SceneComponentInitialization: (scene: Scene) => void;
  63808. /**
  63809. * Instantiates a depth renderer
  63810. * @param scene The scene the renderer belongs to
  63811. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63812. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63813. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63814. */
  63815. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63816. /**
  63817. * Creates the depth rendering effect and checks if the effect is ready.
  63818. * @param subMesh The submesh to be used to render the depth map of
  63819. * @param useInstances If multiple world instances should be used
  63820. * @returns if the depth renderer is ready to render the depth map
  63821. */
  63822. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63823. /**
  63824. * Gets the texture which the depth map will be written to.
  63825. * @returns The depth map texture
  63826. */
  63827. getDepthMap(): RenderTargetTexture;
  63828. /**
  63829. * Disposes of the depth renderer.
  63830. */
  63831. dispose(): void;
  63832. }
  63833. }
  63834. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  63835. import { Nullable } from "babylonjs/types";
  63836. import { Scene } from "babylonjs/scene";
  63837. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63838. import { Camera } from "babylonjs/Cameras/camera";
  63839. import { ISceneComponent } from "babylonjs/sceneComponent";
  63840. module "babylonjs/scene" {
  63841. interface Scene {
  63842. /** @hidden (Backing field) */
  63843. _depthRenderer: {
  63844. [id: string]: DepthRenderer;
  63845. };
  63846. /**
  63847. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  63848. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  63849. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63850. * @returns the created depth renderer
  63851. */
  63852. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  63853. /**
  63854. * Disables a depth renderer for a given camera
  63855. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  63856. */
  63857. disableDepthRenderer(camera?: Nullable<Camera>): void;
  63858. }
  63859. }
  63860. /**
  63861. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  63862. * in several rendering techniques.
  63863. */
  63864. export class DepthRendererSceneComponent implements ISceneComponent {
  63865. /**
  63866. * The component name helpfull to identify the component in the list of scene components.
  63867. */
  63868. readonly name: string;
  63869. /**
  63870. * The scene the component belongs to.
  63871. */
  63872. scene: Scene;
  63873. /**
  63874. * Creates a new instance of the component for the given scene
  63875. * @param scene Defines the scene to register the component in
  63876. */
  63877. constructor(scene: Scene);
  63878. /**
  63879. * Registers the component in a given scene
  63880. */
  63881. register(): void;
  63882. /**
  63883. * Rebuilds the elements related to this component in case of
  63884. * context lost for instance.
  63885. */
  63886. rebuild(): void;
  63887. /**
  63888. * Disposes the component and the associated ressources
  63889. */
  63890. dispose(): void;
  63891. private _gatherRenderTargets;
  63892. private _gatherActiveCameraRenderTargets;
  63893. }
  63894. }
  63895. declare module "babylonjs/Shaders/outline.fragment" {
  63896. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63897. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  63898. /** @hidden */
  63899. export var outlinePixelShader: {
  63900. name: string;
  63901. shader: string;
  63902. };
  63903. }
  63904. declare module "babylonjs/Shaders/outline.vertex" {
  63905. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63906. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63907. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63908. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63909. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63910. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63911. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63912. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63913. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  63914. /** @hidden */
  63915. export var outlineVertexShader: {
  63916. name: string;
  63917. shader: string;
  63918. };
  63919. }
  63920. declare module "babylonjs/Rendering/outlineRenderer" {
  63921. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63922. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  63923. import { Scene } from "babylonjs/scene";
  63924. import { ISceneComponent } from "babylonjs/sceneComponent";
  63925. import "babylonjs/Shaders/outline.fragment";
  63926. import "babylonjs/Shaders/outline.vertex";
  63927. module "babylonjs/scene" {
  63928. interface Scene {
  63929. /** @hidden */
  63930. _outlineRenderer: OutlineRenderer;
  63931. /**
  63932. * Gets the outline renderer associated with the scene
  63933. * @returns a OutlineRenderer
  63934. */
  63935. getOutlineRenderer(): OutlineRenderer;
  63936. }
  63937. }
  63938. module "babylonjs/Meshes/abstractMesh" {
  63939. interface AbstractMesh {
  63940. /** @hidden (Backing field) */
  63941. _renderOutline: boolean;
  63942. /**
  63943. * Gets or sets a boolean indicating if the outline must be rendered as well
  63944. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  63945. */
  63946. renderOutline: boolean;
  63947. /** @hidden (Backing field) */
  63948. _renderOverlay: boolean;
  63949. /**
  63950. * Gets or sets a boolean indicating if the overlay must be rendered as well
  63951. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  63952. */
  63953. renderOverlay: boolean;
  63954. }
  63955. }
  63956. /**
  63957. * This class is responsible to draw bothe outline/overlay of meshes.
  63958. * It should not be used directly but through the available method on mesh.
  63959. */
  63960. export class OutlineRenderer implements ISceneComponent {
  63961. /**
  63962. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  63963. */
  63964. private static _StencilReference;
  63965. /**
  63966. * The name of the component. Each component must have a unique name.
  63967. */
  63968. name: string;
  63969. /**
  63970. * The scene the component belongs to.
  63971. */
  63972. scene: Scene;
  63973. /**
  63974. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  63975. */
  63976. zOffset: number;
  63977. private _engine;
  63978. private _effect;
  63979. private _cachedDefines;
  63980. private _savedDepthWrite;
  63981. /**
  63982. * Instantiates a new outline renderer. (There could be only one per scene).
  63983. * @param scene Defines the scene it belongs to
  63984. */
  63985. constructor(scene: Scene);
  63986. /**
  63987. * Register the component to one instance of a scene.
  63988. */
  63989. register(): void;
  63990. /**
  63991. * Rebuilds the elements related to this component in case of
  63992. * context lost for instance.
  63993. */
  63994. rebuild(): void;
  63995. /**
  63996. * Disposes the component and the associated ressources.
  63997. */
  63998. dispose(): void;
  63999. /**
  64000. * Renders the outline in the canvas.
  64001. * @param subMesh Defines the sumesh to render
  64002. * @param batch Defines the batch of meshes in case of instances
  64003. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64004. */
  64005. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64006. /**
  64007. * Returns whether or not the outline renderer is ready for a given submesh.
  64008. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64009. * @param subMesh Defines the submesh to check readyness for
  64010. * @param useInstances Defines wheter wee are trying to render instances or not
  64011. * @returns true if ready otherwise false
  64012. */
  64013. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64014. private _beforeRenderingMesh;
  64015. private _afterRenderingMesh;
  64016. }
  64017. }
  64018. declare module "babylonjs/Rendering/index" {
  64019. export * from "babylonjs/Rendering/boundingBoxRenderer";
  64020. export * from "babylonjs/Rendering/depthRenderer";
  64021. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  64022. export * from "babylonjs/Rendering/edgesRenderer";
  64023. export * from "babylonjs/Rendering/geometryBufferRenderer";
  64024. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64025. export * from "babylonjs/Rendering/outlineRenderer";
  64026. export * from "babylonjs/Rendering/renderingGroup";
  64027. export * from "babylonjs/Rendering/renderingManager";
  64028. export * from "babylonjs/Rendering/utilityLayerRenderer";
  64029. }
  64030. declare module "babylonjs/Sprites/spritePackedManager" {
  64031. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  64032. import { Scene } from "babylonjs/scene";
  64033. /**
  64034. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64035. * @see http://doc.babylonjs.com/babylon101/sprites
  64036. */
  64037. export class SpritePackedManager extends SpriteManager {
  64038. /** defines the packed manager's name */
  64039. name: string;
  64040. /**
  64041. * Creates a new sprite manager from a packed sprite sheet
  64042. * @param name defines the manager's name
  64043. * @param imgUrl defines the sprite sheet url
  64044. * @param capacity defines the maximum allowed number of sprites
  64045. * @param scene defines the hosting scene
  64046. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  64047. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  64048. * @param samplingMode defines the smapling mode to use with spritesheet
  64049. * @param fromPacked set to true; do not alter
  64050. */
  64051. constructor(
  64052. /** defines the packed manager's name */
  64053. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  64054. }
  64055. }
  64056. declare module "babylonjs/Sprites/index" {
  64057. export * from "babylonjs/Sprites/sprite";
  64058. export * from "babylonjs/Sprites/spriteManager";
  64059. export * from "babylonjs/Sprites/spritePackedManager";
  64060. export * from "babylonjs/Sprites/spriteSceneComponent";
  64061. }
  64062. declare module "babylonjs/Misc/assetsManager" {
  64063. import { Scene } from "babylonjs/scene";
  64064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64065. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64066. import { Skeleton } from "babylonjs/Bones/skeleton";
  64067. import { Observable } from "babylonjs/Misc/observable";
  64068. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64069. import { Texture } from "babylonjs/Materials/Textures/texture";
  64070. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64071. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  64072. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64073. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  64074. /**
  64075. * Defines the list of states available for a task inside a AssetsManager
  64076. */
  64077. export enum AssetTaskState {
  64078. /**
  64079. * Initialization
  64080. */
  64081. INIT = 0,
  64082. /**
  64083. * Running
  64084. */
  64085. RUNNING = 1,
  64086. /**
  64087. * Done
  64088. */
  64089. DONE = 2,
  64090. /**
  64091. * Error
  64092. */
  64093. ERROR = 3
  64094. }
  64095. /**
  64096. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  64097. */
  64098. export abstract class AbstractAssetTask {
  64099. /**
  64100. * Task name
  64101. */ name: string;
  64102. /**
  64103. * Callback called when the task is successful
  64104. */
  64105. onSuccess: (task: any) => void;
  64106. /**
  64107. * Callback called when the task is not successful
  64108. */
  64109. onError: (task: any, message?: string, exception?: any) => void;
  64110. /**
  64111. * Creates a new AssetsManager
  64112. * @param name defines the name of the task
  64113. */
  64114. constructor(
  64115. /**
  64116. * Task name
  64117. */ name: string);
  64118. private _isCompleted;
  64119. private _taskState;
  64120. private _errorObject;
  64121. /**
  64122. * Get if the task is completed
  64123. */
  64124. readonly isCompleted: boolean;
  64125. /**
  64126. * Gets the current state of the task
  64127. */
  64128. readonly taskState: AssetTaskState;
  64129. /**
  64130. * Gets the current error object (if task is in error)
  64131. */
  64132. readonly errorObject: {
  64133. message?: string;
  64134. exception?: any;
  64135. };
  64136. /**
  64137. * Internal only
  64138. * @hidden
  64139. */
  64140. _setErrorObject(message?: string, exception?: any): void;
  64141. /**
  64142. * Execute the current task
  64143. * @param scene defines the scene where you want your assets to be loaded
  64144. * @param onSuccess is a callback called when the task is successfully executed
  64145. * @param onError is a callback called if an error occurs
  64146. */
  64147. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64148. /**
  64149. * Execute the current task
  64150. * @param scene defines the scene where you want your assets to be loaded
  64151. * @param onSuccess is a callback called when the task is successfully executed
  64152. * @param onError is a callback called if an error occurs
  64153. */
  64154. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64155. /**
  64156. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  64157. * This can be used with failed tasks that have the reason for failure fixed.
  64158. */
  64159. reset(): void;
  64160. private onErrorCallback;
  64161. private onDoneCallback;
  64162. }
  64163. /**
  64164. * Define the interface used by progress events raised during assets loading
  64165. */
  64166. export interface IAssetsProgressEvent {
  64167. /**
  64168. * Defines the number of remaining tasks to process
  64169. */
  64170. remainingCount: number;
  64171. /**
  64172. * Defines the total number of tasks
  64173. */
  64174. totalCount: number;
  64175. /**
  64176. * Defines the task that was just processed
  64177. */
  64178. task: AbstractAssetTask;
  64179. }
  64180. /**
  64181. * Class used to share progress information about assets loading
  64182. */
  64183. export class AssetsProgressEvent implements IAssetsProgressEvent {
  64184. /**
  64185. * Defines the number of remaining tasks to process
  64186. */
  64187. remainingCount: number;
  64188. /**
  64189. * Defines the total number of tasks
  64190. */
  64191. totalCount: number;
  64192. /**
  64193. * Defines the task that was just processed
  64194. */
  64195. task: AbstractAssetTask;
  64196. /**
  64197. * Creates a AssetsProgressEvent
  64198. * @param remainingCount defines the number of remaining tasks to process
  64199. * @param totalCount defines the total number of tasks
  64200. * @param task defines the task that was just processed
  64201. */
  64202. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  64203. }
  64204. /**
  64205. * Define a task used by AssetsManager to load meshes
  64206. */
  64207. export class MeshAssetTask extends AbstractAssetTask {
  64208. /**
  64209. * Defines the name of the task
  64210. */
  64211. name: string;
  64212. /**
  64213. * Defines the list of mesh's names you want to load
  64214. */
  64215. meshesNames: any;
  64216. /**
  64217. * Defines the root url to use as a base to load your meshes and associated resources
  64218. */
  64219. rootUrl: string;
  64220. /**
  64221. * Defines the filename of the scene to load from
  64222. */
  64223. sceneFilename: string;
  64224. /**
  64225. * Gets the list of loaded meshes
  64226. */
  64227. loadedMeshes: Array<AbstractMesh>;
  64228. /**
  64229. * Gets the list of loaded particle systems
  64230. */
  64231. loadedParticleSystems: Array<IParticleSystem>;
  64232. /**
  64233. * Gets the list of loaded skeletons
  64234. */
  64235. loadedSkeletons: Array<Skeleton>;
  64236. /**
  64237. * Gets the list of loaded animation groups
  64238. */
  64239. loadedAnimationGroups: Array<AnimationGroup>;
  64240. /**
  64241. * Callback called when the task is successful
  64242. */
  64243. onSuccess: (task: MeshAssetTask) => void;
  64244. /**
  64245. * Callback called when the task is successful
  64246. */
  64247. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  64248. /**
  64249. * Creates a new MeshAssetTask
  64250. * @param name defines the name of the task
  64251. * @param meshesNames defines the list of mesh's names you want to load
  64252. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  64253. * @param sceneFilename defines the filename of the scene to load from
  64254. */
  64255. constructor(
  64256. /**
  64257. * Defines the name of the task
  64258. */
  64259. name: string,
  64260. /**
  64261. * Defines the list of mesh's names you want to load
  64262. */
  64263. meshesNames: any,
  64264. /**
  64265. * Defines the root url to use as a base to load your meshes and associated resources
  64266. */
  64267. rootUrl: string,
  64268. /**
  64269. * Defines the filename of the scene to load from
  64270. */
  64271. sceneFilename: string);
  64272. /**
  64273. * Execute the current task
  64274. * @param scene defines the scene where you want your assets to be loaded
  64275. * @param onSuccess is a callback called when the task is successfully executed
  64276. * @param onError is a callback called if an error occurs
  64277. */
  64278. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64279. }
  64280. /**
  64281. * Define a task used by AssetsManager to load text content
  64282. */
  64283. export class TextFileAssetTask extends AbstractAssetTask {
  64284. /**
  64285. * Defines the name of the task
  64286. */
  64287. name: string;
  64288. /**
  64289. * Defines the location of the file to load
  64290. */
  64291. url: string;
  64292. /**
  64293. * Gets the loaded text string
  64294. */
  64295. text: string;
  64296. /**
  64297. * Callback called when the task is successful
  64298. */
  64299. onSuccess: (task: TextFileAssetTask) => void;
  64300. /**
  64301. * Callback called when the task is successful
  64302. */
  64303. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  64304. /**
  64305. * Creates a new TextFileAssetTask object
  64306. * @param name defines the name of the task
  64307. * @param url defines the location of the file to load
  64308. */
  64309. constructor(
  64310. /**
  64311. * Defines the name of the task
  64312. */
  64313. name: string,
  64314. /**
  64315. * Defines the location of the file to load
  64316. */
  64317. url: string);
  64318. /**
  64319. * Execute the current task
  64320. * @param scene defines the scene where you want your assets to be loaded
  64321. * @param onSuccess is a callback called when the task is successfully executed
  64322. * @param onError is a callback called if an error occurs
  64323. */
  64324. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64325. }
  64326. /**
  64327. * Define a task used by AssetsManager to load binary data
  64328. */
  64329. export class BinaryFileAssetTask extends AbstractAssetTask {
  64330. /**
  64331. * Defines the name of the task
  64332. */
  64333. name: string;
  64334. /**
  64335. * Defines the location of the file to load
  64336. */
  64337. url: string;
  64338. /**
  64339. * Gets the lodaded data (as an array buffer)
  64340. */
  64341. data: ArrayBuffer;
  64342. /**
  64343. * Callback called when the task is successful
  64344. */
  64345. onSuccess: (task: BinaryFileAssetTask) => void;
  64346. /**
  64347. * Callback called when the task is successful
  64348. */
  64349. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  64350. /**
  64351. * Creates a new BinaryFileAssetTask object
  64352. * @param name defines the name of the new task
  64353. * @param url defines the location of the file to load
  64354. */
  64355. constructor(
  64356. /**
  64357. * Defines the name of the task
  64358. */
  64359. name: string,
  64360. /**
  64361. * Defines the location of the file to load
  64362. */
  64363. url: string);
  64364. /**
  64365. * Execute the current task
  64366. * @param scene defines the scene where you want your assets to be loaded
  64367. * @param onSuccess is a callback called when the task is successfully executed
  64368. * @param onError is a callback called if an error occurs
  64369. */
  64370. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64371. }
  64372. /**
  64373. * Define a task used by AssetsManager to load images
  64374. */
  64375. export class ImageAssetTask extends AbstractAssetTask {
  64376. /**
  64377. * Defines the name of the task
  64378. */
  64379. name: string;
  64380. /**
  64381. * Defines the location of the image to load
  64382. */
  64383. url: string;
  64384. /**
  64385. * Gets the loaded images
  64386. */
  64387. image: HTMLImageElement;
  64388. /**
  64389. * Callback called when the task is successful
  64390. */
  64391. onSuccess: (task: ImageAssetTask) => void;
  64392. /**
  64393. * Callback called when the task is successful
  64394. */
  64395. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  64396. /**
  64397. * Creates a new ImageAssetTask
  64398. * @param name defines the name of the task
  64399. * @param url defines the location of the image to load
  64400. */
  64401. constructor(
  64402. /**
  64403. * Defines the name of the task
  64404. */
  64405. name: string,
  64406. /**
  64407. * Defines the location of the image to load
  64408. */
  64409. url: string);
  64410. /**
  64411. * Execute the current task
  64412. * @param scene defines the scene where you want your assets to be loaded
  64413. * @param onSuccess is a callback called when the task is successfully executed
  64414. * @param onError is a callback called if an error occurs
  64415. */
  64416. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64417. }
  64418. /**
  64419. * Defines the interface used by texture loading tasks
  64420. */
  64421. export interface ITextureAssetTask<TEX extends BaseTexture> {
  64422. /**
  64423. * Gets the loaded texture
  64424. */
  64425. texture: TEX;
  64426. }
  64427. /**
  64428. * Define a task used by AssetsManager to load 2D textures
  64429. */
  64430. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  64431. /**
  64432. * Defines the name of the task
  64433. */
  64434. name: string;
  64435. /**
  64436. * Defines the location of the file to load
  64437. */
  64438. url: string;
  64439. /**
  64440. * Defines if mipmap should not be generated (default is false)
  64441. */
  64442. noMipmap?: boolean | undefined;
  64443. /**
  64444. * Defines if texture must be inverted on Y axis (default is false)
  64445. */
  64446. invertY?: boolean | undefined;
  64447. /**
  64448. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64449. */
  64450. samplingMode: number;
  64451. /**
  64452. * Gets the loaded texture
  64453. */
  64454. texture: Texture;
  64455. /**
  64456. * Callback called when the task is successful
  64457. */
  64458. onSuccess: (task: TextureAssetTask) => void;
  64459. /**
  64460. * Callback called when the task is successful
  64461. */
  64462. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  64463. /**
  64464. * Creates a new TextureAssetTask object
  64465. * @param name defines the name of the task
  64466. * @param url defines the location of the file to load
  64467. * @param noMipmap defines if mipmap should not be generated (default is false)
  64468. * @param invertY defines if texture must be inverted on Y axis (default is false)
  64469. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64470. */
  64471. constructor(
  64472. /**
  64473. * Defines the name of the task
  64474. */
  64475. name: string,
  64476. /**
  64477. * Defines the location of the file to load
  64478. */
  64479. url: string,
  64480. /**
  64481. * Defines if mipmap should not be generated (default is false)
  64482. */
  64483. noMipmap?: boolean | undefined,
  64484. /**
  64485. * Defines if texture must be inverted on Y axis (default is false)
  64486. */
  64487. invertY?: boolean | undefined,
  64488. /**
  64489. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64490. */
  64491. samplingMode?: number);
  64492. /**
  64493. * Execute the current task
  64494. * @param scene defines the scene where you want your assets to be loaded
  64495. * @param onSuccess is a callback called when the task is successfully executed
  64496. * @param onError is a callback called if an error occurs
  64497. */
  64498. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64499. }
  64500. /**
  64501. * Define a task used by AssetsManager to load cube textures
  64502. */
  64503. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  64504. /**
  64505. * Defines the name of the task
  64506. */
  64507. name: string;
  64508. /**
  64509. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64510. */
  64511. url: string;
  64512. /**
  64513. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64514. */
  64515. extensions?: string[] | undefined;
  64516. /**
  64517. * Defines if mipmaps should not be generated (default is false)
  64518. */
  64519. noMipmap?: boolean | undefined;
  64520. /**
  64521. * Defines the explicit list of files (undefined by default)
  64522. */
  64523. files?: string[] | undefined;
  64524. /**
  64525. * Gets the loaded texture
  64526. */
  64527. texture: CubeTexture;
  64528. /**
  64529. * Callback called when the task is successful
  64530. */
  64531. onSuccess: (task: CubeTextureAssetTask) => void;
  64532. /**
  64533. * Callback called when the task is successful
  64534. */
  64535. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  64536. /**
  64537. * Creates a new CubeTextureAssetTask
  64538. * @param name defines the name of the task
  64539. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64540. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64541. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64542. * @param files defines the explicit list of files (undefined by default)
  64543. */
  64544. constructor(
  64545. /**
  64546. * Defines the name of the task
  64547. */
  64548. name: string,
  64549. /**
  64550. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64551. */
  64552. url: string,
  64553. /**
  64554. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64555. */
  64556. extensions?: string[] | undefined,
  64557. /**
  64558. * Defines if mipmaps should not be generated (default is false)
  64559. */
  64560. noMipmap?: boolean | undefined,
  64561. /**
  64562. * Defines the explicit list of files (undefined by default)
  64563. */
  64564. files?: string[] | undefined);
  64565. /**
  64566. * Execute the current task
  64567. * @param scene defines the scene where you want your assets to be loaded
  64568. * @param onSuccess is a callback called when the task is successfully executed
  64569. * @param onError is a callback called if an error occurs
  64570. */
  64571. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64572. }
  64573. /**
  64574. * Define a task used by AssetsManager to load HDR cube textures
  64575. */
  64576. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  64577. /**
  64578. * Defines the name of the task
  64579. */
  64580. name: string;
  64581. /**
  64582. * Defines the location of the file to load
  64583. */
  64584. url: string;
  64585. /**
  64586. * Defines the desired size (the more it increases the longer the generation will be)
  64587. */
  64588. size: number;
  64589. /**
  64590. * Defines if mipmaps should not be generated (default is false)
  64591. */
  64592. noMipmap: boolean;
  64593. /**
  64594. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64595. */
  64596. generateHarmonics: boolean;
  64597. /**
  64598. * 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)
  64599. */
  64600. gammaSpace: boolean;
  64601. /**
  64602. * Internal Use Only
  64603. */
  64604. reserved: boolean;
  64605. /**
  64606. * Gets the loaded texture
  64607. */
  64608. texture: HDRCubeTexture;
  64609. /**
  64610. * Callback called when the task is successful
  64611. */
  64612. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  64613. /**
  64614. * Callback called when the task is successful
  64615. */
  64616. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  64617. /**
  64618. * Creates a new HDRCubeTextureAssetTask object
  64619. * @param name defines the name of the task
  64620. * @param url defines the location of the file to load
  64621. * @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.
  64622. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64623. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64624. * @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)
  64625. * @param reserved Internal use only
  64626. */
  64627. constructor(
  64628. /**
  64629. * Defines the name of the task
  64630. */
  64631. name: string,
  64632. /**
  64633. * Defines the location of the file to load
  64634. */
  64635. url: string,
  64636. /**
  64637. * Defines the desired size (the more it increases the longer the generation will be)
  64638. */
  64639. size: number,
  64640. /**
  64641. * Defines if mipmaps should not be generated (default is false)
  64642. */
  64643. noMipmap?: boolean,
  64644. /**
  64645. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64646. */
  64647. generateHarmonics?: boolean,
  64648. /**
  64649. * 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)
  64650. */
  64651. gammaSpace?: boolean,
  64652. /**
  64653. * Internal Use Only
  64654. */
  64655. reserved?: boolean);
  64656. /**
  64657. * Execute the current task
  64658. * @param scene defines the scene where you want your assets to be loaded
  64659. * @param onSuccess is a callback called when the task is successfully executed
  64660. * @param onError is a callback called if an error occurs
  64661. */
  64662. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64663. }
  64664. /**
  64665. * Define a task used by AssetsManager to load Equirectangular cube textures
  64666. */
  64667. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  64668. /**
  64669. * Defines the name of the task
  64670. */
  64671. name: string;
  64672. /**
  64673. * Defines the location of the file to load
  64674. */
  64675. url: string;
  64676. /**
  64677. * Defines the desired size (the more it increases the longer the generation will be)
  64678. */
  64679. size: number;
  64680. /**
  64681. * Defines if mipmaps should not be generated (default is false)
  64682. */
  64683. noMipmap: boolean;
  64684. /**
  64685. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64686. * but the standard material would require them in Gamma space) (default is true)
  64687. */
  64688. gammaSpace: boolean;
  64689. /**
  64690. * Gets the loaded texture
  64691. */
  64692. texture: EquiRectangularCubeTexture;
  64693. /**
  64694. * Callback called when the task is successful
  64695. */
  64696. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  64697. /**
  64698. * Callback called when the task is successful
  64699. */
  64700. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  64701. /**
  64702. * Creates a new EquiRectangularCubeTextureAssetTask object
  64703. * @param name defines the name of the task
  64704. * @param url defines the location of the file to load
  64705. * @param size defines the desired size (the more it increases the longer the generation will be)
  64706. * If the size is omitted this implies you are using a preprocessed cubemap.
  64707. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64708. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  64709. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  64710. * (default is true)
  64711. */
  64712. constructor(
  64713. /**
  64714. * Defines the name of the task
  64715. */
  64716. name: string,
  64717. /**
  64718. * Defines the location of the file to load
  64719. */
  64720. url: string,
  64721. /**
  64722. * Defines the desired size (the more it increases the longer the generation will be)
  64723. */
  64724. size: number,
  64725. /**
  64726. * Defines if mipmaps should not be generated (default is false)
  64727. */
  64728. noMipmap?: boolean,
  64729. /**
  64730. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64731. * but the standard material would require them in Gamma space) (default is true)
  64732. */
  64733. gammaSpace?: boolean);
  64734. /**
  64735. * Execute the current task
  64736. * @param scene defines the scene where you want your assets to be loaded
  64737. * @param onSuccess is a callback called when the task is successfully executed
  64738. * @param onError is a callback called if an error occurs
  64739. */
  64740. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64741. }
  64742. /**
  64743. * This class can be used to easily import assets into a scene
  64744. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  64745. */
  64746. export class AssetsManager {
  64747. private _scene;
  64748. private _isLoading;
  64749. protected _tasks: AbstractAssetTask[];
  64750. protected _waitingTasksCount: number;
  64751. protected _totalTasksCount: number;
  64752. /**
  64753. * Callback called when all tasks are processed
  64754. */
  64755. onFinish: (tasks: AbstractAssetTask[]) => void;
  64756. /**
  64757. * Callback called when a task is successful
  64758. */
  64759. onTaskSuccess: (task: AbstractAssetTask) => void;
  64760. /**
  64761. * Callback called when a task had an error
  64762. */
  64763. onTaskError: (task: AbstractAssetTask) => void;
  64764. /**
  64765. * Callback called when a task is done (whatever the result is)
  64766. */
  64767. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  64768. /**
  64769. * Observable called when all tasks are processed
  64770. */
  64771. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  64772. /**
  64773. * Observable called when a task had an error
  64774. */
  64775. onTaskErrorObservable: Observable<AbstractAssetTask>;
  64776. /**
  64777. * Observable called when all tasks were executed
  64778. */
  64779. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  64780. /**
  64781. * Observable called when a task is done (whatever the result is)
  64782. */
  64783. onProgressObservable: Observable<IAssetsProgressEvent>;
  64784. /**
  64785. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  64786. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  64787. */
  64788. useDefaultLoadingScreen: boolean;
  64789. /**
  64790. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  64791. * when all assets have been downloaded.
  64792. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  64793. */
  64794. autoHideLoadingUI: boolean;
  64795. /**
  64796. * Creates a new AssetsManager
  64797. * @param scene defines the scene to work on
  64798. */
  64799. constructor(scene: Scene);
  64800. /**
  64801. * Add a MeshAssetTask to the list of active tasks
  64802. * @param taskName defines the name of the new task
  64803. * @param meshesNames defines the name of meshes to load
  64804. * @param rootUrl defines the root url to use to locate files
  64805. * @param sceneFilename defines the filename of the scene file
  64806. * @returns a new MeshAssetTask object
  64807. */
  64808. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  64809. /**
  64810. * Add a TextFileAssetTask to the list of active tasks
  64811. * @param taskName defines the name of the new task
  64812. * @param url defines the url of the file to load
  64813. * @returns a new TextFileAssetTask object
  64814. */
  64815. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  64816. /**
  64817. * Add a BinaryFileAssetTask to the list of active tasks
  64818. * @param taskName defines the name of the new task
  64819. * @param url defines the url of the file to load
  64820. * @returns a new BinaryFileAssetTask object
  64821. */
  64822. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  64823. /**
  64824. * Add a ImageAssetTask to the list of active tasks
  64825. * @param taskName defines the name of the new task
  64826. * @param url defines the url of the file to load
  64827. * @returns a new ImageAssetTask object
  64828. */
  64829. addImageTask(taskName: string, url: string): ImageAssetTask;
  64830. /**
  64831. * Add a TextureAssetTask to the list of active tasks
  64832. * @param taskName defines the name of the new task
  64833. * @param url defines the url of the file to load
  64834. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64835. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  64836. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64837. * @returns a new TextureAssetTask object
  64838. */
  64839. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  64840. /**
  64841. * Add a CubeTextureAssetTask to the list of active tasks
  64842. * @param taskName defines the name of the new task
  64843. * @param url defines the url of the file to load
  64844. * @param extensions defines the extension to use to load the cube map (can be null)
  64845. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64846. * @param files defines the list of files to load (can be null)
  64847. * @returns a new CubeTextureAssetTask object
  64848. */
  64849. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  64850. /**
  64851. *
  64852. * Add a HDRCubeTextureAssetTask to the list of active tasks
  64853. * @param taskName defines the name of the new task
  64854. * @param url defines the url of the file to load
  64855. * @param size defines the size you want for the cubemap (can be null)
  64856. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64857. * @param generateHarmonics defines if you want to automatically generate (true by default)
  64858. * @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)
  64859. * @param reserved Internal use only
  64860. * @returns a new HDRCubeTextureAssetTask object
  64861. */
  64862. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  64863. /**
  64864. *
  64865. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  64866. * @param taskName defines the name of the new task
  64867. * @param url defines the url of the file to load
  64868. * @param size defines the size you want for the cubemap (can be null)
  64869. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64870. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64871. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64872. * @returns a new EquiRectangularCubeTextureAssetTask object
  64873. */
  64874. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  64875. /**
  64876. * Remove a task from the assets manager.
  64877. * @param task the task to remove
  64878. */
  64879. removeTask(task: AbstractAssetTask): void;
  64880. private _decreaseWaitingTasksCount;
  64881. private _runTask;
  64882. /**
  64883. * Reset the AssetsManager and remove all tasks
  64884. * @return the current instance of the AssetsManager
  64885. */
  64886. reset(): AssetsManager;
  64887. /**
  64888. * Start the loading process
  64889. * @return the current instance of the AssetsManager
  64890. */
  64891. load(): AssetsManager;
  64892. /**
  64893. * Start the loading process as an async operation
  64894. * @return a promise returning the list of failed tasks
  64895. */
  64896. loadAsync(): Promise<void>;
  64897. }
  64898. }
  64899. declare module "babylonjs/Misc/deferred" {
  64900. /**
  64901. * Wrapper class for promise with external resolve and reject.
  64902. */
  64903. export class Deferred<T> {
  64904. /**
  64905. * The promise associated with this deferred object.
  64906. */
  64907. readonly promise: Promise<T>;
  64908. private _resolve;
  64909. private _reject;
  64910. /**
  64911. * The resolve method of the promise associated with this deferred object.
  64912. */
  64913. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  64914. /**
  64915. * The reject method of the promise associated with this deferred object.
  64916. */
  64917. readonly reject: (reason?: any) => void;
  64918. /**
  64919. * Constructor for this deferred object.
  64920. */
  64921. constructor();
  64922. }
  64923. }
  64924. declare module "babylonjs/Misc/meshExploder" {
  64925. import { Mesh } from "babylonjs/Meshes/mesh";
  64926. /**
  64927. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  64928. */
  64929. export class MeshExploder {
  64930. private _centerMesh;
  64931. private _meshes;
  64932. private _meshesOrigins;
  64933. private _toCenterVectors;
  64934. private _scaledDirection;
  64935. private _newPosition;
  64936. private _centerPosition;
  64937. /**
  64938. * Explodes meshes from a center mesh.
  64939. * @param meshes The meshes to explode.
  64940. * @param centerMesh The mesh to be center of explosion.
  64941. */
  64942. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  64943. private _setCenterMesh;
  64944. /**
  64945. * Get class name
  64946. * @returns "MeshExploder"
  64947. */
  64948. getClassName(): string;
  64949. /**
  64950. * "Exploded meshes"
  64951. * @returns Array of meshes with the centerMesh at index 0.
  64952. */
  64953. getMeshes(): Array<Mesh>;
  64954. /**
  64955. * Explodes meshes giving a specific direction
  64956. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  64957. */
  64958. explode(direction?: number): void;
  64959. }
  64960. }
  64961. declare module "babylonjs/Misc/filesInput" {
  64962. import { Engine } from "babylonjs/Engines/engine";
  64963. import { Scene } from "babylonjs/scene";
  64964. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  64965. /**
  64966. * Class used to help managing file picking and drag'n'drop
  64967. */
  64968. export class FilesInput {
  64969. /**
  64970. * List of files ready to be loaded
  64971. */
  64972. static readonly FilesToLoad: {
  64973. [key: string]: File;
  64974. };
  64975. /**
  64976. * Callback called when a file is processed
  64977. */
  64978. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  64979. private _engine;
  64980. private _currentScene;
  64981. private _sceneLoadedCallback;
  64982. private _progressCallback;
  64983. private _additionalRenderLoopLogicCallback;
  64984. private _textureLoadingCallback;
  64985. private _startingProcessingFilesCallback;
  64986. private _onReloadCallback;
  64987. private _errorCallback;
  64988. private _elementToMonitor;
  64989. private _sceneFileToLoad;
  64990. private _filesToLoad;
  64991. /**
  64992. * Creates a new FilesInput
  64993. * @param engine defines the rendering engine
  64994. * @param scene defines the hosting scene
  64995. * @param sceneLoadedCallback callback called when scene is loaded
  64996. * @param progressCallback callback called to track progress
  64997. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  64998. * @param textureLoadingCallback callback called when a texture is loading
  64999. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  65000. * @param onReloadCallback callback called when a reload is requested
  65001. * @param errorCallback callback call if an error occurs
  65002. */
  65003. 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);
  65004. private _dragEnterHandler;
  65005. private _dragOverHandler;
  65006. private _dropHandler;
  65007. /**
  65008. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65009. * @param elementToMonitor defines the DOM element to track
  65010. */
  65011. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65012. /**
  65013. * Release all associated resources
  65014. */
  65015. dispose(): void;
  65016. private renderFunction;
  65017. private drag;
  65018. private drop;
  65019. private _traverseFolder;
  65020. private _processFiles;
  65021. /**
  65022. * Load files from a drop event
  65023. * @param event defines the drop event to use as source
  65024. */
  65025. loadFiles(event: any): void;
  65026. private _processReload;
  65027. /**
  65028. * Reload the current scene from the loaded files
  65029. */
  65030. reload(): void;
  65031. }
  65032. }
  65033. declare module "babylonjs/Misc/HighDynamicRange/index" {
  65034. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  65035. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  65036. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  65037. }
  65038. declare module "babylonjs/Misc/sceneOptimizer" {
  65039. import { Scene, IDisposable } from "babylonjs/scene";
  65040. import { Observable } from "babylonjs/Misc/observable";
  65041. /**
  65042. * Defines the root class used to create scene optimization to use with SceneOptimizer
  65043. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65044. */
  65045. export class SceneOptimization {
  65046. /**
  65047. * Defines the priority of this optimization (0 by default which means first in the list)
  65048. */
  65049. priority: number;
  65050. /**
  65051. * Gets a string describing the action executed by the current optimization
  65052. * @returns description string
  65053. */
  65054. getDescription(): string;
  65055. /**
  65056. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65057. * @param scene defines the current scene where to apply this optimization
  65058. * @param optimizer defines the current optimizer
  65059. * @returns true if everything that can be done was applied
  65060. */
  65061. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65062. /**
  65063. * Creates the SceneOptimization object
  65064. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65065. * @param desc defines the description associated with the optimization
  65066. */
  65067. constructor(
  65068. /**
  65069. * Defines the priority of this optimization (0 by default which means first in the list)
  65070. */
  65071. priority?: number);
  65072. }
  65073. /**
  65074. * Defines an optimization used to reduce the size of render target textures
  65075. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65076. */
  65077. export class TextureOptimization extends SceneOptimization {
  65078. /**
  65079. * Defines the priority of this optimization (0 by default which means first in the list)
  65080. */
  65081. priority: number;
  65082. /**
  65083. * 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
  65084. */
  65085. maximumSize: number;
  65086. /**
  65087. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65088. */
  65089. step: number;
  65090. /**
  65091. * Gets a string describing the action executed by the current optimization
  65092. * @returns description string
  65093. */
  65094. getDescription(): string;
  65095. /**
  65096. * Creates the TextureOptimization object
  65097. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65098. * @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
  65099. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65100. */
  65101. constructor(
  65102. /**
  65103. * Defines the priority of this optimization (0 by default which means first in the list)
  65104. */
  65105. priority?: number,
  65106. /**
  65107. * 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
  65108. */
  65109. maximumSize?: number,
  65110. /**
  65111. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65112. */
  65113. step?: number);
  65114. /**
  65115. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65116. * @param scene defines the current scene where to apply this optimization
  65117. * @param optimizer defines the current optimizer
  65118. * @returns true if everything that can be done was applied
  65119. */
  65120. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65121. }
  65122. /**
  65123. * Defines an optimization used to increase or decrease the rendering resolution
  65124. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65125. */
  65126. export class HardwareScalingOptimization extends SceneOptimization {
  65127. /**
  65128. * Defines the priority of this optimization (0 by default which means first in the list)
  65129. */
  65130. priority: number;
  65131. /**
  65132. * Defines the maximum scale to use (2 by default)
  65133. */
  65134. maximumScale: number;
  65135. /**
  65136. * Defines the step to use between two passes (0.5 by default)
  65137. */
  65138. step: number;
  65139. private _currentScale;
  65140. private _directionOffset;
  65141. /**
  65142. * Gets a string describing the action executed by the current optimization
  65143. * @return description string
  65144. */
  65145. getDescription(): string;
  65146. /**
  65147. * Creates the HardwareScalingOptimization object
  65148. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65149. * @param maximumScale defines the maximum scale to use (2 by default)
  65150. * @param step defines the step to use between two passes (0.5 by default)
  65151. */
  65152. constructor(
  65153. /**
  65154. * Defines the priority of this optimization (0 by default which means first in the list)
  65155. */
  65156. priority?: number,
  65157. /**
  65158. * Defines the maximum scale to use (2 by default)
  65159. */
  65160. maximumScale?: number,
  65161. /**
  65162. * Defines the step to use between two passes (0.5 by default)
  65163. */
  65164. step?: number);
  65165. /**
  65166. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65167. * @param scene defines the current scene where to apply this optimization
  65168. * @param optimizer defines the current optimizer
  65169. * @returns true if everything that can be done was applied
  65170. */
  65171. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65172. }
  65173. /**
  65174. * Defines an optimization used to remove shadows
  65175. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65176. */
  65177. export class ShadowsOptimization extends SceneOptimization {
  65178. /**
  65179. * Gets a string describing the action executed by the current optimization
  65180. * @return description string
  65181. */
  65182. getDescription(): string;
  65183. /**
  65184. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65185. * @param scene defines the current scene where to apply this optimization
  65186. * @param optimizer defines the current optimizer
  65187. * @returns true if everything that can be done was applied
  65188. */
  65189. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65190. }
  65191. /**
  65192. * Defines an optimization used to turn post-processes off
  65193. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65194. */
  65195. export class PostProcessesOptimization extends SceneOptimization {
  65196. /**
  65197. * Gets a string describing the action executed by the current optimization
  65198. * @return description string
  65199. */
  65200. getDescription(): string;
  65201. /**
  65202. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65203. * @param scene defines the current scene where to apply this optimization
  65204. * @param optimizer defines the current optimizer
  65205. * @returns true if everything that can be done was applied
  65206. */
  65207. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65208. }
  65209. /**
  65210. * Defines an optimization used to turn lens flares off
  65211. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65212. */
  65213. export class LensFlaresOptimization extends SceneOptimization {
  65214. /**
  65215. * Gets a string describing the action executed by the current optimization
  65216. * @return description string
  65217. */
  65218. getDescription(): string;
  65219. /**
  65220. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65221. * @param scene defines the current scene where to apply this optimization
  65222. * @param optimizer defines the current optimizer
  65223. * @returns true if everything that can be done was applied
  65224. */
  65225. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65226. }
  65227. /**
  65228. * Defines an optimization based on user defined callback.
  65229. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65230. */
  65231. export class CustomOptimization extends SceneOptimization {
  65232. /**
  65233. * Callback called to apply the custom optimization.
  65234. */
  65235. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  65236. /**
  65237. * Callback called to get custom description
  65238. */
  65239. onGetDescription: () => string;
  65240. /**
  65241. * Gets a string describing the action executed by the current optimization
  65242. * @returns description string
  65243. */
  65244. getDescription(): string;
  65245. /**
  65246. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65247. * @param scene defines the current scene where to apply this optimization
  65248. * @param optimizer defines the current optimizer
  65249. * @returns true if everything that can be done was applied
  65250. */
  65251. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65252. }
  65253. /**
  65254. * Defines an optimization used to turn particles off
  65255. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65256. */
  65257. export class ParticlesOptimization extends SceneOptimization {
  65258. /**
  65259. * Gets a string describing the action executed by the current optimization
  65260. * @return description string
  65261. */
  65262. getDescription(): string;
  65263. /**
  65264. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65265. * @param scene defines the current scene where to apply this optimization
  65266. * @param optimizer defines the current optimizer
  65267. * @returns true if everything that can be done was applied
  65268. */
  65269. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65270. }
  65271. /**
  65272. * Defines an optimization used to turn render targets off
  65273. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65274. */
  65275. export class RenderTargetsOptimization extends SceneOptimization {
  65276. /**
  65277. * Gets a string describing the action executed by the current optimization
  65278. * @return description string
  65279. */
  65280. getDescription(): string;
  65281. /**
  65282. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65283. * @param scene defines the current scene where to apply this optimization
  65284. * @param optimizer defines the current optimizer
  65285. * @returns true if everything that can be done was applied
  65286. */
  65287. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65288. }
  65289. /**
  65290. * Defines an optimization used to merge meshes with compatible materials
  65291. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65292. */
  65293. export class MergeMeshesOptimization extends SceneOptimization {
  65294. private static _UpdateSelectionTree;
  65295. /**
  65296. * Gets or sets a boolean which defines if optimization octree has to be updated
  65297. */
  65298. /**
  65299. * Gets or sets a boolean which defines if optimization octree has to be updated
  65300. */
  65301. static UpdateSelectionTree: boolean;
  65302. /**
  65303. * Gets a string describing the action executed by the current optimization
  65304. * @return description string
  65305. */
  65306. getDescription(): string;
  65307. private _canBeMerged;
  65308. /**
  65309. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65310. * @param scene defines the current scene where to apply this optimization
  65311. * @param optimizer defines the current optimizer
  65312. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  65313. * @returns true if everything that can be done was applied
  65314. */
  65315. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  65316. }
  65317. /**
  65318. * Defines a list of options used by SceneOptimizer
  65319. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65320. */
  65321. export class SceneOptimizerOptions {
  65322. /**
  65323. * Defines the target frame rate to reach (60 by default)
  65324. */
  65325. targetFrameRate: number;
  65326. /**
  65327. * Defines the interval between two checkes (2000ms by default)
  65328. */
  65329. trackerDuration: number;
  65330. /**
  65331. * Gets the list of optimizations to apply
  65332. */
  65333. optimizations: SceneOptimization[];
  65334. /**
  65335. * Creates a new list of options used by SceneOptimizer
  65336. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  65337. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  65338. */
  65339. constructor(
  65340. /**
  65341. * Defines the target frame rate to reach (60 by default)
  65342. */
  65343. targetFrameRate?: number,
  65344. /**
  65345. * Defines the interval between two checkes (2000ms by default)
  65346. */
  65347. trackerDuration?: number);
  65348. /**
  65349. * Add a new optimization
  65350. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  65351. * @returns the current SceneOptimizerOptions
  65352. */
  65353. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  65354. /**
  65355. * Add a new custom optimization
  65356. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  65357. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  65358. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65359. * @returns the current SceneOptimizerOptions
  65360. */
  65361. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  65362. /**
  65363. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  65364. * @param targetFrameRate defines the target frame rate (60 by default)
  65365. * @returns a SceneOptimizerOptions object
  65366. */
  65367. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65368. /**
  65369. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  65370. * @param targetFrameRate defines the target frame rate (60 by default)
  65371. * @returns a SceneOptimizerOptions object
  65372. */
  65373. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65374. /**
  65375. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  65376. * @param targetFrameRate defines the target frame rate (60 by default)
  65377. * @returns a SceneOptimizerOptions object
  65378. */
  65379. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65380. }
  65381. /**
  65382. * Class used to run optimizations in order to reach a target frame rate
  65383. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65384. */
  65385. export class SceneOptimizer implements IDisposable {
  65386. private _isRunning;
  65387. private _options;
  65388. private _scene;
  65389. private _currentPriorityLevel;
  65390. private _targetFrameRate;
  65391. private _trackerDuration;
  65392. private _currentFrameRate;
  65393. private _sceneDisposeObserver;
  65394. private _improvementMode;
  65395. /**
  65396. * Defines an observable called when the optimizer reaches the target frame rate
  65397. */
  65398. onSuccessObservable: Observable<SceneOptimizer>;
  65399. /**
  65400. * Defines an observable called when the optimizer enables an optimization
  65401. */
  65402. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  65403. /**
  65404. * Defines an observable called when the optimizer is not able to reach the target frame rate
  65405. */
  65406. onFailureObservable: Observable<SceneOptimizer>;
  65407. /**
  65408. * Gets a boolean indicating if the optimizer is in improvement mode
  65409. */
  65410. readonly isInImprovementMode: boolean;
  65411. /**
  65412. * Gets the current priority level (0 at start)
  65413. */
  65414. readonly currentPriorityLevel: number;
  65415. /**
  65416. * Gets the current frame rate checked by the SceneOptimizer
  65417. */
  65418. readonly currentFrameRate: number;
  65419. /**
  65420. * Gets or sets the current target frame rate (60 by default)
  65421. */
  65422. /**
  65423. * Gets or sets the current target frame rate (60 by default)
  65424. */
  65425. targetFrameRate: number;
  65426. /**
  65427. * Gets or sets the current interval between two checks (every 2000ms by default)
  65428. */
  65429. /**
  65430. * Gets or sets the current interval between two checks (every 2000ms by default)
  65431. */
  65432. trackerDuration: number;
  65433. /**
  65434. * Gets the list of active optimizations
  65435. */
  65436. readonly optimizations: SceneOptimization[];
  65437. /**
  65438. * Creates a new SceneOptimizer
  65439. * @param scene defines the scene to work on
  65440. * @param options defines the options to use with the SceneOptimizer
  65441. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  65442. * @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)
  65443. */
  65444. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  65445. /**
  65446. * Stops the current optimizer
  65447. */
  65448. stop(): void;
  65449. /**
  65450. * Reset the optimizer to initial step (current priority level = 0)
  65451. */
  65452. reset(): void;
  65453. /**
  65454. * Start the optimizer. By default it will try to reach a specific framerate
  65455. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  65456. */
  65457. start(): void;
  65458. private _checkCurrentState;
  65459. /**
  65460. * Release all resources
  65461. */
  65462. dispose(): void;
  65463. /**
  65464. * Helper function to create a SceneOptimizer with one single line of code
  65465. * @param scene defines the scene to work on
  65466. * @param options defines the options to use with the SceneOptimizer
  65467. * @param onSuccess defines a callback to call on success
  65468. * @param onFailure defines a callback to call on failure
  65469. * @returns the new SceneOptimizer object
  65470. */
  65471. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  65472. }
  65473. }
  65474. declare module "babylonjs/Misc/sceneSerializer" {
  65475. import { Scene } from "babylonjs/scene";
  65476. /**
  65477. * Class used to serialize a scene into a string
  65478. */
  65479. export class SceneSerializer {
  65480. /**
  65481. * Clear cache used by a previous serialization
  65482. */
  65483. static ClearCache(): void;
  65484. /**
  65485. * Serialize a scene into a JSON compatible object
  65486. * @param scene defines the scene to serialize
  65487. * @returns a JSON compatible object
  65488. */
  65489. static Serialize(scene: Scene): any;
  65490. /**
  65491. * Serialize a mesh into a JSON compatible object
  65492. * @param toSerialize defines the mesh to serialize
  65493. * @param withParents defines if parents must be serialized as well
  65494. * @param withChildren defines if children must be serialized as well
  65495. * @returns a JSON compatible object
  65496. */
  65497. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  65498. }
  65499. }
  65500. declare module "babylonjs/Misc/textureTools" {
  65501. import { Texture } from "babylonjs/Materials/Textures/texture";
  65502. /**
  65503. * Class used to host texture specific utilities
  65504. */
  65505. export class TextureTools {
  65506. /**
  65507. * Uses the GPU to create a copy texture rescaled at a given size
  65508. * @param texture Texture to copy from
  65509. * @param width defines the desired width
  65510. * @param height defines the desired height
  65511. * @param useBilinearMode defines if bilinear mode has to be used
  65512. * @return the generated texture
  65513. */
  65514. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  65515. }
  65516. }
  65517. declare module "babylonjs/Misc/videoRecorder" {
  65518. import { Nullable } from "babylonjs/types";
  65519. import { Engine } from "babylonjs/Engines/engine";
  65520. /**
  65521. * This represents the different options available for the video capture.
  65522. */
  65523. export interface VideoRecorderOptions {
  65524. /** Defines the mime type of the video. */
  65525. mimeType: string;
  65526. /** Defines the FPS the video should be recorded at. */
  65527. fps: number;
  65528. /** Defines the chunk size for the recording data. */
  65529. recordChunckSize: number;
  65530. /** The audio tracks to attach to the recording. */
  65531. audioTracks?: MediaStreamTrack[];
  65532. }
  65533. /**
  65534. * This can help with recording videos from BabylonJS.
  65535. * This is based on the available WebRTC functionalities of the browser.
  65536. *
  65537. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  65538. */
  65539. export class VideoRecorder {
  65540. private static readonly _defaultOptions;
  65541. /**
  65542. * Returns whether or not the VideoRecorder is available in your browser.
  65543. * @param engine Defines the Babylon Engine.
  65544. * @returns true if supported otherwise false.
  65545. */
  65546. static IsSupported(engine: Engine): boolean;
  65547. private readonly _options;
  65548. private _canvas;
  65549. private _mediaRecorder;
  65550. private _recordedChunks;
  65551. private _fileName;
  65552. private _resolve;
  65553. private _reject;
  65554. /**
  65555. * True when a recording is already in progress.
  65556. */
  65557. readonly isRecording: boolean;
  65558. /**
  65559. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  65560. * @param engine Defines the BabylonJS Engine you wish to record.
  65561. * @param options Defines options that can be used to customize the capture.
  65562. */
  65563. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  65564. /**
  65565. * Stops the current recording before the default capture timeout passed in the startRecording function.
  65566. */
  65567. stopRecording(): void;
  65568. /**
  65569. * Starts recording the canvas for a max duration specified in parameters.
  65570. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  65571. * If null no automatic download will start and you can rely on the promise to get the data back.
  65572. * @param maxDuration Defines the maximum recording time in seconds.
  65573. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  65574. * @return A promise callback at the end of the recording with the video data in Blob.
  65575. */
  65576. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  65577. /**
  65578. * Releases internal resources used during the recording.
  65579. */
  65580. dispose(): void;
  65581. private _handleDataAvailable;
  65582. private _handleError;
  65583. private _handleStop;
  65584. }
  65585. }
  65586. declare module "babylonjs/Misc/screenshotTools" {
  65587. import { Camera } from "babylonjs/Cameras/camera";
  65588. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  65589. import { Engine } from "babylonjs/Engines/engine";
  65590. /**
  65591. * Class containing a set of static utilities functions for screenshots
  65592. */
  65593. export class ScreenshotTools {
  65594. /**
  65595. * Captures a screenshot of the current rendering
  65596. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65597. * @param engine defines the rendering engine
  65598. * @param camera defines the source camera
  65599. * @param size This parameter can be set to a single number or to an object with the
  65600. * following (optional) properties: precision, width, height. If a single number is passed,
  65601. * it will be used for both width and height. If an object is passed, the screenshot size
  65602. * will be derived from the parameters. The precision property is a multiplier allowing
  65603. * rendering at a higher or lower resolution
  65604. * @param successCallback defines the callback receives a single parameter which contains the
  65605. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65606. * src parameter of an <img> to display it
  65607. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65608. * Check your browser for supported MIME types
  65609. */
  65610. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  65611. /**
  65612. * Captures a screenshot of the current rendering
  65613. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65614. * @param engine defines the rendering engine
  65615. * @param camera defines the source camera
  65616. * @param size This parameter can be set to a single number or to an object with the
  65617. * following (optional) properties: precision, width, height. If a single number is passed,
  65618. * it will be used for both width and height. If an object is passed, the screenshot size
  65619. * will be derived from the parameters. The precision property is a multiplier allowing
  65620. * rendering at a higher or lower resolution
  65621. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65622. * Check your browser for supported MIME types
  65623. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65624. * to the src parameter of an <img> to display it
  65625. */
  65626. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  65627. /**
  65628. * Generates an image screenshot from the specified camera.
  65629. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65630. * @param engine The engine to use for rendering
  65631. * @param camera The camera to use for rendering
  65632. * @param size This parameter can be set to a single number or to an object with the
  65633. * following (optional) properties: precision, width, height. If a single number is passed,
  65634. * it will be used for both width and height. If an object is passed, the screenshot size
  65635. * will be derived from the parameters. The precision property is a multiplier allowing
  65636. * rendering at a higher or lower resolution
  65637. * @param successCallback The callback receives a single parameter which contains the
  65638. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65639. * src parameter of an <img> to display it
  65640. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65641. * Check your browser for supported MIME types
  65642. * @param samples Texture samples (default: 1)
  65643. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65644. * @param fileName A name for for the downloaded file.
  65645. */
  65646. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  65647. /**
  65648. * Generates an image screenshot from the specified camera.
  65649. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65650. * @param engine The engine to use for rendering
  65651. * @param camera The camera to use for rendering
  65652. * @param size This parameter can be set to a single number or to an object with the
  65653. * following (optional) properties: precision, width, height. If a single number is passed,
  65654. * it will be used for both width and height. If an object is passed, the screenshot size
  65655. * will be derived from the parameters. The precision property is a multiplier allowing
  65656. * rendering at a higher or lower resolution
  65657. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65658. * Check your browser for supported MIME types
  65659. * @param samples Texture samples (default: 1)
  65660. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65661. * @param fileName A name for for the downloaded file.
  65662. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65663. * to the src parameter of an <img> to display it
  65664. */
  65665. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  65666. /**
  65667. * Gets height and width for screenshot size
  65668. * @private
  65669. */
  65670. private static _getScreenshotSize;
  65671. }
  65672. }
  65673. declare module "babylonjs/Misc/index" {
  65674. export * from "babylonjs/Misc/andOrNotEvaluator";
  65675. export * from "babylonjs/Misc/assetsManager";
  65676. export * from "babylonjs/Misc/dds";
  65677. export * from "babylonjs/Misc/decorators";
  65678. export * from "babylonjs/Misc/deferred";
  65679. export * from "babylonjs/Misc/environmentTextureTools";
  65680. export * from "babylonjs/Misc/meshExploder";
  65681. export * from "babylonjs/Misc/filesInput";
  65682. export * from "babylonjs/Misc/HighDynamicRange/index";
  65683. export * from "babylonjs/Misc/khronosTextureContainer";
  65684. export * from "babylonjs/Misc/observable";
  65685. export * from "babylonjs/Misc/performanceMonitor";
  65686. export * from "babylonjs/Misc/promise";
  65687. export * from "babylonjs/Misc/sceneOptimizer";
  65688. export * from "babylonjs/Misc/sceneSerializer";
  65689. export * from "babylonjs/Misc/smartArray";
  65690. export * from "babylonjs/Misc/stringDictionary";
  65691. export * from "babylonjs/Misc/tags";
  65692. export * from "babylonjs/Misc/textureTools";
  65693. export * from "babylonjs/Misc/tga";
  65694. export * from "babylonjs/Misc/tools";
  65695. export * from "babylonjs/Misc/videoRecorder";
  65696. export * from "babylonjs/Misc/virtualJoystick";
  65697. export * from "babylonjs/Misc/workerPool";
  65698. export * from "babylonjs/Misc/logger";
  65699. export * from "babylonjs/Misc/typeStore";
  65700. export * from "babylonjs/Misc/filesInputStore";
  65701. export * from "babylonjs/Misc/deepCopier";
  65702. export * from "babylonjs/Misc/pivotTools";
  65703. export * from "babylonjs/Misc/precisionDate";
  65704. export * from "babylonjs/Misc/screenshotTools";
  65705. export * from "babylonjs/Misc/typeStore";
  65706. export * from "babylonjs/Misc/webRequest";
  65707. export * from "babylonjs/Misc/iInspectable";
  65708. export * from "babylonjs/Misc/brdfTextureTools";
  65709. export * from "babylonjs/Misc/rgbdTextureTools";
  65710. export * from "babylonjs/Misc/gradients";
  65711. export * from "babylonjs/Misc/perfCounter";
  65712. export * from "babylonjs/Misc/fileRequest";
  65713. export * from "babylonjs/Misc/customAnimationFrameRequester";
  65714. export * from "babylonjs/Misc/retryStrategy";
  65715. export * from "babylonjs/Misc/loadFileError";
  65716. export * from "babylonjs/Misc/interfaces/screenshotSize";
  65717. }
  65718. declare module "babylonjs/index" {
  65719. export * from "babylonjs/abstractScene";
  65720. export * from "babylonjs/Actions/index";
  65721. export * from "babylonjs/Animations/index";
  65722. export * from "babylonjs/assetContainer";
  65723. export * from "babylonjs/Audio/index";
  65724. export * from "babylonjs/Behaviors/index";
  65725. export * from "babylonjs/Bones/index";
  65726. export * from "babylonjs/Cameras/index";
  65727. export * from "babylonjs/Collisions/index";
  65728. export * from "babylonjs/Culling/index";
  65729. export * from "babylonjs/Debug/index";
  65730. export * from "babylonjs/Engines/index";
  65731. export * from "babylonjs/Events/index";
  65732. export * from "babylonjs/Gamepads/index";
  65733. export * from "babylonjs/Gizmos/index";
  65734. export * from "babylonjs/Helpers/index";
  65735. export * from "babylonjs/Instrumentation/index";
  65736. export * from "babylonjs/Layers/index";
  65737. export * from "babylonjs/LensFlares/index";
  65738. export * from "babylonjs/Lights/index";
  65739. export * from "babylonjs/Loading/index";
  65740. export * from "babylonjs/Materials/index";
  65741. export * from "babylonjs/Maths/index";
  65742. export * from "babylonjs/Meshes/index";
  65743. export * from "babylonjs/Morph/index";
  65744. export * from "babylonjs/Navigation/index";
  65745. export * from "babylonjs/node";
  65746. export * from "babylonjs/Offline/index";
  65747. export * from "babylonjs/Particles/index";
  65748. export * from "babylonjs/Physics/index";
  65749. export * from "babylonjs/PostProcesses/index";
  65750. export * from "babylonjs/Probes/index";
  65751. export * from "babylonjs/Rendering/index";
  65752. export * from "babylonjs/scene";
  65753. export * from "babylonjs/sceneComponent";
  65754. export * from "babylonjs/Sprites/index";
  65755. export * from "babylonjs/States/index";
  65756. export * from "babylonjs/Misc/index";
  65757. export * from "babylonjs/types";
  65758. }
  65759. declare module "babylonjs/Animations/pathCursor" {
  65760. import { Vector3 } from "babylonjs/Maths/math.vector";
  65761. import { Path2 } from "babylonjs/Maths/math.path";
  65762. /**
  65763. * A cursor which tracks a point on a path
  65764. */
  65765. export class PathCursor {
  65766. private path;
  65767. /**
  65768. * Stores path cursor callbacks for when an onchange event is triggered
  65769. */
  65770. private _onchange;
  65771. /**
  65772. * The value of the path cursor
  65773. */
  65774. value: number;
  65775. /**
  65776. * The animation array of the path cursor
  65777. */
  65778. animations: Animation[];
  65779. /**
  65780. * Initializes the path cursor
  65781. * @param path The path to track
  65782. */
  65783. constructor(path: Path2);
  65784. /**
  65785. * Gets the cursor point on the path
  65786. * @returns A point on the path cursor at the cursor location
  65787. */
  65788. getPoint(): Vector3;
  65789. /**
  65790. * Moves the cursor ahead by the step amount
  65791. * @param step The amount to move the cursor forward
  65792. * @returns This path cursor
  65793. */
  65794. moveAhead(step?: number): PathCursor;
  65795. /**
  65796. * Moves the cursor behind by the step amount
  65797. * @param step The amount to move the cursor back
  65798. * @returns This path cursor
  65799. */
  65800. moveBack(step?: number): PathCursor;
  65801. /**
  65802. * Moves the cursor by the step amount
  65803. * If the step amount is greater than one, an exception is thrown
  65804. * @param step The amount to move the cursor
  65805. * @returns This path cursor
  65806. */
  65807. move(step: number): PathCursor;
  65808. /**
  65809. * Ensures that the value is limited between zero and one
  65810. * @returns This path cursor
  65811. */
  65812. private ensureLimits;
  65813. /**
  65814. * Runs onchange callbacks on change (used by the animation engine)
  65815. * @returns This path cursor
  65816. */
  65817. private raiseOnChange;
  65818. /**
  65819. * Executes a function on change
  65820. * @param f A path cursor onchange callback
  65821. * @returns This path cursor
  65822. */
  65823. onchange(f: (cursor: PathCursor) => void): PathCursor;
  65824. }
  65825. }
  65826. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  65827. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  65828. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  65829. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  65830. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  65831. }
  65832. declare module "babylonjs/Engines/Processors/Expressions/index" {
  65833. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  65834. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  65835. }
  65836. declare module "babylonjs/Engines/Processors/index" {
  65837. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  65838. export * from "babylonjs/Engines/Processors/Expressions/index";
  65839. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  65840. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  65841. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  65842. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  65843. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  65844. export * from "babylonjs/Engines/Processors/shaderProcessor";
  65845. }
  65846. declare module "babylonjs/Legacy/legacy" {
  65847. import * as Babylon from "babylonjs/index";
  65848. export * from "babylonjs/index";
  65849. }
  65850. declare module "babylonjs/Shaders/blur.fragment" {
  65851. /** @hidden */
  65852. export var blurPixelShader: {
  65853. name: string;
  65854. shader: string;
  65855. };
  65856. }
  65857. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  65858. /** @hidden */
  65859. export var pointCloudVertexDeclaration: {
  65860. name: string;
  65861. shader: string;
  65862. };
  65863. }
  65864. declare module "babylonjs" {
  65865. export * from "babylonjs/Legacy/legacy";
  65866. }
  65867. declare module BABYLON {
  65868. /** Alias type for value that can be null */
  65869. export type Nullable<T> = T | null;
  65870. /**
  65871. * Alias type for number that are floats
  65872. * @ignorenaming
  65873. */
  65874. export type float = number;
  65875. /**
  65876. * Alias type for number that are doubles.
  65877. * @ignorenaming
  65878. */
  65879. export type double = number;
  65880. /**
  65881. * Alias type for number that are integer
  65882. * @ignorenaming
  65883. */
  65884. export type int = number;
  65885. /** Alias type for number array or Float32Array */
  65886. export type FloatArray = number[] | Float32Array;
  65887. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  65888. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  65889. /**
  65890. * Alias for types that can be used by a Buffer or VertexBuffer.
  65891. */
  65892. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  65893. /**
  65894. * Alias type for primitive types
  65895. * @ignorenaming
  65896. */
  65897. type Primitive = undefined | null | boolean | string | number | Function;
  65898. /**
  65899. * Type modifier to make all the properties of an object Readonly
  65900. */
  65901. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  65902. /**
  65903. * Type modifier to make all the properties of an object Readonly recursively
  65904. */
  65905. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  65906. /** @hidden */
  65907. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  65908. }
  65909. /** @hidden */
  65910. /** @hidden */
  65911. type DeepImmutableObject<T> = {
  65912. readonly [K in keyof T]: DeepImmutable<T[K]>;
  65913. };
  65914. }
  65915. declare module BABYLON {
  65916. /**
  65917. * A class serves as a medium between the observable and its observers
  65918. */
  65919. export class EventState {
  65920. /**
  65921. * Create a new EventState
  65922. * @param mask defines the mask associated with this state
  65923. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65924. * @param target defines the original target of the state
  65925. * @param currentTarget defines the current target of the state
  65926. */
  65927. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  65928. /**
  65929. * Initialize the current event state
  65930. * @param mask defines the mask associated with this state
  65931. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65932. * @param target defines the original target of the state
  65933. * @param currentTarget defines the current target of the state
  65934. * @returns the current event state
  65935. */
  65936. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  65937. /**
  65938. * An Observer can set this property to true to prevent subsequent observers of being notified
  65939. */
  65940. skipNextObservers: boolean;
  65941. /**
  65942. * Get the mask value that were used to trigger the event corresponding to this EventState object
  65943. */
  65944. mask: number;
  65945. /**
  65946. * The object that originally notified the event
  65947. */
  65948. target?: any;
  65949. /**
  65950. * The current object in the bubbling phase
  65951. */
  65952. currentTarget?: any;
  65953. /**
  65954. * This will be populated with the return value of the last function that was executed.
  65955. * If it is the first function in the callback chain it will be the event data.
  65956. */
  65957. lastReturnValue?: any;
  65958. }
  65959. /**
  65960. * Represent an Observer registered to a given Observable object.
  65961. */
  65962. export class Observer<T> {
  65963. /**
  65964. * Defines the callback to call when the observer is notified
  65965. */
  65966. callback: (eventData: T, eventState: EventState) => void;
  65967. /**
  65968. * Defines the mask of the observer (used to filter notifications)
  65969. */
  65970. mask: number;
  65971. /**
  65972. * Defines the current scope used to restore the JS context
  65973. */
  65974. scope: any;
  65975. /** @hidden */
  65976. _willBeUnregistered: boolean;
  65977. /**
  65978. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  65979. */
  65980. unregisterOnNextCall: boolean;
  65981. /**
  65982. * Creates a new observer
  65983. * @param callback defines the callback to call when the observer is notified
  65984. * @param mask defines the mask of the observer (used to filter notifications)
  65985. * @param scope defines the current scope used to restore the JS context
  65986. */
  65987. constructor(
  65988. /**
  65989. * Defines the callback to call when the observer is notified
  65990. */
  65991. callback: (eventData: T, eventState: EventState) => void,
  65992. /**
  65993. * Defines the mask of the observer (used to filter notifications)
  65994. */
  65995. mask: number,
  65996. /**
  65997. * Defines the current scope used to restore the JS context
  65998. */
  65999. scope?: any);
  66000. }
  66001. /**
  66002. * Represent a list of observers registered to multiple Observables object.
  66003. */
  66004. export class MultiObserver<T> {
  66005. private _observers;
  66006. private _observables;
  66007. /**
  66008. * Release associated resources
  66009. */
  66010. dispose(): void;
  66011. /**
  66012. * Raise a callback when one of the observable will notify
  66013. * @param observables defines a list of observables to watch
  66014. * @param callback defines the callback to call on notification
  66015. * @param mask defines the mask used to filter notifications
  66016. * @param scope defines the current scope used to restore the JS context
  66017. * @returns the new MultiObserver
  66018. */
  66019. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66020. }
  66021. /**
  66022. * The Observable class is a simple implementation of the Observable pattern.
  66023. *
  66024. * 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.
  66025. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66026. * 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).
  66027. * 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.
  66028. */
  66029. export class Observable<T> {
  66030. private _observers;
  66031. private _eventState;
  66032. private _onObserverAdded;
  66033. /**
  66034. * Gets the list of observers
  66035. */
  66036. readonly observers: Array<Observer<T>>;
  66037. /**
  66038. * Creates a new observable
  66039. * @param onObserverAdded defines a callback to call when a new observer is added
  66040. */
  66041. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66042. /**
  66043. * Create a new Observer with the specified callback
  66044. * @param callback the callback that will be executed for that Observer
  66045. * @param mask the mask used to filter observers
  66046. * @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.
  66047. * @param scope optional scope for the callback to be called from
  66048. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66049. * @returns the new observer created for the callback
  66050. */
  66051. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66052. /**
  66053. * Create a new Observer with the specified callback and unregisters after the next notification
  66054. * @param callback the callback that will be executed for that Observer
  66055. * @returns the new observer created for the callback
  66056. */
  66057. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66058. /**
  66059. * Remove an Observer from the Observable object
  66060. * @param observer the instance of the Observer to remove
  66061. * @returns false if it doesn't belong to this Observable
  66062. */
  66063. remove(observer: Nullable<Observer<T>>): boolean;
  66064. /**
  66065. * Remove a callback from the Observable object
  66066. * @param callback the callback to remove
  66067. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66068. * @returns false if it doesn't belong to this Observable
  66069. */
  66070. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66071. private _deferUnregister;
  66072. private _remove;
  66073. /**
  66074. * Moves the observable to the top of the observer list making it get called first when notified
  66075. * @param observer the observer to move
  66076. */
  66077. makeObserverTopPriority(observer: Observer<T>): void;
  66078. /**
  66079. * Moves the observable to the bottom of the observer list making it get called last when notified
  66080. * @param observer the observer to move
  66081. */
  66082. makeObserverBottomPriority(observer: Observer<T>): void;
  66083. /**
  66084. * Notify all Observers by calling their respective callback with the given data
  66085. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66086. * @param eventData defines the data to send to all observers
  66087. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66088. * @param target defines the original target of the state
  66089. * @param currentTarget defines the current target of the state
  66090. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66091. */
  66092. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66093. /**
  66094. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66095. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66096. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66097. * and it is crucial that all callbacks will be executed.
  66098. * The order of the callbacks is kept, callbacks are not executed parallel.
  66099. *
  66100. * @param eventData The data to be sent to each callback
  66101. * @param mask is used to filter observers defaults to -1
  66102. * @param target defines the callback target (see EventState)
  66103. * @param currentTarget defines he current object in the bubbling phase
  66104. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66105. */
  66106. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66107. /**
  66108. * Notify a specific observer
  66109. * @param observer defines the observer to notify
  66110. * @param eventData defines the data to be sent to each callback
  66111. * @param mask is used to filter observers defaults to -1
  66112. */
  66113. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66114. /**
  66115. * Gets a boolean indicating if the observable has at least one observer
  66116. * @returns true is the Observable has at least one Observer registered
  66117. */
  66118. hasObservers(): boolean;
  66119. /**
  66120. * Clear the list of observers
  66121. */
  66122. clear(): void;
  66123. /**
  66124. * Clone the current observable
  66125. * @returns a new observable
  66126. */
  66127. clone(): Observable<T>;
  66128. /**
  66129. * Does this observable handles observer registered with a given mask
  66130. * @param mask defines the mask to be tested
  66131. * @return whether or not one observer registered with the given mask is handeled
  66132. **/
  66133. hasSpecificMask(mask?: number): boolean;
  66134. }
  66135. }
  66136. declare module BABYLON {
  66137. /**
  66138. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  66139. * Babylon.js
  66140. */
  66141. export class DomManagement {
  66142. /**
  66143. * Checks if the window object exists
  66144. * @returns true if the window object exists
  66145. */
  66146. static IsWindowObjectExist(): boolean;
  66147. /**
  66148. * Checks if the navigator object exists
  66149. * @returns true if the navigator object exists
  66150. */
  66151. static IsNavigatorAvailable(): boolean;
  66152. /**
  66153. * Extracts text content from a DOM element hierarchy
  66154. * @param element defines the root element
  66155. * @returns a string
  66156. */
  66157. static GetDOMTextContent(element: HTMLElement): string;
  66158. }
  66159. }
  66160. declare module BABYLON {
  66161. /**
  66162. * Logger used througouht the application to allow configuration of
  66163. * the log level required for the messages.
  66164. */
  66165. export class Logger {
  66166. /**
  66167. * No log
  66168. */
  66169. static readonly NoneLogLevel: number;
  66170. /**
  66171. * Only message logs
  66172. */
  66173. static readonly MessageLogLevel: number;
  66174. /**
  66175. * Only warning logs
  66176. */
  66177. static readonly WarningLogLevel: number;
  66178. /**
  66179. * Only error logs
  66180. */
  66181. static readonly ErrorLogLevel: number;
  66182. /**
  66183. * All logs
  66184. */
  66185. static readonly AllLogLevel: number;
  66186. private static _LogCache;
  66187. /**
  66188. * Gets a value indicating the number of loading errors
  66189. * @ignorenaming
  66190. */
  66191. static errorsCount: number;
  66192. /**
  66193. * Callback called when a new log is added
  66194. */
  66195. static OnNewCacheEntry: (entry: string) => void;
  66196. private static _AddLogEntry;
  66197. private static _FormatMessage;
  66198. private static _LogDisabled;
  66199. private static _LogEnabled;
  66200. private static _WarnDisabled;
  66201. private static _WarnEnabled;
  66202. private static _ErrorDisabled;
  66203. private static _ErrorEnabled;
  66204. /**
  66205. * Log a message to the console
  66206. */
  66207. static Log: (message: string) => void;
  66208. /**
  66209. * Write a warning message to the console
  66210. */
  66211. static Warn: (message: string) => void;
  66212. /**
  66213. * Write an error message to the console
  66214. */
  66215. static Error: (message: string) => void;
  66216. /**
  66217. * Gets current log cache (list of logs)
  66218. */
  66219. static readonly LogCache: string;
  66220. /**
  66221. * Clears the log cache
  66222. */
  66223. static ClearLogCache(): void;
  66224. /**
  66225. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  66226. */
  66227. static LogLevels: number;
  66228. }
  66229. }
  66230. declare module BABYLON {
  66231. /** @hidden */
  66232. export class _TypeStore {
  66233. /** @hidden */
  66234. static RegisteredTypes: {
  66235. [key: string]: Object;
  66236. };
  66237. /** @hidden */
  66238. static GetClass(fqdn: string): any;
  66239. }
  66240. }
  66241. declare module BABYLON {
  66242. /**
  66243. * Class containing a set of static utilities functions for deep copy.
  66244. */
  66245. export class DeepCopier {
  66246. /**
  66247. * Tries to copy an object by duplicating every property
  66248. * @param source defines the source object
  66249. * @param destination defines the target object
  66250. * @param doNotCopyList defines a list of properties to avoid
  66251. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  66252. */
  66253. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  66254. }
  66255. }
  66256. declare module BABYLON {
  66257. /**
  66258. * Class containing a set of static utilities functions for precision date
  66259. */
  66260. export class PrecisionDate {
  66261. /**
  66262. * Gets either window.performance.now() if supported or Date.now() else
  66263. */
  66264. static readonly Now: number;
  66265. }
  66266. }
  66267. declare module BABYLON {
  66268. /** @hidden */
  66269. export class _DevTools {
  66270. static WarnImport(name: string): string;
  66271. }
  66272. }
  66273. declare module BABYLON {
  66274. /**
  66275. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  66276. */
  66277. export class WebRequest {
  66278. private _xhr;
  66279. /**
  66280. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  66281. * i.e. when loading files, where the server/service expects an Authorization header
  66282. */
  66283. static CustomRequestHeaders: {
  66284. [key: string]: string;
  66285. };
  66286. /**
  66287. * Add callback functions in this array to update all the requests before they get sent to the network
  66288. */
  66289. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  66290. private _injectCustomRequestHeaders;
  66291. /**
  66292. * Gets or sets a function to be called when loading progress changes
  66293. */
  66294. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  66295. /**
  66296. * Returns client's state
  66297. */
  66298. readonly readyState: number;
  66299. /**
  66300. * Returns client's status
  66301. */
  66302. readonly status: number;
  66303. /**
  66304. * Returns client's status as a text
  66305. */
  66306. readonly statusText: string;
  66307. /**
  66308. * Returns client's response
  66309. */
  66310. readonly response: any;
  66311. /**
  66312. * Returns client's response url
  66313. */
  66314. readonly responseURL: string;
  66315. /**
  66316. * Returns client's response as text
  66317. */
  66318. readonly responseText: string;
  66319. /**
  66320. * Gets or sets the expected response type
  66321. */
  66322. responseType: XMLHttpRequestResponseType;
  66323. /** @hidden */
  66324. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  66325. /** @hidden */
  66326. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  66327. /**
  66328. * Cancels any network activity
  66329. */
  66330. abort(): void;
  66331. /**
  66332. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  66333. * @param body defines an optional request body
  66334. */
  66335. send(body?: Document | BodyInit | null): void;
  66336. /**
  66337. * Sets the request method, request URL
  66338. * @param method defines the method to use (GET, POST, etc..)
  66339. * @param url defines the url to connect with
  66340. */
  66341. open(method: string, url: string): void;
  66342. }
  66343. }
  66344. declare module BABYLON {
  66345. /**
  66346. * File request interface
  66347. */
  66348. export interface IFileRequest {
  66349. /**
  66350. * Raised when the request is complete (success or error).
  66351. */
  66352. onCompleteObservable: Observable<IFileRequest>;
  66353. /**
  66354. * Aborts the request for a file.
  66355. */
  66356. abort: () => void;
  66357. }
  66358. }
  66359. declare module BABYLON {
  66360. /**
  66361. * Class used to store gfx data (like WebGLBuffer)
  66362. */
  66363. export class DataBuffer {
  66364. /**
  66365. * Gets or sets the number of objects referencing this buffer
  66366. */
  66367. references: number;
  66368. /** Gets or sets the size of the underlying buffer */
  66369. capacity: number;
  66370. /**
  66371. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  66372. */
  66373. is32Bits: boolean;
  66374. /**
  66375. * Gets the underlying buffer
  66376. */
  66377. readonly underlyingResource: any;
  66378. }
  66379. }
  66380. declare module BABYLON {
  66381. /**
  66382. * Class used to store data that will be store in GPU memory
  66383. */
  66384. export class Buffer {
  66385. private _engine;
  66386. private _buffer;
  66387. /** @hidden */
  66388. _data: Nullable<DataArray>;
  66389. private _updatable;
  66390. private _instanced;
  66391. /**
  66392. * Gets the byte stride.
  66393. */
  66394. readonly byteStride: number;
  66395. /**
  66396. * Constructor
  66397. * @param engine the engine
  66398. * @param data the data to use for this buffer
  66399. * @param updatable whether the data is updatable
  66400. * @param stride the stride (optional)
  66401. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66402. * @param instanced whether the buffer is instanced (optional)
  66403. * @param useBytes set to true if the stride in in bytes (optional)
  66404. */
  66405. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  66406. /**
  66407. * Create a new VertexBuffer based on the current buffer
  66408. * @param kind defines the vertex buffer kind (position, normal, etc.)
  66409. * @param offset defines offset in the buffer (0 by default)
  66410. * @param size defines the size in floats of attributes (position is 3 for instance)
  66411. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  66412. * @param instanced defines if the vertex buffer contains indexed data
  66413. * @param useBytes defines if the offset and stride are in bytes
  66414. * @returns the new vertex buffer
  66415. */
  66416. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  66417. /**
  66418. * Gets a boolean indicating if the Buffer is updatable?
  66419. * @returns true if the buffer is updatable
  66420. */
  66421. isUpdatable(): boolean;
  66422. /**
  66423. * Gets current buffer's data
  66424. * @returns a DataArray or null
  66425. */
  66426. getData(): Nullable<DataArray>;
  66427. /**
  66428. * Gets underlying native buffer
  66429. * @returns underlying native buffer
  66430. */
  66431. getBuffer(): Nullable<DataBuffer>;
  66432. /**
  66433. * Gets the stride in float32 units (i.e. byte stride / 4).
  66434. * May not be an integer if the byte stride is not divisible by 4.
  66435. * DEPRECATED. Use byteStride instead.
  66436. * @returns the stride in float32 units
  66437. */
  66438. getStrideSize(): number;
  66439. /**
  66440. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66441. * @param data defines the data to store
  66442. */
  66443. create(data?: Nullable<DataArray>): void;
  66444. /** @hidden */
  66445. _rebuild(): void;
  66446. /**
  66447. * Update current buffer data
  66448. * @param data defines the data to store
  66449. */
  66450. update(data: DataArray): void;
  66451. /**
  66452. * Updates the data directly.
  66453. * @param data the new data
  66454. * @param offset the new offset
  66455. * @param vertexCount the vertex count (optional)
  66456. * @param useBytes set to true if the offset is in bytes
  66457. */
  66458. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  66459. /**
  66460. * Release all resources
  66461. */
  66462. dispose(): void;
  66463. }
  66464. /**
  66465. * Specialized buffer used to store vertex data
  66466. */
  66467. export class VertexBuffer {
  66468. /** @hidden */
  66469. _buffer: Buffer;
  66470. private _kind;
  66471. private _size;
  66472. private _ownsBuffer;
  66473. private _instanced;
  66474. private _instanceDivisor;
  66475. /**
  66476. * The byte type.
  66477. */
  66478. static readonly BYTE: number;
  66479. /**
  66480. * The unsigned byte type.
  66481. */
  66482. static readonly UNSIGNED_BYTE: number;
  66483. /**
  66484. * The short type.
  66485. */
  66486. static readonly SHORT: number;
  66487. /**
  66488. * The unsigned short type.
  66489. */
  66490. static readonly UNSIGNED_SHORT: number;
  66491. /**
  66492. * The integer type.
  66493. */
  66494. static readonly INT: number;
  66495. /**
  66496. * The unsigned integer type.
  66497. */
  66498. static readonly UNSIGNED_INT: number;
  66499. /**
  66500. * The float type.
  66501. */
  66502. static readonly FLOAT: number;
  66503. /**
  66504. * Gets or sets the instance divisor when in instanced mode
  66505. */
  66506. instanceDivisor: number;
  66507. /**
  66508. * Gets the byte stride.
  66509. */
  66510. readonly byteStride: number;
  66511. /**
  66512. * Gets the byte offset.
  66513. */
  66514. readonly byteOffset: number;
  66515. /**
  66516. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  66517. */
  66518. readonly normalized: boolean;
  66519. /**
  66520. * Gets the data type of each component in the array.
  66521. */
  66522. readonly type: number;
  66523. /**
  66524. * Constructor
  66525. * @param engine the engine
  66526. * @param data the data to use for this vertex buffer
  66527. * @param kind the vertex buffer kind
  66528. * @param updatable whether the data is updatable
  66529. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66530. * @param stride the stride (optional)
  66531. * @param instanced whether the buffer is instanced (optional)
  66532. * @param offset the offset of the data (optional)
  66533. * @param size the number of components (optional)
  66534. * @param type the type of the component (optional)
  66535. * @param normalized whether the data contains normalized data (optional)
  66536. * @param useBytes set to true if stride and offset are in bytes (optional)
  66537. */
  66538. 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);
  66539. /** @hidden */
  66540. _rebuild(): void;
  66541. /**
  66542. * Returns the kind of the VertexBuffer (string)
  66543. * @returns a string
  66544. */
  66545. getKind(): string;
  66546. /**
  66547. * Gets a boolean indicating if the VertexBuffer is updatable?
  66548. * @returns true if the buffer is updatable
  66549. */
  66550. isUpdatable(): boolean;
  66551. /**
  66552. * Gets current buffer's data
  66553. * @returns a DataArray or null
  66554. */
  66555. getData(): Nullable<DataArray>;
  66556. /**
  66557. * Gets underlying native buffer
  66558. * @returns underlying native buffer
  66559. */
  66560. getBuffer(): Nullable<DataBuffer>;
  66561. /**
  66562. * Gets the stride in float32 units (i.e. byte stride / 4).
  66563. * May not be an integer if the byte stride is not divisible by 4.
  66564. * DEPRECATED. Use byteStride instead.
  66565. * @returns the stride in float32 units
  66566. */
  66567. getStrideSize(): number;
  66568. /**
  66569. * Returns the offset as a multiple of the type byte length.
  66570. * DEPRECATED. Use byteOffset instead.
  66571. * @returns the offset in bytes
  66572. */
  66573. getOffset(): number;
  66574. /**
  66575. * Returns the number of components per vertex attribute (integer)
  66576. * @returns the size in float
  66577. */
  66578. getSize(): number;
  66579. /**
  66580. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  66581. * @returns true if this buffer is instanced
  66582. */
  66583. getIsInstanced(): boolean;
  66584. /**
  66585. * Returns the instancing divisor, zero for non-instanced (integer).
  66586. * @returns a number
  66587. */
  66588. getInstanceDivisor(): number;
  66589. /**
  66590. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66591. * @param data defines the data to store
  66592. */
  66593. create(data?: DataArray): void;
  66594. /**
  66595. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  66596. * This function will create a new buffer if the current one is not updatable
  66597. * @param data defines the data to store
  66598. */
  66599. update(data: DataArray): void;
  66600. /**
  66601. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  66602. * Returns the directly updated WebGLBuffer.
  66603. * @param data the new data
  66604. * @param offset the new offset
  66605. * @param useBytes set to true if the offset is in bytes
  66606. */
  66607. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  66608. /**
  66609. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  66610. */
  66611. dispose(): void;
  66612. /**
  66613. * Enumerates each value of this vertex buffer as numbers.
  66614. * @param count the number of values to enumerate
  66615. * @param callback the callback function called for each value
  66616. */
  66617. forEach(count: number, callback: (value: number, index: number) => void): void;
  66618. /**
  66619. * Positions
  66620. */
  66621. static readonly PositionKind: string;
  66622. /**
  66623. * Normals
  66624. */
  66625. static readonly NormalKind: string;
  66626. /**
  66627. * Tangents
  66628. */
  66629. static readonly TangentKind: string;
  66630. /**
  66631. * Texture coordinates
  66632. */
  66633. static readonly UVKind: string;
  66634. /**
  66635. * Texture coordinates 2
  66636. */
  66637. static readonly UV2Kind: string;
  66638. /**
  66639. * Texture coordinates 3
  66640. */
  66641. static readonly UV3Kind: string;
  66642. /**
  66643. * Texture coordinates 4
  66644. */
  66645. static readonly UV4Kind: string;
  66646. /**
  66647. * Texture coordinates 5
  66648. */
  66649. static readonly UV5Kind: string;
  66650. /**
  66651. * Texture coordinates 6
  66652. */
  66653. static readonly UV6Kind: string;
  66654. /**
  66655. * Colors
  66656. */
  66657. static readonly ColorKind: string;
  66658. /**
  66659. * Matrix indices (for bones)
  66660. */
  66661. static readonly MatricesIndicesKind: string;
  66662. /**
  66663. * Matrix weights (for bones)
  66664. */
  66665. static readonly MatricesWeightsKind: string;
  66666. /**
  66667. * Additional matrix indices (for bones)
  66668. */
  66669. static readonly MatricesIndicesExtraKind: string;
  66670. /**
  66671. * Additional matrix weights (for bones)
  66672. */
  66673. static readonly MatricesWeightsExtraKind: string;
  66674. /**
  66675. * Deduces the stride given a kind.
  66676. * @param kind The kind string to deduce
  66677. * @returns The deduced stride
  66678. */
  66679. static DeduceStride(kind: string): number;
  66680. /**
  66681. * Gets the byte length of the given type.
  66682. * @param type the type
  66683. * @returns the number of bytes
  66684. */
  66685. static GetTypeByteLength(type: number): number;
  66686. /**
  66687. * Enumerates each value of the given parameters as numbers.
  66688. * @param data the data to enumerate
  66689. * @param byteOffset the byte offset of the data
  66690. * @param byteStride the byte stride of the data
  66691. * @param componentCount the number of components per element
  66692. * @param componentType the type of the component
  66693. * @param count the number of values to enumerate
  66694. * @param normalized whether the data is normalized
  66695. * @param callback the callback function called for each value
  66696. */
  66697. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  66698. private static _GetFloatValue;
  66699. }
  66700. }
  66701. declare module BABYLON {
  66702. /**
  66703. * Scalar computation library
  66704. */
  66705. export class Scalar {
  66706. /**
  66707. * Two pi constants convenient for computation.
  66708. */
  66709. static TwoPi: number;
  66710. /**
  66711. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66712. * @param a number
  66713. * @param b number
  66714. * @param epsilon (default = 1.401298E-45)
  66715. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66716. */
  66717. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  66718. /**
  66719. * Returns a string : the upper case translation of the number i to hexadecimal.
  66720. * @param i number
  66721. * @returns the upper case translation of the number i to hexadecimal.
  66722. */
  66723. static ToHex(i: number): string;
  66724. /**
  66725. * Returns -1 if value is negative and +1 is value is positive.
  66726. * @param value the value
  66727. * @returns the value itself if it's equal to zero.
  66728. */
  66729. static Sign(value: number): number;
  66730. /**
  66731. * Returns the value itself if it's between min and max.
  66732. * Returns min if the value is lower than min.
  66733. * Returns max if the value is greater than max.
  66734. * @param value the value to clmap
  66735. * @param min the min value to clamp to (default: 0)
  66736. * @param max the max value to clamp to (default: 1)
  66737. * @returns the clamped value
  66738. */
  66739. static Clamp(value: number, min?: number, max?: number): number;
  66740. /**
  66741. * the log2 of value.
  66742. * @param value the value to compute log2 of
  66743. * @returns the log2 of value.
  66744. */
  66745. static Log2(value: number): number;
  66746. /**
  66747. * Loops the value, so that it is never larger than length and never smaller than 0.
  66748. *
  66749. * This is similar to the modulo operator but it works with floating point numbers.
  66750. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  66751. * With t = 5 and length = 2.5, the result would be 0.0.
  66752. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  66753. * @param value the value
  66754. * @param length the length
  66755. * @returns the looped value
  66756. */
  66757. static Repeat(value: number, length: number): number;
  66758. /**
  66759. * Normalize the value between 0.0 and 1.0 using min and max values
  66760. * @param value value to normalize
  66761. * @param min max to normalize between
  66762. * @param max min to normalize between
  66763. * @returns the normalized value
  66764. */
  66765. static Normalize(value: number, min: number, max: number): number;
  66766. /**
  66767. * Denormalize the value from 0.0 and 1.0 using min and max values
  66768. * @param normalized value to denormalize
  66769. * @param min max to denormalize between
  66770. * @param max min to denormalize between
  66771. * @returns the denormalized value
  66772. */
  66773. static Denormalize(normalized: number, min: number, max: number): number;
  66774. /**
  66775. * Calculates the shortest difference between two given angles given in degrees.
  66776. * @param current current angle in degrees
  66777. * @param target target angle in degrees
  66778. * @returns the delta
  66779. */
  66780. static DeltaAngle(current: number, target: number): number;
  66781. /**
  66782. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  66783. * @param tx value
  66784. * @param length length
  66785. * @returns The returned value will move back and forth between 0 and length
  66786. */
  66787. static PingPong(tx: number, length: number): number;
  66788. /**
  66789. * Interpolates between min and max with smoothing at the limits.
  66790. *
  66791. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  66792. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  66793. * @param from from
  66794. * @param to to
  66795. * @param tx value
  66796. * @returns the smooth stepped value
  66797. */
  66798. static SmoothStep(from: number, to: number, tx: number): number;
  66799. /**
  66800. * Moves a value current towards target.
  66801. *
  66802. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  66803. * Negative values of maxDelta pushes the value away from target.
  66804. * @param current current value
  66805. * @param target target value
  66806. * @param maxDelta max distance to move
  66807. * @returns resulting value
  66808. */
  66809. static MoveTowards(current: number, target: number, maxDelta: number): number;
  66810. /**
  66811. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66812. *
  66813. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  66814. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  66815. * @param current current value
  66816. * @param target target value
  66817. * @param maxDelta max distance to move
  66818. * @returns resulting angle
  66819. */
  66820. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  66821. /**
  66822. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  66823. * @param start start value
  66824. * @param end target value
  66825. * @param amount amount to lerp between
  66826. * @returns the lerped value
  66827. */
  66828. static Lerp(start: number, end: number, amount: number): number;
  66829. /**
  66830. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66831. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  66832. * @param start start value
  66833. * @param end target value
  66834. * @param amount amount to lerp between
  66835. * @returns the lerped value
  66836. */
  66837. static LerpAngle(start: number, end: number, amount: number): number;
  66838. /**
  66839. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  66840. * @param a start value
  66841. * @param b target value
  66842. * @param value value between a and b
  66843. * @returns the inverseLerp value
  66844. */
  66845. static InverseLerp(a: number, b: number, value: number): number;
  66846. /**
  66847. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  66848. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  66849. * @param value1 spline value
  66850. * @param tangent1 spline value
  66851. * @param value2 spline value
  66852. * @param tangent2 spline value
  66853. * @param amount input value
  66854. * @returns hermite result
  66855. */
  66856. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  66857. /**
  66858. * Returns a random float number between and min and max values
  66859. * @param min min value of random
  66860. * @param max max value of random
  66861. * @returns random value
  66862. */
  66863. static RandomRange(min: number, max: number): number;
  66864. /**
  66865. * This function returns percentage of a number in a given range.
  66866. *
  66867. * RangeToPercent(40,20,60) will return 0.5 (50%)
  66868. * RangeToPercent(34,0,100) will return 0.34 (34%)
  66869. * @param number to convert to percentage
  66870. * @param min min range
  66871. * @param max max range
  66872. * @returns the percentage
  66873. */
  66874. static RangeToPercent(number: number, min: number, max: number): number;
  66875. /**
  66876. * This function returns number that corresponds to the percentage in a given range.
  66877. *
  66878. * PercentToRange(0.34,0,100) will return 34.
  66879. * @param percent to convert to number
  66880. * @param min min range
  66881. * @param max max range
  66882. * @returns the number
  66883. */
  66884. static PercentToRange(percent: number, min: number, max: number): number;
  66885. /**
  66886. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  66887. * @param angle The angle to normalize in radian.
  66888. * @return The converted angle.
  66889. */
  66890. static NormalizeRadians(angle: number): number;
  66891. }
  66892. }
  66893. declare module BABYLON {
  66894. /**
  66895. * Constant used to convert a value to gamma space
  66896. * @ignorenaming
  66897. */
  66898. export const ToGammaSpace: number;
  66899. /**
  66900. * Constant used to convert a value to linear space
  66901. * @ignorenaming
  66902. */
  66903. export const ToLinearSpace = 2.2;
  66904. /**
  66905. * Constant used to define the minimal number value in Babylon.js
  66906. * @ignorenaming
  66907. */
  66908. let Epsilon: number;
  66909. }
  66910. declare module BABYLON {
  66911. /**
  66912. * Class used to represent a viewport on screen
  66913. */
  66914. export class Viewport {
  66915. /** viewport left coordinate */
  66916. x: number;
  66917. /** viewport top coordinate */
  66918. y: number;
  66919. /**viewport width */
  66920. width: number;
  66921. /** viewport height */
  66922. height: number;
  66923. /**
  66924. * Creates a Viewport object located at (x, y) and sized (width, height)
  66925. * @param x defines viewport left coordinate
  66926. * @param y defines viewport top coordinate
  66927. * @param width defines the viewport width
  66928. * @param height defines the viewport height
  66929. */
  66930. constructor(
  66931. /** viewport left coordinate */
  66932. x: number,
  66933. /** viewport top coordinate */
  66934. y: number,
  66935. /**viewport width */
  66936. width: number,
  66937. /** viewport height */
  66938. height: number);
  66939. /**
  66940. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66941. * @param renderWidth defines the rendering width
  66942. * @param renderHeight defines the rendering height
  66943. * @returns a new Viewport
  66944. */
  66945. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66946. /**
  66947. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66948. * @param renderWidth defines the rendering width
  66949. * @param renderHeight defines the rendering height
  66950. * @param ref defines the target viewport
  66951. * @returns the current viewport
  66952. */
  66953. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66954. /**
  66955. * Returns a new Viewport copied from the current one
  66956. * @returns a new Viewport
  66957. */
  66958. clone(): Viewport;
  66959. }
  66960. }
  66961. declare module BABYLON {
  66962. /**
  66963. * Class containing a set of static utilities functions for arrays.
  66964. */
  66965. export class ArrayTools {
  66966. /**
  66967. * Returns an array of the given size filled with element built from the given constructor and the paramters
  66968. * @param size the number of element to construct and put in the array
  66969. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  66970. * @returns a new array filled with new objects
  66971. */
  66972. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  66973. }
  66974. }
  66975. declare module BABYLON {
  66976. /**
  66977. * @hidden
  66978. */
  66979. export interface IColor4Like {
  66980. r: float;
  66981. g: float;
  66982. b: float;
  66983. a: float;
  66984. }
  66985. /**
  66986. * @hidden
  66987. */
  66988. export interface IColor3Like {
  66989. r: float;
  66990. g: float;
  66991. b: float;
  66992. }
  66993. /**
  66994. * @hidden
  66995. */
  66996. export interface IVector4Like {
  66997. x: float;
  66998. y: float;
  66999. z: float;
  67000. w: float;
  67001. }
  67002. /**
  67003. * @hidden
  67004. */
  67005. export interface IVector3Like {
  67006. x: float;
  67007. y: float;
  67008. z: float;
  67009. }
  67010. /**
  67011. * @hidden
  67012. */
  67013. export interface IVector2Like {
  67014. x: float;
  67015. y: float;
  67016. }
  67017. /**
  67018. * @hidden
  67019. */
  67020. export interface IMatrixLike {
  67021. toArray(): DeepImmutable<Float32Array>;
  67022. updateFlag: int;
  67023. }
  67024. /**
  67025. * @hidden
  67026. */
  67027. export interface IViewportLike {
  67028. x: float;
  67029. y: float;
  67030. width: float;
  67031. height: float;
  67032. }
  67033. /**
  67034. * @hidden
  67035. */
  67036. export interface IPlaneLike {
  67037. normal: IVector3Like;
  67038. d: float;
  67039. normalize(): void;
  67040. }
  67041. }
  67042. declare module BABYLON {
  67043. /**
  67044. * Class representing a vector containing 2 coordinates
  67045. */
  67046. export class Vector2 {
  67047. /** defines the first coordinate */
  67048. x: number;
  67049. /** defines the second coordinate */
  67050. y: number;
  67051. /**
  67052. * Creates a new Vector2 from the given x and y coordinates
  67053. * @param x defines the first coordinate
  67054. * @param y defines the second coordinate
  67055. */
  67056. constructor(
  67057. /** defines the first coordinate */
  67058. x?: number,
  67059. /** defines the second coordinate */
  67060. y?: number);
  67061. /**
  67062. * Gets a string with the Vector2 coordinates
  67063. * @returns a string with the Vector2 coordinates
  67064. */
  67065. toString(): string;
  67066. /**
  67067. * Gets class name
  67068. * @returns the string "Vector2"
  67069. */
  67070. getClassName(): string;
  67071. /**
  67072. * Gets current vector hash code
  67073. * @returns the Vector2 hash code as a number
  67074. */
  67075. getHashCode(): number;
  67076. /**
  67077. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67078. * @param array defines the source array
  67079. * @param index defines the offset in source array
  67080. * @returns the current Vector2
  67081. */
  67082. toArray(array: FloatArray, index?: number): Vector2;
  67083. /**
  67084. * Copy the current vector to an array
  67085. * @returns a new array with 2 elements: the Vector2 coordinates.
  67086. */
  67087. asArray(): number[];
  67088. /**
  67089. * Sets the Vector2 coordinates with the given Vector2 coordinates
  67090. * @param source defines the source Vector2
  67091. * @returns the current updated Vector2
  67092. */
  67093. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  67094. /**
  67095. * Sets the Vector2 coordinates with the given floats
  67096. * @param x defines the first coordinate
  67097. * @param y defines the second coordinate
  67098. * @returns the current updated Vector2
  67099. */
  67100. copyFromFloats(x: number, y: number): Vector2;
  67101. /**
  67102. * Sets the Vector2 coordinates with the given floats
  67103. * @param x defines the first coordinate
  67104. * @param y defines the second coordinate
  67105. * @returns the current updated Vector2
  67106. */
  67107. set(x: number, y: number): Vector2;
  67108. /**
  67109. * Add another vector with the current one
  67110. * @param otherVector defines the other vector
  67111. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67112. */
  67113. add(otherVector: DeepImmutable<Vector2>): Vector2;
  67114. /**
  67115. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67116. * @param otherVector defines the other vector
  67117. * @param result defines the target vector
  67118. * @returns the unmodified current Vector2
  67119. */
  67120. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67121. /**
  67122. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67123. * @param otherVector defines the other vector
  67124. * @returns the current updated Vector2
  67125. */
  67126. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67127. /**
  67128. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67129. * @param otherVector defines the other vector
  67130. * @returns a new Vector2
  67131. */
  67132. addVector3(otherVector: Vector3): Vector2;
  67133. /**
  67134. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67135. * @param otherVector defines the other vector
  67136. * @returns a new Vector2
  67137. */
  67138. subtract(otherVector: Vector2): Vector2;
  67139. /**
  67140. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67141. * @param otherVector defines the other vector
  67142. * @param result defines the target vector
  67143. * @returns the unmodified current Vector2
  67144. */
  67145. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67146. /**
  67147. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67148. * @param otherVector defines the other vector
  67149. * @returns the current updated Vector2
  67150. */
  67151. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67152. /**
  67153. * Multiplies in place the current Vector2 coordinates by the given ones
  67154. * @param otherVector defines the other vector
  67155. * @returns the current updated Vector2
  67156. */
  67157. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67158. /**
  67159. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67160. * @param otherVector defines the other vector
  67161. * @returns a new Vector2
  67162. */
  67163. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  67164. /**
  67165. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67166. * @param otherVector defines the other vector
  67167. * @param result defines the target vector
  67168. * @returns the unmodified current Vector2
  67169. */
  67170. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67171. /**
  67172. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67173. * @param x defines the first coordinate
  67174. * @param y defines the second coordinate
  67175. * @returns a new Vector2
  67176. */
  67177. multiplyByFloats(x: number, y: number): Vector2;
  67178. /**
  67179. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67180. * @param otherVector defines the other vector
  67181. * @returns a new Vector2
  67182. */
  67183. divide(otherVector: Vector2): Vector2;
  67184. /**
  67185. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67186. * @param otherVector defines the other vector
  67187. * @param result defines the target vector
  67188. * @returns the unmodified current Vector2
  67189. */
  67190. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67191. /**
  67192. * Divides the current Vector2 coordinates by the given ones
  67193. * @param otherVector defines the other vector
  67194. * @returns the current updated Vector2
  67195. */
  67196. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67197. /**
  67198. * Gets a new Vector2 with current Vector2 negated coordinates
  67199. * @returns a new Vector2
  67200. */
  67201. negate(): Vector2;
  67202. /**
  67203. * Multiply the Vector2 coordinates by scale
  67204. * @param scale defines the scaling factor
  67205. * @returns the current updated Vector2
  67206. */
  67207. scaleInPlace(scale: number): Vector2;
  67208. /**
  67209. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67210. * @param scale defines the scaling factor
  67211. * @returns a new Vector2
  67212. */
  67213. scale(scale: number): Vector2;
  67214. /**
  67215. * Scale the current Vector2 values by a factor to a given Vector2
  67216. * @param scale defines the scale factor
  67217. * @param result defines the Vector2 object where to store the result
  67218. * @returns the unmodified current Vector2
  67219. */
  67220. scaleToRef(scale: number, result: Vector2): Vector2;
  67221. /**
  67222. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67223. * @param scale defines the scale factor
  67224. * @param result defines the Vector2 object where to store the result
  67225. * @returns the unmodified current Vector2
  67226. */
  67227. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67228. /**
  67229. * Gets a boolean if two vectors are equals
  67230. * @param otherVector defines the other vector
  67231. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67232. */
  67233. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67234. /**
  67235. * Gets a boolean if two vectors are equals (using an epsilon value)
  67236. * @param otherVector defines the other vector
  67237. * @param epsilon defines the minimal distance to consider equality
  67238. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67239. */
  67240. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67241. /**
  67242. * Gets a new Vector2 from current Vector2 floored values
  67243. * @returns a new Vector2
  67244. */
  67245. floor(): Vector2;
  67246. /**
  67247. * Gets a new Vector2 from current Vector2 floored values
  67248. * @returns a new Vector2
  67249. */
  67250. fract(): Vector2;
  67251. /**
  67252. * Gets the length of the vector
  67253. * @returns the vector length (float)
  67254. */
  67255. length(): number;
  67256. /**
  67257. * Gets the vector squared length
  67258. * @returns the vector squared length (float)
  67259. */
  67260. lengthSquared(): number;
  67261. /**
  67262. * Normalize the vector
  67263. * @returns the current updated Vector2
  67264. */
  67265. normalize(): Vector2;
  67266. /**
  67267. * Gets a new Vector2 copied from the Vector2
  67268. * @returns a new Vector2
  67269. */
  67270. clone(): Vector2;
  67271. /**
  67272. * Gets a new Vector2(0, 0)
  67273. * @returns a new Vector2
  67274. */
  67275. static Zero(): Vector2;
  67276. /**
  67277. * Gets a new Vector2(1, 1)
  67278. * @returns a new Vector2
  67279. */
  67280. static One(): Vector2;
  67281. /**
  67282. * Gets a new Vector2 set from the given index element of the given array
  67283. * @param array defines the data source
  67284. * @param offset defines the offset in the data source
  67285. * @returns a new Vector2
  67286. */
  67287. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67288. /**
  67289. * Sets "result" from the given index element of the given array
  67290. * @param array defines the data source
  67291. * @param offset defines the offset in the data source
  67292. * @param result defines the target vector
  67293. */
  67294. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67295. /**
  67296. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67297. * @param value1 defines 1st point of control
  67298. * @param value2 defines 2nd point of control
  67299. * @param value3 defines 3rd point of control
  67300. * @param value4 defines 4th point of control
  67301. * @param amount defines the interpolation factor
  67302. * @returns a new Vector2
  67303. */
  67304. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67305. /**
  67306. * 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".
  67307. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67308. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67309. * @param value defines the value to clamp
  67310. * @param min defines the lower limit
  67311. * @param max defines the upper limit
  67312. * @returns a new Vector2
  67313. */
  67314. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67315. /**
  67316. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67317. * @param value1 defines the 1st control point
  67318. * @param tangent1 defines the outgoing tangent
  67319. * @param value2 defines the 2nd control point
  67320. * @param tangent2 defines the incoming tangent
  67321. * @param amount defines the interpolation factor
  67322. * @returns a new Vector2
  67323. */
  67324. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67325. /**
  67326. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67327. * @param start defines the start vector
  67328. * @param end defines the end vector
  67329. * @param amount defines the interpolation factor
  67330. * @returns a new Vector2
  67331. */
  67332. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67333. /**
  67334. * Gets the dot product of the vector "left" and the vector "right"
  67335. * @param left defines first vector
  67336. * @param right defines second vector
  67337. * @returns the dot product (float)
  67338. */
  67339. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67340. /**
  67341. * Returns a new Vector2 equal to the normalized given vector
  67342. * @param vector defines the vector to normalize
  67343. * @returns a new Vector2
  67344. */
  67345. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67346. /**
  67347. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67348. * @param left defines 1st vector
  67349. * @param right defines 2nd vector
  67350. * @returns a new Vector2
  67351. */
  67352. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67353. /**
  67354. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67355. * @param left defines 1st vector
  67356. * @param right defines 2nd vector
  67357. * @returns a new Vector2
  67358. */
  67359. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67360. /**
  67361. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67362. * @param vector defines the vector to transform
  67363. * @param transformation defines the matrix to apply
  67364. * @returns a new Vector2
  67365. */
  67366. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67367. /**
  67368. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67369. * @param vector defines the vector to transform
  67370. * @param transformation defines the matrix to apply
  67371. * @param result defines the target vector
  67372. */
  67373. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67374. /**
  67375. * Determines if a given vector is included in a triangle
  67376. * @param p defines the vector to test
  67377. * @param p0 defines 1st triangle point
  67378. * @param p1 defines 2nd triangle point
  67379. * @param p2 defines 3rd triangle point
  67380. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67381. */
  67382. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67383. /**
  67384. * Gets the distance between the vectors "value1" and "value2"
  67385. * @param value1 defines first vector
  67386. * @param value2 defines second vector
  67387. * @returns the distance between vectors
  67388. */
  67389. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67390. /**
  67391. * Returns the squared distance between the vectors "value1" and "value2"
  67392. * @param value1 defines first vector
  67393. * @param value2 defines second vector
  67394. * @returns the squared distance between vectors
  67395. */
  67396. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67397. /**
  67398. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  67399. * @param value1 defines first vector
  67400. * @param value2 defines second vector
  67401. * @returns a new Vector2
  67402. */
  67403. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  67404. /**
  67405. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  67406. * @param p defines the middle point
  67407. * @param segA defines one point of the segment
  67408. * @param segB defines the other point of the segment
  67409. * @returns the shortest distance
  67410. */
  67411. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  67412. }
  67413. /**
  67414. * Classed used to store (x,y,z) vector representation
  67415. * A Vector3 is the main object used in 3D geometry
  67416. * It can represent etiher the coordinates of a point the space, either a direction
  67417. * Reminder: js uses a left handed forward facing system
  67418. */
  67419. export class Vector3 {
  67420. /**
  67421. * Defines the first coordinates (on X axis)
  67422. */
  67423. x: number;
  67424. /**
  67425. * Defines the second coordinates (on Y axis)
  67426. */
  67427. y: number;
  67428. /**
  67429. * Defines the third coordinates (on Z axis)
  67430. */
  67431. z: number;
  67432. private static _UpReadOnly;
  67433. private static _ZeroReadOnly;
  67434. /**
  67435. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  67436. * @param x defines the first coordinates (on X axis)
  67437. * @param y defines the second coordinates (on Y axis)
  67438. * @param z defines the third coordinates (on Z axis)
  67439. */
  67440. constructor(
  67441. /**
  67442. * Defines the first coordinates (on X axis)
  67443. */
  67444. x?: number,
  67445. /**
  67446. * Defines the second coordinates (on Y axis)
  67447. */
  67448. y?: number,
  67449. /**
  67450. * Defines the third coordinates (on Z axis)
  67451. */
  67452. z?: number);
  67453. /**
  67454. * Creates a string representation of the Vector3
  67455. * @returns a string with the Vector3 coordinates.
  67456. */
  67457. toString(): string;
  67458. /**
  67459. * Gets the class name
  67460. * @returns the string "Vector3"
  67461. */
  67462. getClassName(): string;
  67463. /**
  67464. * Creates the Vector3 hash code
  67465. * @returns a number which tends to be unique between Vector3 instances
  67466. */
  67467. getHashCode(): number;
  67468. /**
  67469. * Creates an array containing three elements : the coordinates of the Vector3
  67470. * @returns a new array of numbers
  67471. */
  67472. asArray(): number[];
  67473. /**
  67474. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  67475. * @param array defines the destination array
  67476. * @param index defines the offset in the destination array
  67477. * @returns the current Vector3
  67478. */
  67479. toArray(array: FloatArray, index?: number): Vector3;
  67480. /**
  67481. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  67482. * @returns a new Quaternion object, computed from the Vector3 coordinates
  67483. */
  67484. toQuaternion(): Quaternion;
  67485. /**
  67486. * Adds the given vector to the current Vector3
  67487. * @param otherVector defines the second operand
  67488. * @returns the current updated Vector3
  67489. */
  67490. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67491. /**
  67492. * Adds the given coordinates to the current Vector3
  67493. * @param x defines the x coordinate of the operand
  67494. * @param y defines the y coordinate of the operand
  67495. * @param z defines the z coordinate of the operand
  67496. * @returns the current updated Vector3
  67497. */
  67498. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67499. /**
  67500. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  67501. * @param otherVector defines the second operand
  67502. * @returns the resulting Vector3
  67503. */
  67504. add(otherVector: DeepImmutable<Vector3>): Vector3;
  67505. /**
  67506. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  67507. * @param otherVector defines the second operand
  67508. * @param result defines the Vector3 object where to store the result
  67509. * @returns the current Vector3
  67510. */
  67511. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67512. /**
  67513. * Subtract the given vector from the current Vector3
  67514. * @param otherVector defines the second operand
  67515. * @returns the current updated Vector3
  67516. */
  67517. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67518. /**
  67519. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  67520. * @param otherVector defines the second operand
  67521. * @returns the resulting Vector3
  67522. */
  67523. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  67524. /**
  67525. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  67526. * @param otherVector defines the second operand
  67527. * @param result defines the Vector3 object where to store the result
  67528. * @returns the current Vector3
  67529. */
  67530. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67531. /**
  67532. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  67533. * @param x defines the x coordinate of the operand
  67534. * @param y defines the y coordinate of the operand
  67535. * @param z defines the z coordinate of the operand
  67536. * @returns the resulting Vector3
  67537. */
  67538. subtractFromFloats(x: number, y: number, z: number): Vector3;
  67539. /**
  67540. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  67541. * @param x defines the x coordinate of the operand
  67542. * @param y defines the y coordinate of the operand
  67543. * @param z defines the z coordinate of the operand
  67544. * @param result defines the Vector3 object where to store the result
  67545. * @returns the current Vector3
  67546. */
  67547. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  67548. /**
  67549. * Gets a new Vector3 set with the current Vector3 negated coordinates
  67550. * @returns a new Vector3
  67551. */
  67552. negate(): Vector3;
  67553. /**
  67554. * Multiplies the Vector3 coordinates by the float "scale"
  67555. * @param scale defines the multiplier factor
  67556. * @returns the current updated Vector3
  67557. */
  67558. scaleInPlace(scale: number): Vector3;
  67559. /**
  67560. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  67561. * @param scale defines the multiplier factor
  67562. * @returns a new Vector3
  67563. */
  67564. scale(scale: number): Vector3;
  67565. /**
  67566. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  67567. * @param scale defines the multiplier factor
  67568. * @param result defines the Vector3 object where to store the result
  67569. * @returns the current Vector3
  67570. */
  67571. scaleToRef(scale: number, result: Vector3): Vector3;
  67572. /**
  67573. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  67574. * @param scale defines the scale factor
  67575. * @param result defines the Vector3 object where to store the result
  67576. * @returns the unmodified current Vector3
  67577. */
  67578. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  67579. /**
  67580. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  67581. * @param otherVector defines the second operand
  67582. * @returns true if both vectors are equals
  67583. */
  67584. equals(otherVector: DeepImmutable<Vector3>): boolean;
  67585. /**
  67586. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  67587. * @param otherVector defines the second operand
  67588. * @param epsilon defines the minimal distance to define values as equals
  67589. * @returns true if both vectors are distant less than epsilon
  67590. */
  67591. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  67592. /**
  67593. * Returns true if the current Vector3 coordinates equals the given floats
  67594. * @param x defines the x coordinate of the operand
  67595. * @param y defines the y coordinate of the operand
  67596. * @param z defines the z coordinate of the operand
  67597. * @returns true if both vectors are equals
  67598. */
  67599. equalsToFloats(x: number, y: number, z: number): boolean;
  67600. /**
  67601. * Multiplies the current Vector3 coordinates by the given ones
  67602. * @param otherVector defines the second operand
  67603. * @returns the current updated Vector3
  67604. */
  67605. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67606. /**
  67607. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  67608. * @param otherVector defines the second operand
  67609. * @returns the new Vector3
  67610. */
  67611. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  67612. /**
  67613. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  67614. * @param otherVector defines the second operand
  67615. * @param result defines the Vector3 object where to store the result
  67616. * @returns the current Vector3
  67617. */
  67618. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67619. /**
  67620. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  67621. * @param x defines the x coordinate of the operand
  67622. * @param y defines the y coordinate of the operand
  67623. * @param z defines the z coordinate of the operand
  67624. * @returns the new Vector3
  67625. */
  67626. multiplyByFloats(x: number, y: number, z: number): Vector3;
  67627. /**
  67628. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  67629. * @param otherVector defines the second operand
  67630. * @returns the new Vector3
  67631. */
  67632. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  67633. /**
  67634. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  67635. * @param otherVector defines the second operand
  67636. * @param result defines the Vector3 object where to store the result
  67637. * @returns the current Vector3
  67638. */
  67639. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67640. /**
  67641. * Divides the current Vector3 coordinates by the given ones.
  67642. * @param otherVector defines the second operand
  67643. * @returns the current updated Vector3
  67644. */
  67645. divideInPlace(otherVector: Vector3): Vector3;
  67646. /**
  67647. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  67648. * @param other defines the second operand
  67649. * @returns the current updated Vector3
  67650. */
  67651. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67652. /**
  67653. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  67654. * @param other defines the second operand
  67655. * @returns the current updated Vector3
  67656. */
  67657. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67658. /**
  67659. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  67660. * @param x defines the x coordinate of the operand
  67661. * @param y defines the y coordinate of the operand
  67662. * @param z defines the z coordinate of the operand
  67663. * @returns the current updated Vector3
  67664. */
  67665. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67666. /**
  67667. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  67668. * @param x defines the x coordinate of the operand
  67669. * @param y defines the y coordinate of the operand
  67670. * @param z defines the z coordinate of the operand
  67671. * @returns the current updated Vector3
  67672. */
  67673. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67674. /**
  67675. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  67676. * Check if is non uniform within a certain amount of decimal places to account for this
  67677. * @param epsilon the amount the values can differ
  67678. * @returns if the the vector is non uniform to a certain number of decimal places
  67679. */
  67680. isNonUniformWithinEpsilon(epsilon: number): boolean;
  67681. /**
  67682. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  67683. */
  67684. readonly isNonUniform: boolean;
  67685. /**
  67686. * Gets a new Vector3 from current Vector3 floored values
  67687. * @returns a new Vector3
  67688. */
  67689. floor(): Vector3;
  67690. /**
  67691. * Gets a new Vector3 from current Vector3 floored values
  67692. * @returns a new Vector3
  67693. */
  67694. fract(): Vector3;
  67695. /**
  67696. * Gets the length of the Vector3
  67697. * @returns the length of the Vector3
  67698. */
  67699. length(): number;
  67700. /**
  67701. * Gets the squared length of the Vector3
  67702. * @returns squared length of the Vector3
  67703. */
  67704. lengthSquared(): number;
  67705. /**
  67706. * Normalize the current Vector3.
  67707. * Please note that this is an in place operation.
  67708. * @returns the current updated Vector3
  67709. */
  67710. normalize(): Vector3;
  67711. /**
  67712. * Reorders the x y z properties of the vector in place
  67713. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  67714. * @returns the current updated vector
  67715. */
  67716. reorderInPlace(order: string): this;
  67717. /**
  67718. * Rotates the vector around 0,0,0 by a quaternion
  67719. * @param quaternion the rotation quaternion
  67720. * @param result vector to store the result
  67721. * @returns the resulting vector
  67722. */
  67723. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  67724. /**
  67725. * Rotates a vector around a given point
  67726. * @param quaternion the rotation quaternion
  67727. * @param point the point to rotate around
  67728. * @param result vector to store the result
  67729. * @returns the resulting vector
  67730. */
  67731. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  67732. /**
  67733. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  67734. * The cross product is then orthogonal to both current and "other"
  67735. * @param other defines the right operand
  67736. * @returns the cross product
  67737. */
  67738. cross(other: Vector3): Vector3;
  67739. /**
  67740. * Normalize the current Vector3 with the given input length.
  67741. * Please note that this is an in place operation.
  67742. * @param len the length of the vector
  67743. * @returns the current updated Vector3
  67744. */
  67745. normalizeFromLength(len: number): Vector3;
  67746. /**
  67747. * Normalize the current Vector3 to a new vector
  67748. * @returns the new Vector3
  67749. */
  67750. normalizeToNew(): Vector3;
  67751. /**
  67752. * Normalize the current Vector3 to the reference
  67753. * @param reference define the Vector3 to update
  67754. * @returns the updated Vector3
  67755. */
  67756. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  67757. /**
  67758. * Creates a new Vector3 copied from the current Vector3
  67759. * @returns the new Vector3
  67760. */
  67761. clone(): Vector3;
  67762. /**
  67763. * Copies the given vector coordinates to the current Vector3 ones
  67764. * @param source defines the source Vector3
  67765. * @returns the current updated Vector3
  67766. */
  67767. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  67768. /**
  67769. * Copies the given floats to the current Vector3 coordinates
  67770. * @param x defines the x coordinate of the operand
  67771. * @param y defines the y coordinate of the operand
  67772. * @param z defines the z coordinate of the operand
  67773. * @returns the current updated Vector3
  67774. */
  67775. copyFromFloats(x: number, y: number, z: number): Vector3;
  67776. /**
  67777. * Copies the given floats to the current Vector3 coordinates
  67778. * @param x defines the x coordinate of the operand
  67779. * @param y defines the y coordinate of the operand
  67780. * @param z defines the z coordinate of the operand
  67781. * @returns the current updated Vector3
  67782. */
  67783. set(x: number, y: number, z: number): Vector3;
  67784. /**
  67785. * Copies the given float to the current Vector3 coordinates
  67786. * @param v defines the x, y and z coordinates of the operand
  67787. * @returns the current updated Vector3
  67788. */
  67789. setAll(v: number): Vector3;
  67790. /**
  67791. * Get the clip factor between two vectors
  67792. * @param vector0 defines the first operand
  67793. * @param vector1 defines the second operand
  67794. * @param axis defines the axis to use
  67795. * @param size defines the size along the axis
  67796. * @returns the clip factor
  67797. */
  67798. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  67799. /**
  67800. * Get angle between two vectors
  67801. * @param vector0 angle between vector0 and vector1
  67802. * @param vector1 angle between vector0 and vector1
  67803. * @param normal direction of the normal
  67804. * @return the angle between vector0 and vector1
  67805. */
  67806. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  67807. /**
  67808. * Returns a new Vector3 set from the index "offset" of the given array
  67809. * @param array defines the source array
  67810. * @param offset defines the offset in the source array
  67811. * @returns the new Vector3
  67812. */
  67813. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  67814. /**
  67815. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  67816. * This function is deprecated. Use FromArray instead
  67817. * @param array defines the source array
  67818. * @param offset defines the offset in the source array
  67819. * @returns the new Vector3
  67820. */
  67821. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  67822. /**
  67823. * Sets the given vector "result" with the element values from the index "offset" of the given array
  67824. * @param array defines the source array
  67825. * @param offset defines the offset in the source array
  67826. * @param result defines the Vector3 where to store the result
  67827. */
  67828. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  67829. /**
  67830. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  67831. * This function is deprecated. Use FromArrayToRef instead.
  67832. * @param array defines the source array
  67833. * @param offset defines the offset in the source array
  67834. * @param result defines the Vector3 where to store the result
  67835. */
  67836. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  67837. /**
  67838. * Sets the given vector "result" with the given floats.
  67839. * @param x defines the x coordinate of the source
  67840. * @param y defines the y coordinate of the source
  67841. * @param z defines the z coordinate of the source
  67842. * @param result defines the Vector3 where to store the result
  67843. */
  67844. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  67845. /**
  67846. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  67847. * @returns a new empty Vector3
  67848. */
  67849. static Zero(): Vector3;
  67850. /**
  67851. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  67852. * @returns a new unit Vector3
  67853. */
  67854. static One(): Vector3;
  67855. /**
  67856. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  67857. * @returns a new up Vector3
  67858. */
  67859. static Up(): Vector3;
  67860. /**
  67861. * Gets a up Vector3 that must not be updated
  67862. */
  67863. static readonly UpReadOnly: DeepImmutable<Vector3>;
  67864. /**
  67865. * Gets a zero Vector3 that must not be updated
  67866. */
  67867. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  67868. /**
  67869. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  67870. * @returns a new down Vector3
  67871. */
  67872. static Down(): Vector3;
  67873. /**
  67874. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  67875. * @returns a new forward Vector3
  67876. */
  67877. static Forward(): Vector3;
  67878. /**
  67879. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  67880. * @returns a new forward Vector3
  67881. */
  67882. static Backward(): Vector3;
  67883. /**
  67884. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  67885. * @returns a new right Vector3
  67886. */
  67887. static Right(): Vector3;
  67888. /**
  67889. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  67890. * @returns a new left Vector3
  67891. */
  67892. static Left(): Vector3;
  67893. /**
  67894. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  67895. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  67896. * @param vector defines the Vector3 to transform
  67897. * @param transformation defines the transformation matrix
  67898. * @returns the transformed Vector3
  67899. */
  67900. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  67901. /**
  67902. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  67903. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  67904. * @param vector defines the Vector3 to transform
  67905. * @param transformation defines the transformation matrix
  67906. * @param result defines the Vector3 where to store the result
  67907. */
  67908. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67909. /**
  67910. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  67911. * This method computes tranformed coordinates only, not transformed direction vectors
  67912. * @param x define the x coordinate of the source vector
  67913. * @param y define the y coordinate of the source vector
  67914. * @param z define the z coordinate of the source vector
  67915. * @param transformation defines the transformation matrix
  67916. * @param result defines the Vector3 where to store the result
  67917. */
  67918. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67919. /**
  67920. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  67921. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67922. * @param vector defines the Vector3 to transform
  67923. * @param transformation defines the transformation matrix
  67924. * @returns the new Vector3
  67925. */
  67926. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  67927. /**
  67928. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  67929. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67930. * @param vector defines the Vector3 to transform
  67931. * @param transformation defines the transformation matrix
  67932. * @param result defines the Vector3 where to store the result
  67933. */
  67934. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67935. /**
  67936. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  67937. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  67938. * @param x define the x coordinate of the source vector
  67939. * @param y define the y coordinate of the source vector
  67940. * @param z define the z coordinate of the source vector
  67941. * @param transformation defines the transformation matrix
  67942. * @param result defines the Vector3 where to store the result
  67943. */
  67944. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  67945. /**
  67946. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  67947. * @param value1 defines the first control point
  67948. * @param value2 defines the second control point
  67949. * @param value3 defines the third control point
  67950. * @param value4 defines the fourth control point
  67951. * @param amount defines the amount on the spline to use
  67952. * @returns the new Vector3
  67953. */
  67954. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  67955. /**
  67956. * 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"
  67957. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  67958. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  67959. * @param value defines the current value
  67960. * @param min defines the lower range value
  67961. * @param max defines the upper range value
  67962. * @returns the new Vector3
  67963. */
  67964. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  67965. /**
  67966. * 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"
  67967. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  67968. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  67969. * @param value defines the current value
  67970. * @param min defines the lower range value
  67971. * @param max defines the upper range value
  67972. * @param result defines the Vector3 where to store the result
  67973. */
  67974. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  67975. /**
  67976. * Checks if a given vector is inside a specific range
  67977. * @param v defines the vector to test
  67978. * @param min defines the minimum range
  67979. * @param max defines the maximum range
  67980. */
  67981. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  67982. /**
  67983. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  67984. * @param value1 defines the first control point
  67985. * @param tangent1 defines the first tangent vector
  67986. * @param value2 defines the second control point
  67987. * @param tangent2 defines the second tangent vector
  67988. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  67989. * @returns the new Vector3
  67990. */
  67991. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  67992. /**
  67993. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  67994. * @param start defines the start value
  67995. * @param end defines the end value
  67996. * @param amount max defines amount between both (between 0 and 1)
  67997. * @returns the new Vector3
  67998. */
  67999. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  68000. /**
  68001. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  68002. * @param start defines the start value
  68003. * @param end defines the end value
  68004. * @param amount max defines amount between both (between 0 and 1)
  68005. * @param result defines the Vector3 where to store the result
  68006. */
  68007. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  68008. /**
  68009. * Returns the dot product (float) between the vectors "left" and "right"
  68010. * @param left defines the left operand
  68011. * @param right defines the right operand
  68012. * @returns the dot product
  68013. */
  68014. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  68015. /**
  68016. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  68017. * The cross product is then orthogonal to both "left" and "right"
  68018. * @param left defines the left operand
  68019. * @param right defines the right operand
  68020. * @returns the cross product
  68021. */
  68022. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68023. /**
  68024. * Sets the given vector "result" with the cross product of "left" and "right"
  68025. * The cross product is then orthogonal to both "left" and "right"
  68026. * @param left defines the left operand
  68027. * @param right defines the right operand
  68028. * @param result defines the Vector3 where to store the result
  68029. */
  68030. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  68031. /**
  68032. * Returns a new Vector3 as the normalization of the given vector
  68033. * @param vector defines the Vector3 to normalize
  68034. * @returns the new Vector3
  68035. */
  68036. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  68037. /**
  68038. * Sets the given vector "result" with the normalization of the given first vector
  68039. * @param vector defines the Vector3 to normalize
  68040. * @param result defines the Vector3 where to store the result
  68041. */
  68042. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  68043. /**
  68044. * Project a Vector3 onto screen space
  68045. * @param vector defines the Vector3 to project
  68046. * @param world defines the world matrix to use
  68047. * @param transform defines the transform (view x projection) matrix to use
  68048. * @param viewport defines the screen viewport to use
  68049. * @returns the new Vector3
  68050. */
  68051. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  68052. /** @hidden */
  68053. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  68054. /**
  68055. * Unproject from screen space to object space
  68056. * @param source defines the screen space Vector3 to use
  68057. * @param viewportWidth defines the current width of the viewport
  68058. * @param viewportHeight defines the current height of the viewport
  68059. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68060. * @param transform defines the transform (view x projection) matrix to use
  68061. * @returns the new Vector3
  68062. */
  68063. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  68064. /**
  68065. * Unproject from screen space to object space
  68066. * @param source defines the screen space Vector3 to use
  68067. * @param viewportWidth defines the current width of the viewport
  68068. * @param viewportHeight defines the current height of the viewport
  68069. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68070. * @param view defines the view matrix to use
  68071. * @param projection defines the projection matrix to use
  68072. * @returns the new Vector3
  68073. */
  68074. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  68075. /**
  68076. * Unproject from screen space to object space
  68077. * @param source defines the screen space Vector3 to use
  68078. * @param viewportWidth defines the current width of the viewport
  68079. * @param viewportHeight defines the current height of the viewport
  68080. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68081. * @param view defines the view matrix to use
  68082. * @param projection defines the projection matrix to use
  68083. * @param result defines the Vector3 where to store the result
  68084. */
  68085. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68086. /**
  68087. * Unproject from screen space to object space
  68088. * @param sourceX defines the screen space x coordinate to use
  68089. * @param sourceY defines the screen space y coordinate to use
  68090. * @param sourceZ defines the screen space z coordinate to use
  68091. * @param viewportWidth defines the current width of the viewport
  68092. * @param viewportHeight defines the current height of the viewport
  68093. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68094. * @param view defines the view matrix to use
  68095. * @param projection defines the projection matrix to use
  68096. * @param result defines the Vector3 where to store the result
  68097. */
  68098. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68099. /**
  68100. * Gets the minimal coordinate values between two Vector3
  68101. * @param left defines the first operand
  68102. * @param right defines the second operand
  68103. * @returns the new Vector3
  68104. */
  68105. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68106. /**
  68107. * Gets the maximal coordinate values between two Vector3
  68108. * @param left defines the first operand
  68109. * @param right defines the second operand
  68110. * @returns the new Vector3
  68111. */
  68112. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68113. /**
  68114. * Returns the distance between the vectors "value1" and "value2"
  68115. * @param value1 defines the first operand
  68116. * @param value2 defines the second operand
  68117. * @returns the distance
  68118. */
  68119. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68120. /**
  68121. * Returns the squared distance between the vectors "value1" and "value2"
  68122. * @param value1 defines the first operand
  68123. * @param value2 defines the second operand
  68124. * @returns the squared distance
  68125. */
  68126. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68127. /**
  68128. * Returns a new Vector3 located at the center between "value1" and "value2"
  68129. * @param value1 defines the first operand
  68130. * @param value2 defines the second operand
  68131. * @returns the new Vector3
  68132. */
  68133. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  68134. /**
  68135. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  68136. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  68137. * to something in order to rotate it from its local system to the given target system
  68138. * Note: axis1, axis2 and axis3 are normalized during this operation
  68139. * @param axis1 defines the first axis
  68140. * @param axis2 defines the second axis
  68141. * @param axis3 defines the third axis
  68142. * @returns a new Vector3
  68143. */
  68144. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  68145. /**
  68146. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  68147. * @param axis1 defines the first axis
  68148. * @param axis2 defines the second axis
  68149. * @param axis3 defines the third axis
  68150. * @param ref defines the Vector3 where to store the result
  68151. */
  68152. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  68153. }
  68154. /**
  68155. * Vector4 class created for EulerAngle class conversion to Quaternion
  68156. */
  68157. export class Vector4 {
  68158. /** x value of the vector */
  68159. x: number;
  68160. /** y value of the vector */
  68161. y: number;
  68162. /** z value of the vector */
  68163. z: number;
  68164. /** w value of the vector */
  68165. w: number;
  68166. /**
  68167. * Creates a Vector4 object from the given floats.
  68168. * @param x x value of the vector
  68169. * @param y y value of the vector
  68170. * @param z z value of the vector
  68171. * @param w w value of the vector
  68172. */
  68173. constructor(
  68174. /** x value of the vector */
  68175. x: number,
  68176. /** y value of the vector */
  68177. y: number,
  68178. /** z value of the vector */
  68179. z: number,
  68180. /** w value of the vector */
  68181. w: number);
  68182. /**
  68183. * Returns the string with the Vector4 coordinates.
  68184. * @returns a string containing all the vector values
  68185. */
  68186. toString(): string;
  68187. /**
  68188. * Returns the string "Vector4".
  68189. * @returns "Vector4"
  68190. */
  68191. getClassName(): string;
  68192. /**
  68193. * Returns the Vector4 hash code.
  68194. * @returns a unique hash code
  68195. */
  68196. getHashCode(): number;
  68197. /**
  68198. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68199. * @returns the resulting array
  68200. */
  68201. asArray(): number[];
  68202. /**
  68203. * Populates the given array from the given index with the Vector4 coordinates.
  68204. * @param array array to populate
  68205. * @param index index of the array to start at (default: 0)
  68206. * @returns the Vector4.
  68207. */
  68208. toArray(array: FloatArray, index?: number): Vector4;
  68209. /**
  68210. * Adds the given vector to the current Vector4.
  68211. * @param otherVector the vector to add
  68212. * @returns the updated Vector4.
  68213. */
  68214. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68215. /**
  68216. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68217. * @param otherVector the vector to add
  68218. * @returns the resulting vector
  68219. */
  68220. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68221. /**
  68222. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68223. * @param otherVector the vector to add
  68224. * @param result the vector to store the result
  68225. * @returns the current Vector4.
  68226. */
  68227. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68228. /**
  68229. * Subtract in place the given vector from the current Vector4.
  68230. * @param otherVector the vector to subtract
  68231. * @returns the updated Vector4.
  68232. */
  68233. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68234. /**
  68235. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68236. * @param otherVector the vector to add
  68237. * @returns the new vector with the result
  68238. */
  68239. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68240. /**
  68241. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68242. * @param otherVector the vector to subtract
  68243. * @param result the vector to store the result
  68244. * @returns the current Vector4.
  68245. */
  68246. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68247. /**
  68248. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68249. */
  68250. /**
  68251. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68252. * @param x value to subtract
  68253. * @param y value to subtract
  68254. * @param z value to subtract
  68255. * @param w value to subtract
  68256. * @returns new vector containing the result
  68257. */
  68258. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68259. /**
  68260. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68261. * @param x value to subtract
  68262. * @param y value to subtract
  68263. * @param z value to subtract
  68264. * @param w value to subtract
  68265. * @param result the vector to store the result in
  68266. * @returns the current Vector4.
  68267. */
  68268. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68269. /**
  68270. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68271. * @returns a new vector with the negated values
  68272. */
  68273. negate(): Vector4;
  68274. /**
  68275. * Multiplies the current Vector4 coordinates by scale (float).
  68276. * @param scale the number to scale with
  68277. * @returns the updated Vector4.
  68278. */
  68279. scaleInPlace(scale: number): Vector4;
  68280. /**
  68281. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68282. * @param scale the number to scale with
  68283. * @returns a new vector with the result
  68284. */
  68285. scale(scale: number): Vector4;
  68286. /**
  68287. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68288. * @param scale the number to scale with
  68289. * @param result a vector to store the result in
  68290. * @returns the current Vector4.
  68291. */
  68292. scaleToRef(scale: number, result: Vector4): Vector4;
  68293. /**
  68294. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68295. * @param scale defines the scale factor
  68296. * @param result defines the Vector4 object where to store the result
  68297. * @returns the unmodified current Vector4
  68298. */
  68299. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68300. /**
  68301. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68302. * @param otherVector the vector to compare against
  68303. * @returns true if they are equal
  68304. */
  68305. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68306. /**
  68307. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68308. * @param otherVector vector to compare against
  68309. * @param epsilon (Default: very small number)
  68310. * @returns true if they are equal
  68311. */
  68312. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68313. /**
  68314. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68315. * @param x x value to compare against
  68316. * @param y y value to compare against
  68317. * @param z z value to compare against
  68318. * @param w w value to compare against
  68319. * @returns true if equal
  68320. */
  68321. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68322. /**
  68323. * Multiplies in place the current Vector4 by the given one.
  68324. * @param otherVector vector to multiple with
  68325. * @returns the updated Vector4.
  68326. */
  68327. multiplyInPlace(otherVector: Vector4): Vector4;
  68328. /**
  68329. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68330. * @param otherVector vector to multiple with
  68331. * @returns resulting new vector
  68332. */
  68333. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68334. /**
  68335. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68336. * @param otherVector vector to multiple with
  68337. * @param result vector to store the result
  68338. * @returns the current Vector4.
  68339. */
  68340. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68341. /**
  68342. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68343. * @param x x value multiply with
  68344. * @param y y value multiply with
  68345. * @param z z value multiply with
  68346. * @param w w value multiply with
  68347. * @returns resulting new vector
  68348. */
  68349. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68350. /**
  68351. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68352. * @param otherVector vector to devide with
  68353. * @returns resulting new vector
  68354. */
  68355. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68356. /**
  68357. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68358. * @param otherVector vector to devide with
  68359. * @param result vector to store the result
  68360. * @returns the current Vector4.
  68361. */
  68362. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68363. /**
  68364. * Divides the current Vector3 coordinates by the given ones.
  68365. * @param otherVector vector to devide with
  68366. * @returns the updated Vector3.
  68367. */
  68368. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68369. /**
  68370. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68371. * @param other defines the second operand
  68372. * @returns the current updated Vector4
  68373. */
  68374. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68375. /**
  68376. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68377. * @param other defines the second operand
  68378. * @returns the current updated Vector4
  68379. */
  68380. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68381. /**
  68382. * Gets a new Vector4 from current Vector4 floored values
  68383. * @returns a new Vector4
  68384. */
  68385. floor(): Vector4;
  68386. /**
  68387. * Gets a new Vector4 from current Vector3 floored values
  68388. * @returns a new Vector4
  68389. */
  68390. fract(): Vector4;
  68391. /**
  68392. * Returns the Vector4 length (float).
  68393. * @returns the length
  68394. */
  68395. length(): number;
  68396. /**
  68397. * Returns the Vector4 squared length (float).
  68398. * @returns the length squared
  68399. */
  68400. lengthSquared(): number;
  68401. /**
  68402. * Normalizes in place the Vector4.
  68403. * @returns the updated Vector4.
  68404. */
  68405. normalize(): Vector4;
  68406. /**
  68407. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  68408. * @returns this converted to a new vector3
  68409. */
  68410. toVector3(): Vector3;
  68411. /**
  68412. * Returns a new Vector4 copied from the current one.
  68413. * @returns the new cloned vector
  68414. */
  68415. clone(): Vector4;
  68416. /**
  68417. * Updates the current Vector4 with the given one coordinates.
  68418. * @param source the source vector to copy from
  68419. * @returns the updated Vector4.
  68420. */
  68421. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  68422. /**
  68423. * Updates the current Vector4 coordinates with the given floats.
  68424. * @param x float to copy from
  68425. * @param y float to copy from
  68426. * @param z float to copy from
  68427. * @param w float to copy from
  68428. * @returns the updated Vector4.
  68429. */
  68430. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68431. /**
  68432. * Updates the current Vector4 coordinates with the given floats.
  68433. * @param x float to set from
  68434. * @param y float to set from
  68435. * @param z float to set from
  68436. * @param w float to set from
  68437. * @returns the updated Vector4.
  68438. */
  68439. set(x: number, y: number, z: number, w: number): Vector4;
  68440. /**
  68441. * Copies the given float to the current Vector3 coordinates
  68442. * @param v defines the x, y, z and w coordinates of the operand
  68443. * @returns the current updated Vector3
  68444. */
  68445. setAll(v: number): Vector4;
  68446. /**
  68447. * Returns a new Vector4 set from the starting index of the given array.
  68448. * @param array the array to pull values from
  68449. * @param offset the offset into the array to start at
  68450. * @returns the new vector
  68451. */
  68452. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  68453. /**
  68454. * Updates the given vector "result" from the starting index of the given array.
  68455. * @param array the array to pull values from
  68456. * @param offset the offset into the array to start at
  68457. * @param result the vector to store the result in
  68458. */
  68459. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  68460. /**
  68461. * Updates the given vector "result" from the starting index of the given Float32Array.
  68462. * @param array the array to pull values from
  68463. * @param offset the offset into the array to start at
  68464. * @param result the vector to store the result in
  68465. */
  68466. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  68467. /**
  68468. * Updates the given vector "result" coordinates from the given floats.
  68469. * @param x float to set from
  68470. * @param y float to set from
  68471. * @param z float to set from
  68472. * @param w float to set from
  68473. * @param result the vector to the floats in
  68474. */
  68475. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  68476. /**
  68477. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  68478. * @returns the new vector
  68479. */
  68480. static Zero(): Vector4;
  68481. /**
  68482. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  68483. * @returns the new vector
  68484. */
  68485. static One(): Vector4;
  68486. /**
  68487. * Returns a new normalized Vector4 from the given one.
  68488. * @param vector the vector to normalize
  68489. * @returns the vector
  68490. */
  68491. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  68492. /**
  68493. * Updates the given vector "result" from the normalization of the given one.
  68494. * @param vector the vector to normalize
  68495. * @param result the vector to store the result in
  68496. */
  68497. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  68498. /**
  68499. * Returns a vector with the minimum values from the left and right vectors
  68500. * @param left left vector to minimize
  68501. * @param right right vector to minimize
  68502. * @returns a new vector with the minimum of the left and right vector values
  68503. */
  68504. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68505. /**
  68506. * Returns a vector with the maximum values from the left and right vectors
  68507. * @param left left vector to maximize
  68508. * @param right right vector to maximize
  68509. * @returns a new vector with the maximum of the left and right vector values
  68510. */
  68511. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68512. /**
  68513. * Returns the distance (float) between the vectors "value1" and "value2".
  68514. * @param value1 value to calulate the distance between
  68515. * @param value2 value to calulate the distance between
  68516. * @return the distance between the two vectors
  68517. */
  68518. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68519. /**
  68520. * Returns the squared distance (float) between the vectors "value1" and "value2".
  68521. * @param value1 value to calulate the distance between
  68522. * @param value2 value to calulate the distance between
  68523. * @return the distance between the two vectors squared
  68524. */
  68525. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68526. /**
  68527. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  68528. * @param value1 value to calulate the center between
  68529. * @param value2 value to calulate the center between
  68530. * @return the center between the two vectors
  68531. */
  68532. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  68533. /**
  68534. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  68535. * This methods computes transformed normalized direction vectors only.
  68536. * @param vector the vector to transform
  68537. * @param transformation the transformation matrix to apply
  68538. * @returns the new vector
  68539. */
  68540. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  68541. /**
  68542. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  68543. * This methods computes transformed normalized direction vectors only.
  68544. * @param vector the vector to transform
  68545. * @param transformation the transformation matrix to apply
  68546. * @param result the vector to store the result in
  68547. */
  68548. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68549. /**
  68550. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  68551. * This methods computes transformed normalized direction vectors only.
  68552. * @param x value to transform
  68553. * @param y value to transform
  68554. * @param z value to transform
  68555. * @param w value to transform
  68556. * @param transformation the transformation matrix to apply
  68557. * @param result the vector to store the results in
  68558. */
  68559. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68560. /**
  68561. * Creates a new Vector4 from a Vector3
  68562. * @param source defines the source data
  68563. * @param w defines the 4th component (default is 0)
  68564. * @returns a new Vector4
  68565. */
  68566. static FromVector3(source: Vector3, w?: number): Vector4;
  68567. }
  68568. /**
  68569. * Class used to store quaternion data
  68570. * @see https://en.wikipedia.org/wiki/Quaternion
  68571. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  68572. */
  68573. export class Quaternion {
  68574. /** defines the first component (0 by default) */
  68575. x: number;
  68576. /** defines the second component (0 by default) */
  68577. y: number;
  68578. /** defines the third component (0 by default) */
  68579. z: number;
  68580. /** defines the fourth component (1.0 by default) */
  68581. w: number;
  68582. /**
  68583. * Creates a new Quaternion from the given floats
  68584. * @param x defines the first component (0 by default)
  68585. * @param y defines the second component (0 by default)
  68586. * @param z defines the third component (0 by default)
  68587. * @param w defines the fourth component (1.0 by default)
  68588. */
  68589. constructor(
  68590. /** defines the first component (0 by default) */
  68591. x?: number,
  68592. /** defines the second component (0 by default) */
  68593. y?: number,
  68594. /** defines the third component (0 by default) */
  68595. z?: number,
  68596. /** defines the fourth component (1.0 by default) */
  68597. w?: number);
  68598. /**
  68599. * Gets a string representation for the current quaternion
  68600. * @returns a string with the Quaternion coordinates
  68601. */
  68602. toString(): string;
  68603. /**
  68604. * Gets the class name of the quaternion
  68605. * @returns the string "Quaternion"
  68606. */
  68607. getClassName(): string;
  68608. /**
  68609. * Gets a hash code for this quaternion
  68610. * @returns the quaternion hash code
  68611. */
  68612. getHashCode(): number;
  68613. /**
  68614. * Copy the quaternion to an array
  68615. * @returns a new array populated with 4 elements from the quaternion coordinates
  68616. */
  68617. asArray(): number[];
  68618. /**
  68619. * Check if two quaternions are equals
  68620. * @param otherQuaternion defines the second operand
  68621. * @return true if the current quaternion and the given one coordinates are strictly equals
  68622. */
  68623. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  68624. /**
  68625. * Clone the current quaternion
  68626. * @returns a new quaternion copied from the current one
  68627. */
  68628. clone(): Quaternion;
  68629. /**
  68630. * Copy a quaternion to the current one
  68631. * @param other defines the other quaternion
  68632. * @returns the updated current quaternion
  68633. */
  68634. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  68635. /**
  68636. * Updates the current quaternion with the given float coordinates
  68637. * @param x defines the x coordinate
  68638. * @param y defines the y coordinate
  68639. * @param z defines the z coordinate
  68640. * @param w defines the w coordinate
  68641. * @returns the updated current quaternion
  68642. */
  68643. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  68644. /**
  68645. * Updates the current quaternion from the given float coordinates
  68646. * @param x defines the x coordinate
  68647. * @param y defines the y coordinate
  68648. * @param z defines the z coordinate
  68649. * @param w defines the w coordinate
  68650. * @returns the updated current quaternion
  68651. */
  68652. set(x: number, y: number, z: number, w: number): Quaternion;
  68653. /**
  68654. * Adds two quaternions
  68655. * @param other defines the second operand
  68656. * @returns a new quaternion as the addition result of the given one and the current quaternion
  68657. */
  68658. add(other: DeepImmutable<Quaternion>): Quaternion;
  68659. /**
  68660. * Add a quaternion to the current one
  68661. * @param other defines the quaternion to add
  68662. * @returns the current quaternion
  68663. */
  68664. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  68665. /**
  68666. * Subtract two quaternions
  68667. * @param other defines the second operand
  68668. * @returns a new quaternion as the subtraction result of the given one from the current one
  68669. */
  68670. subtract(other: Quaternion): Quaternion;
  68671. /**
  68672. * Multiplies the current quaternion by a scale factor
  68673. * @param value defines the scale factor
  68674. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  68675. */
  68676. scale(value: number): Quaternion;
  68677. /**
  68678. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  68679. * @param scale defines the scale factor
  68680. * @param result defines the Quaternion object where to store the result
  68681. * @returns the unmodified current quaternion
  68682. */
  68683. scaleToRef(scale: number, result: Quaternion): Quaternion;
  68684. /**
  68685. * Multiplies in place the current quaternion by a scale factor
  68686. * @param value defines the scale factor
  68687. * @returns the current modified quaternion
  68688. */
  68689. scaleInPlace(value: number): Quaternion;
  68690. /**
  68691. * Scale the current quaternion values by a factor and add the result to a given quaternion
  68692. * @param scale defines the scale factor
  68693. * @param result defines the Quaternion object where to store the result
  68694. * @returns the unmodified current quaternion
  68695. */
  68696. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  68697. /**
  68698. * Multiplies two quaternions
  68699. * @param q1 defines the second operand
  68700. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  68701. */
  68702. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  68703. /**
  68704. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  68705. * @param q1 defines the second operand
  68706. * @param result defines the target quaternion
  68707. * @returns the current quaternion
  68708. */
  68709. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  68710. /**
  68711. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  68712. * @param q1 defines the second operand
  68713. * @returns the currentupdated quaternion
  68714. */
  68715. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  68716. /**
  68717. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  68718. * @param ref defines the target quaternion
  68719. * @returns the current quaternion
  68720. */
  68721. conjugateToRef(ref: Quaternion): Quaternion;
  68722. /**
  68723. * Conjugates in place (1-q) the current quaternion
  68724. * @returns the current updated quaternion
  68725. */
  68726. conjugateInPlace(): Quaternion;
  68727. /**
  68728. * Conjugates in place (1-q) the current quaternion
  68729. * @returns a new quaternion
  68730. */
  68731. conjugate(): Quaternion;
  68732. /**
  68733. * Gets length of current quaternion
  68734. * @returns the quaternion length (float)
  68735. */
  68736. length(): number;
  68737. /**
  68738. * Normalize in place the current quaternion
  68739. * @returns the current updated quaternion
  68740. */
  68741. normalize(): Quaternion;
  68742. /**
  68743. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  68744. * @param order is a reserved parameter and is ignore for now
  68745. * @returns a new Vector3 containing the Euler angles
  68746. */
  68747. toEulerAngles(order?: string): Vector3;
  68748. /**
  68749. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  68750. * @param result defines the vector which will be filled with the Euler angles
  68751. * @param order is a reserved parameter and is ignore for now
  68752. * @returns the current unchanged quaternion
  68753. */
  68754. toEulerAnglesToRef(result: Vector3): Quaternion;
  68755. /**
  68756. * Updates the given rotation matrix with the current quaternion values
  68757. * @param result defines the target matrix
  68758. * @returns the current unchanged quaternion
  68759. */
  68760. toRotationMatrix(result: Matrix): Quaternion;
  68761. /**
  68762. * Updates the current quaternion from the given rotation matrix values
  68763. * @param matrix defines the source matrix
  68764. * @returns the current updated quaternion
  68765. */
  68766. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68767. /**
  68768. * Creates a new quaternion from a rotation matrix
  68769. * @param matrix defines the source matrix
  68770. * @returns a new quaternion created from the given rotation matrix values
  68771. */
  68772. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68773. /**
  68774. * Updates the given quaternion with the given rotation matrix values
  68775. * @param matrix defines the source matrix
  68776. * @param result defines the target quaternion
  68777. */
  68778. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  68779. /**
  68780. * Returns the dot product (float) between the quaternions "left" and "right"
  68781. * @param left defines the left operand
  68782. * @param right defines the right operand
  68783. * @returns the dot product
  68784. */
  68785. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  68786. /**
  68787. * Checks if the two quaternions are close to each other
  68788. * @param quat0 defines the first quaternion to check
  68789. * @param quat1 defines the second quaternion to check
  68790. * @returns true if the two quaternions are close to each other
  68791. */
  68792. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  68793. /**
  68794. * Creates an empty quaternion
  68795. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  68796. */
  68797. static Zero(): Quaternion;
  68798. /**
  68799. * Inverse a given quaternion
  68800. * @param q defines the source quaternion
  68801. * @returns a new quaternion as the inverted current quaternion
  68802. */
  68803. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  68804. /**
  68805. * Inverse a given quaternion
  68806. * @param q defines the source quaternion
  68807. * @param result the quaternion the result will be stored in
  68808. * @returns the result quaternion
  68809. */
  68810. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  68811. /**
  68812. * Creates an identity quaternion
  68813. * @returns the identity quaternion
  68814. */
  68815. static Identity(): Quaternion;
  68816. /**
  68817. * Gets a boolean indicating if the given quaternion is identity
  68818. * @param quaternion defines the quaternion to check
  68819. * @returns true if the quaternion is identity
  68820. */
  68821. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  68822. /**
  68823. * Creates a quaternion from a rotation around an axis
  68824. * @param axis defines the axis to use
  68825. * @param angle defines the angle to use
  68826. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  68827. */
  68828. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  68829. /**
  68830. * Creates a rotation around an axis and stores it into the given quaternion
  68831. * @param axis defines the axis to use
  68832. * @param angle defines the angle to use
  68833. * @param result defines the target quaternion
  68834. * @returns the target quaternion
  68835. */
  68836. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  68837. /**
  68838. * Creates a new quaternion from data stored into an array
  68839. * @param array defines the data source
  68840. * @param offset defines the offset in the source array where the data starts
  68841. * @returns a new quaternion
  68842. */
  68843. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  68844. /**
  68845. * Create a quaternion from Euler rotation angles
  68846. * @param x Pitch
  68847. * @param y Yaw
  68848. * @param z Roll
  68849. * @returns the new Quaternion
  68850. */
  68851. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  68852. /**
  68853. * Updates a quaternion from Euler rotation angles
  68854. * @param x Pitch
  68855. * @param y Yaw
  68856. * @param z Roll
  68857. * @param result the quaternion to store the result
  68858. * @returns the updated quaternion
  68859. */
  68860. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  68861. /**
  68862. * Create a quaternion from Euler rotation vector
  68863. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68864. * @returns the new Quaternion
  68865. */
  68866. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  68867. /**
  68868. * Updates a quaternion from Euler rotation vector
  68869. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68870. * @param result the quaternion to store the result
  68871. * @returns the updated quaternion
  68872. */
  68873. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  68874. /**
  68875. * Creates a new quaternion from the given Euler float angles (y, x, z)
  68876. * @param yaw defines the rotation around Y axis
  68877. * @param pitch defines the rotation around X axis
  68878. * @param roll defines the rotation around Z axis
  68879. * @returns the new quaternion
  68880. */
  68881. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  68882. /**
  68883. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  68884. * @param yaw defines the rotation around Y axis
  68885. * @param pitch defines the rotation around X axis
  68886. * @param roll defines the rotation around Z axis
  68887. * @param result defines the target quaternion
  68888. */
  68889. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  68890. /**
  68891. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  68892. * @param alpha defines the rotation around first axis
  68893. * @param beta defines the rotation around second axis
  68894. * @param gamma defines the rotation around third axis
  68895. * @returns the new quaternion
  68896. */
  68897. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  68898. /**
  68899. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  68900. * @param alpha defines the rotation around first axis
  68901. * @param beta defines the rotation around second axis
  68902. * @param gamma defines the rotation around third axis
  68903. * @param result defines the target quaternion
  68904. */
  68905. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  68906. /**
  68907. * 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)
  68908. * @param axis1 defines the first axis
  68909. * @param axis2 defines the second axis
  68910. * @param axis3 defines the third axis
  68911. * @returns the new quaternion
  68912. */
  68913. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  68914. /**
  68915. * 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
  68916. * @param axis1 defines the first axis
  68917. * @param axis2 defines the second axis
  68918. * @param axis3 defines the third axis
  68919. * @param ref defines the target quaternion
  68920. */
  68921. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  68922. /**
  68923. * Interpolates between two quaternions
  68924. * @param left defines first quaternion
  68925. * @param right defines second quaternion
  68926. * @param amount defines the gradient to use
  68927. * @returns the new interpolated quaternion
  68928. */
  68929. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  68930. /**
  68931. * Interpolates between two quaternions and stores it into a target quaternion
  68932. * @param left defines first quaternion
  68933. * @param right defines second quaternion
  68934. * @param amount defines the gradient to use
  68935. * @param result defines the target quaternion
  68936. */
  68937. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  68938. /**
  68939. * Interpolate between two quaternions using Hermite interpolation
  68940. * @param value1 defines first quaternion
  68941. * @param tangent1 defines the incoming tangent
  68942. * @param value2 defines second quaternion
  68943. * @param tangent2 defines the outgoing tangent
  68944. * @param amount defines the target quaternion
  68945. * @returns the new interpolated quaternion
  68946. */
  68947. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  68948. }
  68949. /**
  68950. * Class used to store matrix data (4x4)
  68951. */
  68952. export class Matrix {
  68953. private static _updateFlagSeed;
  68954. private static _identityReadOnly;
  68955. private _isIdentity;
  68956. private _isIdentityDirty;
  68957. private _isIdentity3x2;
  68958. private _isIdentity3x2Dirty;
  68959. /**
  68960. * Gets the update flag of the matrix which is an unique number for the matrix.
  68961. * It will be incremented every time the matrix data change.
  68962. * You can use it to speed the comparison between two versions of the same matrix.
  68963. */
  68964. updateFlag: number;
  68965. private readonly _m;
  68966. /**
  68967. * Gets the internal data of the matrix
  68968. */
  68969. readonly m: DeepImmutable<Float32Array>;
  68970. /** @hidden */
  68971. _markAsUpdated(): void;
  68972. /** @hidden */
  68973. private _updateIdentityStatus;
  68974. /**
  68975. * Creates an empty matrix (filled with zeros)
  68976. */
  68977. constructor();
  68978. /**
  68979. * Check if the current matrix is identity
  68980. * @returns true is the matrix is the identity matrix
  68981. */
  68982. isIdentity(): boolean;
  68983. /**
  68984. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  68985. * @returns true is the matrix is the identity matrix
  68986. */
  68987. isIdentityAs3x2(): boolean;
  68988. /**
  68989. * Gets the determinant of the matrix
  68990. * @returns the matrix determinant
  68991. */
  68992. determinant(): number;
  68993. /**
  68994. * Returns the matrix as a Float32Array
  68995. * @returns the matrix underlying array
  68996. */
  68997. toArray(): DeepImmutable<Float32Array>;
  68998. /**
  68999. * Returns the matrix as a Float32Array
  69000. * @returns the matrix underlying array.
  69001. */
  69002. asArray(): DeepImmutable<Float32Array>;
  69003. /**
  69004. * Inverts the current matrix in place
  69005. * @returns the current inverted matrix
  69006. */
  69007. invert(): Matrix;
  69008. /**
  69009. * Sets all the matrix elements to zero
  69010. * @returns the current matrix
  69011. */
  69012. reset(): Matrix;
  69013. /**
  69014. * Adds the current matrix with a second one
  69015. * @param other defines the matrix to add
  69016. * @returns a new matrix as the addition of the current matrix and the given one
  69017. */
  69018. add(other: DeepImmutable<Matrix>): Matrix;
  69019. /**
  69020. * Sets the given matrix "result" to the addition of the current matrix and the given one
  69021. * @param other defines the matrix to add
  69022. * @param result defines the target matrix
  69023. * @returns the current matrix
  69024. */
  69025. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69026. /**
  69027. * Adds in place the given matrix to the current matrix
  69028. * @param other defines the second operand
  69029. * @returns the current updated matrix
  69030. */
  69031. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  69032. /**
  69033. * Sets the given matrix to the current inverted Matrix
  69034. * @param other defines the target matrix
  69035. * @returns the unmodified current matrix
  69036. */
  69037. invertToRef(other: Matrix): Matrix;
  69038. /**
  69039. * add a value at the specified position in the current Matrix
  69040. * @param index the index of the value within the matrix. between 0 and 15.
  69041. * @param value the value to be added
  69042. * @returns the current updated matrix
  69043. */
  69044. addAtIndex(index: number, value: number): Matrix;
  69045. /**
  69046. * mutiply the specified position in the current Matrix by a value
  69047. * @param index the index of the value within the matrix. between 0 and 15.
  69048. * @param value the value to be added
  69049. * @returns the current updated matrix
  69050. */
  69051. multiplyAtIndex(index: number, value: number): Matrix;
  69052. /**
  69053. * Inserts the translation vector (using 3 floats) in the current matrix
  69054. * @param x defines the 1st component of the translation
  69055. * @param y defines the 2nd component of the translation
  69056. * @param z defines the 3rd component of the translation
  69057. * @returns the current updated matrix
  69058. */
  69059. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69060. /**
  69061. * Adds the translation vector (using 3 floats) in the current matrix
  69062. * @param x defines the 1st component of the translation
  69063. * @param y defines the 2nd component of the translation
  69064. * @param z defines the 3rd component of the translation
  69065. * @returns the current updated matrix
  69066. */
  69067. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69068. /**
  69069. * Inserts the translation vector in the current matrix
  69070. * @param vector3 defines the translation to insert
  69071. * @returns the current updated matrix
  69072. */
  69073. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  69074. /**
  69075. * Gets the translation value of the current matrix
  69076. * @returns a new Vector3 as the extracted translation from the matrix
  69077. */
  69078. getTranslation(): Vector3;
  69079. /**
  69080. * Fill a Vector3 with the extracted translation from the matrix
  69081. * @param result defines the Vector3 where to store the translation
  69082. * @returns the current matrix
  69083. */
  69084. getTranslationToRef(result: Vector3): Matrix;
  69085. /**
  69086. * Remove rotation and scaling part from the matrix
  69087. * @returns the updated matrix
  69088. */
  69089. removeRotationAndScaling(): Matrix;
  69090. /**
  69091. * Multiply two matrices
  69092. * @param other defines the second operand
  69093. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  69094. */
  69095. multiply(other: DeepImmutable<Matrix>): Matrix;
  69096. /**
  69097. * Copy the current matrix from the given one
  69098. * @param other defines the source matrix
  69099. * @returns the current updated matrix
  69100. */
  69101. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  69102. /**
  69103. * Populates the given array from the starting index with the current matrix values
  69104. * @param array defines the target array
  69105. * @param offset defines the offset in the target array where to start storing values
  69106. * @returns the current matrix
  69107. */
  69108. copyToArray(array: Float32Array, offset?: number): Matrix;
  69109. /**
  69110. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  69111. * @param other defines the second operand
  69112. * @param result defines the matrix where to store the multiplication
  69113. * @returns the current matrix
  69114. */
  69115. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69116. /**
  69117. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  69118. * @param other defines the second operand
  69119. * @param result defines the array where to store the multiplication
  69120. * @param offset defines the offset in the target array where to start storing values
  69121. * @returns the current matrix
  69122. */
  69123. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  69124. /**
  69125. * Check equality between this matrix and a second one
  69126. * @param value defines the second matrix to compare
  69127. * @returns true is the current matrix and the given one values are strictly equal
  69128. */
  69129. equals(value: DeepImmutable<Matrix>): boolean;
  69130. /**
  69131. * Clone the current matrix
  69132. * @returns a new matrix from the current matrix
  69133. */
  69134. clone(): Matrix;
  69135. /**
  69136. * Returns the name of the current matrix class
  69137. * @returns the string "Matrix"
  69138. */
  69139. getClassName(): string;
  69140. /**
  69141. * Gets the hash code of the current matrix
  69142. * @returns the hash code
  69143. */
  69144. getHashCode(): number;
  69145. /**
  69146. * Decomposes the current Matrix into a translation, rotation and scaling components
  69147. * @param scale defines the scale vector3 given as a reference to update
  69148. * @param rotation defines the rotation quaternion given as a reference to update
  69149. * @param translation defines the translation vector3 given as a reference to update
  69150. * @returns true if operation was successful
  69151. */
  69152. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  69153. /**
  69154. * Gets specific row of the matrix
  69155. * @param index defines the number of the row to get
  69156. * @returns the index-th row of the current matrix as a new Vector4
  69157. */
  69158. getRow(index: number): Nullable<Vector4>;
  69159. /**
  69160. * Sets the index-th row of the current matrix to the vector4 values
  69161. * @param index defines the number of the row to set
  69162. * @param row defines the target vector4
  69163. * @returns the updated current matrix
  69164. */
  69165. setRow(index: number, row: Vector4): Matrix;
  69166. /**
  69167. * Compute the transpose of the matrix
  69168. * @returns the new transposed matrix
  69169. */
  69170. transpose(): Matrix;
  69171. /**
  69172. * Compute the transpose of the matrix and store it in a given matrix
  69173. * @param result defines the target matrix
  69174. * @returns the current matrix
  69175. */
  69176. transposeToRef(result: Matrix): Matrix;
  69177. /**
  69178. * Sets the index-th row of the current matrix with the given 4 x float values
  69179. * @param index defines the row index
  69180. * @param x defines the x component to set
  69181. * @param y defines the y component to set
  69182. * @param z defines the z component to set
  69183. * @param w defines the w component to set
  69184. * @returns the updated current matrix
  69185. */
  69186. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  69187. /**
  69188. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69189. * @param scale defines the scale factor
  69190. * @returns a new matrix
  69191. */
  69192. scale(scale: number): Matrix;
  69193. /**
  69194. * Scale the current matrix values by a factor to a given result matrix
  69195. * @param scale defines the scale factor
  69196. * @param result defines the matrix to store the result
  69197. * @returns the current matrix
  69198. */
  69199. scaleToRef(scale: number, result: Matrix): Matrix;
  69200. /**
  69201. * Scale the current matrix values by a factor and add the result to a given matrix
  69202. * @param scale defines the scale factor
  69203. * @param result defines the Matrix to store the result
  69204. * @returns the current matrix
  69205. */
  69206. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69207. /**
  69208. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69209. * @param ref matrix to store the result
  69210. */
  69211. toNormalMatrix(ref: Matrix): void;
  69212. /**
  69213. * Gets only rotation part of the current matrix
  69214. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69215. */
  69216. getRotationMatrix(): Matrix;
  69217. /**
  69218. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69219. * @param result defines the target matrix to store data to
  69220. * @returns the current matrix
  69221. */
  69222. getRotationMatrixToRef(result: Matrix): Matrix;
  69223. /**
  69224. * Toggles model matrix from being right handed to left handed in place and vice versa
  69225. */
  69226. toggleModelMatrixHandInPlace(): void;
  69227. /**
  69228. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69229. */
  69230. toggleProjectionMatrixHandInPlace(): void;
  69231. /**
  69232. * Creates a matrix from an array
  69233. * @param array defines the source array
  69234. * @param offset defines an offset in the source array
  69235. * @returns a new Matrix set from the starting index of the given array
  69236. */
  69237. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69238. /**
  69239. * Copy the content of an array into a given matrix
  69240. * @param array defines the source array
  69241. * @param offset defines an offset in the source array
  69242. * @param result defines the target matrix
  69243. */
  69244. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69245. /**
  69246. * Stores an array into a matrix after having multiplied each component by a given factor
  69247. * @param array defines the source array
  69248. * @param offset defines the offset in the source array
  69249. * @param scale defines the scaling factor
  69250. * @param result defines the target matrix
  69251. */
  69252. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69253. /**
  69254. * Gets an identity matrix that must not be updated
  69255. */
  69256. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69257. /**
  69258. * Stores a list of values (16) inside a given matrix
  69259. * @param initialM11 defines 1st value of 1st row
  69260. * @param initialM12 defines 2nd value of 1st row
  69261. * @param initialM13 defines 3rd value of 1st row
  69262. * @param initialM14 defines 4th value of 1st row
  69263. * @param initialM21 defines 1st value of 2nd row
  69264. * @param initialM22 defines 2nd value of 2nd row
  69265. * @param initialM23 defines 3rd value of 2nd row
  69266. * @param initialM24 defines 4th value of 2nd row
  69267. * @param initialM31 defines 1st value of 3rd row
  69268. * @param initialM32 defines 2nd value of 3rd row
  69269. * @param initialM33 defines 3rd value of 3rd row
  69270. * @param initialM34 defines 4th value of 3rd row
  69271. * @param initialM41 defines 1st value of 4th row
  69272. * @param initialM42 defines 2nd value of 4th row
  69273. * @param initialM43 defines 3rd value of 4th row
  69274. * @param initialM44 defines 4th value of 4th row
  69275. * @param result defines the target matrix
  69276. */
  69277. 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;
  69278. /**
  69279. * Creates new matrix from a list of values (16)
  69280. * @param initialM11 defines 1st value of 1st row
  69281. * @param initialM12 defines 2nd value of 1st row
  69282. * @param initialM13 defines 3rd value of 1st row
  69283. * @param initialM14 defines 4th value of 1st row
  69284. * @param initialM21 defines 1st value of 2nd row
  69285. * @param initialM22 defines 2nd value of 2nd row
  69286. * @param initialM23 defines 3rd value of 2nd row
  69287. * @param initialM24 defines 4th value of 2nd row
  69288. * @param initialM31 defines 1st value of 3rd row
  69289. * @param initialM32 defines 2nd value of 3rd row
  69290. * @param initialM33 defines 3rd value of 3rd row
  69291. * @param initialM34 defines 4th value of 3rd row
  69292. * @param initialM41 defines 1st value of 4th row
  69293. * @param initialM42 defines 2nd value of 4th row
  69294. * @param initialM43 defines 3rd value of 4th row
  69295. * @param initialM44 defines 4th value of 4th row
  69296. * @returns the new matrix
  69297. */
  69298. 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;
  69299. /**
  69300. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69301. * @param scale defines the scale vector3
  69302. * @param rotation defines the rotation quaternion
  69303. * @param translation defines the translation vector3
  69304. * @returns a new matrix
  69305. */
  69306. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69307. /**
  69308. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69309. * @param scale defines the scale vector3
  69310. * @param rotation defines the rotation quaternion
  69311. * @param translation defines the translation vector3
  69312. * @param result defines the target matrix
  69313. */
  69314. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69315. /**
  69316. * Creates a new identity matrix
  69317. * @returns a new identity matrix
  69318. */
  69319. static Identity(): Matrix;
  69320. /**
  69321. * Creates a new identity matrix and stores the result in a given matrix
  69322. * @param result defines the target matrix
  69323. */
  69324. static IdentityToRef(result: Matrix): void;
  69325. /**
  69326. * Creates a new zero matrix
  69327. * @returns a new zero matrix
  69328. */
  69329. static Zero(): Matrix;
  69330. /**
  69331. * Creates a new rotation matrix for "angle" radians around the X axis
  69332. * @param angle defines the angle (in radians) to use
  69333. * @return the new matrix
  69334. */
  69335. static RotationX(angle: number): Matrix;
  69336. /**
  69337. * Creates a new matrix as the invert of a given matrix
  69338. * @param source defines the source matrix
  69339. * @returns the new matrix
  69340. */
  69341. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69342. /**
  69343. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69344. * @param angle defines the angle (in radians) to use
  69345. * @param result defines the target matrix
  69346. */
  69347. static RotationXToRef(angle: number, result: Matrix): void;
  69348. /**
  69349. * Creates a new rotation matrix for "angle" radians around the Y axis
  69350. * @param angle defines the angle (in radians) to use
  69351. * @return the new matrix
  69352. */
  69353. static RotationY(angle: number): Matrix;
  69354. /**
  69355. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69356. * @param angle defines the angle (in radians) to use
  69357. * @param result defines the target matrix
  69358. */
  69359. static RotationYToRef(angle: number, result: Matrix): void;
  69360. /**
  69361. * Creates a new rotation matrix for "angle" radians around the Z axis
  69362. * @param angle defines the angle (in radians) to use
  69363. * @return the new matrix
  69364. */
  69365. static RotationZ(angle: number): Matrix;
  69366. /**
  69367. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69368. * @param angle defines the angle (in radians) to use
  69369. * @param result defines the target matrix
  69370. */
  69371. static RotationZToRef(angle: number, result: Matrix): void;
  69372. /**
  69373. * Creates a new rotation matrix for "angle" radians around the given axis
  69374. * @param axis defines the axis to use
  69375. * @param angle defines the angle (in radians) to use
  69376. * @return the new matrix
  69377. */
  69378. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69379. /**
  69380. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69381. * @param axis defines the axis to use
  69382. * @param angle defines the angle (in radians) to use
  69383. * @param result defines the target matrix
  69384. */
  69385. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69386. /**
  69387. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69388. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69389. * @param from defines the vector to align
  69390. * @param to defines the vector to align to
  69391. * @param result defines the target matrix
  69392. */
  69393. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69394. /**
  69395. * Creates a rotation matrix
  69396. * @param yaw defines the yaw angle in radians (Y axis)
  69397. * @param pitch defines the pitch angle in radians (X axis)
  69398. * @param roll defines the roll angle in radians (X axis)
  69399. * @returns the new rotation matrix
  69400. */
  69401. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  69402. /**
  69403. * Creates a rotation matrix and stores it in a given matrix
  69404. * @param yaw defines the yaw angle in radians (Y axis)
  69405. * @param pitch defines the pitch angle in radians (X axis)
  69406. * @param roll defines the roll angle in radians (X axis)
  69407. * @param result defines the target matrix
  69408. */
  69409. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  69410. /**
  69411. * Creates a scaling matrix
  69412. * @param x defines the scale factor on X axis
  69413. * @param y defines the scale factor on Y axis
  69414. * @param z defines the scale factor on Z axis
  69415. * @returns the new matrix
  69416. */
  69417. static Scaling(x: number, y: number, z: number): Matrix;
  69418. /**
  69419. * Creates a scaling matrix and stores it in a given matrix
  69420. * @param x defines the scale factor on X axis
  69421. * @param y defines the scale factor on Y axis
  69422. * @param z defines the scale factor on Z axis
  69423. * @param result defines the target matrix
  69424. */
  69425. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  69426. /**
  69427. * Creates a translation matrix
  69428. * @param x defines the translation on X axis
  69429. * @param y defines the translation on Y axis
  69430. * @param z defines the translationon Z axis
  69431. * @returns the new matrix
  69432. */
  69433. static Translation(x: number, y: number, z: number): Matrix;
  69434. /**
  69435. * Creates a translation matrix and stores it in a given matrix
  69436. * @param x defines the translation on X axis
  69437. * @param y defines the translation on Y axis
  69438. * @param z defines the translationon Z axis
  69439. * @param result defines the target matrix
  69440. */
  69441. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  69442. /**
  69443. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69444. * @param startValue defines the start value
  69445. * @param endValue defines the end value
  69446. * @param gradient defines the gradient factor
  69447. * @returns the new matrix
  69448. */
  69449. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69450. /**
  69451. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69452. * @param startValue defines the start value
  69453. * @param endValue defines the end value
  69454. * @param gradient defines the gradient factor
  69455. * @param result defines the Matrix object where to store data
  69456. */
  69457. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69458. /**
  69459. * Builds a new matrix whose values are computed by:
  69460. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69461. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69462. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69463. * @param startValue defines the first matrix
  69464. * @param endValue defines the second matrix
  69465. * @param gradient defines the gradient between the two matrices
  69466. * @returns the new matrix
  69467. */
  69468. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69469. /**
  69470. * Update a matrix to values which are computed by:
  69471. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69472. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69473. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69474. * @param startValue defines the first matrix
  69475. * @param endValue defines the second matrix
  69476. * @param gradient defines the gradient between the two matrices
  69477. * @param result defines the target matrix
  69478. */
  69479. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69480. /**
  69481. * 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"
  69482. * This function works in left handed mode
  69483. * @param eye defines the final position of the entity
  69484. * @param target defines where the entity should look at
  69485. * @param up defines the up vector for the entity
  69486. * @returns the new matrix
  69487. */
  69488. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69489. /**
  69490. * 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".
  69491. * This function works in left handed mode
  69492. * @param eye defines the final position of the entity
  69493. * @param target defines where the entity should look at
  69494. * @param up defines the up vector for the entity
  69495. * @param result defines the target matrix
  69496. */
  69497. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69498. /**
  69499. * 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"
  69500. * This function works in right handed mode
  69501. * @param eye defines the final position of the entity
  69502. * @param target defines where the entity should look at
  69503. * @param up defines the up vector for the entity
  69504. * @returns the new matrix
  69505. */
  69506. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69507. /**
  69508. * 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".
  69509. * This function works in right handed mode
  69510. * @param eye defines the final position of the entity
  69511. * @param target defines where the entity should look at
  69512. * @param up defines the up vector for the entity
  69513. * @param result defines the target matrix
  69514. */
  69515. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69516. /**
  69517. * Create a left-handed orthographic projection matrix
  69518. * @param width defines the viewport width
  69519. * @param height defines the viewport height
  69520. * @param znear defines the near clip plane
  69521. * @param zfar defines the far clip plane
  69522. * @returns a new matrix as a left-handed orthographic projection matrix
  69523. */
  69524. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69525. /**
  69526. * Store a left-handed orthographic projection to a given matrix
  69527. * @param width defines the viewport width
  69528. * @param height defines the viewport height
  69529. * @param znear defines the near clip plane
  69530. * @param zfar defines the far clip plane
  69531. * @param result defines the target matrix
  69532. */
  69533. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  69534. /**
  69535. * Create a left-handed orthographic projection matrix
  69536. * @param left defines the viewport left coordinate
  69537. * @param right defines the viewport right coordinate
  69538. * @param bottom defines the viewport bottom coordinate
  69539. * @param top defines the viewport top coordinate
  69540. * @param znear defines the near clip plane
  69541. * @param zfar defines the far clip plane
  69542. * @returns a new matrix as a left-handed orthographic projection matrix
  69543. */
  69544. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69545. /**
  69546. * Stores a left-handed orthographic projection into a given matrix
  69547. * @param left defines the viewport left coordinate
  69548. * @param right defines the viewport right coordinate
  69549. * @param bottom defines the viewport bottom coordinate
  69550. * @param top defines the viewport top coordinate
  69551. * @param znear defines the near clip plane
  69552. * @param zfar defines the far clip plane
  69553. * @param result defines the target matrix
  69554. */
  69555. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69556. /**
  69557. * Creates a right-handed orthographic projection matrix
  69558. * @param left defines the viewport left coordinate
  69559. * @param right defines the viewport right coordinate
  69560. * @param bottom defines the viewport bottom coordinate
  69561. * @param top defines the viewport top coordinate
  69562. * @param znear defines the near clip plane
  69563. * @param zfar defines the far clip plane
  69564. * @returns a new matrix as a right-handed orthographic projection matrix
  69565. */
  69566. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69567. /**
  69568. * Stores a right-handed orthographic projection into a given matrix
  69569. * @param left defines the viewport left coordinate
  69570. * @param right defines the viewport right coordinate
  69571. * @param bottom defines the viewport bottom coordinate
  69572. * @param top defines the viewport top coordinate
  69573. * @param znear defines the near clip plane
  69574. * @param zfar defines the far clip plane
  69575. * @param result defines the target matrix
  69576. */
  69577. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69578. /**
  69579. * Creates a left-handed perspective projection matrix
  69580. * @param width defines the viewport width
  69581. * @param height defines the viewport height
  69582. * @param znear defines the near clip plane
  69583. * @param zfar defines the far clip plane
  69584. * @returns a new matrix as a left-handed perspective projection matrix
  69585. */
  69586. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69587. /**
  69588. * Creates a left-handed perspective projection matrix
  69589. * @param fov defines the horizontal field of view
  69590. * @param aspect defines the aspect ratio
  69591. * @param znear defines the near clip plane
  69592. * @param zfar defines the far clip plane
  69593. * @returns a new matrix as a left-handed perspective projection matrix
  69594. */
  69595. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69596. /**
  69597. * Stores a left-handed perspective projection into a given matrix
  69598. * @param fov defines the horizontal field of view
  69599. * @param aspect defines the aspect ratio
  69600. * @param znear defines the near clip plane
  69601. * @param zfar defines the far clip plane
  69602. * @param result defines the target matrix
  69603. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69604. */
  69605. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69606. /**
  69607. * Creates a right-handed perspective projection matrix
  69608. * @param fov defines the horizontal field of view
  69609. * @param aspect defines the aspect ratio
  69610. * @param znear defines the near clip plane
  69611. * @param zfar defines the far clip plane
  69612. * @returns a new matrix as a right-handed perspective projection matrix
  69613. */
  69614. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69615. /**
  69616. * Stores a right-handed perspective projection into a given matrix
  69617. * @param fov defines the horizontal field of view
  69618. * @param aspect defines the aspect ratio
  69619. * @param znear defines the near clip plane
  69620. * @param zfar defines the far clip plane
  69621. * @param result defines the target matrix
  69622. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69623. */
  69624. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69625. /**
  69626. * Stores a perspective projection for WebVR info a given matrix
  69627. * @param fov defines the field of view
  69628. * @param znear defines the near clip plane
  69629. * @param zfar defines the far clip plane
  69630. * @param result defines the target matrix
  69631. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  69632. */
  69633. static PerspectiveFovWebVRToRef(fov: {
  69634. upDegrees: number;
  69635. downDegrees: number;
  69636. leftDegrees: number;
  69637. rightDegrees: number;
  69638. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  69639. /**
  69640. * Computes a complete transformation matrix
  69641. * @param viewport defines the viewport to use
  69642. * @param world defines the world matrix
  69643. * @param view defines the view matrix
  69644. * @param projection defines the projection matrix
  69645. * @param zmin defines the near clip plane
  69646. * @param zmax defines the far clip plane
  69647. * @returns the transformation matrix
  69648. */
  69649. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  69650. /**
  69651. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  69652. * @param matrix defines the matrix to use
  69653. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  69654. */
  69655. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  69656. /**
  69657. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  69658. * @param matrix defines the matrix to use
  69659. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  69660. */
  69661. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  69662. /**
  69663. * Compute the transpose of a given matrix
  69664. * @param matrix defines the matrix to transpose
  69665. * @returns the new matrix
  69666. */
  69667. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  69668. /**
  69669. * Compute the transpose of a matrix and store it in a target matrix
  69670. * @param matrix defines the matrix to transpose
  69671. * @param result defines the target matrix
  69672. */
  69673. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  69674. /**
  69675. * Computes a reflection matrix from a plane
  69676. * @param plane defines the reflection plane
  69677. * @returns a new matrix
  69678. */
  69679. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  69680. /**
  69681. * Computes a reflection matrix from a plane
  69682. * @param plane defines the reflection plane
  69683. * @param result defines the target matrix
  69684. */
  69685. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  69686. /**
  69687. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  69688. * @param xaxis defines the value of the 1st axis
  69689. * @param yaxis defines the value of the 2nd axis
  69690. * @param zaxis defines the value of the 3rd axis
  69691. * @param result defines the target matrix
  69692. */
  69693. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  69694. /**
  69695. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  69696. * @param quat defines the quaternion to use
  69697. * @param result defines the target matrix
  69698. */
  69699. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  69700. }
  69701. /**
  69702. * @hidden
  69703. */
  69704. export class TmpVectors {
  69705. static Vector2: Vector2[];
  69706. static Vector3: Vector3[];
  69707. static Vector4: Vector4[];
  69708. static Quaternion: Quaternion[];
  69709. static Matrix: Matrix[];
  69710. }
  69711. }
  69712. declare module BABYLON {
  69713. /** Defines the cross module used constants to avoid circular dependncies */
  69714. export class Constants {
  69715. /** Defines that alpha blending is disabled */
  69716. static readonly ALPHA_DISABLE: number;
  69717. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69718. static readonly ALPHA_ADD: number;
  69719. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69720. static readonly ALPHA_COMBINE: number;
  69721. /** Defines that alpha blending to DEST - SRC * DEST */
  69722. static readonly ALPHA_SUBTRACT: number;
  69723. /** Defines that alpha blending to SRC * DEST */
  69724. static readonly ALPHA_MULTIPLY: number;
  69725. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69726. static readonly ALPHA_MAXIMIZED: number;
  69727. /** Defines that alpha blending to SRC + DEST */
  69728. static readonly ALPHA_ONEONE: number;
  69729. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69730. static readonly ALPHA_PREMULTIPLIED: number;
  69731. /**
  69732. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69733. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69734. */
  69735. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69736. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69737. static readonly ALPHA_INTERPOLATE: number;
  69738. /**
  69739. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69740. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69741. */
  69742. static readonly ALPHA_SCREENMODE: number;
  69743. /**
  69744. * Defines that alpha blending to SRC + DST
  69745. * Alpha will be set to SRC ALPHA + DST ALPHA
  69746. */
  69747. static readonly ALPHA_ONEONE_ONEONE: number;
  69748. /**
  69749. * Defines that alpha blending to SRC * DST ALPHA + DST
  69750. * Alpha will be set to 0
  69751. */
  69752. static readonly ALPHA_ALPHATOCOLOR: number;
  69753. /**
  69754. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  69755. */
  69756. static readonly ALPHA_REVERSEONEMINUS: number;
  69757. /**
  69758. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  69759. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  69760. */
  69761. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  69762. /**
  69763. * Defines that alpha blending to SRC + DST
  69764. * Alpha will be set to SRC ALPHA
  69765. */
  69766. static readonly ALPHA_ONEONE_ONEZERO: number;
  69767. /** Defines that alpha blending equation a SUM */
  69768. static readonly ALPHA_EQUATION_ADD: number;
  69769. /** Defines that alpha blending equation a SUBSTRACTION */
  69770. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  69771. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  69772. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  69773. /** Defines that alpha blending equation a MAX operation */
  69774. static readonly ALPHA_EQUATION_MAX: number;
  69775. /** Defines that alpha blending equation a MIN operation */
  69776. static readonly ALPHA_EQUATION_MIN: number;
  69777. /**
  69778. * Defines that alpha blending equation a DARKEN operation:
  69779. * It takes the min of the src and sums the alpha channels.
  69780. */
  69781. static readonly ALPHA_EQUATION_DARKEN: number;
  69782. /** Defines that the ressource is not delayed*/
  69783. static readonly DELAYLOADSTATE_NONE: number;
  69784. /** Defines that the ressource was successfully delay loaded */
  69785. static readonly DELAYLOADSTATE_LOADED: number;
  69786. /** Defines that the ressource is currently delay loading */
  69787. static readonly DELAYLOADSTATE_LOADING: number;
  69788. /** Defines that the ressource is delayed and has not started loading */
  69789. static readonly DELAYLOADSTATE_NOTLOADED: number;
  69790. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  69791. static readonly NEVER: number;
  69792. /** 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 */
  69793. static readonly ALWAYS: number;
  69794. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69795. static readonly LESS: number;
  69796. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69797. static readonly EQUAL: number;
  69798. /** 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 */
  69799. static readonly LEQUAL: number;
  69800. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69801. static readonly GREATER: number;
  69802. /** 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 */
  69803. static readonly GEQUAL: number;
  69804. /** 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 */
  69805. static readonly NOTEQUAL: number;
  69806. /** Passed to stencilOperation to specify that stencil value must be kept */
  69807. static readonly KEEP: number;
  69808. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69809. static readonly REPLACE: number;
  69810. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69811. static readonly INCR: number;
  69812. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69813. static readonly DECR: number;
  69814. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69815. static readonly INVERT: number;
  69816. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69817. static readonly INCR_WRAP: number;
  69818. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69819. static readonly DECR_WRAP: number;
  69820. /** Texture is not repeating outside of 0..1 UVs */
  69821. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69822. /** Texture is repeating outside of 0..1 UVs */
  69823. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69824. /** Texture is repeating and mirrored */
  69825. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69826. /** ALPHA */
  69827. static readonly TEXTUREFORMAT_ALPHA: number;
  69828. /** LUMINANCE */
  69829. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69830. /** LUMINANCE_ALPHA */
  69831. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69832. /** RGB */
  69833. static readonly TEXTUREFORMAT_RGB: number;
  69834. /** RGBA */
  69835. static readonly TEXTUREFORMAT_RGBA: number;
  69836. /** RED */
  69837. static readonly TEXTUREFORMAT_RED: number;
  69838. /** RED (2nd reference) */
  69839. static readonly TEXTUREFORMAT_R: number;
  69840. /** RG */
  69841. static readonly TEXTUREFORMAT_RG: number;
  69842. /** RED_INTEGER */
  69843. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69844. /** RED_INTEGER (2nd reference) */
  69845. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69846. /** RG_INTEGER */
  69847. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69848. /** RGB_INTEGER */
  69849. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69850. /** RGBA_INTEGER */
  69851. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69852. /** UNSIGNED_BYTE */
  69853. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69854. /** UNSIGNED_BYTE (2nd reference) */
  69855. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69856. /** FLOAT */
  69857. static readonly TEXTURETYPE_FLOAT: number;
  69858. /** HALF_FLOAT */
  69859. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69860. /** BYTE */
  69861. static readonly TEXTURETYPE_BYTE: number;
  69862. /** SHORT */
  69863. static readonly TEXTURETYPE_SHORT: number;
  69864. /** UNSIGNED_SHORT */
  69865. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69866. /** INT */
  69867. static readonly TEXTURETYPE_INT: number;
  69868. /** UNSIGNED_INT */
  69869. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69870. /** UNSIGNED_SHORT_4_4_4_4 */
  69871. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69872. /** UNSIGNED_SHORT_5_5_5_1 */
  69873. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69874. /** UNSIGNED_SHORT_5_6_5 */
  69875. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69876. /** UNSIGNED_INT_2_10_10_10_REV */
  69877. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69878. /** UNSIGNED_INT_24_8 */
  69879. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69880. /** UNSIGNED_INT_10F_11F_11F_REV */
  69881. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69882. /** UNSIGNED_INT_5_9_9_9_REV */
  69883. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69884. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69885. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69886. /** nearest is mag = nearest and min = nearest and mip = linear */
  69887. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69888. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69889. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69890. /** Trilinear is mag = linear and min = linear and mip = linear */
  69891. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69892. /** nearest is mag = nearest and min = nearest and mip = linear */
  69893. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69894. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69895. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69896. /** Trilinear is mag = linear and min = linear and mip = linear */
  69897. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69898. /** mag = nearest and min = nearest and mip = nearest */
  69899. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  69900. /** mag = nearest and min = linear and mip = nearest */
  69901. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  69902. /** mag = nearest and min = linear and mip = linear */
  69903. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  69904. /** mag = nearest and min = linear and mip = none */
  69905. static readonly TEXTURE_NEAREST_LINEAR: number;
  69906. /** mag = nearest and min = nearest and mip = none */
  69907. static readonly TEXTURE_NEAREST_NEAREST: number;
  69908. /** mag = linear and min = nearest and mip = nearest */
  69909. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  69910. /** mag = linear and min = nearest and mip = linear */
  69911. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  69912. /** mag = linear and min = linear and mip = none */
  69913. static readonly TEXTURE_LINEAR_LINEAR: number;
  69914. /** mag = linear and min = nearest and mip = none */
  69915. static readonly TEXTURE_LINEAR_NEAREST: number;
  69916. /** Explicit coordinates mode */
  69917. static readonly TEXTURE_EXPLICIT_MODE: number;
  69918. /** Spherical coordinates mode */
  69919. static readonly TEXTURE_SPHERICAL_MODE: number;
  69920. /** Planar coordinates mode */
  69921. static readonly TEXTURE_PLANAR_MODE: number;
  69922. /** Cubic coordinates mode */
  69923. static readonly TEXTURE_CUBIC_MODE: number;
  69924. /** Projection coordinates mode */
  69925. static readonly TEXTURE_PROJECTION_MODE: number;
  69926. /** Skybox coordinates mode */
  69927. static readonly TEXTURE_SKYBOX_MODE: number;
  69928. /** Inverse Cubic coordinates mode */
  69929. static readonly TEXTURE_INVCUBIC_MODE: number;
  69930. /** Equirectangular coordinates mode */
  69931. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  69932. /** Equirectangular Fixed coordinates mode */
  69933. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  69934. /** Equirectangular Fixed Mirrored coordinates mode */
  69935. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  69936. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  69937. static readonly SCALEMODE_FLOOR: number;
  69938. /** Defines that texture rescaling will look for the nearest power of 2 size */
  69939. static readonly SCALEMODE_NEAREST: number;
  69940. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  69941. static readonly SCALEMODE_CEILING: number;
  69942. /**
  69943. * The dirty texture flag value
  69944. */
  69945. static readonly MATERIAL_TextureDirtyFlag: number;
  69946. /**
  69947. * The dirty light flag value
  69948. */
  69949. static readonly MATERIAL_LightDirtyFlag: number;
  69950. /**
  69951. * The dirty fresnel flag value
  69952. */
  69953. static readonly MATERIAL_FresnelDirtyFlag: number;
  69954. /**
  69955. * The dirty attribute flag value
  69956. */
  69957. static readonly MATERIAL_AttributesDirtyFlag: number;
  69958. /**
  69959. * The dirty misc flag value
  69960. */
  69961. static readonly MATERIAL_MiscDirtyFlag: number;
  69962. /**
  69963. * The all dirty flag value
  69964. */
  69965. static readonly MATERIAL_AllDirtyFlag: number;
  69966. /**
  69967. * Returns the triangle fill mode
  69968. */
  69969. static readonly MATERIAL_TriangleFillMode: number;
  69970. /**
  69971. * Returns the wireframe mode
  69972. */
  69973. static readonly MATERIAL_WireFrameFillMode: number;
  69974. /**
  69975. * Returns the point fill mode
  69976. */
  69977. static readonly MATERIAL_PointFillMode: number;
  69978. /**
  69979. * Returns the point list draw mode
  69980. */
  69981. static readonly MATERIAL_PointListDrawMode: number;
  69982. /**
  69983. * Returns the line list draw mode
  69984. */
  69985. static readonly MATERIAL_LineListDrawMode: number;
  69986. /**
  69987. * Returns the line loop draw mode
  69988. */
  69989. static readonly MATERIAL_LineLoopDrawMode: number;
  69990. /**
  69991. * Returns the line strip draw mode
  69992. */
  69993. static readonly MATERIAL_LineStripDrawMode: number;
  69994. /**
  69995. * Returns the triangle strip draw mode
  69996. */
  69997. static readonly MATERIAL_TriangleStripDrawMode: number;
  69998. /**
  69999. * Returns the triangle fan draw mode
  70000. */
  70001. static readonly MATERIAL_TriangleFanDrawMode: number;
  70002. /**
  70003. * Stores the clock-wise side orientation
  70004. */
  70005. static readonly MATERIAL_ClockWiseSideOrientation: number;
  70006. /**
  70007. * Stores the counter clock-wise side orientation
  70008. */
  70009. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  70010. /**
  70011. * Nothing
  70012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70013. */
  70014. static readonly ACTION_NothingTrigger: number;
  70015. /**
  70016. * On pick
  70017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70018. */
  70019. static readonly ACTION_OnPickTrigger: number;
  70020. /**
  70021. * On left pick
  70022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70023. */
  70024. static readonly ACTION_OnLeftPickTrigger: number;
  70025. /**
  70026. * On right pick
  70027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70028. */
  70029. static readonly ACTION_OnRightPickTrigger: number;
  70030. /**
  70031. * On center pick
  70032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70033. */
  70034. static readonly ACTION_OnCenterPickTrigger: number;
  70035. /**
  70036. * On pick down
  70037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70038. */
  70039. static readonly ACTION_OnPickDownTrigger: number;
  70040. /**
  70041. * On double pick
  70042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70043. */
  70044. static readonly ACTION_OnDoublePickTrigger: number;
  70045. /**
  70046. * On pick up
  70047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70048. */
  70049. static readonly ACTION_OnPickUpTrigger: number;
  70050. /**
  70051. * On pick out.
  70052. * This trigger will only be raised if you also declared a OnPickDown
  70053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70054. */
  70055. static readonly ACTION_OnPickOutTrigger: number;
  70056. /**
  70057. * On long press
  70058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70059. */
  70060. static readonly ACTION_OnLongPressTrigger: number;
  70061. /**
  70062. * On pointer over
  70063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70064. */
  70065. static readonly ACTION_OnPointerOverTrigger: number;
  70066. /**
  70067. * On pointer out
  70068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70069. */
  70070. static readonly ACTION_OnPointerOutTrigger: number;
  70071. /**
  70072. * On every frame
  70073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70074. */
  70075. static readonly ACTION_OnEveryFrameTrigger: number;
  70076. /**
  70077. * On intersection enter
  70078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70079. */
  70080. static readonly ACTION_OnIntersectionEnterTrigger: number;
  70081. /**
  70082. * On intersection exit
  70083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70084. */
  70085. static readonly ACTION_OnIntersectionExitTrigger: number;
  70086. /**
  70087. * On key down
  70088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70089. */
  70090. static readonly ACTION_OnKeyDownTrigger: number;
  70091. /**
  70092. * On key up
  70093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70094. */
  70095. static readonly ACTION_OnKeyUpTrigger: number;
  70096. /**
  70097. * Billboard mode will only apply to Y axis
  70098. */
  70099. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  70100. /**
  70101. * Billboard mode will apply to all axes
  70102. */
  70103. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  70104. /**
  70105. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  70106. */
  70107. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  70108. /**
  70109. * Gets or sets base Assets URL
  70110. */
  70111. static PARTICLES_BaseAssetsUrl: string;
  70112. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  70113. * Test order :
  70114. * Is the bounding sphere outside the frustum ?
  70115. * If not, are the bounding box vertices outside the frustum ?
  70116. * It not, then the cullable object is in the frustum.
  70117. */
  70118. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  70119. /** Culling strategy : Bounding Sphere Only.
  70120. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  70121. * It's also less accurate than the standard because some not visible objects can still be selected.
  70122. * Test : is the bounding sphere outside the frustum ?
  70123. * If not, then the cullable object is in the frustum.
  70124. */
  70125. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  70126. /** Culling strategy : Optimistic Inclusion.
  70127. * This in an inclusion test first, then the standard exclusion test.
  70128. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  70129. * 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.
  70130. * Anyway, it's as accurate as the standard strategy.
  70131. * Test :
  70132. * Is the cullable object bounding sphere center in the frustum ?
  70133. * If not, apply the default culling strategy.
  70134. */
  70135. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  70136. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  70137. * This in an inclusion test first, then the bounding sphere only exclusion test.
  70138. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  70139. * 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.
  70140. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  70141. * Test :
  70142. * Is the cullable object bounding sphere center in the frustum ?
  70143. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  70144. */
  70145. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  70146. /**
  70147. * No logging while loading
  70148. */
  70149. static readonly SCENELOADER_NO_LOGGING: number;
  70150. /**
  70151. * Minimal logging while loading
  70152. */
  70153. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  70154. /**
  70155. * Summary logging while loading
  70156. */
  70157. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  70158. /**
  70159. * Detailled logging while loading
  70160. */
  70161. static readonly SCENELOADER_DETAILED_LOGGING: number;
  70162. }
  70163. }
  70164. declare module BABYLON {
  70165. /**
  70166. * Class used to store and describe the pipeline context associated with an effect
  70167. */
  70168. export interface IPipelineContext {
  70169. /**
  70170. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  70171. */
  70172. isAsync: boolean;
  70173. /**
  70174. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  70175. */
  70176. isReady: boolean;
  70177. /** @hidden */
  70178. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  70179. }
  70180. }
  70181. declare module BABYLON {
  70182. /** @hidden */
  70183. export interface IShaderProcessor {
  70184. attributeProcessor?: (attribute: string) => string;
  70185. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  70186. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  70187. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  70188. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  70189. lineProcessor?: (line: string, isFragment: boolean) => string;
  70190. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70191. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70192. }
  70193. }
  70194. declare module BABYLON {
  70195. /** @hidden */
  70196. export interface ProcessingOptions {
  70197. defines: string[];
  70198. indexParameters: any;
  70199. isFragment: boolean;
  70200. shouldUseHighPrecisionShader: boolean;
  70201. supportsUniformBuffers: boolean;
  70202. shadersRepository: string;
  70203. includesShadersStore: {
  70204. [key: string]: string;
  70205. };
  70206. processor?: IShaderProcessor;
  70207. version: string;
  70208. platformName: string;
  70209. lookForClosingBracketForUniformBuffer?: boolean;
  70210. }
  70211. }
  70212. declare module BABYLON {
  70213. /**
  70214. * Helper to manipulate strings
  70215. */
  70216. export class StringTools {
  70217. /**
  70218. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  70219. * @param str Source string
  70220. * @param suffix Suffix to search for in the source string
  70221. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70222. */
  70223. static EndsWith(str: string, suffix: string): boolean;
  70224. /**
  70225. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  70226. * @param str Source string
  70227. * @param suffix Suffix to search for in the source string
  70228. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70229. */
  70230. static StartsWith(str: string, suffix: string): boolean;
  70231. }
  70232. }
  70233. declare module BABYLON {
  70234. /** @hidden */
  70235. export class ShaderCodeNode {
  70236. line: string;
  70237. children: ShaderCodeNode[];
  70238. additionalDefineKey?: string;
  70239. additionalDefineValue?: string;
  70240. isValid(preprocessors: {
  70241. [key: string]: string;
  70242. }): boolean;
  70243. process(preprocessors: {
  70244. [key: string]: string;
  70245. }, options: ProcessingOptions): string;
  70246. }
  70247. }
  70248. declare module BABYLON {
  70249. /** @hidden */
  70250. export class ShaderCodeCursor {
  70251. private _lines;
  70252. lineIndex: number;
  70253. readonly currentLine: string;
  70254. readonly canRead: boolean;
  70255. lines: string[];
  70256. }
  70257. }
  70258. declare module BABYLON {
  70259. /** @hidden */
  70260. export class ShaderCodeConditionNode extends ShaderCodeNode {
  70261. process(preprocessors: {
  70262. [key: string]: string;
  70263. }, options: ProcessingOptions): string;
  70264. }
  70265. }
  70266. declare module BABYLON {
  70267. /** @hidden */
  70268. export class ShaderDefineExpression {
  70269. isTrue(preprocessors: {
  70270. [key: string]: string;
  70271. }): boolean;
  70272. }
  70273. }
  70274. declare module BABYLON {
  70275. /** @hidden */
  70276. export class ShaderCodeTestNode extends ShaderCodeNode {
  70277. testExpression: ShaderDefineExpression;
  70278. isValid(preprocessors: {
  70279. [key: string]: string;
  70280. }): boolean;
  70281. }
  70282. }
  70283. declare module BABYLON {
  70284. /** @hidden */
  70285. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  70286. define: string;
  70287. not: boolean;
  70288. constructor(define: string, not?: boolean);
  70289. isTrue(preprocessors: {
  70290. [key: string]: string;
  70291. }): boolean;
  70292. }
  70293. }
  70294. declare module BABYLON {
  70295. /** @hidden */
  70296. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  70297. leftOperand: ShaderDefineExpression;
  70298. rightOperand: ShaderDefineExpression;
  70299. isTrue(preprocessors: {
  70300. [key: string]: string;
  70301. }): boolean;
  70302. }
  70303. }
  70304. declare module BABYLON {
  70305. /** @hidden */
  70306. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  70307. leftOperand: ShaderDefineExpression;
  70308. rightOperand: ShaderDefineExpression;
  70309. isTrue(preprocessors: {
  70310. [key: string]: string;
  70311. }): boolean;
  70312. }
  70313. }
  70314. declare module BABYLON {
  70315. /** @hidden */
  70316. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  70317. define: string;
  70318. operand: string;
  70319. testValue: string;
  70320. constructor(define: string, operand: string, testValue: string);
  70321. isTrue(preprocessors: {
  70322. [key: string]: string;
  70323. }): boolean;
  70324. }
  70325. }
  70326. declare module BABYLON {
  70327. /**
  70328. * @ignore
  70329. * Application error to support additional information when loading a file
  70330. */
  70331. export class LoadFileError extends Error {
  70332. /** defines the optional web request */
  70333. request?: WebRequest | undefined;
  70334. private static _setPrototypeOf;
  70335. /**
  70336. * Creates a new LoadFileError
  70337. * @param message defines the message of the error
  70338. * @param request defines the optional web request
  70339. */
  70340. constructor(message: string,
  70341. /** defines the optional web request */
  70342. request?: WebRequest | undefined);
  70343. }
  70344. }
  70345. declare module BABYLON {
  70346. /**
  70347. * Class used to enable access to offline support
  70348. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70349. */
  70350. export interface IOfflineProvider {
  70351. /**
  70352. * Gets a boolean indicating if scene must be saved in the database
  70353. */
  70354. enableSceneOffline: boolean;
  70355. /**
  70356. * Gets a boolean indicating if textures must be saved in the database
  70357. */
  70358. enableTexturesOffline: boolean;
  70359. /**
  70360. * Open the offline support and make it available
  70361. * @param successCallback defines the callback to call on success
  70362. * @param errorCallback defines the callback to call on error
  70363. */
  70364. open(successCallback: () => void, errorCallback: () => void): void;
  70365. /**
  70366. * Loads an image from the offline support
  70367. * @param url defines the url to load from
  70368. * @param image defines the target DOM image
  70369. */
  70370. loadImage(url: string, image: HTMLImageElement): void;
  70371. /**
  70372. * Loads a file from offline support
  70373. * @param url defines the URL to load from
  70374. * @param sceneLoaded defines a callback to call on success
  70375. * @param progressCallBack defines a callback to call when progress changed
  70376. * @param errorCallback defines a callback to call on error
  70377. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70378. */
  70379. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70380. }
  70381. }
  70382. declare module BABYLON {
  70383. /**
  70384. * Class used to help managing file picking and drag'n'drop
  70385. * File Storage
  70386. */
  70387. export class FilesInputStore {
  70388. /**
  70389. * List of files ready to be loaded
  70390. */
  70391. static FilesToLoad: {
  70392. [key: string]: File;
  70393. };
  70394. }
  70395. }
  70396. declare module BABYLON {
  70397. /**
  70398. * Class used to define a retry strategy when error happens while loading assets
  70399. */
  70400. export class RetryStrategy {
  70401. /**
  70402. * Function used to defines an exponential back off strategy
  70403. * @param maxRetries defines the maximum number of retries (3 by default)
  70404. * @param baseInterval defines the interval between retries
  70405. * @returns the strategy function to use
  70406. */
  70407. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  70408. }
  70409. }
  70410. declare module BABYLON {
  70411. /**
  70412. * @hidden
  70413. */
  70414. export class FileTools {
  70415. /**
  70416. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  70417. */
  70418. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  70419. /**
  70420. * Gets or sets the base URL to use to load assets
  70421. */
  70422. static BaseUrl: string;
  70423. /**
  70424. * Default behaviour for cors in the application.
  70425. * It can be a string if the expected behavior is identical in the entire app.
  70426. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  70427. */
  70428. static CorsBehavior: string | ((url: string | string[]) => string);
  70429. /**
  70430. * Gets or sets a function used to pre-process url before using them to load assets
  70431. */
  70432. static PreprocessUrl: (url: string) => string;
  70433. /**
  70434. * Removes unwanted characters from an url
  70435. * @param url defines the url to clean
  70436. * @returns the cleaned url
  70437. */
  70438. private static _CleanUrl;
  70439. /**
  70440. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  70441. * @param url define the url we are trying
  70442. * @param element define the dom element where to configure the cors policy
  70443. */
  70444. static SetCorsBehavior(url: string | string[], element: {
  70445. crossOrigin: string | null;
  70446. }): void;
  70447. /**
  70448. * Loads an image as an HTMLImageElement.
  70449. * @param input url string, ArrayBuffer, or Blob to load
  70450. * @param onLoad callback called when the image successfully loads
  70451. * @param onError callback called when the image fails to load
  70452. * @param offlineProvider offline provider for caching
  70453. * @returns the HTMLImageElement of the loaded image
  70454. */
  70455. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  70456. /**
  70457. * Loads a file
  70458. * @param fileToLoad defines the file to load
  70459. * @param callback defines the callback to call when data is loaded
  70460. * @param progressCallBack defines the callback to call during loading process
  70461. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  70462. * @returns a file request object
  70463. */
  70464. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  70465. /**
  70466. * Loads a file
  70467. * @param url url string, ArrayBuffer, or Blob to load
  70468. * @param onSuccess callback called when the file successfully loads
  70469. * @param onProgress callback called while file is loading (if the server supports this mode)
  70470. * @param offlineProvider defines the offline provider for caching
  70471. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70472. * @param onError callback called when the file fails to load
  70473. * @returns a file request object
  70474. */
  70475. 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;
  70476. /**
  70477. * Checks if the loaded document was accessed via `file:`-Protocol.
  70478. * @returns boolean
  70479. */
  70480. static IsFileURL(): boolean;
  70481. }
  70482. }
  70483. declare module BABYLON {
  70484. /** @hidden */
  70485. export class ShaderProcessor {
  70486. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  70487. private static _ProcessPrecision;
  70488. private static _ExtractOperation;
  70489. private static _BuildSubExpression;
  70490. private static _BuildExpression;
  70491. private static _MoveCursorWithinIf;
  70492. private static _MoveCursor;
  70493. private static _EvaluatePreProcessors;
  70494. private static _PreparePreProcessors;
  70495. private static _ProcessShaderConversion;
  70496. private static _ProcessIncludes;
  70497. }
  70498. }
  70499. declare module BABYLON {
  70500. /**
  70501. * Class used to hold a RBG color
  70502. */
  70503. export class Color3 {
  70504. /**
  70505. * Defines the red component (between 0 and 1, default is 0)
  70506. */
  70507. r: number;
  70508. /**
  70509. * Defines the green component (between 0 and 1, default is 0)
  70510. */
  70511. g: number;
  70512. /**
  70513. * Defines the blue component (between 0 and 1, default is 0)
  70514. */
  70515. b: number;
  70516. /**
  70517. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  70518. * @param r defines the red component (between 0 and 1, default is 0)
  70519. * @param g defines the green component (between 0 and 1, default is 0)
  70520. * @param b defines the blue component (between 0 and 1, default is 0)
  70521. */
  70522. constructor(
  70523. /**
  70524. * Defines the red component (between 0 and 1, default is 0)
  70525. */
  70526. r?: number,
  70527. /**
  70528. * Defines the green component (between 0 and 1, default is 0)
  70529. */
  70530. g?: number,
  70531. /**
  70532. * Defines the blue component (between 0 and 1, default is 0)
  70533. */
  70534. b?: number);
  70535. /**
  70536. * Creates a string with the Color3 current values
  70537. * @returns the string representation of the Color3 object
  70538. */
  70539. toString(): string;
  70540. /**
  70541. * Returns the string "Color3"
  70542. * @returns "Color3"
  70543. */
  70544. getClassName(): string;
  70545. /**
  70546. * Compute the Color3 hash code
  70547. * @returns an unique number that can be used to hash Color3 objects
  70548. */
  70549. getHashCode(): number;
  70550. /**
  70551. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  70552. * @param array defines the array where to store the r,g,b components
  70553. * @param index defines an optional index in the target array to define where to start storing values
  70554. * @returns the current Color3 object
  70555. */
  70556. toArray(array: FloatArray, index?: number): Color3;
  70557. /**
  70558. * Returns a new Color4 object from the current Color3 and the given alpha
  70559. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  70560. * @returns a new Color4 object
  70561. */
  70562. toColor4(alpha?: number): Color4;
  70563. /**
  70564. * Returns a new array populated with 3 numeric elements : red, green and blue values
  70565. * @returns the new array
  70566. */
  70567. asArray(): number[];
  70568. /**
  70569. * Returns the luminance value
  70570. * @returns a float value
  70571. */
  70572. toLuminance(): number;
  70573. /**
  70574. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70575. * @param otherColor defines the second operand
  70576. * @returns the new Color3 object
  70577. */
  70578. multiply(otherColor: DeepImmutable<Color3>): Color3;
  70579. /**
  70580. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70581. * @param otherColor defines the second operand
  70582. * @param result defines the Color3 object where to store the result
  70583. * @returns the current Color3
  70584. */
  70585. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70586. /**
  70587. * Determines equality between Color3 objects
  70588. * @param otherColor defines the second operand
  70589. * @returns true if the rgb values are equal to the given ones
  70590. */
  70591. equals(otherColor: DeepImmutable<Color3>): boolean;
  70592. /**
  70593. * Determines equality between the current Color3 object and a set of r,b,g values
  70594. * @param r defines the red component to check
  70595. * @param g defines the green component to check
  70596. * @param b defines the blue component to check
  70597. * @returns true if the rgb values are equal to the given ones
  70598. */
  70599. equalsFloats(r: number, g: number, b: number): boolean;
  70600. /**
  70601. * Multiplies in place each rgb value by scale
  70602. * @param scale defines the scaling factor
  70603. * @returns the updated Color3
  70604. */
  70605. scale(scale: number): Color3;
  70606. /**
  70607. * Multiplies the rgb values by scale and stores the result into "result"
  70608. * @param scale defines the scaling factor
  70609. * @param result defines the Color3 object where to store the result
  70610. * @returns the unmodified current Color3
  70611. */
  70612. scaleToRef(scale: number, result: Color3): Color3;
  70613. /**
  70614. * Scale the current Color3 values by a factor and add the result to a given Color3
  70615. * @param scale defines the scale factor
  70616. * @param result defines color to store the result into
  70617. * @returns the unmodified current Color3
  70618. */
  70619. scaleAndAddToRef(scale: number, result: Color3): Color3;
  70620. /**
  70621. * Clamps the rgb values by the min and max values and stores the result into "result"
  70622. * @param min defines minimum clamping value (default is 0)
  70623. * @param max defines maximum clamping value (default is 1)
  70624. * @param result defines color to store the result into
  70625. * @returns the original Color3
  70626. */
  70627. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  70628. /**
  70629. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70630. * @param otherColor defines the second operand
  70631. * @returns the new Color3
  70632. */
  70633. add(otherColor: DeepImmutable<Color3>): Color3;
  70634. /**
  70635. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70636. * @param otherColor defines the second operand
  70637. * @param result defines Color3 object to store the result into
  70638. * @returns the unmodified current Color3
  70639. */
  70640. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70641. /**
  70642. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70643. * @param otherColor defines the second operand
  70644. * @returns the new Color3
  70645. */
  70646. subtract(otherColor: DeepImmutable<Color3>): Color3;
  70647. /**
  70648. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70649. * @param otherColor defines the second operand
  70650. * @param result defines Color3 object to store the result into
  70651. * @returns the unmodified current Color3
  70652. */
  70653. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70654. /**
  70655. * Copy the current object
  70656. * @returns a new Color3 copied the current one
  70657. */
  70658. clone(): Color3;
  70659. /**
  70660. * Copies the rgb values from the source in the current Color3
  70661. * @param source defines the source Color3 object
  70662. * @returns the updated Color3 object
  70663. */
  70664. copyFrom(source: DeepImmutable<Color3>): Color3;
  70665. /**
  70666. * Updates the Color3 rgb values from the given floats
  70667. * @param r defines the red component to read from
  70668. * @param g defines the green component to read from
  70669. * @param b defines the blue component to read from
  70670. * @returns the current Color3 object
  70671. */
  70672. copyFromFloats(r: number, g: number, b: number): Color3;
  70673. /**
  70674. * Updates the Color3 rgb values from the given floats
  70675. * @param r defines the red component to read from
  70676. * @param g defines the green component to read from
  70677. * @param b defines the blue component to read from
  70678. * @returns the current Color3 object
  70679. */
  70680. set(r: number, g: number, b: number): Color3;
  70681. /**
  70682. * Compute the Color3 hexadecimal code as a string
  70683. * @returns a string containing the hexadecimal representation of the Color3 object
  70684. */
  70685. toHexString(): string;
  70686. /**
  70687. * Computes a new Color3 converted from the current one to linear space
  70688. * @returns a new Color3 object
  70689. */
  70690. toLinearSpace(): Color3;
  70691. /**
  70692. * Converts current color in rgb space to HSV values
  70693. * @returns a new color3 representing the HSV values
  70694. */
  70695. toHSV(): Color3;
  70696. /**
  70697. * Converts current color in rgb space to HSV values
  70698. * @param result defines the Color3 where to store the HSV values
  70699. */
  70700. toHSVToRef(result: Color3): void;
  70701. /**
  70702. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70703. * @param convertedColor defines the Color3 object where to store the linear space version
  70704. * @returns the unmodified Color3
  70705. */
  70706. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70707. /**
  70708. * Computes a new Color3 converted from the current one to gamma space
  70709. * @returns a new Color3 object
  70710. */
  70711. toGammaSpace(): Color3;
  70712. /**
  70713. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70714. * @param convertedColor defines the Color3 object where to store the gamma space version
  70715. * @returns the unmodified Color3
  70716. */
  70717. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70718. private static _BlackReadOnly;
  70719. /**
  70720. * Convert Hue, saturation and value to a Color3 (RGB)
  70721. * @param hue defines the hue
  70722. * @param saturation defines the saturation
  70723. * @param value defines the value
  70724. * @param result defines the Color3 where to store the RGB values
  70725. */
  70726. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70727. /**
  70728. * Creates a new Color3 from the string containing valid hexadecimal values
  70729. * @param hex defines a string containing valid hexadecimal values
  70730. * @returns a new Color3 object
  70731. */
  70732. static FromHexString(hex: string): Color3;
  70733. /**
  70734. * Creates a new Color3 from the starting index of the given array
  70735. * @param array defines the source array
  70736. * @param offset defines an offset in the source array
  70737. * @returns a new Color3 object
  70738. */
  70739. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70740. /**
  70741. * Creates a new Color3 from integer values (< 256)
  70742. * @param r defines the red component to read from (value between 0 and 255)
  70743. * @param g defines the green component to read from (value between 0 and 255)
  70744. * @param b defines the blue component to read from (value between 0 and 255)
  70745. * @returns a new Color3 object
  70746. */
  70747. static FromInts(r: number, g: number, b: number): Color3;
  70748. /**
  70749. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70750. * @param start defines the start Color3 value
  70751. * @param end defines the end Color3 value
  70752. * @param amount defines the gradient value between start and end
  70753. * @returns a new Color3 object
  70754. */
  70755. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70756. /**
  70757. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70758. * @param left defines the start value
  70759. * @param right defines the end value
  70760. * @param amount defines the gradient factor
  70761. * @param result defines the Color3 object where to store the result
  70762. */
  70763. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70764. /**
  70765. * Returns a Color3 value containing a red color
  70766. * @returns a new Color3 object
  70767. */
  70768. static Red(): Color3;
  70769. /**
  70770. * Returns a Color3 value containing a green color
  70771. * @returns a new Color3 object
  70772. */
  70773. static Green(): Color3;
  70774. /**
  70775. * Returns a Color3 value containing a blue color
  70776. * @returns a new Color3 object
  70777. */
  70778. static Blue(): Color3;
  70779. /**
  70780. * Returns a Color3 value containing a black color
  70781. * @returns a new Color3 object
  70782. */
  70783. static Black(): Color3;
  70784. /**
  70785. * Gets a Color3 value containing a black color that must not be updated
  70786. */
  70787. static readonly BlackReadOnly: DeepImmutable<Color3>;
  70788. /**
  70789. * Returns a Color3 value containing a white color
  70790. * @returns a new Color3 object
  70791. */
  70792. static White(): Color3;
  70793. /**
  70794. * Returns a Color3 value containing a purple color
  70795. * @returns a new Color3 object
  70796. */
  70797. static Purple(): Color3;
  70798. /**
  70799. * Returns a Color3 value containing a magenta color
  70800. * @returns a new Color3 object
  70801. */
  70802. static Magenta(): Color3;
  70803. /**
  70804. * Returns a Color3 value containing a yellow color
  70805. * @returns a new Color3 object
  70806. */
  70807. static Yellow(): Color3;
  70808. /**
  70809. * Returns a Color3 value containing a gray color
  70810. * @returns a new Color3 object
  70811. */
  70812. static Gray(): Color3;
  70813. /**
  70814. * Returns a Color3 value containing a teal color
  70815. * @returns a new Color3 object
  70816. */
  70817. static Teal(): Color3;
  70818. /**
  70819. * Returns a Color3 value containing a random color
  70820. * @returns a new Color3 object
  70821. */
  70822. static Random(): Color3;
  70823. }
  70824. /**
  70825. * Class used to hold a RBGA color
  70826. */
  70827. export class Color4 {
  70828. /**
  70829. * Defines the red component (between 0 and 1, default is 0)
  70830. */
  70831. r: number;
  70832. /**
  70833. * Defines the green component (between 0 and 1, default is 0)
  70834. */
  70835. g: number;
  70836. /**
  70837. * Defines the blue component (between 0 and 1, default is 0)
  70838. */
  70839. b: number;
  70840. /**
  70841. * Defines the alpha component (between 0 and 1, default is 1)
  70842. */
  70843. a: number;
  70844. /**
  70845. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70846. * @param r defines the red component (between 0 and 1, default is 0)
  70847. * @param g defines the green component (between 0 and 1, default is 0)
  70848. * @param b defines the blue component (between 0 and 1, default is 0)
  70849. * @param a defines the alpha component (between 0 and 1, default is 1)
  70850. */
  70851. constructor(
  70852. /**
  70853. * Defines the red component (between 0 and 1, default is 0)
  70854. */
  70855. r?: number,
  70856. /**
  70857. * Defines the green component (between 0 and 1, default is 0)
  70858. */
  70859. g?: number,
  70860. /**
  70861. * Defines the blue component (between 0 and 1, default is 0)
  70862. */
  70863. b?: number,
  70864. /**
  70865. * Defines the alpha component (between 0 and 1, default is 1)
  70866. */
  70867. a?: number);
  70868. /**
  70869. * Adds in place the given Color4 values to the current Color4 object
  70870. * @param right defines the second operand
  70871. * @returns the current updated Color4 object
  70872. */
  70873. addInPlace(right: DeepImmutable<Color4>): Color4;
  70874. /**
  70875. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70876. * @returns the new array
  70877. */
  70878. asArray(): number[];
  70879. /**
  70880. * Stores from the starting index in the given array the Color4 successive values
  70881. * @param array defines the array where to store the r,g,b components
  70882. * @param index defines an optional index in the target array to define where to start storing values
  70883. * @returns the current Color4 object
  70884. */
  70885. toArray(array: number[], index?: number): Color4;
  70886. /**
  70887. * Determines equality between Color4 objects
  70888. * @param otherColor defines the second operand
  70889. * @returns true if the rgba values are equal to the given ones
  70890. */
  70891. equals(otherColor: DeepImmutable<Color4>): boolean;
  70892. /**
  70893. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70894. * @param right defines the second operand
  70895. * @returns a new Color4 object
  70896. */
  70897. add(right: DeepImmutable<Color4>): Color4;
  70898. /**
  70899. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70900. * @param right defines the second operand
  70901. * @returns a new Color4 object
  70902. */
  70903. subtract(right: DeepImmutable<Color4>): Color4;
  70904. /**
  70905. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70906. * @param right defines the second operand
  70907. * @param result defines the Color4 object where to store the result
  70908. * @returns the current Color4 object
  70909. */
  70910. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  70911. /**
  70912. * Creates a new Color4 with the current Color4 values multiplied by scale
  70913. * @param scale defines the scaling factor to apply
  70914. * @returns a new Color4 object
  70915. */
  70916. scale(scale: number): Color4;
  70917. /**
  70918. * Multiplies the current Color4 values by scale and stores the result in "result"
  70919. * @param scale defines the scaling factor to apply
  70920. * @param result defines the Color4 object where to store the result
  70921. * @returns the current unmodified Color4
  70922. */
  70923. scaleToRef(scale: number, result: Color4): Color4;
  70924. /**
  70925. * Scale the current Color4 values by a factor and add the result to a given Color4
  70926. * @param scale defines the scale factor
  70927. * @param result defines the Color4 object where to store the result
  70928. * @returns the unmodified current Color4
  70929. */
  70930. scaleAndAddToRef(scale: number, result: Color4): Color4;
  70931. /**
  70932. * Clamps the rgb values by the min and max values and stores the result into "result"
  70933. * @param min defines minimum clamping value (default is 0)
  70934. * @param max defines maximum clamping value (default is 1)
  70935. * @param result defines color to store the result into.
  70936. * @returns the cuurent Color4
  70937. */
  70938. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  70939. /**
  70940. * Multipy an Color4 value by another and return a new Color4 object
  70941. * @param color defines the Color4 value to multiply by
  70942. * @returns a new Color4 object
  70943. */
  70944. multiply(color: Color4): Color4;
  70945. /**
  70946. * Multipy a Color4 value by another and push the result in a reference value
  70947. * @param color defines the Color4 value to multiply by
  70948. * @param result defines the Color4 to fill the result in
  70949. * @returns the result Color4
  70950. */
  70951. multiplyToRef(color: Color4, result: Color4): Color4;
  70952. /**
  70953. * Creates a string with the Color4 current values
  70954. * @returns the string representation of the Color4 object
  70955. */
  70956. toString(): string;
  70957. /**
  70958. * Returns the string "Color4"
  70959. * @returns "Color4"
  70960. */
  70961. getClassName(): string;
  70962. /**
  70963. * Compute the Color4 hash code
  70964. * @returns an unique number that can be used to hash Color4 objects
  70965. */
  70966. getHashCode(): number;
  70967. /**
  70968. * Creates a new Color4 copied from the current one
  70969. * @returns a new Color4 object
  70970. */
  70971. clone(): Color4;
  70972. /**
  70973. * Copies the given Color4 values into the current one
  70974. * @param source defines the source Color4 object
  70975. * @returns the current updated Color4 object
  70976. */
  70977. copyFrom(source: Color4): Color4;
  70978. /**
  70979. * Copies the given float values into the current one
  70980. * @param r defines the red component to read from
  70981. * @param g defines the green component to read from
  70982. * @param b defines the blue component to read from
  70983. * @param a defines the alpha component to read from
  70984. * @returns the current updated Color4 object
  70985. */
  70986. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  70987. /**
  70988. * Copies the given float values into the current one
  70989. * @param r defines the red component to read from
  70990. * @param g defines the green component to read from
  70991. * @param b defines the blue component to read from
  70992. * @param a defines the alpha component to read from
  70993. * @returns the current updated Color4 object
  70994. */
  70995. set(r: number, g: number, b: number, a: number): Color4;
  70996. /**
  70997. * Compute the Color4 hexadecimal code as a string
  70998. * @returns a string containing the hexadecimal representation of the Color4 object
  70999. */
  71000. toHexString(): string;
  71001. /**
  71002. * Computes a new Color4 converted from the current one to linear space
  71003. * @returns a new Color4 object
  71004. */
  71005. toLinearSpace(): Color4;
  71006. /**
  71007. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  71008. * @param convertedColor defines the Color4 object where to store the linear space version
  71009. * @returns the unmodified Color4
  71010. */
  71011. toLinearSpaceToRef(convertedColor: Color4): Color4;
  71012. /**
  71013. * Computes a new Color4 converted from the current one to gamma space
  71014. * @returns a new Color4 object
  71015. */
  71016. toGammaSpace(): Color4;
  71017. /**
  71018. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  71019. * @param convertedColor defines the Color4 object where to store the gamma space version
  71020. * @returns the unmodified Color4
  71021. */
  71022. toGammaSpaceToRef(convertedColor: Color4): Color4;
  71023. /**
  71024. * Creates a new Color4 from the string containing valid hexadecimal values
  71025. * @param hex defines a string containing valid hexadecimal values
  71026. * @returns a new Color4 object
  71027. */
  71028. static FromHexString(hex: string): Color4;
  71029. /**
  71030. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71031. * @param left defines the start value
  71032. * @param right defines the end value
  71033. * @param amount defines the gradient factor
  71034. * @returns a new Color4 object
  71035. */
  71036. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  71037. /**
  71038. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71039. * @param left defines the start value
  71040. * @param right defines the end value
  71041. * @param amount defines the gradient factor
  71042. * @param result defines the Color4 object where to store data
  71043. */
  71044. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  71045. /**
  71046. * Creates a new Color4 from a Color3 and an alpha value
  71047. * @param color3 defines the source Color3 to read from
  71048. * @param alpha defines the alpha component (1.0 by default)
  71049. * @returns a new Color4 object
  71050. */
  71051. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  71052. /**
  71053. * Creates a new Color4 from the starting index element of the given array
  71054. * @param array defines the source array to read from
  71055. * @param offset defines the offset in the source array
  71056. * @returns a new Color4 object
  71057. */
  71058. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  71059. /**
  71060. * Creates a new Color3 from integer values (< 256)
  71061. * @param r defines the red component to read from (value between 0 and 255)
  71062. * @param g defines the green component to read from (value between 0 and 255)
  71063. * @param b defines the blue component to read from (value between 0 and 255)
  71064. * @param a defines the alpha component to read from (value between 0 and 255)
  71065. * @returns a new Color3 object
  71066. */
  71067. static FromInts(r: number, g: number, b: number, a: number): Color4;
  71068. /**
  71069. * Check the content of a given array and convert it to an array containing RGBA data
  71070. * If the original array was already containing count * 4 values then it is returned directly
  71071. * @param colors defines the array to check
  71072. * @param count defines the number of RGBA data to expect
  71073. * @returns an array containing count * 4 values (RGBA)
  71074. */
  71075. static CheckColors4(colors: number[], count: number): number[];
  71076. }
  71077. /**
  71078. * @hidden
  71079. */
  71080. export class TmpColors {
  71081. static Color3: Color3[];
  71082. static Color4: Color4[];
  71083. }
  71084. }
  71085. declare module BABYLON {
  71086. /**
  71087. * Class representing spherical harmonics coefficients to the 3rd degree
  71088. */
  71089. export class SphericalHarmonics {
  71090. /**
  71091. * Defines whether or not the harmonics have been prescaled for rendering.
  71092. */
  71093. preScaled: boolean;
  71094. /**
  71095. * The l0,0 coefficients of the spherical harmonics
  71096. */
  71097. l00: Vector3;
  71098. /**
  71099. * The l1,-1 coefficients of the spherical harmonics
  71100. */
  71101. l1_1: Vector3;
  71102. /**
  71103. * The l1,0 coefficients of the spherical harmonics
  71104. */
  71105. l10: Vector3;
  71106. /**
  71107. * The l1,1 coefficients of the spherical harmonics
  71108. */
  71109. l11: Vector3;
  71110. /**
  71111. * The l2,-2 coefficients of the spherical harmonics
  71112. */
  71113. l2_2: Vector3;
  71114. /**
  71115. * The l2,-1 coefficients of the spherical harmonics
  71116. */
  71117. l2_1: Vector3;
  71118. /**
  71119. * The l2,0 coefficients of the spherical harmonics
  71120. */
  71121. l20: Vector3;
  71122. /**
  71123. * The l2,1 coefficients of the spherical harmonics
  71124. */
  71125. l21: Vector3;
  71126. /**
  71127. * The l2,2 coefficients of the spherical harmonics
  71128. */
  71129. l22: Vector3;
  71130. /**
  71131. * Adds a light to the spherical harmonics
  71132. * @param direction the direction of the light
  71133. * @param color the color of the light
  71134. * @param deltaSolidAngle the delta solid angle of the light
  71135. */
  71136. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  71137. /**
  71138. * Scales the spherical harmonics by the given amount
  71139. * @param scale the amount to scale
  71140. */
  71141. scaleInPlace(scale: number): void;
  71142. /**
  71143. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  71144. *
  71145. * ```
  71146. * E_lm = A_l * L_lm
  71147. * ```
  71148. *
  71149. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  71150. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  71151. * the scaling factors are given in equation 9.
  71152. */
  71153. convertIncidentRadianceToIrradiance(): void;
  71154. /**
  71155. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  71156. *
  71157. * ```
  71158. * L = (1/pi) * E * rho
  71159. * ```
  71160. *
  71161. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  71162. */
  71163. convertIrradianceToLambertianRadiance(): void;
  71164. /**
  71165. * Integrates the reconstruction coefficients directly in to the SH preventing further
  71166. * required operations at run time.
  71167. *
  71168. * This is simply done by scaling back the SH with Ylm constants parameter.
  71169. * The trigonometric part being applied by the shader at run time.
  71170. */
  71171. preScaleForRendering(): void;
  71172. /**
  71173. * Constructs a spherical harmonics from an array.
  71174. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  71175. * @returns the spherical harmonics
  71176. */
  71177. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  71178. /**
  71179. * Gets the spherical harmonics from polynomial
  71180. * @param polynomial the spherical polynomial
  71181. * @returns the spherical harmonics
  71182. */
  71183. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  71184. }
  71185. /**
  71186. * Class representing spherical polynomial coefficients to the 3rd degree
  71187. */
  71188. export class SphericalPolynomial {
  71189. private _harmonics;
  71190. /**
  71191. * The spherical harmonics used to create the polynomials.
  71192. */
  71193. readonly preScaledHarmonics: SphericalHarmonics;
  71194. /**
  71195. * The x coefficients of the spherical polynomial
  71196. */
  71197. x: Vector3;
  71198. /**
  71199. * The y coefficients of the spherical polynomial
  71200. */
  71201. y: Vector3;
  71202. /**
  71203. * The z coefficients of the spherical polynomial
  71204. */
  71205. z: Vector3;
  71206. /**
  71207. * The xx coefficients of the spherical polynomial
  71208. */
  71209. xx: Vector3;
  71210. /**
  71211. * The yy coefficients of the spherical polynomial
  71212. */
  71213. yy: Vector3;
  71214. /**
  71215. * The zz coefficients of the spherical polynomial
  71216. */
  71217. zz: Vector3;
  71218. /**
  71219. * The xy coefficients of the spherical polynomial
  71220. */
  71221. xy: Vector3;
  71222. /**
  71223. * The yz coefficients of the spherical polynomial
  71224. */
  71225. yz: Vector3;
  71226. /**
  71227. * The zx coefficients of the spherical polynomial
  71228. */
  71229. zx: Vector3;
  71230. /**
  71231. * Adds an ambient color to the spherical polynomial
  71232. * @param color the color to add
  71233. */
  71234. addAmbient(color: Color3): void;
  71235. /**
  71236. * Scales the spherical polynomial by the given amount
  71237. * @param scale the amount to scale
  71238. */
  71239. scaleInPlace(scale: number): void;
  71240. /**
  71241. * Gets the spherical polynomial from harmonics
  71242. * @param harmonics the spherical harmonics
  71243. * @returns the spherical polynomial
  71244. */
  71245. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  71246. /**
  71247. * Constructs a spherical polynomial from an array.
  71248. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  71249. * @returns the spherical polynomial
  71250. */
  71251. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  71252. }
  71253. }
  71254. declare module BABYLON {
  71255. /**
  71256. * Define options used to create a render target texture
  71257. */
  71258. export class RenderTargetCreationOptions {
  71259. /**
  71260. * Specifies is mipmaps must be generated
  71261. */
  71262. generateMipMaps?: boolean;
  71263. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71264. generateDepthBuffer?: boolean;
  71265. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71266. generateStencilBuffer?: boolean;
  71267. /** Defines texture type (int by default) */
  71268. type?: number;
  71269. /** Defines sampling mode (trilinear by default) */
  71270. samplingMode?: number;
  71271. /** Defines format (RGBA by default) */
  71272. format?: number;
  71273. }
  71274. }
  71275. declare module BABYLON {
  71276. /**
  71277. * @hidden
  71278. **/
  71279. export class _AlphaState {
  71280. private _isAlphaBlendDirty;
  71281. private _isBlendFunctionParametersDirty;
  71282. private _isBlendEquationParametersDirty;
  71283. private _isBlendConstantsDirty;
  71284. private _alphaBlend;
  71285. private _blendFunctionParameters;
  71286. private _blendEquationParameters;
  71287. private _blendConstants;
  71288. /**
  71289. * Initializes the state.
  71290. */
  71291. constructor();
  71292. readonly isDirty: boolean;
  71293. alphaBlend: boolean;
  71294. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  71295. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  71296. setAlphaEquationParameters(rgb: number, alpha: number): void;
  71297. reset(): void;
  71298. apply(gl: WebGLRenderingContext): void;
  71299. }
  71300. }
  71301. declare module BABYLON {
  71302. /**
  71303. * @hidden
  71304. **/
  71305. export class _DepthCullingState {
  71306. private _isDepthTestDirty;
  71307. private _isDepthMaskDirty;
  71308. private _isDepthFuncDirty;
  71309. private _isCullFaceDirty;
  71310. private _isCullDirty;
  71311. private _isZOffsetDirty;
  71312. private _isFrontFaceDirty;
  71313. private _depthTest;
  71314. private _depthMask;
  71315. private _depthFunc;
  71316. private _cull;
  71317. private _cullFace;
  71318. private _zOffset;
  71319. private _frontFace;
  71320. /**
  71321. * Initializes the state.
  71322. */
  71323. constructor();
  71324. readonly isDirty: boolean;
  71325. zOffset: number;
  71326. cullFace: Nullable<number>;
  71327. cull: Nullable<boolean>;
  71328. depthFunc: Nullable<number>;
  71329. depthMask: boolean;
  71330. depthTest: boolean;
  71331. frontFace: Nullable<number>;
  71332. reset(): void;
  71333. apply(gl: WebGLRenderingContext): void;
  71334. }
  71335. }
  71336. declare module BABYLON {
  71337. /**
  71338. * @hidden
  71339. **/
  71340. export class _StencilState {
  71341. /** 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 */
  71342. static readonly ALWAYS: number;
  71343. /** Passed to stencilOperation to specify that stencil value must be kept */
  71344. static readonly KEEP: number;
  71345. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71346. static readonly REPLACE: number;
  71347. private _isStencilTestDirty;
  71348. private _isStencilMaskDirty;
  71349. private _isStencilFuncDirty;
  71350. private _isStencilOpDirty;
  71351. private _stencilTest;
  71352. private _stencilMask;
  71353. private _stencilFunc;
  71354. private _stencilFuncRef;
  71355. private _stencilFuncMask;
  71356. private _stencilOpStencilFail;
  71357. private _stencilOpDepthFail;
  71358. private _stencilOpStencilDepthPass;
  71359. readonly isDirty: boolean;
  71360. stencilFunc: number;
  71361. stencilFuncRef: number;
  71362. stencilFuncMask: number;
  71363. stencilOpStencilFail: number;
  71364. stencilOpDepthFail: number;
  71365. stencilOpStencilDepthPass: number;
  71366. stencilMask: number;
  71367. stencilTest: boolean;
  71368. constructor();
  71369. reset(): void;
  71370. apply(gl: WebGLRenderingContext): void;
  71371. }
  71372. }
  71373. declare module BABYLON {
  71374. /**
  71375. * @hidden
  71376. **/
  71377. export class _TimeToken {
  71378. _startTimeQuery: Nullable<WebGLQuery>;
  71379. _endTimeQuery: Nullable<WebGLQuery>;
  71380. _timeElapsedQuery: Nullable<WebGLQuery>;
  71381. _timeElapsedQueryEnded: boolean;
  71382. }
  71383. }
  71384. declare module BABYLON {
  71385. /**
  71386. * Class used to evalaute queries containing `and` and `or` operators
  71387. */
  71388. export class AndOrNotEvaluator {
  71389. /**
  71390. * Evaluate a query
  71391. * @param query defines the query to evaluate
  71392. * @param evaluateCallback defines the callback used to filter result
  71393. * @returns true if the query matches
  71394. */
  71395. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71396. private static _HandleParenthesisContent;
  71397. private static _SimplifyNegation;
  71398. }
  71399. }
  71400. declare module BABYLON {
  71401. /**
  71402. * Class used to store custom tags
  71403. */
  71404. export class Tags {
  71405. /**
  71406. * Adds support for tags on the given object
  71407. * @param obj defines the object to use
  71408. */
  71409. static EnableFor(obj: any): void;
  71410. /**
  71411. * Removes tags support
  71412. * @param obj defines the object to use
  71413. */
  71414. static DisableFor(obj: any): void;
  71415. /**
  71416. * Gets a boolean indicating if the given object has tags
  71417. * @param obj defines the object to use
  71418. * @returns a boolean
  71419. */
  71420. static HasTags(obj: any): boolean;
  71421. /**
  71422. * Gets the tags available on a given object
  71423. * @param obj defines the object to use
  71424. * @param asString defines if the tags must be returned as a string instead of an array of strings
  71425. * @returns the tags
  71426. */
  71427. static GetTags(obj: any, asString?: boolean): any;
  71428. /**
  71429. * Adds tags to an object
  71430. * @param obj defines the object to use
  71431. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  71432. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  71433. */
  71434. static AddTagsTo(obj: any, tagsString: string): void;
  71435. /**
  71436. * @hidden
  71437. */
  71438. static _AddTagTo(obj: any, tag: string): void;
  71439. /**
  71440. * Removes specific tags from a specific object
  71441. * @param obj defines the object to use
  71442. * @param tagsString defines the tags to remove
  71443. */
  71444. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71445. /**
  71446. * @hidden
  71447. */
  71448. static _RemoveTagFrom(obj: any, tag: string): void;
  71449. /**
  71450. * Defines if tags hosted on an object match a given query
  71451. * @param obj defines the object to use
  71452. * @param tagsQuery defines the tag query
  71453. * @returns a boolean
  71454. */
  71455. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71456. }
  71457. }
  71458. declare module BABYLON {
  71459. /**
  71460. * Defines potential orientation for back face culling
  71461. */
  71462. export enum Orientation {
  71463. /**
  71464. * Clockwise
  71465. */
  71466. CW = 0,
  71467. /** Counter clockwise */
  71468. CCW = 1
  71469. }
  71470. /** Class used to represent a Bezier curve */
  71471. export class BezierCurve {
  71472. /**
  71473. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71474. * @param t defines the time
  71475. * @param x1 defines the left coordinate on X axis
  71476. * @param y1 defines the left coordinate on Y axis
  71477. * @param x2 defines the right coordinate on X axis
  71478. * @param y2 defines the right coordinate on Y axis
  71479. * @returns the interpolated value
  71480. */
  71481. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71482. }
  71483. /**
  71484. * Defines angle representation
  71485. */
  71486. export class Angle {
  71487. private _radians;
  71488. /**
  71489. * Creates an Angle object of "radians" radians (float).
  71490. * @param radians the angle in radians
  71491. */
  71492. constructor(radians: number);
  71493. /**
  71494. * Get value in degrees
  71495. * @returns the Angle value in degrees (float)
  71496. */
  71497. degrees(): number;
  71498. /**
  71499. * Get value in radians
  71500. * @returns the Angle value in radians (float)
  71501. */
  71502. radians(): number;
  71503. /**
  71504. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71505. * @param a defines first vector
  71506. * @param b defines second vector
  71507. * @returns a new Angle
  71508. */
  71509. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71510. /**
  71511. * Gets a new Angle object from the given float in radians
  71512. * @param radians defines the angle value in radians
  71513. * @returns a new Angle
  71514. */
  71515. static FromRadians(radians: number): Angle;
  71516. /**
  71517. * Gets a new Angle object from the given float in degrees
  71518. * @param degrees defines the angle value in degrees
  71519. * @returns a new Angle
  71520. */
  71521. static FromDegrees(degrees: number): Angle;
  71522. }
  71523. /**
  71524. * This represents an arc in a 2d space.
  71525. */
  71526. export class Arc2 {
  71527. /** Defines the start point of the arc */
  71528. startPoint: Vector2;
  71529. /** Defines the mid point of the arc */
  71530. midPoint: Vector2;
  71531. /** Defines the end point of the arc */
  71532. endPoint: Vector2;
  71533. /**
  71534. * Defines the center point of the arc.
  71535. */
  71536. centerPoint: Vector2;
  71537. /**
  71538. * Defines the radius of the arc.
  71539. */
  71540. radius: number;
  71541. /**
  71542. * Defines the angle of the arc (from mid point to end point).
  71543. */
  71544. angle: Angle;
  71545. /**
  71546. * Defines the start angle of the arc (from start point to middle point).
  71547. */
  71548. startAngle: Angle;
  71549. /**
  71550. * Defines the orientation of the arc (clock wise/counter clock wise).
  71551. */
  71552. orientation: Orientation;
  71553. /**
  71554. * Creates an Arc object from the three given points : start, middle and end.
  71555. * @param startPoint Defines the start point of the arc
  71556. * @param midPoint Defines the midlle point of the arc
  71557. * @param endPoint Defines the end point of the arc
  71558. */
  71559. constructor(
  71560. /** Defines the start point of the arc */
  71561. startPoint: Vector2,
  71562. /** Defines the mid point of the arc */
  71563. midPoint: Vector2,
  71564. /** Defines the end point of the arc */
  71565. endPoint: Vector2);
  71566. }
  71567. /**
  71568. * Represents a 2D path made up of multiple 2D points
  71569. */
  71570. export class Path2 {
  71571. private _points;
  71572. private _length;
  71573. /**
  71574. * If the path start and end point are the same
  71575. */
  71576. closed: boolean;
  71577. /**
  71578. * Creates a Path2 object from the starting 2D coordinates x and y.
  71579. * @param x the starting points x value
  71580. * @param y the starting points y value
  71581. */
  71582. constructor(x: number, y: number);
  71583. /**
  71584. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71585. * @param x the added points x value
  71586. * @param y the added points y value
  71587. * @returns the updated Path2.
  71588. */
  71589. addLineTo(x: number, y: number): Path2;
  71590. /**
  71591. * 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.
  71592. * @param midX middle point x value
  71593. * @param midY middle point y value
  71594. * @param endX end point x value
  71595. * @param endY end point y value
  71596. * @param numberOfSegments (default: 36)
  71597. * @returns the updated Path2.
  71598. */
  71599. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71600. /**
  71601. * Closes the Path2.
  71602. * @returns the Path2.
  71603. */
  71604. close(): Path2;
  71605. /**
  71606. * Gets the sum of the distance between each sequential point in the path
  71607. * @returns the Path2 total length (float).
  71608. */
  71609. length(): number;
  71610. /**
  71611. * Gets the points which construct the path
  71612. * @returns the Path2 internal array of points.
  71613. */
  71614. getPoints(): Vector2[];
  71615. /**
  71616. * Retreives the point at the distance aways from the starting point
  71617. * @param normalizedLengthPosition the length along the path to retreive the point from
  71618. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71619. */
  71620. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71621. /**
  71622. * Creates a new path starting from an x and y position
  71623. * @param x starting x value
  71624. * @param y starting y value
  71625. * @returns a new Path2 starting at the coordinates (x, y).
  71626. */
  71627. static StartingAt(x: number, y: number): Path2;
  71628. }
  71629. /**
  71630. * Represents a 3D path made up of multiple 3D points
  71631. */
  71632. export class Path3D {
  71633. /**
  71634. * an array of Vector3, the curve axis of the Path3D
  71635. */
  71636. path: Vector3[];
  71637. private _curve;
  71638. private _distances;
  71639. private _tangents;
  71640. private _normals;
  71641. private _binormals;
  71642. private _raw;
  71643. /**
  71644. * new Path3D(path, normal, raw)
  71645. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71646. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71647. * @param path an array of Vector3, the curve axis of the Path3D
  71648. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71649. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71650. */
  71651. constructor(
  71652. /**
  71653. * an array of Vector3, the curve axis of the Path3D
  71654. */
  71655. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71656. /**
  71657. * Returns the Path3D array of successive Vector3 designing its curve.
  71658. * @returns the Path3D array of successive Vector3 designing its curve.
  71659. */
  71660. getCurve(): Vector3[];
  71661. /**
  71662. * Returns an array populated with tangent vectors on each Path3D curve point.
  71663. * @returns an array populated with tangent vectors on each Path3D curve point.
  71664. */
  71665. getTangents(): Vector3[];
  71666. /**
  71667. * Returns an array populated with normal vectors on each Path3D curve point.
  71668. * @returns an array populated with normal vectors on each Path3D curve point.
  71669. */
  71670. getNormals(): Vector3[];
  71671. /**
  71672. * Returns an array populated with binormal vectors on each Path3D curve point.
  71673. * @returns an array populated with binormal vectors on each Path3D curve point.
  71674. */
  71675. getBinormals(): Vector3[];
  71676. /**
  71677. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71678. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71679. */
  71680. getDistances(): number[];
  71681. /**
  71682. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71683. * @param path path which all values are copied into the curves points
  71684. * @param firstNormal which should be projected onto the curve
  71685. * @returns the same object updated.
  71686. */
  71687. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71688. private _compute;
  71689. private _getFirstNonNullVector;
  71690. private _getLastNonNullVector;
  71691. private _normalVector;
  71692. }
  71693. /**
  71694. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71695. * A Curve3 is designed from a series of successive Vector3.
  71696. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71697. */
  71698. export class Curve3 {
  71699. private _points;
  71700. private _length;
  71701. /**
  71702. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71703. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71704. * @param v1 (Vector3) the control point
  71705. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71706. * @param nbPoints (integer) the wanted number of points in the curve
  71707. * @returns the created Curve3
  71708. */
  71709. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71710. /**
  71711. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71712. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71713. * @param v1 (Vector3) the first control point
  71714. * @param v2 (Vector3) the second control point
  71715. * @param v3 (Vector3) the end point of the Cubic Bezier
  71716. * @param nbPoints (integer) the wanted number of points in the curve
  71717. * @returns the created Curve3
  71718. */
  71719. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71720. /**
  71721. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71722. * @param p1 (Vector3) the origin point of the Hermite Spline
  71723. * @param t1 (Vector3) the tangent vector at the origin point
  71724. * @param p2 (Vector3) the end point of the Hermite Spline
  71725. * @param t2 (Vector3) the tangent vector at the end point
  71726. * @param nbPoints (integer) the wanted number of points in the curve
  71727. * @returns the created Curve3
  71728. */
  71729. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71730. /**
  71731. * Returns a Curve3 object along a CatmullRom Spline curve :
  71732. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71733. * @param nbPoints (integer) the wanted number of points between each curve control points
  71734. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71735. * @returns the created Curve3
  71736. */
  71737. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71738. /**
  71739. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71740. * A Curve3 is designed from a series of successive Vector3.
  71741. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71742. * @param points points which make up the curve
  71743. */
  71744. constructor(points: Vector3[]);
  71745. /**
  71746. * @returns the Curve3 stored array of successive Vector3
  71747. */
  71748. getPoints(): Vector3[];
  71749. /**
  71750. * @returns the computed length (float) of the curve.
  71751. */
  71752. length(): number;
  71753. /**
  71754. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71755. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71756. * curveA and curveB keep unchanged.
  71757. * @param curve the curve to continue from this curve
  71758. * @returns the newly constructed curve
  71759. */
  71760. continue(curve: DeepImmutable<Curve3>): Curve3;
  71761. private _computeLength;
  71762. }
  71763. }
  71764. declare module BABYLON {
  71765. /**
  71766. * This represents the main contract an easing function should follow.
  71767. * Easing functions are used throughout the animation system.
  71768. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71769. */
  71770. export interface IEasingFunction {
  71771. /**
  71772. * Given an input gradient between 0 and 1, this returns the corrseponding value
  71773. * of the easing function.
  71774. * The link below provides some of the most common examples of easing functions.
  71775. * @see https://easings.net/
  71776. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71777. * @returns the corresponding value on the curve defined by the easing function
  71778. */
  71779. ease(gradient: number): number;
  71780. }
  71781. /**
  71782. * Base class used for every default easing function.
  71783. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71784. */
  71785. export class EasingFunction implements IEasingFunction {
  71786. /**
  71787. * Interpolation follows the mathematical formula associated with the easing function.
  71788. */
  71789. static readonly EASINGMODE_EASEIN: number;
  71790. /**
  71791. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  71792. */
  71793. static readonly EASINGMODE_EASEOUT: number;
  71794. /**
  71795. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71796. */
  71797. static readonly EASINGMODE_EASEINOUT: number;
  71798. private _easingMode;
  71799. /**
  71800. * Sets the easing mode of the current function.
  71801. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71802. */
  71803. setEasingMode(easingMode: number): void;
  71804. /**
  71805. * Gets the current easing mode.
  71806. * @returns the easing mode
  71807. */
  71808. getEasingMode(): number;
  71809. /**
  71810. * @hidden
  71811. */
  71812. easeInCore(gradient: number): number;
  71813. /**
  71814. * Given an input gradient between 0 and 1, this returns the corresponding value
  71815. * of the easing function.
  71816. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71817. * @returns the corresponding value on the curve defined by the easing function
  71818. */
  71819. ease(gradient: number): number;
  71820. }
  71821. /**
  71822. * Easing function with a circle shape (see link below).
  71823. * @see https://easings.net/#easeInCirc
  71824. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71825. */
  71826. export class CircleEase extends EasingFunction implements IEasingFunction {
  71827. /** @hidden */
  71828. easeInCore(gradient: number): number;
  71829. }
  71830. /**
  71831. * Easing function with a ease back shape (see link below).
  71832. * @see https://easings.net/#easeInBack
  71833. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71834. */
  71835. export class BackEase extends EasingFunction implements IEasingFunction {
  71836. /** Defines the amplitude of the function */
  71837. amplitude: number;
  71838. /**
  71839. * Instantiates a back ease easing
  71840. * @see https://easings.net/#easeInBack
  71841. * @param amplitude Defines the amplitude of the function
  71842. */
  71843. constructor(
  71844. /** Defines the amplitude of the function */
  71845. amplitude?: number);
  71846. /** @hidden */
  71847. easeInCore(gradient: number): number;
  71848. }
  71849. /**
  71850. * Easing function with a bouncing shape (see link below).
  71851. * @see https://easings.net/#easeInBounce
  71852. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71853. */
  71854. export class BounceEase extends EasingFunction implements IEasingFunction {
  71855. /** Defines the number of bounces */
  71856. bounces: number;
  71857. /** Defines the amplitude of the bounce */
  71858. bounciness: number;
  71859. /**
  71860. * Instantiates a bounce easing
  71861. * @see https://easings.net/#easeInBounce
  71862. * @param bounces Defines the number of bounces
  71863. * @param bounciness Defines the amplitude of the bounce
  71864. */
  71865. constructor(
  71866. /** Defines the number of bounces */
  71867. bounces?: number,
  71868. /** Defines the amplitude of the bounce */
  71869. bounciness?: number);
  71870. /** @hidden */
  71871. easeInCore(gradient: number): number;
  71872. }
  71873. /**
  71874. * Easing function with a power of 3 shape (see link below).
  71875. * @see https://easings.net/#easeInCubic
  71876. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71877. */
  71878. export class CubicEase extends EasingFunction implements IEasingFunction {
  71879. /** @hidden */
  71880. easeInCore(gradient: number): number;
  71881. }
  71882. /**
  71883. * Easing function with an elastic shape (see link below).
  71884. * @see https://easings.net/#easeInElastic
  71885. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71886. */
  71887. export class ElasticEase extends EasingFunction implements IEasingFunction {
  71888. /** Defines the number of oscillations*/
  71889. oscillations: number;
  71890. /** Defines the amplitude of the oscillations*/
  71891. springiness: number;
  71892. /**
  71893. * Instantiates an elastic easing function
  71894. * @see https://easings.net/#easeInElastic
  71895. * @param oscillations Defines the number of oscillations
  71896. * @param springiness Defines the amplitude of the oscillations
  71897. */
  71898. constructor(
  71899. /** Defines the number of oscillations*/
  71900. oscillations?: number,
  71901. /** Defines the amplitude of the oscillations*/
  71902. springiness?: number);
  71903. /** @hidden */
  71904. easeInCore(gradient: number): number;
  71905. }
  71906. /**
  71907. * Easing function with an exponential shape (see link below).
  71908. * @see https://easings.net/#easeInExpo
  71909. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71910. */
  71911. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  71912. /** Defines the exponent of the function */
  71913. exponent: number;
  71914. /**
  71915. * Instantiates an exponential easing function
  71916. * @see https://easings.net/#easeInExpo
  71917. * @param exponent Defines the exponent of the function
  71918. */
  71919. constructor(
  71920. /** Defines the exponent of the function */
  71921. exponent?: number);
  71922. /** @hidden */
  71923. easeInCore(gradient: number): number;
  71924. }
  71925. /**
  71926. * Easing function with a power shape (see link below).
  71927. * @see https://easings.net/#easeInQuad
  71928. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71929. */
  71930. export class PowerEase extends EasingFunction implements IEasingFunction {
  71931. /** Defines the power of the function */
  71932. power: number;
  71933. /**
  71934. * Instantiates an power base easing function
  71935. * @see https://easings.net/#easeInQuad
  71936. * @param power Defines the power of the function
  71937. */
  71938. constructor(
  71939. /** Defines the power of the function */
  71940. power?: number);
  71941. /** @hidden */
  71942. easeInCore(gradient: number): number;
  71943. }
  71944. /**
  71945. * Easing function with a power of 2 shape (see link below).
  71946. * @see https://easings.net/#easeInQuad
  71947. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71948. */
  71949. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  71950. /** @hidden */
  71951. easeInCore(gradient: number): number;
  71952. }
  71953. /**
  71954. * Easing function with a power of 4 shape (see link below).
  71955. * @see https://easings.net/#easeInQuart
  71956. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71957. */
  71958. export class QuarticEase extends EasingFunction implements IEasingFunction {
  71959. /** @hidden */
  71960. easeInCore(gradient: number): number;
  71961. }
  71962. /**
  71963. * Easing function with a power of 5 shape (see link below).
  71964. * @see https://easings.net/#easeInQuint
  71965. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71966. */
  71967. export class QuinticEase extends EasingFunction implements IEasingFunction {
  71968. /** @hidden */
  71969. easeInCore(gradient: number): number;
  71970. }
  71971. /**
  71972. * Easing function with a sin shape (see link below).
  71973. * @see https://easings.net/#easeInSine
  71974. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71975. */
  71976. export class SineEase extends EasingFunction implements IEasingFunction {
  71977. /** @hidden */
  71978. easeInCore(gradient: number): number;
  71979. }
  71980. /**
  71981. * Easing function with a bezier shape (see link below).
  71982. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71983. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71984. */
  71985. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  71986. /** Defines the x component of the start tangent in the bezier curve */
  71987. x1: number;
  71988. /** Defines the y component of the start tangent in the bezier curve */
  71989. y1: number;
  71990. /** Defines the x component of the end tangent in the bezier curve */
  71991. x2: number;
  71992. /** Defines the y component of the end tangent in the bezier curve */
  71993. y2: number;
  71994. /**
  71995. * Instantiates a bezier function
  71996. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71997. * @param x1 Defines the x component of the start tangent in the bezier curve
  71998. * @param y1 Defines the y component of the start tangent in the bezier curve
  71999. * @param x2 Defines the x component of the end tangent in the bezier curve
  72000. * @param y2 Defines the y component of the end tangent in the bezier curve
  72001. */
  72002. constructor(
  72003. /** Defines the x component of the start tangent in the bezier curve */
  72004. x1?: number,
  72005. /** Defines the y component of the start tangent in the bezier curve */
  72006. y1?: number,
  72007. /** Defines the x component of the end tangent in the bezier curve */
  72008. x2?: number,
  72009. /** Defines the y component of the end tangent in the bezier curve */
  72010. y2?: number);
  72011. /** @hidden */
  72012. easeInCore(gradient: number): number;
  72013. }
  72014. }
  72015. declare module BABYLON {
  72016. /**
  72017. * Defines an interface which represents an animation key frame
  72018. */
  72019. export interface IAnimationKey {
  72020. /**
  72021. * Frame of the key frame
  72022. */
  72023. frame: number;
  72024. /**
  72025. * Value at the specifies key frame
  72026. */
  72027. value: any;
  72028. /**
  72029. * The input tangent for the cubic hermite spline
  72030. */
  72031. inTangent?: any;
  72032. /**
  72033. * The output tangent for the cubic hermite spline
  72034. */
  72035. outTangent?: any;
  72036. /**
  72037. * The animation interpolation type
  72038. */
  72039. interpolation?: AnimationKeyInterpolation;
  72040. }
  72041. /**
  72042. * Enum for the animation key frame interpolation type
  72043. */
  72044. export enum AnimationKeyInterpolation {
  72045. /**
  72046. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72047. */
  72048. STEP = 1
  72049. }
  72050. }
  72051. declare module BABYLON {
  72052. /**
  72053. * Represents the range of an animation
  72054. */
  72055. export class AnimationRange {
  72056. /**The name of the animation range**/
  72057. name: string;
  72058. /**The starting frame of the animation */
  72059. from: number;
  72060. /**The ending frame of the animation*/
  72061. to: number;
  72062. /**
  72063. * Initializes the range of an animation
  72064. * @param name The name of the animation range
  72065. * @param from The starting frame of the animation
  72066. * @param to The ending frame of the animation
  72067. */
  72068. constructor(
  72069. /**The name of the animation range**/
  72070. name: string,
  72071. /**The starting frame of the animation */
  72072. from: number,
  72073. /**The ending frame of the animation*/
  72074. to: number);
  72075. /**
  72076. * Makes a copy of the animation range
  72077. * @returns A copy of the animation range
  72078. */
  72079. clone(): AnimationRange;
  72080. }
  72081. }
  72082. declare module BABYLON {
  72083. /**
  72084. * Composed of a frame, and an action function
  72085. */
  72086. export class AnimationEvent {
  72087. /** The frame for which the event is triggered **/
  72088. frame: number;
  72089. /** The event to perform when triggered **/
  72090. action: (currentFrame: number) => void;
  72091. /** Specifies if the event should be triggered only once**/
  72092. onlyOnce?: boolean | undefined;
  72093. /**
  72094. * Specifies if the animation event is done
  72095. */
  72096. isDone: boolean;
  72097. /**
  72098. * Initializes the animation event
  72099. * @param frame The frame for which the event is triggered
  72100. * @param action The event to perform when triggered
  72101. * @param onlyOnce Specifies if the event should be triggered only once
  72102. */
  72103. constructor(
  72104. /** The frame for which the event is triggered **/
  72105. frame: number,
  72106. /** The event to perform when triggered **/
  72107. action: (currentFrame: number) => void,
  72108. /** Specifies if the event should be triggered only once**/
  72109. onlyOnce?: boolean | undefined);
  72110. /** @hidden */
  72111. _clone(): AnimationEvent;
  72112. }
  72113. }
  72114. declare module BABYLON {
  72115. /**
  72116. * Interface used to define a behavior
  72117. */
  72118. export interface Behavior<T> {
  72119. /** gets or sets behavior's name */
  72120. name: string;
  72121. /**
  72122. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72123. */
  72124. init(): void;
  72125. /**
  72126. * Called when the behavior is attached to a target
  72127. * @param target defines the target where the behavior is attached to
  72128. */
  72129. attach(target: T): void;
  72130. /**
  72131. * Called when the behavior is detached from its target
  72132. */
  72133. detach(): void;
  72134. }
  72135. /**
  72136. * Interface implemented by classes supporting behaviors
  72137. */
  72138. export interface IBehaviorAware<T> {
  72139. /**
  72140. * Attach a behavior
  72141. * @param behavior defines the behavior to attach
  72142. * @returns the current host
  72143. */
  72144. addBehavior(behavior: Behavior<T>): T;
  72145. /**
  72146. * Remove a behavior from the current object
  72147. * @param behavior defines the behavior to detach
  72148. * @returns the current host
  72149. */
  72150. removeBehavior(behavior: Behavior<T>): T;
  72151. /**
  72152. * Gets a behavior using its name to search
  72153. * @param name defines the name to search
  72154. * @returns the behavior or null if not found
  72155. */
  72156. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72157. }
  72158. }
  72159. declare module BABYLON {
  72160. /**
  72161. * Defines an array and its length.
  72162. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72163. */
  72164. export interface ISmartArrayLike<T> {
  72165. /**
  72166. * The data of the array.
  72167. */
  72168. data: Array<T>;
  72169. /**
  72170. * The active length of the array.
  72171. */
  72172. length: number;
  72173. }
  72174. /**
  72175. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72176. */
  72177. export class SmartArray<T> implements ISmartArrayLike<T> {
  72178. /**
  72179. * The full set of data from the array.
  72180. */
  72181. data: Array<T>;
  72182. /**
  72183. * The active length of the array.
  72184. */
  72185. length: number;
  72186. protected _id: number;
  72187. /**
  72188. * Instantiates a Smart Array.
  72189. * @param capacity defines the default capacity of the array.
  72190. */
  72191. constructor(capacity: number);
  72192. /**
  72193. * Pushes a value at the end of the active data.
  72194. * @param value defines the object to push in the array.
  72195. */
  72196. push(value: T): void;
  72197. /**
  72198. * Iterates over the active data and apply the lambda to them.
  72199. * @param func defines the action to apply on each value.
  72200. */
  72201. forEach(func: (content: T) => void): void;
  72202. /**
  72203. * Sorts the full sets of data.
  72204. * @param compareFn defines the comparison function to apply.
  72205. */
  72206. sort(compareFn: (a: T, b: T) => number): void;
  72207. /**
  72208. * Resets the active data to an empty array.
  72209. */
  72210. reset(): void;
  72211. /**
  72212. * Releases all the data from the array as well as the array.
  72213. */
  72214. dispose(): void;
  72215. /**
  72216. * Concats the active data with a given array.
  72217. * @param array defines the data to concatenate with.
  72218. */
  72219. concat(array: any): void;
  72220. /**
  72221. * Returns the position of a value in the active data.
  72222. * @param value defines the value to find the index for
  72223. * @returns the index if found in the active data otherwise -1
  72224. */
  72225. indexOf(value: T): number;
  72226. /**
  72227. * Returns whether an element is part of the active data.
  72228. * @param value defines the value to look for
  72229. * @returns true if found in the active data otherwise false
  72230. */
  72231. contains(value: T): boolean;
  72232. private static _GlobalId;
  72233. }
  72234. /**
  72235. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72236. * The data in this array can only be present once
  72237. */
  72238. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72239. private _duplicateId;
  72240. /**
  72241. * Pushes a value at the end of the active data.
  72242. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72243. * @param value defines the object to push in the array.
  72244. */
  72245. push(value: T): void;
  72246. /**
  72247. * Pushes a value at the end of the active data.
  72248. * If the data is already present, it won t be added again
  72249. * @param value defines the object to push in the array.
  72250. * @returns true if added false if it was already present
  72251. */
  72252. pushNoDuplicate(value: T): boolean;
  72253. /**
  72254. * Resets the active data to an empty array.
  72255. */
  72256. reset(): void;
  72257. /**
  72258. * Concats the active data with a given array.
  72259. * This ensures no dupplicate will be present in the result.
  72260. * @param array defines the data to concatenate with.
  72261. */
  72262. concatWithNoDuplicate(array: any): void;
  72263. }
  72264. }
  72265. declare module BABYLON {
  72266. /**
  72267. * @ignore
  72268. * This is a list of all the different input types that are available in the application.
  72269. * Fo instance: ArcRotateCameraGamepadInput...
  72270. */
  72271. export var CameraInputTypes: {};
  72272. /**
  72273. * This is the contract to implement in order to create a new input class.
  72274. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72275. */
  72276. export interface ICameraInput<TCamera extends Camera> {
  72277. /**
  72278. * Defines the camera the input is attached to.
  72279. */
  72280. camera: Nullable<TCamera>;
  72281. /**
  72282. * Gets the class name of the current intput.
  72283. * @returns the class name
  72284. */
  72285. getClassName(): string;
  72286. /**
  72287. * Get the friendly name associated with the input class.
  72288. * @returns the input friendly name
  72289. */
  72290. getSimpleName(): string;
  72291. /**
  72292. * Attach the input controls to a specific dom element to get the input from.
  72293. * @param element Defines the element the controls should be listened from
  72294. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72295. */
  72296. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72297. /**
  72298. * Detach the current controls from the specified dom element.
  72299. * @param element Defines the element to stop listening the inputs from
  72300. */
  72301. detachControl(element: Nullable<HTMLElement>): void;
  72302. /**
  72303. * Update the current camera state depending on the inputs that have been used this frame.
  72304. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72305. */
  72306. checkInputs?: () => void;
  72307. }
  72308. /**
  72309. * Represents a map of input types to input instance or input index to input instance.
  72310. */
  72311. export interface CameraInputsMap<TCamera extends Camera> {
  72312. /**
  72313. * Accessor to the input by input type.
  72314. */
  72315. [name: string]: ICameraInput<TCamera>;
  72316. /**
  72317. * Accessor to the input by input index.
  72318. */
  72319. [idx: number]: ICameraInput<TCamera>;
  72320. }
  72321. /**
  72322. * This represents the input manager used within a camera.
  72323. * It helps dealing with all the different kind of input attached to a camera.
  72324. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72325. */
  72326. export class CameraInputsManager<TCamera extends Camera> {
  72327. /**
  72328. * Defines the list of inputs attahed to the camera.
  72329. */
  72330. attached: CameraInputsMap<TCamera>;
  72331. /**
  72332. * Defines the dom element the camera is collecting inputs from.
  72333. * This is null if the controls have not been attached.
  72334. */
  72335. attachedElement: Nullable<HTMLElement>;
  72336. /**
  72337. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72338. */
  72339. noPreventDefault: boolean;
  72340. /**
  72341. * Defined the camera the input manager belongs to.
  72342. */
  72343. camera: TCamera;
  72344. /**
  72345. * Update the current camera state depending on the inputs that have been used this frame.
  72346. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72347. */
  72348. checkInputs: () => void;
  72349. /**
  72350. * Instantiate a new Camera Input Manager.
  72351. * @param camera Defines the camera the input manager blongs to
  72352. */
  72353. constructor(camera: TCamera);
  72354. /**
  72355. * Add an input method to a camera
  72356. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72357. * @param input camera input method
  72358. */
  72359. add(input: ICameraInput<TCamera>): void;
  72360. /**
  72361. * Remove a specific input method from a camera
  72362. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72363. * @param inputToRemove camera input method
  72364. */
  72365. remove(inputToRemove: ICameraInput<TCamera>): void;
  72366. /**
  72367. * Remove a specific input type from a camera
  72368. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72369. * @param inputType the type of the input to remove
  72370. */
  72371. removeByType(inputType: string): void;
  72372. private _addCheckInputs;
  72373. /**
  72374. * Attach the input controls to the currently attached dom element to listen the events from.
  72375. * @param input Defines the input to attach
  72376. */
  72377. attachInput(input: ICameraInput<TCamera>): void;
  72378. /**
  72379. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72380. * @param element Defines the dom element to collect the events from
  72381. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72382. */
  72383. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72384. /**
  72385. * Detach the current manager inputs controls from a specific dom element.
  72386. * @param element Defines the dom element to collect the events from
  72387. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72388. */
  72389. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72390. /**
  72391. * Rebuild the dynamic inputCheck function from the current list of
  72392. * defined inputs in the manager.
  72393. */
  72394. rebuildInputCheck(): void;
  72395. /**
  72396. * Remove all attached input methods from a camera
  72397. */
  72398. clear(): void;
  72399. /**
  72400. * Serialize the current input manager attached to a camera.
  72401. * This ensures than once parsed,
  72402. * the input associated to the camera will be identical to the current ones
  72403. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72404. */
  72405. serialize(serializedCamera: any): void;
  72406. /**
  72407. * Parses an input manager serialized JSON to restore the previous list of inputs
  72408. * and states associated to a camera.
  72409. * @param parsedCamera Defines the JSON to parse
  72410. */
  72411. parse(parsedCamera: any): void;
  72412. }
  72413. }
  72414. declare module BABYLON {
  72415. /**
  72416. * @hidden
  72417. */
  72418. export class IntersectionInfo {
  72419. bu: Nullable<number>;
  72420. bv: Nullable<number>;
  72421. distance: number;
  72422. faceId: number;
  72423. subMeshId: number;
  72424. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  72425. }
  72426. }
  72427. declare module BABYLON {
  72428. /**
  72429. * Represens a plane by the equation ax + by + cz + d = 0
  72430. */
  72431. export class Plane {
  72432. private static _TmpMatrix;
  72433. /**
  72434. * Normal of the plane (a,b,c)
  72435. */
  72436. normal: Vector3;
  72437. /**
  72438. * d component of the plane
  72439. */
  72440. d: number;
  72441. /**
  72442. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  72443. * @param a a component of the plane
  72444. * @param b b component of the plane
  72445. * @param c c component of the plane
  72446. * @param d d component of the plane
  72447. */
  72448. constructor(a: number, b: number, c: number, d: number);
  72449. /**
  72450. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  72451. */
  72452. asArray(): number[];
  72453. /**
  72454. * @returns a new plane copied from the current Plane.
  72455. */
  72456. clone(): Plane;
  72457. /**
  72458. * @returns the string "Plane".
  72459. */
  72460. getClassName(): string;
  72461. /**
  72462. * @returns the Plane hash code.
  72463. */
  72464. getHashCode(): number;
  72465. /**
  72466. * Normalize the current Plane in place.
  72467. * @returns the updated Plane.
  72468. */
  72469. normalize(): Plane;
  72470. /**
  72471. * Applies a transformation the plane and returns the result
  72472. * @param transformation the transformation matrix to be applied to the plane
  72473. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  72474. */
  72475. transform(transformation: DeepImmutable<Matrix>): Plane;
  72476. /**
  72477. * Calcualtte the dot product between the point and the plane normal
  72478. * @param point point to calculate the dot product with
  72479. * @returns the dot product (float) of the point coordinates and the plane normal.
  72480. */
  72481. dotCoordinate(point: DeepImmutable<Vector3>): number;
  72482. /**
  72483. * Updates the current Plane from the plane defined by the three given points.
  72484. * @param point1 one of the points used to contruct the plane
  72485. * @param point2 one of the points used to contruct the plane
  72486. * @param point3 one of the points used to contruct the plane
  72487. * @returns the updated Plane.
  72488. */
  72489. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72490. /**
  72491. * Checks if the plane is facing a given direction
  72492. * @param direction the direction to check if the plane is facing
  72493. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  72494. * @returns True is the vector "direction" is the same side than the plane normal.
  72495. */
  72496. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  72497. /**
  72498. * Calculates the distance to a point
  72499. * @param point point to calculate distance to
  72500. * @returns the signed distance (float) from the given point to the Plane.
  72501. */
  72502. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  72503. /**
  72504. * Creates a plane from an array
  72505. * @param array the array to create a plane from
  72506. * @returns a new Plane from the given array.
  72507. */
  72508. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  72509. /**
  72510. * Creates a plane from three points
  72511. * @param point1 point used to create the plane
  72512. * @param point2 point used to create the plane
  72513. * @param point3 point used to create the plane
  72514. * @returns a new Plane defined by the three given points.
  72515. */
  72516. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72517. /**
  72518. * Creates a plane from an origin point and a normal
  72519. * @param origin origin of the plane to be constructed
  72520. * @param normal normal of the plane to be constructed
  72521. * @returns a new Plane the normal vector to this plane at the given origin point.
  72522. * Note : the vector "normal" is updated because normalized.
  72523. */
  72524. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  72525. /**
  72526. * Calculates the distance from a plane and a point
  72527. * @param origin origin of the plane to be constructed
  72528. * @param normal normal of the plane to be constructed
  72529. * @param point point to calculate distance to
  72530. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  72531. */
  72532. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  72533. }
  72534. }
  72535. declare module BABYLON {
  72536. /**
  72537. * Class used to store bounding sphere information
  72538. */
  72539. export class BoundingSphere {
  72540. /**
  72541. * Gets the center of the bounding sphere in local space
  72542. */
  72543. readonly center: Vector3;
  72544. /**
  72545. * Radius of the bounding sphere in local space
  72546. */
  72547. radius: number;
  72548. /**
  72549. * Gets the center of the bounding sphere in world space
  72550. */
  72551. readonly centerWorld: Vector3;
  72552. /**
  72553. * Radius of the bounding sphere in world space
  72554. */
  72555. radiusWorld: number;
  72556. /**
  72557. * Gets the minimum vector in local space
  72558. */
  72559. readonly minimum: Vector3;
  72560. /**
  72561. * Gets the maximum vector in local space
  72562. */
  72563. readonly maximum: Vector3;
  72564. private _worldMatrix;
  72565. private static readonly TmpVector3;
  72566. /**
  72567. * Creates a new bounding sphere
  72568. * @param min defines the minimum vector (in local space)
  72569. * @param max defines the maximum vector (in local space)
  72570. * @param worldMatrix defines the new world matrix
  72571. */
  72572. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72573. /**
  72574. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  72575. * @param min defines the new minimum vector (in local space)
  72576. * @param max defines the new maximum vector (in local space)
  72577. * @param worldMatrix defines the new world matrix
  72578. */
  72579. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72580. /**
  72581. * Scale the current bounding sphere by applying a scale factor
  72582. * @param factor defines the scale factor to apply
  72583. * @returns the current bounding box
  72584. */
  72585. scale(factor: number): BoundingSphere;
  72586. /**
  72587. * Gets the world matrix of the bounding box
  72588. * @returns a matrix
  72589. */
  72590. getWorldMatrix(): DeepImmutable<Matrix>;
  72591. /** @hidden */
  72592. _update(worldMatrix: DeepImmutable<Matrix>): void;
  72593. /**
  72594. * Tests if the bounding sphere is intersecting the frustum planes
  72595. * @param frustumPlanes defines the frustum planes to test
  72596. * @returns true if there is an intersection
  72597. */
  72598. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72599. /**
  72600. * Tests if the bounding sphere center is in between the frustum planes.
  72601. * Used for optimistic fast inclusion.
  72602. * @param frustumPlanes defines the frustum planes to test
  72603. * @returns true if the sphere center is in between the frustum planes
  72604. */
  72605. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72606. /**
  72607. * Tests if a point is inside the bounding sphere
  72608. * @param point defines the point to test
  72609. * @returns true if the point is inside the bounding sphere
  72610. */
  72611. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72612. /**
  72613. * Checks if two sphere intersct
  72614. * @param sphere0 sphere 0
  72615. * @param sphere1 sphere 1
  72616. * @returns true if the speres intersect
  72617. */
  72618. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  72619. }
  72620. }
  72621. declare module BABYLON {
  72622. /**
  72623. * Class used to store bounding box information
  72624. */
  72625. export class BoundingBox implements ICullable {
  72626. /**
  72627. * Gets the 8 vectors representing the bounding box in local space
  72628. */
  72629. readonly vectors: Vector3[];
  72630. /**
  72631. * Gets the center of the bounding box in local space
  72632. */
  72633. readonly center: Vector3;
  72634. /**
  72635. * Gets the center of the bounding box in world space
  72636. */
  72637. readonly centerWorld: Vector3;
  72638. /**
  72639. * Gets the extend size in local space
  72640. */
  72641. readonly extendSize: Vector3;
  72642. /**
  72643. * Gets the extend size in world space
  72644. */
  72645. readonly extendSizeWorld: Vector3;
  72646. /**
  72647. * Gets the OBB (object bounding box) directions
  72648. */
  72649. readonly directions: Vector3[];
  72650. /**
  72651. * Gets the 8 vectors representing the bounding box in world space
  72652. */
  72653. readonly vectorsWorld: Vector3[];
  72654. /**
  72655. * Gets the minimum vector in world space
  72656. */
  72657. readonly minimumWorld: Vector3;
  72658. /**
  72659. * Gets the maximum vector in world space
  72660. */
  72661. readonly maximumWorld: Vector3;
  72662. /**
  72663. * Gets the minimum vector in local space
  72664. */
  72665. readonly minimum: Vector3;
  72666. /**
  72667. * Gets the maximum vector in local space
  72668. */
  72669. readonly maximum: Vector3;
  72670. private _worldMatrix;
  72671. private static readonly TmpVector3;
  72672. /**
  72673. * @hidden
  72674. */
  72675. _tag: number;
  72676. /**
  72677. * Creates a new bounding box
  72678. * @param min defines the minimum vector (in local space)
  72679. * @param max defines the maximum vector (in local space)
  72680. * @param worldMatrix defines the new world matrix
  72681. */
  72682. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72683. /**
  72684. * Recreates the entire bounding box from scratch as if we call the constructor in place
  72685. * @param min defines the new minimum vector (in local space)
  72686. * @param max defines the new maximum vector (in local space)
  72687. * @param worldMatrix defines the new world matrix
  72688. */
  72689. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72690. /**
  72691. * Scale the current bounding box by applying a scale factor
  72692. * @param factor defines the scale factor to apply
  72693. * @returns the current bounding box
  72694. */
  72695. scale(factor: number): BoundingBox;
  72696. /**
  72697. * Gets the world matrix of the bounding box
  72698. * @returns a matrix
  72699. */
  72700. getWorldMatrix(): DeepImmutable<Matrix>;
  72701. /** @hidden */
  72702. _update(world: DeepImmutable<Matrix>): void;
  72703. /**
  72704. * Tests if the bounding box is intersecting the frustum planes
  72705. * @param frustumPlanes defines the frustum planes to test
  72706. * @returns true if there is an intersection
  72707. */
  72708. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72709. /**
  72710. * Tests if the bounding box is entirely inside the frustum planes
  72711. * @param frustumPlanes defines the frustum planes to test
  72712. * @returns true if there is an inclusion
  72713. */
  72714. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72715. /**
  72716. * Tests if a point is inside the bounding box
  72717. * @param point defines the point to test
  72718. * @returns true if the point is inside the bounding box
  72719. */
  72720. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72721. /**
  72722. * Tests if the bounding box intersects with a bounding sphere
  72723. * @param sphere defines the sphere to test
  72724. * @returns true if there is an intersection
  72725. */
  72726. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  72727. /**
  72728. * Tests if the bounding box intersects with a box defined by a min and max vectors
  72729. * @param min defines the min vector to use
  72730. * @param max defines the max vector to use
  72731. * @returns true if there is an intersection
  72732. */
  72733. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  72734. /**
  72735. * Tests if two bounding boxes are intersections
  72736. * @param box0 defines the first box to test
  72737. * @param box1 defines the second box to test
  72738. * @returns true if there is an intersection
  72739. */
  72740. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  72741. /**
  72742. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  72743. * @param minPoint defines the minimum vector of the bounding box
  72744. * @param maxPoint defines the maximum vector of the bounding box
  72745. * @param sphereCenter defines the sphere center
  72746. * @param sphereRadius defines the sphere radius
  72747. * @returns true if there is an intersection
  72748. */
  72749. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  72750. /**
  72751. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  72752. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72753. * @param frustumPlanes defines the frustum planes to test
  72754. * @return true if there is an inclusion
  72755. */
  72756. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72757. /**
  72758. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  72759. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72760. * @param frustumPlanes defines the frustum planes to test
  72761. * @return true if there is an intersection
  72762. */
  72763. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72764. }
  72765. }
  72766. declare module BABYLON {
  72767. /** @hidden */
  72768. export class Collider {
  72769. /** Define if a collision was found */
  72770. collisionFound: boolean;
  72771. /**
  72772. * Define last intersection point in local space
  72773. */
  72774. intersectionPoint: Vector3;
  72775. /**
  72776. * Define last collided mesh
  72777. */
  72778. collidedMesh: Nullable<AbstractMesh>;
  72779. private _collisionPoint;
  72780. private _planeIntersectionPoint;
  72781. private _tempVector;
  72782. private _tempVector2;
  72783. private _tempVector3;
  72784. private _tempVector4;
  72785. private _edge;
  72786. private _baseToVertex;
  72787. private _destinationPoint;
  72788. private _slidePlaneNormal;
  72789. private _displacementVector;
  72790. /** @hidden */
  72791. _radius: Vector3;
  72792. /** @hidden */
  72793. _retry: number;
  72794. private _velocity;
  72795. private _basePoint;
  72796. private _epsilon;
  72797. /** @hidden */
  72798. _velocityWorldLength: number;
  72799. /** @hidden */
  72800. _basePointWorld: Vector3;
  72801. private _velocityWorld;
  72802. private _normalizedVelocity;
  72803. /** @hidden */
  72804. _initialVelocity: Vector3;
  72805. /** @hidden */
  72806. _initialPosition: Vector3;
  72807. private _nearestDistance;
  72808. private _collisionMask;
  72809. collisionMask: number;
  72810. /**
  72811. * Gets the plane normal used to compute the sliding response (in local space)
  72812. */
  72813. readonly slidePlaneNormal: Vector3;
  72814. /** @hidden */
  72815. _initialize(source: Vector3, dir: Vector3, e: number): void;
  72816. /** @hidden */
  72817. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  72818. /** @hidden */
  72819. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  72820. /** @hidden */
  72821. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72822. /** @hidden */
  72823. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72824. /** @hidden */
  72825. _getResponse(pos: Vector3, vel: Vector3): void;
  72826. }
  72827. }
  72828. declare module BABYLON {
  72829. /**
  72830. * Interface for cullable objects
  72831. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  72832. */
  72833. export interface ICullable {
  72834. /**
  72835. * Checks if the object or part of the object is in the frustum
  72836. * @param frustumPlanes Camera near/planes
  72837. * @returns true if the object is in frustum otherwise false
  72838. */
  72839. isInFrustum(frustumPlanes: Plane[]): boolean;
  72840. /**
  72841. * Checks if a cullable object (mesh...) is in the camera frustum
  72842. * Unlike isInFrustum this cheks the full bounding box
  72843. * @param frustumPlanes Camera near/planes
  72844. * @returns true if the object is in frustum otherwise false
  72845. */
  72846. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  72847. }
  72848. /**
  72849. * Info for a bounding data of a mesh
  72850. */
  72851. export class BoundingInfo implements ICullable {
  72852. /**
  72853. * Bounding box for the mesh
  72854. */
  72855. readonly boundingBox: BoundingBox;
  72856. /**
  72857. * Bounding sphere for the mesh
  72858. */
  72859. readonly boundingSphere: BoundingSphere;
  72860. private _isLocked;
  72861. private static readonly TmpVector3;
  72862. /**
  72863. * Constructs bounding info
  72864. * @param minimum min vector of the bounding box/sphere
  72865. * @param maximum max vector of the bounding box/sphere
  72866. * @param worldMatrix defines the new world matrix
  72867. */
  72868. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72869. /**
  72870. * Recreates the entire bounding info from scratch as if we call the constructor in place
  72871. * @param min defines the new minimum vector (in local space)
  72872. * @param max defines the new maximum vector (in local space)
  72873. * @param worldMatrix defines the new world matrix
  72874. */
  72875. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72876. /**
  72877. * min vector of the bounding box/sphere
  72878. */
  72879. readonly minimum: Vector3;
  72880. /**
  72881. * max vector of the bounding box/sphere
  72882. */
  72883. readonly maximum: Vector3;
  72884. /**
  72885. * If the info is locked and won't be updated to avoid perf overhead
  72886. */
  72887. isLocked: boolean;
  72888. /**
  72889. * Updates the bounding sphere and box
  72890. * @param world world matrix to be used to update
  72891. */
  72892. update(world: DeepImmutable<Matrix>): void;
  72893. /**
  72894. * Recreate the bounding info to be centered around a specific point given a specific extend.
  72895. * @param center New center of the bounding info
  72896. * @param extend New extend of the bounding info
  72897. * @returns the current bounding info
  72898. */
  72899. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  72900. /**
  72901. * Scale the current bounding info by applying a scale factor
  72902. * @param factor defines the scale factor to apply
  72903. * @returns the current bounding info
  72904. */
  72905. scale(factor: number): BoundingInfo;
  72906. /**
  72907. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  72908. * @param frustumPlanes defines the frustum to test
  72909. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  72910. * @returns true if the bounding info is in the frustum planes
  72911. */
  72912. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  72913. /**
  72914. * Gets the world distance between the min and max points of the bounding box
  72915. */
  72916. readonly diagonalLength: number;
  72917. /**
  72918. * Checks if a cullable object (mesh...) is in the camera frustum
  72919. * Unlike isInFrustum this cheks the full bounding box
  72920. * @param frustumPlanes Camera near/planes
  72921. * @returns true if the object is in frustum otherwise false
  72922. */
  72923. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72924. /** @hidden */
  72925. _checkCollision(collider: Collider): boolean;
  72926. /**
  72927. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  72928. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  72929. * @param point the point to check intersection with
  72930. * @returns if the point intersects
  72931. */
  72932. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72933. /**
  72934. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  72935. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  72936. * @param boundingInfo the bounding info to check intersection with
  72937. * @param precise if the intersection should be done using OBB
  72938. * @returns if the bounding info intersects
  72939. */
  72940. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  72941. }
  72942. }
  72943. declare module BABYLON {
  72944. /**
  72945. * Extracts minimum and maximum values from a list of indexed positions
  72946. * @param positions defines the positions to use
  72947. * @param indices defines the indices to the positions
  72948. * @param indexStart defines the start index
  72949. * @param indexCount defines the end index
  72950. * @param bias defines bias value to add to the result
  72951. * @return minimum and maximum values
  72952. */
  72953. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  72954. minimum: Vector3;
  72955. maximum: Vector3;
  72956. };
  72957. /**
  72958. * Extracts minimum and maximum values from a list of positions
  72959. * @param positions defines the positions to use
  72960. * @param start defines the start index in the positions array
  72961. * @param count defines the number of positions to handle
  72962. * @param bias defines bias value to add to the result
  72963. * @param stride defines the stride size to use (distance between two positions in the positions array)
  72964. * @return minimum and maximum values
  72965. */
  72966. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  72967. minimum: Vector3;
  72968. maximum: Vector3;
  72969. };
  72970. }
  72971. declare module BABYLON {
  72972. /**
  72973. * Enum that determines the text-wrapping mode to use.
  72974. */
  72975. export enum InspectableType {
  72976. /**
  72977. * Checkbox for booleans
  72978. */
  72979. Checkbox = 0,
  72980. /**
  72981. * Sliders for numbers
  72982. */
  72983. Slider = 1,
  72984. /**
  72985. * Vector3
  72986. */
  72987. Vector3 = 2,
  72988. /**
  72989. * Quaternions
  72990. */
  72991. Quaternion = 3,
  72992. /**
  72993. * Color3
  72994. */
  72995. Color3 = 4,
  72996. /**
  72997. * String
  72998. */
  72999. String = 5
  73000. }
  73001. /**
  73002. * Interface used to define custom inspectable properties.
  73003. * This interface is used by the inspector to display custom property grids
  73004. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73005. */
  73006. export interface IInspectable {
  73007. /**
  73008. * Gets the label to display
  73009. */
  73010. label: string;
  73011. /**
  73012. * Gets the name of the property to edit
  73013. */
  73014. propertyName: string;
  73015. /**
  73016. * Gets the type of the editor to use
  73017. */
  73018. type: InspectableType;
  73019. /**
  73020. * Gets the minimum value of the property when using in "slider" mode
  73021. */
  73022. min?: number;
  73023. /**
  73024. * Gets the maximum value of the property when using in "slider" mode
  73025. */
  73026. max?: number;
  73027. /**
  73028. * Gets the setp to use when using in "slider" mode
  73029. */
  73030. step?: number;
  73031. }
  73032. }
  73033. declare module BABYLON {
  73034. /**
  73035. * Class used to provide helper for timing
  73036. */
  73037. export class TimingTools {
  73038. /**
  73039. * Polyfill for setImmediate
  73040. * @param action defines the action to execute after the current execution block
  73041. */
  73042. static SetImmediate(action: () => void): void;
  73043. }
  73044. }
  73045. declare module BABYLON {
  73046. /**
  73047. * Class used to enable instatition of objects by class name
  73048. */
  73049. export class InstantiationTools {
  73050. /**
  73051. * Use this object to register external classes like custom textures or material
  73052. * to allow the laoders to instantiate them
  73053. */
  73054. static RegisteredExternalClasses: {
  73055. [key: string]: Object;
  73056. };
  73057. /**
  73058. * Tries to instantiate a new object from a given class name
  73059. * @param className defines the class name to instantiate
  73060. * @returns the new object or null if the system was not able to do the instantiation
  73061. */
  73062. static Instantiate(className: string): any;
  73063. }
  73064. }
  73065. declare module BABYLON {
  73066. /**
  73067. * This represents the required contract to create a new type of texture loader.
  73068. */
  73069. export interface IInternalTextureLoader {
  73070. /**
  73071. * Defines wether the loader supports cascade loading the different faces.
  73072. */
  73073. supportCascades: boolean;
  73074. /**
  73075. * This returns if the loader support the current file information.
  73076. * @param extension defines the file extension of the file being loaded
  73077. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73078. * @param fallback defines the fallback internal texture if any
  73079. * @param isBase64 defines whether the texture is encoded as a base64
  73080. * @param isBuffer defines whether the texture data are stored as a buffer
  73081. * @returns true if the loader can load the specified file
  73082. */
  73083. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  73084. /**
  73085. * Transform the url before loading if required.
  73086. * @param rootUrl the url of the texture
  73087. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73088. * @returns the transformed texture
  73089. */
  73090. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  73091. /**
  73092. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  73093. * @param rootUrl the url of the texture
  73094. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73095. * @returns the fallback texture
  73096. */
  73097. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  73098. /**
  73099. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  73100. * @param data contains the texture data
  73101. * @param texture defines the BabylonJS internal texture
  73102. * @param createPolynomials will be true if polynomials have been requested
  73103. * @param onLoad defines the callback to trigger once the texture is ready
  73104. * @param onError defines the callback to trigger in case of error
  73105. */
  73106. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  73107. /**
  73108. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  73109. * @param data contains the texture data
  73110. * @param texture defines the BabylonJS internal texture
  73111. * @param callback defines the method to call once ready to upload
  73112. */
  73113. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  73114. }
  73115. }
  73116. declare module BABYLON {
  73117. interface Engine {
  73118. /**
  73119. * Creates a depth stencil cube texture.
  73120. * This is only available in WebGL 2.
  73121. * @param size The size of face edge in the cube texture.
  73122. * @param options The options defining the cube texture.
  73123. * @returns The cube texture
  73124. */
  73125. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  73126. /**
  73127. * Creates a cube texture
  73128. * @param rootUrl defines the url where the files to load is located
  73129. * @param scene defines the current scene
  73130. * @param files defines the list of files to load (1 per face)
  73131. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73132. * @param onLoad defines an optional callback raised when the texture is loaded
  73133. * @param onError defines an optional callback raised if there is an issue to load the texture
  73134. * @param format defines the format of the data
  73135. * @param forcedExtension defines the extension to use to pick the right loader
  73136. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73137. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73138. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73139. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  73140. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  73141. * @returns the cube texture as an InternalTexture
  73142. */
  73143. 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;
  73144. /**
  73145. * Creates a cube texture
  73146. * @param rootUrl defines the url where the files to load is located
  73147. * @param scene defines the current scene
  73148. * @param files defines the list of files to load (1 per face)
  73149. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73150. * @param onLoad defines an optional callback raised when the texture is loaded
  73151. * @param onError defines an optional callback raised if there is an issue to load the texture
  73152. * @param format defines the format of the data
  73153. * @param forcedExtension defines the extension to use to pick the right loader
  73154. * @returns the cube texture as an InternalTexture
  73155. */
  73156. 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;
  73157. /**
  73158. * Creates a cube texture
  73159. * @param rootUrl defines the url where the files to load is located
  73160. * @param scene defines the current scene
  73161. * @param files defines the list of files to load (1 per face)
  73162. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73163. * @param onLoad defines an optional callback raised when the texture is loaded
  73164. * @param onError defines an optional callback raised if there is an issue to load the texture
  73165. * @param format defines the format of the data
  73166. * @param forcedExtension defines the extension to use to pick the right loader
  73167. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73168. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73169. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73170. * @returns the cube texture as an InternalTexture
  73171. */
  73172. 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;
  73173. /** @hidden */
  73174. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73175. /** @hidden */
  73176. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73177. /** @hidden */
  73178. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73179. /** @hidden */
  73180. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73181. }
  73182. }
  73183. declare module BABYLON {
  73184. /**
  73185. * Class for creating a cube texture
  73186. */
  73187. export class CubeTexture extends BaseTexture {
  73188. private _delayedOnLoad;
  73189. /**
  73190. * The url of the texture
  73191. */
  73192. url: string;
  73193. /**
  73194. * Gets or sets the center of the bounding box associated with the cube texture.
  73195. * It must define where the camera used to render the texture was set
  73196. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73197. */
  73198. boundingBoxPosition: Vector3;
  73199. private _boundingBoxSize;
  73200. /**
  73201. * Gets or sets the size of the bounding box associated with the cube texture
  73202. * When defined, the cubemap will switch to local mode
  73203. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  73204. * @example https://www.babylonjs-playground.com/#RNASML
  73205. */
  73206. /**
  73207. * Returns the bounding box size
  73208. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73209. */
  73210. boundingBoxSize: Vector3;
  73211. protected _rotationY: number;
  73212. /**
  73213. * Sets texture matrix rotation angle around Y axis in radians.
  73214. */
  73215. /**
  73216. * Gets texture matrix rotation angle around Y axis radians.
  73217. */
  73218. rotationY: number;
  73219. /**
  73220. * Are mip maps generated for this texture or not.
  73221. */
  73222. readonly noMipmap: boolean;
  73223. private _noMipmap;
  73224. private _files;
  73225. private _extensions;
  73226. private _textureMatrix;
  73227. private _format;
  73228. private _createPolynomials;
  73229. /** @hidden */
  73230. _prefiltered: boolean;
  73231. /**
  73232. * Creates a cube texture from an array of image urls
  73233. * @param files defines an array of image urls
  73234. * @param scene defines the hosting scene
  73235. * @param noMipmap specifies if mip maps are not used
  73236. * @returns a cube texture
  73237. */
  73238. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  73239. /**
  73240. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  73241. * @param url defines the url of the prefiltered texture
  73242. * @param scene defines the scene the texture is attached to
  73243. * @param forcedExtension defines the extension of the file if different from the url
  73244. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73245. * @return the prefiltered texture
  73246. */
  73247. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  73248. /**
  73249. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  73250. * as prefiltered data.
  73251. * @param rootUrl defines the url of the texture or the root name of the six images
  73252. * @param scene defines the scene the texture is attached to
  73253. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  73254. * @param noMipmap defines if mipmaps should be created or not
  73255. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  73256. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  73257. * @param onError defines a callback triggered in case of error during load
  73258. * @param format defines the internal format to use for the texture once loaded
  73259. * @param prefiltered defines whether or not the texture is created from prefiltered data
  73260. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  73261. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73262. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73263. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73264. * @return the cube texture
  73265. */
  73266. 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);
  73267. /**
  73268. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  73269. */
  73270. readonly isPrefiltered: boolean;
  73271. /**
  73272. * Get the current class name of the texture useful for serialization or dynamic coding.
  73273. * @returns "CubeTexture"
  73274. */
  73275. getClassName(): string;
  73276. /**
  73277. * Update the url (and optional buffer) of this texture if url was null during construction.
  73278. * @param url the url of the texture
  73279. * @param forcedExtension defines the extension to use
  73280. * @param onLoad callback called when the texture is loaded (defaults to null)
  73281. */
  73282. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  73283. /**
  73284. * Delays loading of the cube texture
  73285. * @param forcedExtension defines the extension to use
  73286. */
  73287. delayLoad(forcedExtension?: string): void;
  73288. /**
  73289. * Returns the reflection texture matrix
  73290. * @returns the reflection texture matrix
  73291. */
  73292. getReflectionTextureMatrix(): Matrix;
  73293. /**
  73294. * Sets the reflection texture matrix
  73295. * @param value Reflection texture matrix
  73296. */
  73297. setReflectionTextureMatrix(value: Matrix): void;
  73298. /**
  73299. * Parses text to create a cube texture
  73300. * @param parsedTexture define the serialized text to read from
  73301. * @param scene defines the hosting scene
  73302. * @param rootUrl defines the root url of the cube texture
  73303. * @returns a cube texture
  73304. */
  73305. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  73306. /**
  73307. * Makes a clone, or deep copy, of the cube texture
  73308. * @returns a new cube texture
  73309. */
  73310. clone(): CubeTexture;
  73311. }
  73312. }
  73313. declare module BABYLON {
  73314. /**
  73315. * Manages the defines for the Material
  73316. */
  73317. export class MaterialDefines {
  73318. /** @hidden */
  73319. protected _keys: string[];
  73320. private _isDirty;
  73321. /** @hidden */
  73322. _renderId: number;
  73323. /** @hidden */
  73324. _areLightsDirty: boolean;
  73325. /** @hidden */
  73326. _areLightsDisposed: boolean;
  73327. /** @hidden */
  73328. _areAttributesDirty: boolean;
  73329. /** @hidden */
  73330. _areTexturesDirty: boolean;
  73331. /** @hidden */
  73332. _areFresnelDirty: boolean;
  73333. /** @hidden */
  73334. _areMiscDirty: boolean;
  73335. /** @hidden */
  73336. _areImageProcessingDirty: boolean;
  73337. /** @hidden */
  73338. _normals: boolean;
  73339. /** @hidden */
  73340. _uvs: boolean;
  73341. /** @hidden */
  73342. _needNormals: boolean;
  73343. /** @hidden */
  73344. _needUVs: boolean;
  73345. [id: string]: any;
  73346. /**
  73347. * Specifies if the material needs to be re-calculated
  73348. */
  73349. readonly isDirty: boolean;
  73350. /**
  73351. * Marks the material to indicate that it has been re-calculated
  73352. */
  73353. markAsProcessed(): void;
  73354. /**
  73355. * Marks the material to indicate that it needs to be re-calculated
  73356. */
  73357. markAsUnprocessed(): void;
  73358. /**
  73359. * Marks the material to indicate all of its defines need to be re-calculated
  73360. */
  73361. markAllAsDirty(): void;
  73362. /**
  73363. * Marks the material to indicate that image processing needs to be re-calculated
  73364. */
  73365. markAsImageProcessingDirty(): void;
  73366. /**
  73367. * Marks the material to indicate the lights need to be re-calculated
  73368. * @param disposed Defines whether the light is dirty due to dispose or not
  73369. */
  73370. markAsLightDirty(disposed?: boolean): void;
  73371. /**
  73372. * Marks the attribute state as changed
  73373. */
  73374. markAsAttributesDirty(): void;
  73375. /**
  73376. * Marks the texture state as changed
  73377. */
  73378. markAsTexturesDirty(): void;
  73379. /**
  73380. * Marks the fresnel state as changed
  73381. */
  73382. markAsFresnelDirty(): void;
  73383. /**
  73384. * Marks the misc state as changed
  73385. */
  73386. markAsMiscDirty(): void;
  73387. /**
  73388. * Rebuilds the material defines
  73389. */
  73390. rebuild(): void;
  73391. /**
  73392. * Specifies if two material defines are equal
  73393. * @param other - A material define instance to compare to
  73394. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  73395. */
  73396. isEqual(other: MaterialDefines): boolean;
  73397. /**
  73398. * Clones this instance's defines to another instance
  73399. * @param other - material defines to clone values to
  73400. */
  73401. cloneTo(other: MaterialDefines): void;
  73402. /**
  73403. * Resets the material define values
  73404. */
  73405. reset(): void;
  73406. /**
  73407. * Converts the material define values to a string
  73408. * @returns - String of material define information
  73409. */
  73410. toString(): string;
  73411. }
  73412. }
  73413. declare module BABYLON {
  73414. /**
  73415. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  73416. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  73417. * 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;
  73418. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  73419. */
  73420. export class ColorCurves {
  73421. private _dirty;
  73422. private _tempColor;
  73423. private _globalCurve;
  73424. private _highlightsCurve;
  73425. private _midtonesCurve;
  73426. private _shadowsCurve;
  73427. private _positiveCurve;
  73428. private _negativeCurve;
  73429. private _globalHue;
  73430. private _globalDensity;
  73431. private _globalSaturation;
  73432. private _globalExposure;
  73433. /**
  73434. * Gets the global Hue value.
  73435. * 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).
  73436. */
  73437. /**
  73438. * Sets the global Hue value.
  73439. * 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).
  73440. */
  73441. globalHue: number;
  73442. /**
  73443. * Gets the global Density value.
  73444. * 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.
  73445. * Values less than zero provide a filter of opposite hue.
  73446. */
  73447. /**
  73448. * Sets the global Density value.
  73449. * 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.
  73450. * Values less than zero provide a filter of opposite hue.
  73451. */
  73452. globalDensity: number;
  73453. /**
  73454. * Gets the global Saturation value.
  73455. * 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.
  73456. */
  73457. /**
  73458. * Sets the global Saturation value.
  73459. * 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.
  73460. */
  73461. globalSaturation: number;
  73462. /**
  73463. * Gets the global Exposure value.
  73464. * 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.
  73465. */
  73466. /**
  73467. * Sets the global Exposure value.
  73468. * 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.
  73469. */
  73470. globalExposure: number;
  73471. private _highlightsHue;
  73472. private _highlightsDensity;
  73473. private _highlightsSaturation;
  73474. private _highlightsExposure;
  73475. /**
  73476. * Gets the highlights Hue value.
  73477. * 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).
  73478. */
  73479. /**
  73480. * Sets the highlights Hue value.
  73481. * 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).
  73482. */
  73483. highlightsHue: number;
  73484. /**
  73485. * Gets the highlights Density value.
  73486. * 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.
  73487. * Values less than zero provide a filter of opposite hue.
  73488. */
  73489. /**
  73490. * Sets the highlights Density value.
  73491. * 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.
  73492. * Values less than zero provide a filter of opposite hue.
  73493. */
  73494. highlightsDensity: number;
  73495. /**
  73496. * Gets the highlights Saturation value.
  73497. * 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.
  73498. */
  73499. /**
  73500. * Sets the highlights Saturation value.
  73501. * 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.
  73502. */
  73503. highlightsSaturation: number;
  73504. /**
  73505. * Gets the highlights Exposure value.
  73506. * 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.
  73507. */
  73508. /**
  73509. * Sets the highlights Exposure value.
  73510. * 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.
  73511. */
  73512. highlightsExposure: number;
  73513. private _midtonesHue;
  73514. private _midtonesDensity;
  73515. private _midtonesSaturation;
  73516. private _midtonesExposure;
  73517. /**
  73518. * Gets the midtones Hue value.
  73519. * 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).
  73520. */
  73521. /**
  73522. * Sets the midtones Hue value.
  73523. * 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).
  73524. */
  73525. midtonesHue: number;
  73526. /**
  73527. * Gets the midtones Density value.
  73528. * 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.
  73529. * Values less than zero provide a filter of opposite hue.
  73530. */
  73531. /**
  73532. * Sets the midtones Density value.
  73533. * 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.
  73534. * Values less than zero provide a filter of opposite hue.
  73535. */
  73536. midtonesDensity: number;
  73537. /**
  73538. * Gets the midtones Saturation value.
  73539. * 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.
  73540. */
  73541. /**
  73542. * Sets the midtones Saturation value.
  73543. * 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.
  73544. */
  73545. midtonesSaturation: number;
  73546. /**
  73547. * Gets the midtones Exposure value.
  73548. * 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.
  73549. */
  73550. /**
  73551. * Sets the midtones Exposure value.
  73552. * 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.
  73553. */
  73554. midtonesExposure: number;
  73555. private _shadowsHue;
  73556. private _shadowsDensity;
  73557. private _shadowsSaturation;
  73558. private _shadowsExposure;
  73559. /**
  73560. * Gets the shadows Hue value.
  73561. * 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).
  73562. */
  73563. /**
  73564. * Sets the shadows Hue value.
  73565. * 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).
  73566. */
  73567. shadowsHue: number;
  73568. /**
  73569. * Gets the shadows Density value.
  73570. * 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.
  73571. * Values less than zero provide a filter of opposite hue.
  73572. */
  73573. /**
  73574. * Sets the shadows Density value.
  73575. * 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.
  73576. * Values less than zero provide a filter of opposite hue.
  73577. */
  73578. shadowsDensity: number;
  73579. /**
  73580. * Gets the shadows Saturation value.
  73581. * 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.
  73582. */
  73583. /**
  73584. * Sets the shadows Saturation value.
  73585. * 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.
  73586. */
  73587. shadowsSaturation: number;
  73588. /**
  73589. * Gets the shadows Exposure value.
  73590. * 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.
  73591. */
  73592. /**
  73593. * Sets the shadows Exposure value.
  73594. * 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.
  73595. */
  73596. shadowsExposure: number;
  73597. /**
  73598. * Returns the class name
  73599. * @returns The class name
  73600. */
  73601. getClassName(): string;
  73602. /**
  73603. * Binds the color curves to the shader.
  73604. * @param colorCurves The color curve to bind
  73605. * @param effect The effect to bind to
  73606. * @param positiveUniform The positive uniform shader parameter
  73607. * @param neutralUniform The neutral uniform shader parameter
  73608. * @param negativeUniform The negative uniform shader parameter
  73609. */
  73610. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  73611. /**
  73612. * Prepare the list of uniforms associated with the ColorCurves effects.
  73613. * @param uniformsList The list of uniforms used in the effect
  73614. */
  73615. static PrepareUniforms(uniformsList: string[]): void;
  73616. /**
  73617. * Returns color grading data based on a hue, density, saturation and exposure value.
  73618. * @param filterHue The hue of the color filter.
  73619. * @param filterDensity The density of the color filter.
  73620. * @param saturation The saturation.
  73621. * @param exposure The exposure.
  73622. * @param result The result data container.
  73623. */
  73624. private getColorGradingDataToRef;
  73625. /**
  73626. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  73627. * @param value The input slider value in range [-100,100].
  73628. * @returns Adjusted value.
  73629. */
  73630. private static applyColorGradingSliderNonlinear;
  73631. /**
  73632. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  73633. * @param hue The hue (H) input.
  73634. * @param saturation The saturation (S) input.
  73635. * @param brightness The brightness (B) input.
  73636. * @result An RGBA color represented as Vector4.
  73637. */
  73638. private static fromHSBToRef;
  73639. /**
  73640. * Returns a value clamped between min and max
  73641. * @param value The value to clamp
  73642. * @param min The minimum of value
  73643. * @param max The maximum of value
  73644. * @returns The clamped value.
  73645. */
  73646. private static clamp;
  73647. /**
  73648. * Clones the current color curve instance.
  73649. * @return The cloned curves
  73650. */
  73651. clone(): ColorCurves;
  73652. /**
  73653. * Serializes the current color curve instance to a json representation.
  73654. * @return a JSON representation
  73655. */
  73656. serialize(): any;
  73657. /**
  73658. * Parses the color curve from a json representation.
  73659. * @param source the JSON source to parse
  73660. * @return The parsed curves
  73661. */
  73662. static Parse(source: any): ColorCurves;
  73663. }
  73664. }
  73665. declare module BABYLON {
  73666. /**
  73667. * Interface to follow in your material defines to integrate easily the
  73668. * Image proccessing functions.
  73669. * @hidden
  73670. */
  73671. export interface IImageProcessingConfigurationDefines {
  73672. IMAGEPROCESSING: boolean;
  73673. VIGNETTE: boolean;
  73674. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73675. VIGNETTEBLENDMODEOPAQUE: boolean;
  73676. TONEMAPPING: boolean;
  73677. TONEMAPPING_ACES: boolean;
  73678. CONTRAST: boolean;
  73679. EXPOSURE: boolean;
  73680. COLORCURVES: boolean;
  73681. COLORGRADING: boolean;
  73682. COLORGRADING3D: boolean;
  73683. SAMPLER3DGREENDEPTH: boolean;
  73684. SAMPLER3DBGRMAP: boolean;
  73685. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73686. }
  73687. /**
  73688. * @hidden
  73689. */
  73690. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  73691. IMAGEPROCESSING: boolean;
  73692. VIGNETTE: boolean;
  73693. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73694. VIGNETTEBLENDMODEOPAQUE: boolean;
  73695. TONEMAPPING: boolean;
  73696. TONEMAPPING_ACES: boolean;
  73697. CONTRAST: boolean;
  73698. COLORCURVES: boolean;
  73699. COLORGRADING: boolean;
  73700. COLORGRADING3D: boolean;
  73701. SAMPLER3DGREENDEPTH: boolean;
  73702. SAMPLER3DBGRMAP: boolean;
  73703. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73704. EXPOSURE: boolean;
  73705. constructor();
  73706. }
  73707. /**
  73708. * This groups together the common properties used for image processing either in direct forward pass
  73709. * or through post processing effect depending on the use of the image processing pipeline in your scene
  73710. * or not.
  73711. */
  73712. export class ImageProcessingConfiguration {
  73713. /**
  73714. * Default tone mapping applied in BabylonJS.
  73715. */
  73716. static readonly TONEMAPPING_STANDARD: number;
  73717. /**
  73718. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  73719. * to other engines rendering to increase portability.
  73720. */
  73721. static readonly TONEMAPPING_ACES: number;
  73722. /**
  73723. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  73724. */
  73725. colorCurves: Nullable<ColorCurves>;
  73726. private _colorCurvesEnabled;
  73727. /**
  73728. * Gets wether the color curves effect is enabled.
  73729. */
  73730. /**
  73731. * Sets wether the color curves effect is enabled.
  73732. */
  73733. colorCurvesEnabled: boolean;
  73734. private _colorGradingTexture;
  73735. /**
  73736. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73737. */
  73738. /**
  73739. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73740. */
  73741. colorGradingTexture: Nullable<BaseTexture>;
  73742. private _colorGradingEnabled;
  73743. /**
  73744. * Gets wether the color grading effect is enabled.
  73745. */
  73746. /**
  73747. * Sets wether the color grading effect is enabled.
  73748. */
  73749. colorGradingEnabled: boolean;
  73750. private _colorGradingWithGreenDepth;
  73751. /**
  73752. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  73753. */
  73754. /**
  73755. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  73756. */
  73757. colorGradingWithGreenDepth: boolean;
  73758. private _colorGradingBGR;
  73759. /**
  73760. * Gets wether the color grading texture contains BGR values.
  73761. */
  73762. /**
  73763. * Sets wether the color grading texture contains BGR values.
  73764. */
  73765. colorGradingBGR: boolean;
  73766. /** @hidden */
  73767. _exposure: number;
  73768. /**
  73769. * Gets the Exposure used in the effect.
  73770. */
  73771. /**
  73772. * Sets the Exposure used in the effect.
  73773. */
  73774. exposure: number;
  73775. private _toneMappingEnabled;
  73776. /**
  73777. * Gets wether the tone mapping effect is enabled.
  73778. */
  73779. /**
  73780. * Sets wether the tone mapping effect is enabled.
  73781. */
  73782. toneMappingEnabled: boolean;
  73783. private _toneMappingType;
  73784. /**
  73785. * Gets the type of tone mapping effect.
  73786. */
  73787. /**
  73788. * Sets the type of tone mapping effect used in BabylonJS.
  73789. */
  73790. toneMappingType: number;
  73791. protected _contrast: number;
  73792. /**
  73793. * Gets the contrast used in the effect.
  73794. */
  73795. /**
  73796. * Sets the contrast used in the effect.
  73797. */
  73798. contrast: number;
  73799. /**
  73800. * Vignette stretch size.
  73801. */
  73802. vignetteStretch: number;
  73803. /**
  73804. * Vignette centre X Offset.
  73805. */
  73806. vignetteCentreX: number;
  73807. /**
  73808. * Vignette centre Y Offset.
  73809. */
  73810. vignetteCentreY: number;
  73811. /**
  73812. * Vignette weight or intensity of the vignette effect.
  73813. */
  73814. vignetteWeight: number;
  73815. /**
  73816. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  73817. * if vignetteEnabled is set to true.
  73818. */
  73819. vignetteColor: Color4;
  73820. /**
  73821. * Camera field of view used by the Vignette effect.
  73822. */
  73823. vignetteCameraFov: number;
  73824. private _vignetteBlendMode;
  73825. /**
  73826. * Gets the vignette blend mode allowing different kind of effect.
  73827. */
  73828. /**
  73829. * Sets the vignette blend mode allowing different kind of effect.
  73830. */
  73831. vignetteBlendMode: number;
  73832. private _vignetteEnabled;
  73833. /**
  73834. * Gets wether the vignette effect is enabled.
  73835. */
  73836. /**
  73837. * Sets wether the vignette effect is enabled.
  73838. */
  73839. vignetteEnabled: boolean;
  73840. private _applyByPostProcess;
  73841. /**
  73842. * Gets wether the image processing is applied through a post process or not.
  73843. */
  73844. /**
  73845. * Sets wether the image processing is applied through a post process or not.
  73846. */
  73847. applyByPostProcess: boolean;
  73848. private _isEnabled;
  73849. /**
  73850. * Gets wether the image processing is enabled or not.
  73851. */
  73852. /**
  73853. * Sets wether the image processing is enabled or not.
  73854. */
  73855. isEnabled: boolean;
  73856. /**
  73857. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  73858. */
  73859. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  73860. /**
  73861. * Method called each time the image processing information changes requires to recompile the effect.
  73862. */
  73863. protected _updateParameters(): void;
  73864. /**
  73865. * Gets the current class name.
  73866. * @return "ImageProcessingConfiguration"
  73867. */
  73868. getClassName(): string;
  73869. /**
  73870. * Prepare the list of uniforms associated with the Image Processing effects.
  73871. * @param uniforms The list of uniforms used in the effect
  73872. * @param defines the list of defines currently in use
  73873. */
  73874. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  73875. /**
  73876. * Prepare the list of samplers associated with the Image Processing effects.
  73877. * @param samplersList The list of uniforms used in the effect
  73878. * @param defines the list of defines currently in use
  73879. */
  73880. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  73881. /**
  73882. * Prepare the list of defines associated to the shader.
  73883. * @param defines the list of defines to complete
  73884. * @param forPostProcess Define if we are currently in post process mode or not
  73885. */
  73886. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  73887. /**
  73888. * Returns true if all the image processing information are ready.
  73889. * @returns True if ready, otherwise, false
  73890. */
  73891. isReady(): boolean;
  73892. /**
  73893. * Binds the image processing to the shader.
  73894. * @param effect The effect to bind to
  73895. * @param aspectRatio Define the current aspect ratio of the effect
  73896. */
  73897. bind(effect: Effect, aspectRatio?: number): void;
  73898. /**
  73899. * Clones the current image processing instance.
  73900. * @return The cloned image processing
  73901. */
  73902. clone(): ImageProcessingConfiguration;
  73903. /**
  73904. * Serializes the current image processing instance to a json representation.
  73905. * @return a JSON representation
  73906. */
  73907. serialize(): any;
  73908. /**
  73909. * Parses the image processing from a json representation.
  73910. * @param source the JSON source to parse
  73911. * @return The parsed image processing
  73912. */
  73913. static Parse(source: any): ImageProcessingConfiguration;
  73914. private static _VIGNETTEMODE_MULTIPLY;
  73915. private static _VIGNETTEMODE_OPAQUE;
  73916. /**
  73917. * Used to apply the vignette as a mix with the pixel color.
  73918. */
  73919. static readonly VIGNETTEMODE_MULTIPLY: number;
  73920. /**
  73921. * Used to apply the vignette as a replacement of the pixel color.
  73922. */
  73923. static readonly VIGNETTEMODE_OPAQUE: number;
  73924. }
  73925. }
  73926. declare module BABYLON {
  73927. /** @hidden */
  73928. export var postprocessVertexShader: {
  73929. name: string;
  73930. shader: string;
  73931. };
  73932. }
  73933. declare module BABYLON {
  73934. /** Defines supported spaces */
  73935. export enum Space {
  73936. /** Local (object) space */
  73937. LOCAL = 0,
  73938. /** World space */
  73939. WORLD = 1,
  73940. /** Bone space */
  73941. BONE = 2
  73942. }
  73943. /** Defines the 3 main axes */
  73944. export class Axis {
  73945. /** X axis */
  73946. static X: Vector3;
  73947. /** Y axis */
  73948. static Y: Vector3;
  73949. /** Z axis */
  73950. static Z: Vector3;
  73951. }
  73952. }
  73953. declare module BABYLON {
  73954. /**
  73955. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  73956. * This is the base of the follow, arc rotate cameras and Free camera
  73957. * @see http://doc.babylonjs.com/features/cameras
  73958. */
  73959. export class TargetCamera extends Camera {
  73960. private static _RigCamTransformMatrix;
  73961. private static _TargetTransformMatrix;
  73962. private static _TargetFocalPoint;
  73963. /**
  73964. * Define the current direction the camera is moving to
  73965. */
  73966. cameraDirection: Vector3;
  73967. /**
  73968. * Define the current rotation the camera is rotating to
  73969. */
  73970. cameraRotation: Vector2;
  73971. /**
  73972. * When set, the up vector of the camera will be updated by the rotation of the camera
  73973. */
  73974. updateUpVectorFromRotation: boolean;
  73975. private _tmpQuaternion;
  73976. /**
  73977. * Define the current rotation of the camera
  73978. */
  73979. rotation: Vector3;
  73980. /**
  73981. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  73982. */
  73983. rotationQuaternion: Quaternion;
  73984. /**
  73985. * Define the current speed of the camera
  73986. */
  73987. speed: number;
  73988. /**
  73989. * Add cconstraint to the camera to prevent it to move freely in all directions and
  73990. * around all axis.
  73991. */
  73992. noRotationConstraint: boolean;
  73993. /**
  73994. * Define the current target of the camera as an object or a position.
  73995. */
  73996. lockedTarget: any;
  73997. /** @hidden */
  73998. _currentTarget: Vector3;
  73999. /** @hidden */
  74000. _initialFocalDistance: number;
  74001. /** @hidden */
  74002. _viewMatrix: Matrix;
  74003. /** @hidden */
  74004. _camMatrix: Matrix;
  74005. /** @hidden */
  74006. _cameraTransformMatrix: Matrix;
  74007. /** @hidden */
  74008. _cameraRotationMatrix: Matrix;
  74009. /** @hidden */
  74010. _referencePoint: Vector3;
  74011. /** @hidden */
  74012. _transformedReferencePoint: Vector3;
  74013. protected _globalCurrentTarget: Vector3;
  74014. protected _globalCurrentUpVector: Vector3;
  74015. /** @hidden */
  74016. _reset: () => void;
  74017. private _defaultUp;
  74018. /**
  74019. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  74020. * This is the base of the follow, arc rotate cameras and Free camera
  74021. * @see http://doc.babylonjs.com/features/cameras
  74022. * @param name Defines the name of the camera in the scene
  74023. * @param position Defines the start position of the camera in the scene
  74024. * @param scene Defines the scene the camera belongs to
  74025. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  74026. */
  74027. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  74028. /**
  74029. * Gets the position in front of the camera at a given distance.
  74030. * @param distance The distance from the camera we want the position to be
  74031. * @returns the position
  74032. */
  74033. getFrontPosition(distance: number): Vector3;
  74034. /** @hidden */
  74035. _getLockedTargetPosition(): Nullable<Vector3>;
  74036. private _storedPosition;
  74037. private _storedRotation;
  74038. private _storedRotationQuaternion;
  74039. /**
  74040. * Store current camera state of the camera (fov, position, rotation, etc..)
  74041. * @returns the camera
  74042. */
  74043. storeState(): Camera;
  74044. /**
  74045. * Restored camera state. You must call storeState() first
  74046. * @returns whether it was successful or not
  74047. * @hidden
  74048. */
  74049. _restoreStateValues(): boolean;
  74050. /** @hidden */
  74051. _initCache(): void;
  74052. /** @hidden */
  74053. _updateCache(ignoreParentClass?: boolean): void;
  74054. /** @hidden */
  74055. _isSynchronizedViewMatrix(): boolean;
  74056. /** @hidden */
  74057. _computeLocalCameraSpeed(): number;
  74058. /**
  74059. * Defines the target the camera should look at.
  74060. * @param target Defines the new target as a Vector or a mesh
  74061. */
  74062. setTarget(target: Vector3): void;
  74063. /**
  74064. * Return the current target position of the camera. This value is expressed in local space.
  74065. * @returns the target position
  74066. */
  74067. getTarget(): Vector3;
  74068. /** @hidden */
  74069. _decideIfNeedsToMove(): boolean;
  74070. /** @hidden */
  74071. _updatePosition(): void;
  74072. /** @hidden */
  74073. _checkInputs(): void;
  74074. protected _updateCameraRotationMatrix(): void;
  74075. /**
  74076. * 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)
  74077. * @returns the current camera
  74078. */
  74079. private _rotateUpVectorWithCameraRotationMatrix;
  74080. private _cachedRotationZ;
  74081. private _cachedQuaternionRotationZ;
  74082. /** @hidden */
  74083. _getViewMatrix(): Matrix;
  74084. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  74085. /**
  74086. * @hidden
  74087. */
  74088. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  74089. /**
  74090. * @hidden
  74091. */
  74092. _updateRigCameras(): void;
  74093. private _getRigCamPositionAndTarget;
  74094. /**
  74095. * Gets the current object class name.
  74096. * @return the class name
  74097. */
  74098. getClassName(): string;
  74099. }
  74100. }
  74101. declare module BABYLON {
  74102. /**
  74103. * Gather the list of keyboard event types as constants.
  74104. */
  74105. export class KeyboardEventTypes {
  74106. /**
  74107. * The keydown event is fired when a key becomes active (pressed).
  74108. */
  74109. static readonly KEYDOWN: number;
  74110. /**
  74111. * The keyup event is fired when a key has been released.
  74112. */
  74113. static readonly KEYUP: number;
  74114. }
  74115. /**
  74116. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74117. */
  74118. export class KeyboardInfo {
  74119. /**
  74120. * Defines the type of event (KeyboardEventTypes)
  74121. */
  74122. type: number;
  74123. /**
  74124. * Defines the related dom event
  74125. */
  74126. event: KeyboardEvent;
  74127. /**
  74128. * Instantiates a new keyboard info.
  74129. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74130. * @param type Defines the type of event (KeyboardEventTypes)
  74131. * @param event Defines the related dom event
  74132. */
  74133. constructor(
  74134. /**
  74135. * Defines the type of event (KeyboardEventTypes)
  74136. */
  74137. type: number,
  74138. /**
  74139. * Defines the related dom event
  74140. */
  74141. event: KeyboardEvent);
  74142. }
  74143. /**
  74144. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74145. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  74146. */
  74147. export class KeyboardInfoPre extends KeyboardInfo {
  74148. /**
  74149. * Defines the type of event (KeyboardEventTypes)
  74150. */
  74151. type: number;
  74152. /**
  74153. * Defines the related dom event
  74154. */
  74155. event: KeyboardEvent;
  74156. /**
  74157. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  74158. */
  74159. skipOnPointerObservable: boolean;
  74160. /**
  74161. * Instantiates a new keyboard pre info.
  74162. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74163. * @param type Defines the type of event (KeyboardEventTypes)
  74164. * @param event Defines the related dom event
  74165. */
  74166. constructor(
  74167. /**
  74168. * Defines the type of event (KeyboardEventTypes)
  74169. */
  74170. type: number,
  74171. /**
  74172. * Defines the related dom event
  74173. */
  74174. event: KeyboardEvent);
  74175. }
  74176. }
  74177. declare module BABYLON {
  74178. /**
  74179. * Manage the keyboard inputs to control the movement of a free camera.
  74180. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74181. */
  74182. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  74183. /**
  74184. * Defines the camera the input is attached to.
  74185. */
  74186. camera: FreeCamera;
  74187. /**
  74188. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  74189. */
  74190. keysUp: number[];
  74191. /**
  74192. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  74193. */
  74194. keysDown: number[];
  74195. /**
  74196. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  74197. */
  74198. keysLeft: number[];
  74199. /**
  74200. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  74201. */
  74202. keysRight: number[];
  74203. private _keys;
  74204. private _onCanvasBlurObserver;
  74205. private _onKeyboardObserver;
  74206. private _engine;
  74207. private _scene;
  74208. /**
  74209. * Attach the input controls to a specific dom element to get the input from.
  74210. * @param element Defines the element the controls should be listened from
  74211. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74212. */
  74213. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74214. /**
  74215. * Detach the current controls from the specified dom element.
  74216. * @param element Defines the element to stop listening the inputs from
  74217. */
  74218. detachControl(element: Nullable<HTMLElement>): void;
  74219. /**
  74220. * Update the current camera state depending on the inputs that have been used this frame.
  74221. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74222. */
  74223. checkInputs(): void;
  74224. /**
  74225. * Gets the class name of the current intput.
  74226. * @returns the class name
  74227. */
  74228. getClassName(): string;
  74229. /** @hidden */
  74230. _onLostFocus(): void;
  74231. /**
  74232. * Get the friendly name associated with the input class.
  74233. * @returns the input friendly name
  74234. */
  74235. getSimpleName(): string;
  74236. }
  74237. }
  74238. declare module BABYLON {
  74239. /**
  74240. * Interface describing all the common properties and methods a shadow light needs to implement.
  74241. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  74242. * as well as binding the different shadow properties to the effects.
  74243. */
  74244. export interface IShadowLight extends Light {
  74245. /**
  74246. * The light id in the scene (used in scene.findLighById for instance)
  74247. */
  74248. id: string;
  74249. /**
  74250. * The position the shdow will be casted from.
  74251. */
  74252. position: Vector3;
  74253. /**
  74254. * In 2d mode (needCube being false), the direction used to cast the shadow.
  74255. */
  74256. direction: Vector3;
  74257. /**
  74258. * The transformed position. Position of the light in world space taking parenting in account.
  74259. */
  74260. transformedPosition: Vector3;
  74261. /**
  74262. * The transformed direction. Direction of the light in world space taking parenting in account.
  74263. */
  74264. transformedDirection: Vector3;
  74265. /**
  74266. * The friendly name of the light in the scene.
  74267. */
  74268. name: string;
  74269. /**
  74270. * Defines the shadow projection clipping minimum z value.
  74271. */
  74272. shadowMinZ: number;
  74273. /**
  74274. * Defines the shadow projection clipping maximum z value.
  74275. */
  74276. shadowMaxZ: number;
  74277. /**
  74278. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74279. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74280. */
  74281. computeTransformedInformation(): boolean;
  74282. /**
  74283. * Gets the scene the light belongs to.
  74284. * @returns The scene
  74285. */
  74286. getScene(): Scene;
  74287. /**
  74288. * Callback defining a custom Projection Matrix Builder.
  74289. * This can be used to override the default projection matrix computation.
  74290. */
  74291. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74292. /**
  74293. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74294. * @param matrix The materix to updated with the projection information
  74295. * @param viewMatrix The transform matrix of the light
  74296. * @param renderList The list of mesh to render in the map
  74297. * @returns The current light
  74298. */
  74299. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74300. /**
  74301. * Gets the current depth scale used in ESM.
  74302. * @returns The scale
  74303. */
  74304. getDepthScale(): number;
  74305. /**
  74306. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74307. * @returns true if a cube texture needs to be use
  74308. */
  74309. needCube(): boolean;
  74310. /**
  74311. * Detects if the projection matrix requires to be recomputed this frame.
  74312. * @returns true if it requires to be recomputed otherwise, false.
  74313. */
  74314. needProjectionMatrixCompute(): boolean;
  74315. /**
  74316. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74317. */
  74318. forceProjectionMatrixCompute(): void;
  74319. /**
  74320. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74321. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74322. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74323. */
  74324. getShadowDirection(faceIndex?: number): Vector3;
  74325. /**
  74326. * Gets the minZ used for shadow according to both the scene and the light.
  74327. * @param activeCamera The camera we are returning the min for
  74328. * @returns the depth min z
  74329. */
  74330. getDepthMinZ(activeCamera: Camera): number;
  74331. /**
  74332. * Gets the maxZ used for shadow according to both the scene and the light.
  74333. * @param activeCamera The camera we are returning the max for
  74334. * @returns the depth max z
  74335. */
  74336. getDepthMaxZ(activeCamera: Camera): number;
  74337. }
  74338. /**
  74339. * Base implementation IShadowLight
  74340. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  74341. */
  74342. export abstract class ShadowLight extends Light implements IShadowLight {
  74343. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  74344. protected _position: Vector3;
  74345. protected _setPosition(value: Vector3): void;
  74346. /**
  74347. * Sets the position the shadow will be casted from. Also use as the light position for both
  74348. * point and spot lights.
  74349. */
  74350. /**
  74351. * Sets the position the shadow will be casted from. Also use as the light position for both
  74352. * point and spot lights.
  74353. */
  74354. position: Vector3;
  74355. protected _direction: Vector3;
  74356. protected _setDirection(value: Vector3): void;
  74357. /**
  74358. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  74359. * Also use as the light direction on spot and directional lights.
  74360. */
  74361. /**
  74362. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  74363. * Also use as the light direction on spot and directional lights.
  74364. */
  74365. direction: Vector3;
  74366. private _shadowMinZ;
  74367. /**
  74368. * Gets the shadow projection clipping minimum z value.
  74369. */
  74370. /**
  74371. * Sets the shadow projection clipping minimum z value.
  74372. */
  74373. shadowMinZ: number;
  74374. private _shadowMaxZ;
  74375. /**
  74376. * Sets the shadow projection clipping maximum z value.
  74377. */
  74378. /**
  74379. * Gets the shadow projection clipping maximum z value.
  74380. */
  74381. shadowMaxZ: number;
  74382. /**
  74383. * Callback defining a custom Projection Matrix Builder.
  74384. * This can be used to override the default projection matrix computation.
  74385. */
  74386. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74387. /**
  74388. * The transformed position. Position of the light in world space taking parenting in account.
  74389. */
  74390. transformedPosition: Vector3;
  74391. /**
  74392. * The transformed direction. Direction of the light in world space taking parenting in account.
  74393. */
  74394. transformedDirection: Vector3;
  74395. private _needProjectionMatrixCompute;
  74396. /**
  74397. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74398. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74399. */
  74400. computeTransformedInformation(): boolean;
  74401. /**
  74402. * Return the depth scale used for the shadow map.
  74403. * @returns the depth scale.
  74404. */
  74405. getDepthScale(): number;
  74406. /**
  74407. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74408. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74409. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74410. */
  74411. getShadowDirection(faceIndex?: number): Vector3;
  74412. /**
  74413. * Returns the ShadowLight absolute position in the World.
  74414. * @returns the position vector in world space
  74415. */
  74416. getAbsolutePosition(): Vector3;
  74417. /**
  74418. * Sets the ShadowLight direction toward the passed target.
  74419. * @param target The point to target in local space
  74420. * @returns the updated ShadowLight direction
  74421. */
  74422. setDirectionToTarget(target: Vector3): Vector3;
  74423. /**
  74424. * Returns the light rotation in euler definition.
  74425. * @returns the x y z rotation in local space.
  74426. */
  74427. getRotation(): Vector3;
  74428. /**
  74429. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74430. * @returns true if a cube texture needs to be use
  74431. */
  74432. needCube(): boolean;
  74433. /**
  74434. * Detects if the projection matrix requires to be recomputed this frame.
  74435. * @returns true if it requires to be recomputed otherwise, false.
  74436. */
  74437. needProjectionMatrixCompute(): boolean;
  74438. /**
  74439. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74440. */
  74441. forceProjectionMatrixCompute(): void;
  74442. /** @hidden */
  74443. _initCache(): void;
  74444. /** @hidden */
  74445. _isSynchronized(): boolean;
  74446. /**
  74447. * Computes the world matrix of the node
  74448. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  74449. * @returns the world matrix
  74450. */
  74451. computeWorldMatrix(force?: boolean): Matrix;
  74452. /**
  74453. * Gets the minZ used for shadow according to both the scene and the light.
  74454. * @param activeCamera The camera we are returning the min for
  74455. * @returns the depth min z
  74456. */
  74457. getDepthMinZ(activeCamera: Camera): number;
  74458. /**
  74459. * Gets the maxZ used for shadow according to both the scene and the light.
  74460. * @param activeCamera The camera we are returning the max for
  74461. * @returns the depth max z
  74462. */
  74463. getDepthMaxZ(activeCamera: Camera): number;
  74464. /**
  74465. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74466. * @param matrix The materix to updated with the projection information
  74467. * @param viewMatrix The transform matrix of the light
  74468. * @param renderList The list of mesh to render in the map
  74469. * @returns The current light
  74470. */
  74471. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74472. }
  74473. }
  74474. declare module BABYLON {
  74475. /**
  74476. * "Static Class" containing the most commonly used helper while dealing with material for
  74477. * rendering purpose.
  74478. *
  74479. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  74480. *
  74481. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  74482. */
  74483. export class MaterialHelper {
  74484. /**
  74485. * Bind the current view position to an effect.
  74486. * @param effect The effect to be bound
  74487. * @param scene The scene the eyes position is used from
  74488. */
  74489. static BindEyePosition(effect: Effect, scene: Scene): void;
  74490. /**
  74491. * Helps preparing the defines values about the UVs in used in the effect.
  74492. * UVs are shared as much as we can accross channels in the shaders.
  74493. * @param texture The texture we are preparing the UVs for
  74494. * @param defines The defines to update
  74495. * @param key The channel key "diffuse", "specular"... used in the shader
  74496. */
  74497. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  74498. /**
  74499. * Binds a texture matrix value to its corrsponding uniform
  74500. * @param texture The texture to bind the matrix for
  74501. * @param uniformBuffer The uniform buffer receivin the data
  74502. * @param key The channel key "diffuse", "specular"... used in the shader
  74503. */
  74504. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  74505. /**
  74506. * Gets the current status of the fog (should it be enabled?)
  74507. * @param mesh defines the mesh to evaluate for fog support
  74508. * @param scene defines the hosting scene
  74509. * @returns true if fog must be enabled
  74510. */
  74511. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  74512. /**
  74513. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  74514. * @param mesh defines the current mesh
  74515. * @param scene defines the current scene
  74516. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  74517. * @param pointsCloud defines if point cloud rendering has to be turned on
  74518. * @param fogEnabled defines if fog has to be turned on
  74519. * @param alphaTest defines if alpha testing has to be turned on
  74520. * @param defines defines the current list of defines
  74521. */
  74522. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  74523. /**
  74524. * Helper used to prepare the list of defines associated with frame values for shader compilation
  74525. * @param scene defines the current scene
  74526. * @param engine defines the current engine
  74527. * @param defines specifies the list of active defines
  74528. * @param useInstances defines if instances have to be turned on
  74529. * @param useClipPlane defines if clip plane have to be turned on
  74530. */
  74531. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  74532. /**
  74533. * Prepares the defines for bones
  74534. * @param mesh The mesh containing the geometry data we will draw
  74535. * @param defines The defines to update
  74536. */
  74537. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  74538. /**
  74539. * Prepares the defines for morph targets
  74540. * @param mesh The mesh containing the geometry data we will draw
  74541. * @param defines The defines to update
  74542. */
  74543. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  74544. /**
  74545. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  74546. * @param mesh The mesh containing the geometry data we will draw
  74547. * @param defines The defines to update
  74548. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  74549. * @param useBones Precise whether bones should be used or not (override mesh info)
  74550. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  74551. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  74552. * @returns false if defines are considered not dirty and have not been checked
  74553. */
  74554. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  74555. /**
  74556. * Prepares the defines related to multiview
  74557. * @param scene The scene we are intending to draw
  74558. * @param defines The defines to update
  74559. */
  74560. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  74561. /**
  74562. * Prepares the defines related to the light information passed in parameter
  74563. * @param scene The scene we are intending to draw
  74564. * @param mesh The mesh the effect is compiling for
  74565. * @param light The light the effect is compiling for
  74566. * @param lightIndex The index of the light
  74567. * @param defines The defines to update
  74568. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74569. * @param state Defines the current state regarding what is needed (normals, etc...)
  74570. */
  74571. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  74572. needNormals: boolean;
  74573. needRebuild: boolean;
  74574. shadowEnabled: boolean;
  74575. specularEnabled: boolean;
  74576. lightmapMode: boolean;
  74577. }): void;
  74578. /**
  74579. * Prepares the defines related to the light information passed in parameter
  74580. * @param scene The scene we are intending to draw
  74581. * @param mesh The mesh the effect is compiling for
  74582. * @param defines The defines to update
  74583. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74584. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  74585. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  74586. * @returns true if normals will be required for the rest of the effect
  74587. */
  74588. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  74589. /**
  74590. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  74591. * @param lightIndex defines the light index
  74592. * @param uniformsList The uniform list
  74593. * @param samplersList The sampler list
  74594. * @param projectedLightTexture defines if projected texture must be used
  74595. * @param uniformBuffersList defines an optional list of uniform buffers
  74596. */
  74597. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  74598. /**
  74599. * Prepares the uniforms and samplers list to be used in the effect
  74600. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  74601. * @param samplersList The sampler list
  74602. * @param defines The defines helping in the list generation
  74603. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  74604. */
  74605. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  74606. /**
  74607. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  74608. * @param defines The defines to update while falling back
  74609. * @param fallbacks The authorized effect fallbacks
  74610. * @param maxSimultaneousLights The maximum number of lights allowed
  74611. * @param rank the current rank of the Effect
  74612. * @returns The newly affected rank
  74613. */
  74614. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  74615. private static _TmpMorphInfluencers;
  74616. /**
  74617. * Prepares the list of attributes required for morph targets according to the effect defines.
  74618. * @param attribs The current list of supported attribs
  74619. * @param mesh The mesh to prepare the morph targets attributes for
  74620. * @param influencers The number of influencers
  74621. */
  74622. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  74623. /**
  74624. * Prepares the list of attributes required for morph targets according to the effect defines.
  74625. * @param attribs The current list of supported attribs
  74626. * @param mesh The mesh to prepare the morph targets attributes for
  74627. * @param defines The current Defines of the effect
  74628. */
  74629. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  74630. /**
  74631. * Prepares the list of attributes required for bones according to the effect defines.
  74632. * @param attribs The current list of supported attribs
  74633. * @param mesh The mesh to prepare the bones attributes for
  74634. * @param defines The current Defines of the effect
  74635. * @param fallbacks The current efffect fallback strategy
  74636. */
  74637. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  74638. /**
  74639. * Check and prepare the list of attributes required for instances according to the effect defines.
  74640. * @param attribs The current list of supported attribs
  74641. * @param defines The current MaterialDefines of the effect
  74642. */
  74643. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  74644. /**
  74645. * Add the list of attributes required for instances to the attribs array.
  74646. * @param attribs The current list of supported attribs
  74647. */
  74648. static PushAttributesForInstances(attribs: string[]): void;
  74649. /**
  74650. * Binds the light shadow information to the effect for the given mesh.
  74651. * @param light The light containing the generator
  74652. * @param scene The scene the lights belongs to
  74653. * @param mesh The mesh we are binding the information to render
  74654. * @param lightIndex The light index in the effect used to render the mesh
  74655. * @param effect The effect we are binding the data to
  74656. */
  74657. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  74658. /**
  74659. * Binds the light information to the effect.
  74660. * @param light The light containing the generator
  74661. * @param effect The effect we are binding the data to
  74662. * @param lightIndex The light index in the effect used to render
  74663. */
  74664. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  74665. /**
  74666. * Binds the lights information from the scene to the effect for the given mesh.
  74667. * @param light Light to bind
  74668. * @param lightIndex Light index
  74669. * @param scene The scene where the light belongs to
  74670. * @param mesh The mesh we are binding the information to render
  74671. * @param effect The effect we are binding the data to
  74672. * @param useSpecular Defines if specular is supported
  74673. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74674. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74675. */
  74676. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74677. /**
  74678. * Binds the lights information from the scene to the effect for the given mesh.
  74679. * @param scene The scene the lights belongs to
  74680. * @param mesh The mesh we are binding the information to render
  74681. * @param effect The effect we are binding the data to
  74682. * @param defines The generated defines for the effect
  74683. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  74684. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74685. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74686. */
  74687. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74688. private static _tempFogColor;
  74689. /**
  74690. * Binds the fog information from the scene to the effect for the given mesh.
  74691. * @param scene The scene the lights belongs to
  74692. * @param mesh The mesh we are binding the information to render
  74693. * @param effect The effect we are binding the data to
  74694. * @param linearSpace Defines if the fog effect is applied in linear space
  74695. */
  74696. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  74697. /**
  74698. * Binds the bones information from the mesh to the effect.
  74699. * @param mesh The mesh we are binding the information to render
  74700. * @param effect The effect we are binding the data to
  74701. */
  74702. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  74703. /**
  74704. * Binds the morph targets information from the mesh to the effect.
  74705. * @param abstractMesh The mesh we are binding the information to render
  74706. * @param effect The effect we are binding the data to
  74707. */
  74708. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  74709. /**
  74710. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  74711. * @param defines The generated defines used in the effect
  74712. * @param effect The effect we are binding the data to
  74713. * @param scene The scene we are willing to render with logarithmic scale for
  74714. */
  74715. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  74716. /**
  74717. * Binds the clip plane information from the scene to the effect.
  74718. * @param scene The scene the clip plane information are extracted from
  74719. * @param effect The effect we are binding the data to
  74720. */
  74721. static BindClipPlane(effect: Effect, scene: Scene): void;
  74722. }
  74723. }
  74724. declare module BABYLON {
  74725. /** @hidden */
  74726. export var packingFunctions: {
  74727. name: string;
  74728. shader: string;
  74729. };
  74730. }
  74731. declare module BABYLON {
  74732. /** @hidden */
  74733. export var shadowMapPixelShader: {
  74734. name: string;
  74735. shader: string;
  74736. };
  74737. }
  74738. declare module BABYLON {
  74739. /** @hidden */
  74740. export var bonesDeclaration: {
  74741. name: string;
  74742. shader: string;
  74743. };
  74744. }
  74745. declare module BABYLON {
  74746. /** @hidden */
  74747. export var morphTargetsVertexGlobalDeclaration: {
  74748. name: string;
  74749. shader: string;
  74750. };
  74751. }
  74752. declare module BABYLON {
  74753. /** @hidden */
  74754. export var morphTargetsVertexDeclaration: {
  74755. name: string;
  74756. shader: string;
  74757. };
  74758. }
  74759. declare module BABYLON {
  74760. /** @hidden */
  74761. export var instancesDeclaration: {
  74762. name: string;
  74763. shader: string;
  74764. };
  74765. }
  74766. declare module BABYLON {
  74767. /** @hidden */
  74768. export var helperFunctions: {
  74769. name: string;
  74770. shader: string;
  74771. };
  74772. }
  74773. declare module BABYLON {
  74774. /** @hidden */
  74775. export var morphTargetsVertex: {
  74776. name: string;
  74777. shader: string;
  74778. };
  74779. }
  74780. declare module BABYLON {
  74781. /** @hidden */
  74782. export var instancesVertex: {
  74783. name: string;
  74784. shader: string;
  74785. };
  74786. }
  74787. declare module BABYLON {
  74788. /** @hidden */
  74789. export var bonesVertex: {
  74790. name: string;
  74791. shader: string;
  74792. };
  74793. }
  74794. declare module BABYLON {
  74795. /** @hidden */
  74796. export var shadowMapVertexShader: {
  74797. name: string;
  74798. shader: string;
  74799. };
  74800. }
  74801. declare module BABYLON {
  74802. /** @hidden */
  74803. export var depthBoxBlurPixelShader: {
  74804. name: string;
  74805. shader: string;
  74806. };
  74807. }
  74808. declare module BABYLON {
  74809. /**
  74810. * Defines the options associated with the creation of a custom shader for a shadow generator.
  74811. */
  74812. export interface ICustomShaderOptions {
  74813. /**
  74814. * Gets or sets the custom shader name to use
  74815. */
  74816. shaderName: string;
  74817. /**
  74818. * The list of attribute names used in the shader
  74819. */
  74820. attributes?: string[];
  74821. /**
  74822. * The list of unifrom names used in the shader
  74823. */
  74824. uniforms?: string[];
  74825. /**
  74826. * The list of sampler names used in the shader
  74827. */
  74828. samplers?: string[];
  74829. /**
  74830. * The list of defines used in the shader
  74831. */
  74832. defines?: string[];
  74833. }
  74834. /**
  74835. * Interface to implement to create a shadow generator compatible with BJS.
  74836. */
  74837. export interface IShadowGenerator {
  74838. /**
  74839. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74840. * @returns The render target texture if present otherwise, null
  74841. */
  74842. getShadowMap(): Nullable<RenderTargetTexture>;
  74843. /**
  74844. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74845. * @returns The render target texture if the shadow map is present otherwise, null
  74846. */
  74847. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74848. /**
  74849. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74850. * @param subMesh The submesh we want to render in the shadow map
  74851. * @param useInstances Defines wether will draw in the map using instances
  74852. * @returns true if ready otherwise, false
  74853. */
  74854. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74855. /**
  74856. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74857. * @param defines Defines of the material we want to update
  74858. * @param lightIndex Index of the light in the enabled light list of the material
  74859. */
  74860. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  74861. /**
  74862. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74863. * defined in the generator but impacting the effect).
  74864. * It implies the unifroms available on the materials are the standard BJS ones.
  74865. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74866. * @param effect The effect we are binfing the information for
  74867. */
  74868. bindShadowLight(lightIndex: string, effect: Effect): void;
  74869. /**
  74870. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74871. * (eq to shadow prjection matrix * light transform matrix)
  74872. * @returns The transform matrix used to create the shadow map
  74873. */
  74874. getTransformMatrix(): Matrix;
  74875. /**
  74876. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74877. * Cube and 2D textures for instance.
  74878. */
  74879. recreateShadowMap(): void;
  74880. /**
  74881. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74882. * @param onCompiled Callback triggered at the and of the effects compilation
  74883. * @param options Sets of optional options forcing the compilation with different modes
  74884. */
  74885. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74886. useInstances: boolean;
  74887. }>): void;
  74888. /**
  74889. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74890. * @param options Sets of optional options forcing the compilation with different modes
  74891. * @returns A promise that resolves when the compilation completes
  74892. */
  74893. forceCompilationAsync(options?: Partial<{
  74894. useInstances: boolean;
  74895. }>): Promise<void>;
  74896. /**
  74897. * Serializes the shadow generator setup to a json object.
  74898. * @returns The serialized JSON object
  74899. */
  74900. serialize(): any;
  74901. /**
  74902. * Disposes the Shadow map and related Textures and effects.
  74903. */
  74904. dispose(): void;
  74905. }
  74906. /**
  74907. * Default implementation IShadowGenerator.
  74908. * This is the main object responsible of generating shadows in the framework.
  74909. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  74910. */
  74911. export class ShadowGenerator implements IShadowGenerator {
  74912. /**
  74913. * Shadow generator mode None: no filtering applied.
  74914. */
  74915. static readonly FILTER_NONE: number;
  74916. /**
  74917. * Shadow generator mode ESM: Exponential Shadow Mapping.
  74918. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74919. */
  74920. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  74921. /**
  74922. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  74923. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  74924. */
  74925. static readonly FILTER_POISSONSAMPLING: number;
  74926. /**
  74927. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  74928. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74929. */
  74930. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  74931. /**
  74932. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  74933. * edge artifacts on steep falloff.
  74934. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74935. */
  74936. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  74937. /**
  74938. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  74939. * edge artifacts on steep falloff.
  74940. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  74941. */
  74942. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  74943. /**
  74944. * Shadow generator mode PCF: Percentage Closer Filtering
  74945. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74946. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  74947. */
  74948. static readonly FILTER_PCF: number;
  74949. /**
  74950. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  74951. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  74952. * Contact Hardening
  74953. */
  74954. static readonly FILTER_PCSS: number;
  74955. /**
  74956. * Reserved for PCF and PCSS
  74957. * Highest Quality.
  74958. *
  74959. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  74960. *
  74961. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  74962. */
  74963. static readonly QUALITY_HIGH: number;
  74964. /**
  74965. * Reserved for PCF and PCSS
  74966. * Good tradeoff for quality/perf cross devices
  74967. *
  74968. * Execute PCF on a 3*3 kernel.
  74969. *
  74970. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  74971. */
  74972. static readonly QUALITY_MEDIUM: number;
  74973. /**
  74974. * Reserved for PCF and PCSS
  74975. * The lowest quality but the fastest.
  74976. *
  74977. * Execute PCF on a 1*1 kernel.
  74978. *
  74979. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  74980. */
  74981. static readonly QUALITY_LOW: number;
  74982. /** Gets or sets the custom shader name to use */
  74983. customShaderOptions: ICustomShaderOptions;
  74984. /**
  74985. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  74986. */
  74987. onBeforeShadowMapRenderObservable: Observable<Effect>;
  74988. /**
  74989. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  74990. */
  74991. onAfterShadowMapRenderObservable: Observable<Effect>;
  74992. /**
  74993. * Observable triggered before a mesh is rendered in the shadow map.
  74994. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  74995. */
  74996. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  74997. /**
  74998. * Observable triggered after a mesh is rendered in the shadow map.
  74999. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  75000. */
  75001. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  75002. private _bias;
  75003. /**
  75004. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  75005. */
  75006. /**
  75007. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  75008. */
  75009. bias: number;
  75010. private _normalBias;
  75011. /**
  75012. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75013. */
  75014. /**
  75015. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75016. */
  75017. normalBias: number;
  75018. private _blurBoxOffset;
  75019. /**
  75020. * Gets the blur box offset: offset applied during the blur pass.
  75021. * Only useful if useKernelBlur = false
  75022. */
  75023. /**
  75024. * Sets the blur box offset: offset applied during the blur pass.
  75025. * Only useful if useKernelBlur = false
  75026. */
  75027. blurBoxOffset: number;
  75028. private _blurScale;
  75029. /**
  75030. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  75031. * 2 means half of the size.
  75032. */
  75033. /**
  75034. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  75035. * 2 means half of the size.
  75036. */
  75037. blurScale: number;
  75038. private _blurKernel;
  75039. /**
  75040. * Gets the blur kernel: kernel size of the blur pass.
  75041. * Only useful if useKernelBlur = true
  75042. */
  75043. /**
  75044. * Sets the blur kernel: kernel size of the blur pass.
  75045. * Only useful if useKernelBlur = true
  75046. */
  75047. blurKernel: number;
  75048. private _useKernelBlur;
  75049. /**
  75050. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  75051. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75052. */
  75053. /**
  75054. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  75055. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75056. */
  75057. useKernelBlur: boolean;
  75058. private _depthScale;
  75059. /**
  75060. * Gets the depth scale used in ESM mode.
  75061. */
  75062. /**
  75063. * Sets the depth scale used in ESM mode.
  75064. * This can override the scale stored on the light.
  75065. */
  75066. depthScale: number;
  75067. private _filter;
  75068. /**
  75069. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  75070. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75071. */
  75072. /**
  75073. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  75074. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75075. */
  75076. filter: number;
  75077. /**
  75078. * Gets if the current filter is set to Poisson Sampling.
  75079. */
  75080. /**
  75081. * Sets the current filter to Poisson Sampling.
  75082. */
  75083. usePoissonSampling: boolean;
  75084. /**
  75085. * Gets if the current filter is set to ESM.
  75086. */
  75087. /**
  75088. * Sets the current filter is to ESM.
  75089. */
  75090. useExponentialShadowMap: boolean;
  75091. /**
  75092. * Gets if the current filter is set to filtered ESM.
  75093. */
  75094. /**
  75095. * Gets if the current filter is set to filtered ESM.
  75096. */
  75097. useBlurExponentialShadowMap: boolean;
  75098. /**
  75099. * Gets if the current filter is set to "close ESM" (using the inverse of the
  75100. * exponential to prevent steep falloff artifacts).
  75101. */
  75102. /**
  75103. * Sets the current filter to "close ESM" (using the inverse of the
  75104. * exponential to prevent steep falloff artifacts).
  75105. */
  75106. useCloseExponentialShadowMap: boolean;
  75107. /**
  75108. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  75109. * exponential to prevent steep falloff artifacts).
  75110. */
  75111. /**
  75112. * Sets the current filter to filtered "close ESM" (using the inverse of the
  75113. * exponential to prevent steep falloff artifacts).
  75114. */
  75115. useBlurCloseExponentialShadowMap: boolean;
  75116. /**
  75117. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  75118. */
  75119. /**
  75120. * Sets the current filter to "PCF" (percentage closer filtering).
  75121. */
  75122. usePercentageCloserFiltering: boolean;
  75123. private _filteringQuality;
  75124. /**
  75125. * Gets the PCF or PCSS Quality.
  75126. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75127. */
  75128. /**
  75129. * Sets the PCF or PCSS Quality.
  75130. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75131. */
  75132. filteringQuality: number;
  75133. /**
  75134. * Gets if the current filter is set to "PCSS" (contact hardening).
  75135. */
  75136. /**
  75137. * Sets the current filter to "PCSS" (contact hardening).
  75138. */
  75139. useContactHardeningShadow: boolean;
  75140. private _contactHardeningLightSizeUVRatio;
  75141. /**
  75142. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75143. * Using a ratio helps keeping shape stability independently of the map size.
  75144. *
  75145. * It does not account for the light projection as it was having too much
  75146. * instability during the light setup or during light position changes.
  75147. *
  75148. * Only valid if useContactHardeningShadow is true.
  75149. */
  75150. /**
  75151. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75152. * Using a ratio helps keeping shape stability independently of the map size.
  75153. *
  75154. * It does not account for the light projection as it was having too much
  75155. * instability during the light setup or during light position changes.
  75156. *
  75157. * Only valid if useContactHardeningShadow is true.
  75158. */
  75159. contactHardeningLightSizeUVRatio: number;
  75160. private _darkness;
  75161. /** Gets or sets the actual darkness of a shadow */
  75162. darkness: number;
  75163. /**
  75164. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  75165. * 0 means strongest and 1 would means no shadow.
  75166. * @returns the darkness.
  75167. */
  75168. getDarkness(): number;
  75169. /**
  75170. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  75171. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  75172. * @returns the shadow generator allowing fluent coding.
  75173. */
  75174. setDarkness(darkness: number): ShadowGenerator;
  75175. private _transparencyShadow;
  75176. /** Gets or sets the ability to have transparent shadow */
  75177. transparencyShadow: boolean;
  75178. /**
  75179. * Sets the ability to have transparent shadow (boolean).
  75180. * @param transparent True if transparent else False
  75181. * @returns the shadow generator allowing fluent coding
  75182. */
  75183. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  75184. private _shadowMap;
  75185. private _shadowMap2;
  75186. /**
  75187. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75188. * @returns The render target texture if present otherwise, null
  75189. */
  75190. getShadowMap(): Nullable<RenderTargetTexture>;
  75191. /**
  75192. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75193. * @returns The render target texture if the shadow map is present otherwise, null
  75194. */
  75195. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75196. /**
  75197. * Gets the class name of that object
  75198. * @returns "ShadowGenerator"
  75199. */
  75200. getClassName(): string;
  75201. /**
  75202. * Helper function to add a mesh and its descendants to the list of shadow casters.
  75203. * @param mesh Mesh to add
  75204. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  75205. * @returns the Shadow Generator itself
  75206. */
  75207. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75208. /**
  75209. * Helper function to remove a mesh and its descendants from the list of shadow casters
  75210. * @param mesh Mesh to remove
  75211. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  75212. * @returns the Shadow Generator itself
  75213. */
  75214. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75215. /**
  75216. * Controls the extent to which the shadows fade out at the edge of the frustum
  75217. * Used only by directionals and spots
  75218. */
  75219. frustumEdgeFalloff: number;
  75220. private _light;
  75221. /**
  75222. * Returns the associated light object.
  75223. * @returns the light generating the shadow
  75224. */
  75225. getLight(): IShadowLight;
  75226. /**
  75227. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  75228. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  75229. * It might on the other hand introduce peter panning.
  75230. */
  75231. forceBackFacesOnly: boolean;
  75232. private _scene;
  75233. private _lightDirection;
  75234. private _effect;
  75235. private _viewMatrix;
  75236. private _projectionMatrix;
  75237. private _transformMatrix;
  75238. private _cachedPosition;
  75239. private _cachedDirection;
  75240. private _cachedDefines;
  75241. private _currentRenderID;
  75242. private _boxBlurPostprocess;
  75243. private _kernelBlurXPostprocess;
  75244. private _kernelBlurYPostprocess;
  75245. private _blurPostProcesses;
  75246. private _mapSize;
  75247. private _currentFaceIndex;
  75248. private _currentFaceIndexCache;
  75249. private _textureType;
  75250. private _defaultTextureMatrix;
  75251. /** @hidden */
  75252. static _SceneComponentInitialization: (scene: Scene) => void;
  75253. /**
  75254. * Creates a ShadowGenerator object.
  75255. * A ShadowGenerator is the required tool to use the shadows.
  75256. * Each light casting shadows needs to use its own ShadowGenerator.
  75257. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  75258. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  75259. * @param light The light object generating the shadows.
  75260. * @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.
  75261. */
  75262. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  75263. private _initializeGenerator;
  75264. private _initializeShadowMap;
  75265. private _initializeBlurRTTAndPostProcesses;
  75266. private _renderForShadowMap;
  75267. private _renderSubMeshForShadowMap;
  75268. private _applyFilterValues;
  75269. /**
  75270. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75271. * @param onCompiled Callback triggered at the and of the effects compilation
  75272. * @param options Sets of optional options forcing the compilation with different modes
  75273. */
  75274. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  75275. useInstances: boolean;
  75276. }>): void;
  75277. /**
  75278. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75279. * @param options Sets of optional options forcing the compilation with different modes
  75280. * @returns A promise that resolves when the compilation completes
  75281. */
  75282. forceCompilationAsync(options?: Partial<{
  75283. useInstances: boolean;
  75284. }>): Promise<void>;
  75285. /**
  75286. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75287. * @param subMesh The submesh we want to render in the shadow map
  75288. * @param useInstances Defines wether will draw in the map using instances
  75289. * @returns true if ready otherwise, false
  75290. */
  75291. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75292. /**
  75293. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75294. * @param defines Defines of the material we want to update
  75295. * @param lightIndex Index of the light in the enabled light list of the material
  75296. */
  75297. prepareDefines(defines: any, lightIndex: number): void;
  75298. /**
  75299. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75300. * defined in the generator but impacting the effect).
  75301. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75302. * @param effect The effect we are binfing the information for
  75303. */
  75304. bindShadowLight(lightIndex: string, effect: Effect): void;
  75305. /**
  75306. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75307. * (eq to shadow prjection matrix * light transform matrix)
  75308. * @returns The transform matrix used to create the shadow map
  75309. */
  75310. getTransformMatrix(): Matrix;
  75311. /**
  75312. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  75313. * Cube and 2D textures for instance.
  75314. */
  75315. recreateShadowMap(): void;
  75316. private _disposeBlurPostProcesses;
  75317. private _disposeRTTandPostProcesses;
  75318. /**
  75319. * Disposes the ShadowGenerator.
  75320. * Returns nothing.
  75321. */
  75322. dispose(): void;
  75323. /**
  75324. * Serializes the shadow generator setup to a json object.
  75325. * @returns The serialized JSON object
  75326. */
  75327. serialize(): any;
  75328. /**
  75329. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  75330. * @param parsedShadowGenerator The JSON object to parse
  75331. * @param scene The scene to create the shadow map for
  75332. * @returns The parsed shadow generator
  75333. */
  75334. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  75335. }
  75336. }
  75337. declare module BABYLON {
  75338. /**
  75339. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  75340. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  75341. * 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.
  75342. */
  75343. export abstract class Light extends Node {
  75344. /**
  75345. * Falloff Default: light is falling off following the material specification:
  75346. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  75347. */
  75348. static readonly FALLOFF_DEFAULT: number;
  75349. /**
  75350. * Falloff Physical: light is falling off following the inverse squared distance law.
  75351. */
  75352. static readonly FALLOFF_PHYSICAL: number;
  75353. /**
  75354. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  75355. * to enhance interoperability with other engines.
  75356. */
  75357. static readonly FALLOFF_GLTF: number;
  75358. /**
  75359. * Falloff Standard: light is falling off like in the standard material
  75360. * to enhance interoperability with other materials.
  75361. */
  75362. static readonly FALLOFF_STANDARD: number;
  75363. /**
  75364. * If every light affecting the material is in this lightmapMode,
  75365. * material.lightmapTexture adds or multiplies
  75366. * (depends on material.useLightmapAsShadowmap)
  75367. * after every other light calculations.
  75368. */
  75369. static readonly LIGHTMAP_DEFAULT: number;
  75370. /**
  75371. * material.lightmapTexture as only diffuse lighting from this light
  75372. * adds only specular lighting from this light
  75373. * adds dynamic shadows
  75374. */
  75375. static readonly LIGHTMAP_SPECULAR: number;
  75376. /**
  75377. * material.lightmapTexture as only lighting
  75378. * no light calculation from this light
  75379. * only adds dynamic shadows from this light
  75380. */
  75381. static readonly LIGHTMAP_SHADOWSONLY: number;
  75382. /**
  75383. * Each light type uses the default quantity according to its type:
  75384. * point/spot lights use luminous intensity
  75385. * directional lights use illuminance
  75386. */
  75387. static readonly INTENSITYMODE_AUTOMATIC: number;
  75388. /**
  75389. * lumen (lm)
  75390. */
  75391. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  75392. /**
  75393. * candela (lm/sr)
  75394. */
  75395. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  75396. /**
  75397. * lux (lm/m^2)
  75398. */
  75399. static readonly INTENSITYMODE_ILLUMINANCE: number;
  75400. /**
  75401. * nit (cd/m^2)
  75402. */
  75403. static readonly INTENSITYMODE_LUMINANCE: number;
  75404. /**
  75405. * Light type const id of the point light.
  75406. */
  75407. static readonly LIGHTTYPEID_POINTLIGHT: number;
  75408. /**
  75409. * Light type const id of the directional light.
  75410. */
  75411. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  75412. /**
  75413. * Light type const id of the spot light.
  75414. */
  75415. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  75416. /**
  75417. * Light type const id of the hemispheric light.
  75418. */
  75419. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  75420. /**
  75421. * Diffuse gives the basic color to an object.
  75422. */
  75423. diffuse: Color3;
  75424. /**
  75425. * Specular produces a highlight color on an object.
  75426. * Note: This is note affecting PBR materials.
  75427. */
  75428. specular: Color3;
  75429. /**
  75430. * Defines the falloff type for this light. This lets overrriding how punctual light are
  75431. * falling off base on range or angle.
  75432. * This can be set to any values in Light.FALLOFF_x.
  75433. *
  75434. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  75435. * other types of materials.
  75436. */
  75437. falloffType: number;
  75438. /**
  75439. * Strength of the light.
  75440. * Note: By default it is define in the framework own unit.
  75441. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  75442. */
  75443. intensity: number;
  75444. private _range;
  75445. protected _inverseSquaredRange: number;
  75446. /**
  75447. * Defines how far from the source the light is impacting in scene units.
  75448. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75449. */
  75450. /**
  75451. * Defines how far from the source the light is impacting in scene units.
  75452. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75453. */
  75454. range: number;
  75455. /**
  75456. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  75457. * of light.
  75458. */
  75459. private _photometricScale;
  75460. private _intensityMode;
  75461. /**
  75462. * Gets the photometric scale used to interpret the intensity.
  75463. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75464. */
  75465. /**
  75466. * Sets the photometric scale used to interpret the intensity.
  75467. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75468. */
  75469. intensityMode: number;
  75470. private _radius;
  75471. /**
  75472. * Gets the light radius used by PBR Materials to simulate soft area lights.
  75473. */
  75474. /**
  75475. * sets the light radius used by PBR Materials to simulate soft area lights.
  75476. */
  75477. radius: number;
  75478. private _renderPriority;
  75479. /**
  75480. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  75481. * exceeding the number allowed of the materials.
  75482. */
  75483. renderPriority: number;
  75484. private _shadowEnabled;
  75485. /**
  75486. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75487. * the current shadow generator.
  75488. */
  75489. /**
  75490. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75491. * the current shadow generator.
  75492. */
  75493. shadowEnabled: boolean;
  75494. private _includedOnlyMeshes;
  75495. /**
  75496. * Gets the only meshes impacted by this light.
  75497. */
  75498. /**
  75499. * Sets the only meshes impacted by this light.
  75500. */
  75501. includedOnlyMeshes: AbstractMesh[];
  75502. private _excludedMeshes;
  75503. /**
  75504. * Gets the meshes not impacted by this light.
  75505. */
  75506. /**
  75507. * Sets the meshes not impacted by this light.
  75508. */
  75509. excludedMeshes: AbstractMesh[];
  75510. private _excludeWithLayerMask;
  75511. /**
  75512. * Gets the layer id use to find what meshes are not impacted by the light.
  75513. * Inactive if 0
  75514. */
  75515. /**
  75516. * Sets the layer id use to find what meshes are not impacted by the light.
  75517. * Inactive if 0
  75518. */
  75519. excludeWithLayerMask: number;
  75520. private _includeOnlyWithLayerMask;
  75521. /**
  75522. * Gets the layer id use to find what meshes are impacted by the light.
  75523. * Inactive if 0
  75524. */
  75525. /**
  75526. * Sets the layer id use to find what meshes are impacted by the light.
  75527. * Inactive if 0
  75528. */
  75529. includeOnlyWithLayerMask: number;
  75530. private _lightmapMode;
  75531. /**
  75532. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75533. */
  75534. /**
  75535. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75536. */
  75537. lightmapMode: number;
  75538. /**
  75539. * Shadow generator associted to the light.
  75540. * @hidden Internal use only.
  75541. */
  75542. _shadowGenerator: Nullable<IShadowGenerator>;
  75543. /**
  75544. * @hidden Internal use only.
  75545. */
  75546. _excludedMeshesIds: string[];
  75547. /**
  75548. * @hidden Internal use only.
  75549. */
  75550. _includedOnlyMeshesIds: string[];
  75551. /**
  75552. * The current light unifom buffer.
  75553. * @hidden Internal use only.
  75554. */
  75555. _uniformBuffer: UniformBuffer;
  75556. /**
  75557. * Creates a Light object in the scene.
  75558. * Documentation : https://doc.babylonjs.com/babylon101/lights
  75559. * @param name The firendly name of the light
  75560. * @param scene The scene the light belongs too
  75561. */
  75562. constructor(name: string, scene: Scene);
  75563. protected abstract _buildUniformLayout(): void;
  75564. /**
  75565. * Sets the passed Effect "effect" with the Light information.
  75566. * @param effect The effect to update
  75567. * @param lightIndex The index of the light in the effect to update
  75568. * @returns The light
  75569. */
  75570. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  75571. /**
  75572. * Sets the passed Effect "effect" with the Light information.
  75573. * @param effect The effect to update
  75574. * @param lightDataUniformName The uniform used to store light data (position or direction)
  75575. * @returns The light
  75576. */
  75577. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  75578. /**
  75579. * Returns the string "Light".
  75580. * @returns the class name
  75581. */
  75582. getClassName(): string;
  75583. /** @hidden */
  75584. readonly _isLight: boolean;
  75585. /**
  75586. * Converts the light information to a readable string for debug purpose.
  75587. * @param fullDetails Supports for multiple levels of logging within scene loading
  75588. * @returns the human readable light info
  75589. */
  75590. toString(fullDetails?: boolean): string;
  75591. /** @hidden */
  75592. protected _syncParentEnabledState(): void;
  75593. /**
  75594. * Set the enabled state of this node.
  75595. * @param value - the new enabled state
  75596. */
  75597. setEnabled(value: boolean): void;
  75598. /**
  75599. * Returns the Light associated shadow generator if any.
  75600. * @return the associated shadow generator.
  75601. */
  75602. getShadowGenerator(): Nullable<IShadowGenerator>;
  75603. /**
  75604. * Returns a Vector3, the absolute light position in the World.
  75605. * @returns the world space position of the light
  75606. */
  75607. getAbsolutePosition(): Vector3;
  75608. /**
  75609. * Specifies if the light will affect the passed mesh.
  75610. * @param mesh The mesh to test against the light
  75611. * @return true the mesh is affected otherwise, false.
  75612. */
  75613. canAffectMesh(mesh: AbstractMesh): boolean;
  75614. /**
  75615. * Sort function to order lights for rendering.
  75616. * @param a First Light object to compare to second.
  75617. * @param b Second Light object to compare first.
  75618. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  75619. */
  75620. static CompareLightsPriority(a: Light, b: Light): number;
  75621. /**
  75622. * Releases resources associated with this node.
  75623. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  75624. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  75625. */
  75626. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75627. /**
  75628. * Returns the light type ID (integer).
  75629. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  75630. */
  75631. getTypeID(): number;
  75632. /**
  75633. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  75634. * @returns the scaled intensity in intensity mode unit
  75635. */
  75636. getScaledIntensity(): number;
  75637. /**
  75638. * Returns a new Light object, named "name", from the current one.
  75639. * @param name The name of the cloned light
  75640. * @returns the new created light
  75641. */
  75642. clone(name: string): Nullable<Light>;
  75643. /**
  75644. * Serializes the current light into a Serialization object.
  75645. * @returns the serialized object.
  75646. */
  75647. serialize(): any;
  75648. /**
  75649. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  75650. * This new light is named "name" and added to the passed scene.
  75651. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  75652. * @param name The friendly name of the light
  75653. * @param scene The scene the new light will belong to
  75654. * @returns the constructor function
  75655. */
  75656. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  75657. /**
  75658. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  75659. * @param parsedLight The JSON representation of the light
  75660. * @param scene The scene to create the parsed light in
  75661. * @returns the created light after parsing
  75662. */
  75663. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  75664. private _hookArrayForExcluded;
  75665. private _hookArrayForIncludedOnly;
  75666. private _resyncMeshes;
  75667. /**
  75668. * Forces the meshes to update their light related information in their rendering used effects
  75669. * @hidden Internal Use Only
  75670. */
  75671. _markMeshesAsLightDirty(): void;
  75672. /**
  75673. * Recomputes the cached photometric scale if needed.
  75674. */
  75675. private _computePhotometricScale;
  75676. /**
  75677. * Returns the Photometric Scale according to the light type and intensity mode.
  75678. */
  75679. private _getPhotometricScale;
  75680. /**
  75681. * Reorder the light in the scene according to their defined priority.
  75682. * @hidden Internal Use Only
  75683. */
  75684. _reorderLightsInScene(): void;
  75685. /**
  75686. * Prepares the list of defines specific to the light type.
  75687. * @param defines the list of defines
  75688. * @param lightIndex defines the index of the light for the effect
  75689. */
  75690. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  75691. }
  75692. }
  75693. declare module BABYLON {
  75694. /**
  75695. * Interface used to define Action
  75696. */
  75697. export interface IAction {
  75698. /**
  75699. * Trigger for the action
  75700. */
  75701. trigger: number;
  75702. /** Options of the trigger */
  75703. triggerOptions: any;
  75704. /**
  75705. * Gets the trigger parameters
  75706. * @returns the trigger parameters
  75707. */
  75708. getTriggerParameter(): any;
  75709. /**
  75710. * Internal only - executes current action event
  75711. * @hidden
  75712. */
  75713. _executeCurrent(evt?: ActionEvent): void;
  75714. /**
  75715. * Serialize placeholder for child classes
  75716. * @param parent of child
  75717. * @returns the serialized object
  75718. */
  75719. serialize(parent: any): any;
  75720. /**
  75721. * Internal only
  75722. * @hidden
  75723. */
  75724. _prepare(): void;
  75725. /**
  75726. * Internal only - manager for action
  75727. * @hidden
  75728. */
  75729. _actionManager: AbstractActionManager;
  75730. /**
  75731. * Adds action to chain of actions, may be a DoNothingAction
  75732. * @param action defines the next action to execute
  75733. * @returns The action passed in
  75734. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75735. */
  75736. then(action: IAction): IAction;
  75737. }
  75738. /**
  75739. * The action to be carried out following a trigger
  75740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  75741. */
  75742. export class Action implements IAction {
  75743. /** the trigger, with or without parameters, for the action */
  75744. triggerOptions: any;
  75745. /**
  75746. * Trigger for the action
  75747. */
  75748. trigger: number;
  75749. /**
  75750. * Internal only - manager for action
  75751. * @hidden
  75752. */
  75753. _actionManager: ActionManager;
  75754. private _nextActiveAction;
  75755. private _child;
  75756. private _condition?;
  75757. private _triggerParameter;
  75758. /**
  75759. * An event triggered prior to action being executed.
  75760. */
  75761. onBeforeExecuteObservable: Observable<Action>;
  75762. /**
  75763. * Creates a new Action
  75764. * @param triggerOptions the trigger, with or without parameters, for the action
  75765. * @param condition an optional determinant of action
  75766. */
  75767. constructor(
  75768. /** the trigger, with or without parameters, for the action */
  75769. triggerOptions: any, condition?: Condition);
  75770. /**
  75771. * Internal only
  75772. * @hidden
  75773. */
  75774. _prepare(): void;
  75775. /**
  75776. * Gets the trigger parameters
  75777. * @returns the trigger parameters
  75778. */
  75779. getTriggerParameter(): any;
  75780. /**
  75781. * Internal only - executes current action event
  75782. * @hidden
  75783. */
  75784. _executeCurrent(evt?: ActionEvent): void;
  75785. /**
  75786. * Execute placeholder for child classes
  75787. * @param evt optional action event
  75788. */
  75789. execute(evt?: ActionEvent): void;
  75790. /**
  75791. * Skips to next active action
  75792. */
  75793. skipToNextActiveAction(): void;
  75794. /**
  75795. * Adds action to chain of actions, may be a DoNothingAction
  75796. * @param action defines the next action to execute
  75797. * @returns The action passed in
  75798. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75799. */
  75800. then(action: Action): Action;
  75801. /**
  75802. * Internal only
  75803. * @hidden
  75804. */
  75805. _getProperty(propertyPath: string): string;
  75806. /**
  75807. * Internal only
  75808. * @hidden
  75809. */
  75810. _getEffectiveTarget(target: any, propertyPath: string): any;
  75811. /**
  75812. * Serialize placeholder for child classes
  75813. * @param parent of child
  75814. * @returns the serialized object
  75815. */
  75816. serialize(parent: any): any;
  75817. /**
  75818. * Internal only called by serialize
  75819. * @hidden
  75820. */
  75821. protected _serialize(serializedAction: any, parent?: any): any;
  75822. /**
  75823. * Internal only
  75824. * @hidden
  75825. */
  75826. static _SerializeValueAsString: (value: any) => string;
  75827. /**
  75828. * Internal only
  75829. * @hidden
  75830. */
  75831. static _GetTargetProperty: (target: Node | Scene) => {
  75832. name: string;
  75833. targetType: string;
  75834. value: string;
  75835. };
  75836. }
  75837. }
  75838. declare module BABYLON {
  75839. /**
  75840. * A Condition applied to an Action
  75841. */
  75842. export class Condition {
  75843. /**
  75844. * Internal only - manager for action
  75845. * @hidden
  75846. */
  75847. _actionManager: ActionManager;
  75848. /**
  75849. * Internal only
  75850. * @hidden
  75851. */
  75852. _evaluationId: number;
  75853. /**
  75854. * Internal only
  75855. * @hidden
  75856. */
  75857. _currentResult: boolean;
  75858. /**
  75859. * Creates a new Condition
  75860. * @param actionManager the manager of the action the condition is applied to
  75861. */
  75862. constructor(actionManager: ActionManager);
  75863. /**
  75864. * Check if the current condition is valid
  75865. * @returns a boolean
  75866. */
  75867. isValid(): boolean;
  75868. /**
  75869. * Internal only
  75870. * @hidden
  75871. */
  75872. _getProperty(propertyPath: string): string;
  75873. /**
  75874. * Internal only
  75875. * @hidden
  75876. */
  75877. _getEffectiveTarget(target: any, propertyPath: string): any;
  75878. /**
  75879. * Serialize placeholder for child classes
  75880. * @returns the serialized object
  75881. */
  75882. serialize(): any;
  75883. /**
  75884. * Internal only
  75885. * @hidden
  75886. */
  75887. protected _serialize(serializedCondition: any): any;
  75888. }
  75889. /**
  75890. * Defines specific conditional operators as extensions of Condition
  75891. */
  75892. export class ValueCondition extends Condition {
  75893. /** path to specify the property of the target the conditional operator uses */
  75894. propertyPath: string;
  75895. /** the value compared by the conditional operator against the current value of the property */
  75896. value: any;
  75897. /** the conditional operator, default ValueCondition.IsEqual */
  75898. operator: number;
  75899. /**
  75900. * Internal only
  75901. * @hidden
  75902. */
  75903. private static _IsEqual;
  75904. /**
  75905. * Internal only
  75906. * @hidden
  75907. */
  75908. private static _IsDifferent;
  75909. /**
  75910. * Internal only
  75911. * @hidden
  75912. */
  75913. private static _IsGreater;
  75914. /**
  75915. * Internal only
  75916. * @hidden
  75917. */
  75918. private static _IsLesser;
  75919. /**
  75920. * returns the number for IsEqual
  75921. */
  75922. static readonly IsEqual: number;
  75923. /**
  75924. * Returns the number for IsDifferent
  75925. */
  75926. static readonly IsDifferent: number;
  75927. /**
  75928. * Returns the number for IsGreater
  75929. */
  75930. static readonly IsGreater: number;
  75931. /**
  75932. * Returns the number for IsLesser
  75933. */
  75934. static readonly IsLesser: number;
  75935. /**
  75936. * Internal only The action manager for the condition
  75937. * @hidden
  75938. */
  75939. _actionManager: ActionManager;
  75940. /**
  75941. * Internal only
  75942. * @hidden
  75943. */
  75944. private _target;
  75945. /**
  75946. * Internal only
  75947. * @hidden
  75948. */
  75949. private _effectiveTarget;
  75950. /**
  75951. * Internal only
  75952. * @hidden
  75953. */
  75954. private _property;
  75955. /**
  75956. * Creates a new ValueCondition
  75957. * @param actionManager manager for the action the condition applies to
  75958. * @param target for the action
  75959. * @param propertyPath path to specify the property of the target the conditional operator uses
  75960. * @param value the value compared by the conditional operator against the current value of the property
  75961. * @param operator the conditional operator, default ValueCondition.IsEqual
  75962. */
  75963. constructor(actionManager: ActionManager, target: any,
  75964. /** path to specify the property of the target the conditional operator uses */
  75965. propertyPath: string,
  75966. /** the value compared by the conditional operator against the current value of the property */
  75967. value: any,
  75968. /** the conditional operator, default ValueCondition.IsEqual */
  75969. operator?: number);
  75970. /**
  75971. * Compares the given value with the property value for the specified conditional operator
  75972. * @returns the result of the comparison
  75973. */
  75974. isValid(): boolean;
  75975. /**
  75976. * Serialize the ValueCondition into a JSON compatible object
  75977. * @returns serialization object
  75978. */
  75979. serialize(): any;
  75980. /**
  75981. * Gets the name of the conditional operator for the ValueCondition
  75982. * @param operator the conditional operator
  75983. * @returns the name
  75984. */
  75985. static GetOperatorName(operator: number): string;
  75986. }
  75987. /**
  75988. * Defines a predicate condition as an extension of Condition
  75989. */
  75990. export class PredicateCondition extends Condition {
  75991. /** defines the predicate function used to validate the condition */
  75992. predicate: () => boolean;
  75993. /**
  75994. * Internal only - manager for action
  75995. * @hidden
  75996. */
  75997. _actionManager: ActionManager;
  75998. /**
  75999. * Creates a new PredicateCondition
  76000. * @param actionManager manager for the action the condition applies to
  76001. * @param predicate defines the predicate function used to validate the condition
  76002. */
  76003. constructor(actionManager: ActionManager,
  76004. /** defines the predicate function used to validate the condition */
  76005. predicate: () => boolean);
  76006. /**
  76007. * @returns the validity of the predicate condition
  76008. */
  76009. isValid(): boolean;
  76010. }
  76011. /**
  76012. * Defines a state condition as an extension of Condition
  76013. */
  76014. export class StateCondition extends Condition {
  76015. /** Value to compare with target state */
  76016. value: string;
  76017. /**
  76018. * Internal only - manager for action
  76019. * @hidden
  76020. */
  76021. _actionManager: ActionManager;
  76022. /**
  76023. * Internal only
  76024. * @hidden
  76025. */
  76026. private _target;
  76027. /**
  76028. * Creates a new StateCondition
  76029. * @param actionManager manager for the action the condition applies to
  76030. * @param target of the condition
  76031. * @param value to compare with target state
  76032. */
  76033. constructor(actionManager: ActionManager, target: any,
  76034. /** Value to compare with target state */
  76035. value: string);
  76036. /**
  76037. * Gets a boolean indicating if the current condition is met
  76038. * @returns the validity of the state
  76039. */
  76040. isValid(): boolean;
  76041. /**
  76042. * Serialize the StateCondition into a JSON compatible object
  76043. * @returns serialization object
  76044. */
  76045. serialize(): any;
  76046. }
  76047. }
  76048. declare module BABYLON {
  76049. /**
  76050. * This defines an action responsible to toggle a boolean once triggered.
  76051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76052. */
  76053. export class SwitchBooleanAction extends Action {
  76054. /**
  76055. * The path to the boolean property in the target object
  76056. */
  76057. propertyPath: string;
  76058. private _target;
  76059. private _effectiveTarget;
  76060. private _property;
  76061. /**
  76062. * Instantiate the action
  76063. * @param triggerOptions defines the trigger options
  76064. * @param target defines the object containing the boolean
  76065. * @param propertyPath defines the path to the boolean property in the target object
  76066. * @param condition defines the trigger related conditions
  76067. */
  76068. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  76069. /** @hidden */
  76070. _prepare(): void;
  76071. /**
  76072. * Execute the action toggle the boolean value.
  76073. */
  76074. execute(): void;
  76075. /**
  76076. * Serializes the actions and its related information.
  76077. * @param parent defines the object to serialize in
  76078. * @returns the serialized object
  76079. */
  76080. serialize(parent: any): any;
  76081. }
  76082. /**
  76083. * This defines an action responsible to set a the state field of the target
  76084. * to a desired value once triggered.
  76085. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76086. */
  76087. export class SetStateAction extends Action {
  76088. /**
  76089. * The value to store in the state field.
  76090. */
  76091. value: string;
  76092. private _target;
  76093. /**
  76094. * Instantiate the action
  76095. * @param triggerOptions defines the trigger options
  76096. * @param target defines the object containing the state property
  76097. * @param value defines the value to store in the state field
  76098. * @param condition defines the trigger related conditions
  76099. */
  76100. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  76101. /**
  76102. * Execute the action and store the value on the target state property.
  76103. */
  76104. execute(): void;
  76105. /**
  76106. * Serializes the actions and its related information.
  76107. * @param parent defines the object to serialize in
  76108. * @returns the serialized object
  76109. */
  76110. serialize(parent: any): any;
  76111. }
  76112. /**
  76113. * This defines an action responsible to set a property of the target
  76114. * to a desired value once triggered.
  76115. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76116. */
  76117. export class SetValueAction extends Action {
  76118. /**
  76119. * The path of the property to set in the target.
  76120. */
  76121. propertyPath: string;
  76122. /**
  76123. * The value to set in the property
  76124. */
  76125. value: any;
  76126. private _target;
  76127. private _effectiveTarget;
  76128. private _property;
  76129. /**
  76130. * Instantiate the action
  76131. * @param triggerOptions defines the trigger options
  76132. * @param target defines the object containing the property
  76133. * @param propertyPath defines the path of the property to set in the target
  76134. * @param value defines the value to set in the property
  76135. * @param condition defines the trigger related conditions
  76136. */
  76137. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76138. /** @hidden */
  76139. _prepare(): void;
  76140. /**
  76141. * Execute the action and set the targetted property to the desired value.
  76142. */
  76143. execute(): void;
  76144. /**
  76145. * Serializes the actions and its related information.
  76146. * @param parent defines the object to serialize in
  76147. * @returns the serialized object
  76148. */
  76149. serialize(parent: any): any;
  76150. }
  76151. /**
  76152. * This defines an action responsible to increment the target value
  76153. * to a desired value once triggered.
  76154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76155. */
  76156. export class IncrementValueAction extends Action {
  76157. /**
  76158. * The path of the property to increment in the target.
  76159. */
  76160. propertyPath: string;
  76161. /**
  76162. * The value we should increment the property by.
  76163. */
  76164. value: any;
  76165. private _target;
  76166. private _effectiveTarget;
  76167. private _property;
  76168. /**
  76169. * Instantiate the action
  76170. * @param triggerOptions defines the trigger options
  76171. * @param target defines the object containing the property
  76172. * @param propertyPath defines the path of the property to increment in the target
  76173. * @param value defines the value value we should increment the property by
  76174. * @param condition defines the trigger related conditions
  76175. */
  76176. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76177. /** @hidden */
  76178. _prepare(): void;
  76179. /**
  76180. * Execute the action and increment the target of the value amount.
  76181. */
  76182. execute(): void;
  76183. /**
  76184. * Serializes the actions and its related information.
  76185. * @param parent defines the object to serialize in
  76186. * @returns the serialized object
  76187. */
  76188. serialize(parent: any): any;
  76189. }
  76190. /**
  76191. * This defines an action responsible to start an animation once triggered.
  76192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76193. */
  76194. export class PlayAnimationAction extends Action {
  76195. /**
  76196. * Where the animation should start (animation frame)
  76197. */
  76198. from: number;
  76199. /**
  76200. * Where the animation should stop (animation frame)
  76201. */
  76202. to: number;
  76203. /**
  76204. * Define if the animation should loop or stop after the first play.
  76205. */
  76206. loop?: boolean;
  76207. private _target;
  76208. /**
  76209. * Instantiate the action
  76210. * @param triggerOptions defines the trigger options
  76211. * @param target defines the target animation or animation name
  76212. * @param from defines from where the animation should start (animation frame)
  76213. * @param end defines where the animation should stop (animation frame)
  76214. * @param loop defines if the animation should loop or stop after the first play
  76215. * @param condition defines the trigger related conditions
  76216. */
  76217. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  76218. /** @hidden */
  76219. _prepare(): void;
  76220. /**
  76221. * Execute the action and play the animation.
  76222. */
  76223. execute(): void;
  76224. /**
  76225. * Serializes the actions and its related information.
  76226. * @param parent defines the object to serialize in
  76227. * @returns the serialized object
  76228. */
  76229. serialize(parent: any): any;
  76230. }
  76231. /**
  76232. * This defines an action responsible to stop an animation once triggered.
  76233. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76234. */
  76235. export class StopAnimationAction extends Action {
  76236. private _target;
  76237. /**
  76238. * Instantiate the action
  76239. * @param triggerOptions defines the trigger options
  76240. * @param target defines the target animation or animation name
  76241. * @param condition defines the trigger related conditions
  76242. */
  76243. constructor(triggerOptions: any, target: any, condition?: Condition);
  76244. /** @hidden */
  76245. _prepare(): void;
  76246. /**
  76247. * Execute the action and stop the animation.
  76248. */
  76249. execute(): void;
  76250. /**
  76251. * Serializes the actions and its related information.
  76252. * @param parent defines the object to serialize in
  76253. * @returns the serialized object
  76254. */
  76255. serialize(parent: any): any;
  76256. }
  76257. /**
  76258. * This defines an action responsible that does nothing once triggered.
  76259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76260. */
  76261. export class DoNothingAction extends Action {
  76262. /**
  76263. * Instantiate the action
  76264. * @param triggerOptions defines the trigger options
  76265. * @param condition defines the trigger related conditions
  76266. */
  76267. constructor(triggerOptions?: any, condition?: Condition);
  76268. /**
  76269. * Execute the action and do nothing.
  76270. */
  76271. execute(): void;
  76272. /**
  76273. * Serializes the actions and its related information.
  76274. * @param parent defines the object to serialize in
  76275. * @returns the serialized object
  76276. */
  76277. serialize(parent: any): any;
  76278. }
  76279. /**
  76280. * This defines an action responsible to trigger several actions once triggered.
  76281. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76282. */
  76283. export class CombineAction extends Action {
  76284. /**
  76285. * The list of aggregated animations to run.
  76286. */
  76287. children: Action[];
  76288. /**
  76289. * Instantiate the action
  76290. * @param triggerOptions defines the trigger options
  76291. * @param children defines the list of aggregated animations to run
  76292. * @param condition defines the trigger related conditions
  76293. */
  76294. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  76295. /** @hidden */
  76296. _prepare(): void;
  76297. /**
  76298. * Execute the action and executes all the aggregated actions.
  76299. */
  76300. execute(evt: ActionEvent): void;
  76301. /**
  76302. * Serializes the actions and its related information.
  76303. * @param parent defines the object to serialize in
  76304. * @returns the serialized object
  76305. */
  76306. serialize(parent: any): any;
  76307. }
  76308. /**
  76309. * This defines an action responsible to run code (external event) once triggered.
  76310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76311. */
  76312. export class ExecuteCodeAction extends Action {
  76313. /**
  76314. * The callback function to run.
  76315. */
  76316. func: (evt: ActionEvent) => void;
  76317. /**
  76318. * Instantiate the action
  76319. * @param triggerOptions defines the trigger options
  76320. * @param func defines the callback function to run
  76321. * @param condition defines the trigger related conditions
  76322. */
  76323. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  76324. /**
  76325. * Execute the action and run the attached code.
  76326. */
  76327. execute(evt: ActionEvent): void;
  76328. }
  76329. /**
  76330. * This defines an action responsible to set the parent property of the target once triggered.
  76331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76332. */
  76333. export class SetParentAction extends Action {
  76334. private _parent;
  76335. private _target;
  76336. /**
  76337. * Instantiate the action
  76338. * @param triggerOptions defines the trigger options
  76339. * @param target defines the target containing the parent property
  76340. * @param parent defines from where the animation should start (animation frame)
  76341. * @param condition defines the trigger related conditions
  76342. */
  76343. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  76344. /** @hidden */
  76345. _prepare(): void;
  76346. /**
  76347. * Execute the action and set the parent property.
  76348. */
  76349. execute(): void;
  76350. /**
  76351. * Serializes the actions and its related information.
  76352. * @param parent defines the object to serialize in
  76353. * @returns the serialized object
  76354. */
  76355. serialize(parent: any): any;
  76356. }
  76357. }
  76358. declare module BABYLON {
  76359. /**
  76360. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  76361. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  76362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76363. */
  76364. export class ActionManager extends AbstractActionManager {
  76365. /**
  76366. * Nothing
  76367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76368. */
  76369. static readonly NothingTrigger: number;
  76370. /**
  76371. * On pick
  76372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76373. */
  76374. static readonly OnPickTrigger: number;
  76375. /**
  76376. * On left pick
  76377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76378. */
  76379. static readonly OnLeftPickTrigger: number;
  76380. /**
  76381. * On right pick
  76382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76383. */
  76384. static readonly OnRightPickTrigger: number;
  76385. /**
  76386. * On center pick
  76387. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76388. */
  76389. static readonly OnCenterPickTrigger: number;
  76390. /**
  76391. * On pick down
  76392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76393. */
  76394. static readonly OnPickDownTrigger: number;
  76395. /**
  76396. * On double pick
  76397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76398. */
  76399. static readonly OnDoublePickTrigger: number;
  76400. /**
  76401. * On pick up
  76402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76403. */
  76404. static readonly OnPickUpTrigger: number;
  76405. /**
  76406. * On pick out.
  76407. * This trigger will only be raised if you also declared a OnPickDown
  76408. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76409. */
  76410. static readonly OnPickOutTrigger: number;
  76411. /**
  76412. * On long press
  76413. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76414. */
  76415. static readonly OnLongPressTrigger: number;
  76416. /**
  76417. * On pointer over
  76418. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76419. */
  76420. static readonly OnPointerOverTrigger: number;
  76421. /**
  76422. * On pointer out
  76423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76424. */
  76425. static readonly OnPointerOutTrigger: number;
  76426. /**
  76427. * On every frame
  76428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76429. */
  76430. static readonly OnEveryFrameTrigger: number;
  76431. /**
  76432. * On intersection enter
  76433. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76434. */
  76435. static readonly OnIntersectionEnterTrigger: number;
  76436. /**
  76437. * On intersection exit
  76438. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76439. */
  76440. static readonly OnIntersectionExitTrigger: number;
  76441. /**
  76442. * On key down
  76443. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76444. */
  76445. static readonly OnKeyDownTrigger: number;
  76446. /**
  76447. * On key up
  76448. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76449. */
  76450. static readonly OnKeyUpTrigger: number;
  76451. private _scene;
  76452. /**
  76453. * Creates a new action manager
  76454. * @param scene defines the hosting scene
  76455. */
  76456. constructor(scene: Scene);
  76457. /**
  76458. * Releases all associated resources
  76459. */
  76460. dispose(): void;
  76461. /**
  76462. * Gets hosting scene
  76463. * @returns the hosting scene
  76464. */
  76465. getScene(): Scene;
  76466. /**
  76467. * Does this action manager handles actions of any of the given triggers
  76468. * @param triggers defines the triggers to be tested
  76469. * @return a boolean indicating whether one (or more) of the triggers is handled
  76470. */
  76471. hasSpecificTriggers(triggers: number[]): boolean;
  76472. /**
  76473. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  76474. * speed.
  76475. * @param triggerA defines the trigger to be tested
  76476. * @param triggerB defines the trigger to be tested
  76477. * @return a boolean indicating whether one (or more) of the triggers is handled
  76478. */
  76479. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  76480. /**
  76481. * Does this action manager handles actions of a given trigger
  76482. * @param trigger defines the trigger to be tested
  76483. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  76484. * @return whether the trigger is handled
  76485. */
  76486. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  76487. /**
  76488. * Does this action manager has pointer triggers
  76489. */
  76490. readonly hasPointerTriggers: boolean;
  76491. /**
  76492. * Does this action manager has pick triggers
  76493. */
  76494. readonly hasPickTriggers: boolean;
  76495. /**
  76496. * Registers an action to this action manager
  76497. * @param action defines the action to be registered
  76498. * @return the action amended (prepared) after registration
  76499. */
  76500. registerAction(action: IAction): Nullable<IAction>;
  76501. /**
  76502. * Unregisters an action to this action manager
  76503. * @param action defines the action to be unregistered
  76504. * @return a boolean indicating whether the action has been unregistered
  76505. */
  76506. unregisterAction(action: IAction): Boolean;
  76507. /**
  76508. * Process a specific trigger
  76509. * @param trigger defines the trigger to process
  76510. * @param evt defines the event details to be processed
  76511. */
  76512. processTrigger(trigger: number, evt?: IActionEvent): void;
  76513. /** @hidden */
  76514. _getEffectiveTarget(target: any, propertyPath: string): any;
  76515. /** @hidden */
  76516. _getProperty(propertyPath: string): string;
  76517. /**
  76518. * Serialize this manager to a JSON object
  76519. * @param name defines the property name to store this manager
  76520. * @returns a JSON representation of this manager
  76521. */
  76522. serialize(name: string): any;
  76523. /**
  76524. * Creates a new ActionManager from a JSON data
  76525. * @param parsedActions defines the JSON data to read from
  76526. * @param object defines the hosting mesh
  76527. * @param scene defines the hosting scene
  76528. */
  76529. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  76530. /**
  76531. * Get a trigger name by index
  76532. * @param trigger defines the trigger index
  76533. * @returns a trigger name
  76534. */
  76535. static GetTriggerName(trigger: number): string;
  76536. }
  76537. }
  76538. declare module BABYLON {
  76539. /**
  76540. * Class representing a ray with position and direction
  76541. */
  76542. export class Ray {
  76543. /** origin point */
  76544. origin: Vector3;
  76545. /** direction */
  76546. direction: Vector3;
  76547. /** length of the ray */
  76548. length: number;
  76549. private static readonly TmpVector3;
  76550. private _tmpRay;
  76551. /**
  76552. * Creates a new ray
  76553. * @param origin origin point
  76554. * @param direction direction
  76555. * @param length length of the ray
  76556. */
  76557. constructor(
  76558. /** origin point */
  76559. origin: Vector3,
  76560. /** direction */
  76561. direction: Vector3,
  76562. /** length of the ray */
  76563. length?: number);
  76564. /**
  76565. * Checks if the ray intersects a box
  76566. * @param minimum bound of the box
  76567. * @param maximum bound of the box
  76568. * @param intersectionTreshold extra extend to be added to the box in all direction
  76569. * @returns if the box was hit
  76570. */
  76571. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  76572. /**
  76573. * Checks if the ray intersects a box
  76574. * @param box the bounding box to check
  76575. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  76576. * @returns if the box was hit
  76577. */
  76578. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  76579. /**
  76580. * If the ray hits a sphere
  76581. * @param sphere the bounding sphere to check
  76582. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  76583. * @returns true if it hits the sphere
  76584. */
  76585. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  76586. /**
  76587. * If the ray hits a triange
  76588. * @param vertex0 triangle vertex
  76589. * @param vertex1 triangle vertex
  76590. * @param vertex2 triangle vertex
  76591. * @returns intersection information if hit
  76592. */
  76593. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  76594. /**
  76595. * Checks if ray intersects a plane
  76596. * @param plane the plane to check
  76597. * @returns the distance away it was hit
  76598. */
  76599. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  76600. /**
  76601. * Calculate the intercept of a ray on a given axis
  76602. * @param axis to check 'x' | 'y' | 'z'
  76603. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  76604. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  76605. */
  76606. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  76607. /**
  76608. * Checks if ray intersects a mesh
  76609. * @param mesh the mesh to check
  76610. * @param fastCheck if only the bounding box should checked
  76611. * @returns picking info of the intersecton
  76612. */
  76613. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  76614. /**
  76615. * Checks if ray intersects a mesh
  76616. * @param meshes the meshes to check
  76617. * @param fastCheck if only the bounding box should checked
  76618. * @param results array to store result in
  76619. * @returns Array of picking infos
  76620. */
  76621. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  76622. private _comparePickingInfo;
  76623. private static smallnum;
  76624. private static rayl;
  76625. /**
  76626. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  76627. * @param sega the first point of the segment to test the intersection against
  76628. * @param segb the second point of the segment to test the intersection against
  76629. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  76630. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  76631. */
  76632. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  76633. /**
  76634. * Update the ray from viewport position
  76635. * @param x position
  76636. * @param y y position
  76637. * @param viewportWidth viewport width
  76638. * @param viewportHeight viewport height
  76639. * @param world world matrix
  76640. * @param view view matrix
  76641. * @param projection projection matrix
  76642. * @returns this ray updated
  76643. */
  76644. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76645. /**
  76646. * Creates a ray with origin and direction of 0,0,0
  76647. * @returns the new ray
  76648. */
  76649. static Zero(): Ray;
  76650. /**
  76651. * Creates a new ray from screen space and viewport
  76652. * @param x position
  76653. * @param y y position
  76654. * @param viewportWidth viewport width
  76655. * @param viewportHeight viewport height
  76656. * @param world world matrix
  76657. * @param view view matrix
  76658. * @param projection projection matrix
  76659. * @returns new ray
  76660. */
  76661. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76662. /**
  76663. * 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
  76664. * transformed to the given world matrix.
  76665. * @param origin The origin point
  76666. * @param end The end point
  76667. * @param world a matrix to transform the ray to. Default is the identity matrix.
  76668. * @returns the new ray
  76669. */
  76670. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  76671. /**
  76672. * Transforms a ray by a matrix
  76673. * @param ray ray to transform
  76674. * @param matrix matrix to apply
  76675. * @returns the resulting new ray
  76676. */
  76677. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  76678. /**
  76679. * Transforms a ray by a matrix
  76680. * @param ray ray to transform
  76681. * @param matrix matrix to apply
  76682. * @param result ray to store result in
  76683. */
  76684. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  76685. /**
  76686. * Unproject a ray from screen space to object space
  76687. * @param sourceX defines the screen space x coordinate to use
  76688. * @param sourceY defines the screen space y coordinate to use
  76689. * @param viewportWidth defines the current width of the viewport
  76690. * @param viewportHeight defines the current height of the viewport
  76691. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76692. * @param view defines the view matrix to use
  76693. * @param projection defines the projection matrix to use
  76694. */
  76695. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  76696. }
  76697. /**
  76698. * Type used to define predicate used to select faces when a mesh intersection is detected
  76699. */
  76700. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  76701. interface Scene {
  76702. /** @hidden */
  76703. _tempPickingRay: Nullable<Ray>;
  76704. /** @hidden */
  76705. _cachedRayForTransform: Ray;
  76706. /** @hidden */
  76707. _pickWithRayInverseMatrix: Matrix;
  76708. /** @hidden */
  76709. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  76710. /** @hidden */
  76711. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  76712. }
  76713. }
  76714. declare module BABYLON {
  76715. /**
  76716. * Groups all the scene component constants in one place to ease maintenance.
  76717. * @hidden
  76718. */
  76719. export class SceneComponentConstants {
  76720. static readonly NAME_EFFECTLAYER: string;
  76721. static readonly NAME_LAYER: string;
  76722. static readonly NAME_LENSFLARESYSTEM: string;
  76723. static readonly NAME_BOUNDINGBOXRENDERER: string;
  76724. static readonly NAME_PARTICLESYSTEM: string;
  76725. static readonly NAME_GAMEPAD: string;
  76726. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  76727. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  76728. static readonly NAME_DEPTHRENDERER: string;
  76729. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  76730. static readonly NAME_SPRITE: string;
  76731. static readonly NAME_OUTLINERENDERER: string;
  76732. static readonly NAME_PROCEDURALTEXTURE: string;
  76733. static readonly NAME_SHADOWGENERATOR: string;
  76734. static readonly NAME_OCTREE: string;
  76735. static readonly NAME_PHYSICSENGINE: string;
  76736. static readonly NAME_AUDIO: string;
  76737. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  76738. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76739. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  76740. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76741. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  76742. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  76743. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  76744. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  76745. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  76746. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  76747. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  76748. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  76749. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  76750. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  76751. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  76752. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  76753. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  76754. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  76755. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  76756. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  76757. static readonly STEP_AFTERRENDER_AUDIO: number;
  76758. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  76759. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  76760. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  76761. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  76762. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  76763. static readonly STEP_POINTERMOVE_SPRITE: number;
  76764. static readonly STEP_POINTERDOWN_SPRITE: number;
  76765. static readonly STEP_POINTERUP_SPRITE: number;
  76766. }
  76767. /**
  76768. * This represents a scene component.
  76769. *
  76770. * This is used to decouple the dependency the scene is having on the different workloads like
  76771. * layers, post processes...
  76772. */
  76773. export interface ISceneComponent {
  76774. /**
  76775. * The name of the component. Each component must have a unique name.
  76776. */
  76777. name: string;
  76778. /**
  76779. * The scene the component belongs to.
  76780. */
  76781. scene: Scene;
  76782. /**
  76783. * Register the component to one instance of a scene.
  76784. */
  76785. register(): void;
  76786. /**
  76787. * Rebuilds the elements related to this component in case of
  76788. * context lost for instance.
  76789. */
  76790. rebuild(): void;
  76791. /**
  76792. * Disposes the component and the associated ressources.
  76793. */
  76794. dispose(): void;
  76795. }
  76796. /**
  76797. * This represents a SERIALIZABLE scene component.
  76798. *
  76799. * This extends Scene Component to add Serialization methods on top.
  76800. */
  76801. export interface ISceneSerializableComponent extends ISceneComponent {
  76802. /**
  76803. * Adds all the elements from the container to the scene
  76804. * @param container the container holding the elements
  76805. */
  76806. addFromContainer(container: AbstractScene): void;
  76807. /**
  76808. * Removes all the elements in the container from the scene
  76809. * @param container contains the elements to remove
  76810. * @param dispose if the removed element should be disposed (default: false)
  76811. */
  76812. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76813. /**
  76814. * Serializes the component data to the specified json object
  76815. * @param serializationObject The object to serialize to
  76816. */
  76817. serialize(serializationObject: any): void;
  76818. }
  76819. /**
  76820. * Strong typing of a Mesh related stage step action
  76821. */
  76822. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  76823. /**
  76824. * Strong typing of a Evaluate Sub Mesh related stage step action
  76825. */
  76826. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  76827. /**
  76828. * Strong typing of a Active Mesh related stage step action
  76829. */
  76830. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  76831. /**
  76832. * Strong typing of a Camera related stage step action
  76833. */
  76834. export type CameraStageAction = (camera: Camera) => void;
  76835. /**
  76836. * Strong typing of a Camera Frame buffer related stage step action
  76837. */
  76838. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  76839. /**
  76840. * Strong typing of a Render Target related stage step action
  76841. */
  76842. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  76843. /**
  76844. * Strong typing of a RenderingGroup related stage step action
  76845. */
  76846. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  76847. /**
  76848. * Strong typing of a Mesh Render related stage step action
  76849. */
  76850. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  76851. /**
  76852. * Strong typing of a simple stage step action
  76853. */
  76854. export type SimpleStageAction = () => void;
  76855. /**
  76856. * Strong typing of a render target action.
  76857. */
  76858. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  76859. /**
  76860. * Strong typing of a pointer move action.
  76861. */
  76862. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  76863. /**
  76864. * Strong typing of a pointer up/down action.
  76865. */
  76866. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  76867. /**
  76868. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  76869. * @hidden
  76870. */
  76871. export class Stage<T extends Function> extends Array<{
  76872. index: number;
  76873. component: ISceneComponent;
  76874. action: T;
  76875. }> {
  76876. /**
  76877. * Hide ctor from the rest of the world.
  76878. * @param items The items to add.
  76879. */
  76880. private constructor();
  76881. /**
  76882. * Creates a new Stage.
  76883. * @returns A new instance of a Stage
  76884. */
  76885. static Create<T extends Function>(): Stage<T>;
  76886. /**
  76887. * Registers a step in an ordered way in the targeted stage.
  76888. * @param index Defines the position to register the step in
  76889. * @param component Defines the component attached to the step
  76890. * @param action Defines the action to launch during the step
  76891. */
  76892. registerStep(index: number, component: ISceneComponent, action: T): void;
  76893. /**
  76894. * Clears all the steps from the stage.
  76895. */
  76896. clear(): void;
  76897. }
  76898. }
  76899. declare module BABYLON {
  76900. interface Scene {
  76901. /** @hidden */
  76902. _pointerOverSprite: Nullable<Sprite>;
  76903. /** @hidden */
  76904. _pickedDownSprite: Nullable<Sprite>;
  76905. /** @hidden */
  76906. _tempSpritePickingRay: Nullable<Ray>;
  76907. /**
  76908. * All of the sprite managers added to this scene
  76909. * @see http://doc.babylonjs.com/babylon101/sprites
  76910. */
  76911. spriteManagers: Array<ISpriteManager>;
  76912. /**
  76913. * An event triggered when sprites rendering is about to start
  76914. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  76915. */
  76916. onBeforeSpritesRenderingObservable: Observable<Scene>;
  76917. /**
  76918. * An event triggered when sprites rendering is done
  76919. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  76920. */
  76921. onAfterSpritesRenderingObservable: Observable<Scene>;
  76922. /** @hidden */
  76923. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76924. /** Launch a ray to try to pick a sprite in the scene
  76925. * @param x position on screen
  76926. * @param y position on screen
  76927. * @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
  76928. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  76929. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  76930. * @returns a PickingInfo
  76931. */
  76932. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76933. /** Use the given ray to pick a sprite in the scene
  76934. * @param ray The ray (in world space) to use to pick meshes
  76935. * @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
  76936. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  76937. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  76938. * @returns a PickingInfo
  76939. */
  76940. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  76941. /** @hidden */
  76942. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76943. /** Launch a ray to try to pick sprites in the scene
  76944. * @param x position on screen
  76945. * @param y position on screen
  76946. * @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
  76947. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  76948. * @returns a PickingInfo array
  76949. */
  76950. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76951. /** Use the given ray to pick sprites in the scene
  76952. * @param ray The ray (in world space) to use to pick meshes
  76953. * @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
  76954. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  76955. * @returns a PickingInfo array
  76956. */
  76957. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  76958. /**
  76959. * Force the sprite under the pointer
  76960. * @param sprite defines the sprite to use
  76961. */
  76962. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  76963. /**
  76964. * Gets the sprite under the pointer
  76965. * @returns a Sprite or null if no sprite is under the pointer
  76966. */
  76967. getPointerOverSprite(): Nullable<Sprite>;
  76968. }
  76969. /**
  76970. * Defines the sprite scene component responsible to manage sprites
  76971. * in a given scene.
  76972. */
  76973. export class SpriteSceneComponent implements ISceneComponent {
  76974. /**
  76975. * The component name helpfull to identify the component in the list of scene components.
  76976. */
  76977. readonly name: string;
  76978. /**
  76979. * The scene the component belongs to.
  76980. */
  76981. scene: Scene;
  76982. /** @hidden */
  76983. private _spritePredicate;
  76984. /**
  76985. * Creates a new instance of the component for the given scene
  76986. * @param scene Defines the scene to register the component in
  76987. */
  76988. constructor(scene: Scene);
  76989. /**
  76990. * Registers the component in a given scene
  76991. */
  76992. register(): void;
  76993. /**
  76994. * Rebuilds the elements related to this component in case of
  76995. * context lost for instance.
  76996. */
  76997. rebuild(): void;
  76998. /**
  76999. * Disposes the component and the associated ressources.
  77000. */
  77001. dispose(): void;
  77002. private _pickSpriteButKeepRay;
  77003. private _pointerMove;
  77004. private _pointerDown;
  77005. private _pointerUp;
  77006. }
  77007. }
  77008. declare module BABYLON {
  77009. /** @hidden */
  77010. export var fogFragmentDeclaration: {
  77011. name: string;
  77012. shader: string;
  77013. };
  77014. }
  77015. declare module BABYLON {
  77016. /** @hidden */
  77017. export var fogFragment: {
  77018. name: string;
  77019. shader: string;
  77020. };
  77021. }
  77022. declare module BABYLON {
  77023. /** @hidden */
  77024. export var spritesPixelShader: {
  77025. name: string;
  77026. shader: string;
  77027. };
  77028. }
  77029. declare module BABYLON {
  77030. /** @hidden */
  77031. export var fogVertexDeclaration: {
  77032. name: string;
  77033. shader: string;
  77034. };
  77035. }
  77036. declare module BABYLON {
  77037. /** @hidden */
  77038. export var spritesVertexShader: {
  77039. name: string;
  77040. shader: string;
  77041. };
  77042. }
  77043. declare module BABYLON {
  77044. /**
  77045. * Defines the minimum interface to fullfil in order to be a sprite manager.
  77046. */
  77047. export interface ISpriteManager extends IDisposable {
  77048. /**
  77049. * Restricts the camera to viewing objects with the same layerMask.
  77050. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  77051. */
  77052. layerMask: number;
  77053. /**
  77054. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  77055. */
  77056. isPickable: boolean;
  77057. /**
  77058. * Specifies the rendering group id for this mesh (0 by default)
  77059. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  77060. */
  77061. renderingGroupId: number;
  77062. /**
  77063. * Defines the list of sprites managed by the manager.
  77064. */
  77065. sprites: Array<Sprite>;
  77066. /**
  77067. * Tests the intersection of a sprite with a specific ray.
  77068. * @param ray The ray we are sending to test the collision
  77069. * @param camera The camera space we are sending rays in
  77070. * @param predicate A predicate allowing excluding sprites from the list of object to test
  77071. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  77072. * @returns picking info or null.
  77073. */
  77074. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77075. /**
  77076. * Intersects the sprites with a ray
  77077. * @param ray defines the ray to intersect with
  77078. * @param camera defines the current active camera
  77079. * @param predicate defines a predicate used to select candidate sprites
  77080. * @returns null if no hit or a PickingInfo array
  77081. */
  77082. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77083. /**
  77084. * Renders the list of sprites on screen.
  77085. */
  77086. render(): void;
  77087. }
  77088. /**
  77089. * Class used to manage multiple sprites on the same spritesheet
  77090. * @see http://doc.babylonjs.com/babylon101/sprites
  77091. */
  77092. export class SpriteManager implements ISpriteManager {
  77093. /** defines the manager's name */
  77094. name: string;
  77095. /** Gets the list of sprites */
  77096. sprites: Sprite[];
  77097. /** Gets or sets the rendering group id (0 by default) */
  77098. renderingGroupId: number;
  77099. /** Gets or sets camera layer mask */
  77100. layerMask: number;
  77101. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  77102. fogEnabled: boolean;
  77103. /** Gets or sets a boolean indicating if the sprites are pickable */
  77104. isPickable: boolean;
  77105. /** Defines the default width of a cell in the spritesheet */
  77106. cellWidth: number;
  77107. /** Defines the default height of a cell in the spritesheet */
  77108. cellHeight: number;
  77109. /** Associative array from JSON sprite data file */
  77110. private _cellData;
  77111. /** Array of sprite names from JSON sprite data file */
  77112. private _spriteMap;
  77113. /** True when packed cell data from JSON file is ready*/
  77114. private _packedAndReady;
  77115. /**
  77116. * An event triggered when the manager is disposed.
  77117. */
  77118. onDisposeObservable: Observable<SpriteManager>;
  77119. private _onDisposeObserver;
  77120. /**
  77121. * Callback called when the manager is disposed
  77122. */
  77123. onDispose: () => void;
  77124. private _capacity;
  77125. private _fromPacked;
  77126. private _spriteTexture;
  77127. private _epsilon;
  77128. private _scene;
  77129. private _vertexData;
  77130. private _buffer;
  77131. private _vertexBuffers;
  77132. private _indexBuffer;
  77133. private _effectBase;
  77134. private _effectFog;
  77135. /**
  77136. * Gets or sets the spritesheet texture
  77137. */
  77138. texture: Texture;
  77139. /**
  77140. * Creates a new sprite manager
  77141. * @param name defines the manager's name
  77142. * @param imgUrl defines the sprite sheet url
  77143. * @param capacity defines the maximum allowed number of sprites
  77144. * @param cellSize defines the size of a sprite cell
  77145. * @param scene defines the hosting scene
  77146. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77147. * @param samplingMode defines the smapling mode to use with spritesheet
  77148. * @param fromPacked set to false; do not alter
  77149. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  77150. */
  77151. constructor(
  77152. /** defines the manager's name */
  77153. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  77154. private _makePacked;
  77155. private _appendSpriteVertex;
  77156. /**
  77157. * Intersects the sprites with a ray
  77158. * @param ray defines the ray to intersect with
  77159. * @param camera defines the current active camera
  77160. * @param predicate defines a predicate used to select candidate sprites
  77161. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  77162. * @returns null if no hit or a PickingInfo
  77163. */
  77164. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77165. /**
  77166. * Intersects the sprites with a ray
  77167. * @param ray defines the ray to intersect with
  77168. * @param camera defines the current active camera
  77169. * @param predicate defines a predicate used to select candidate sprites
  77170. * @returns null if no hit or a PickingInfo array
  77171. */
  77172. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77173. /**
  77174. * Render all child sprites
  77175. */
  77176. render(): void;
  77177. /**
  77178. * Release associated resources
  77179. */
  77180. dispose(): void;
  77181. }
  77182. }
  77183. declare module BABYLON {
  77184. /**
  77185. * Class used to represent a sprite
  77186. * @see http://doc.babylonjs.com/babylon101/sprites
  77187. */
  77188. export class Sprite {
  77189. /** defines the name */
  77190. name: string;
  77191. /** Gets or sets the current world position */
  77192. position: Vector3;
  77193. /** Gets or sets the main color */
  77194. color: Color4;
  77195. /** Gets or sets the width */
  77196. width: number;
  77197. /** Gets or sets the height */
  77198. height: number;
  77199. /** Gets or sets rotation angle */
  77200. angle: number;
  77201. /** Gets or sets the cell index in the sprite sheet */
  77202. cellIndex: number;
  77203. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  77204. cellRef: string;
  77205. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  77206. invertU: number;
  77207. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  77208. invertV: number;
  77209. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  77210. disposeWhenFinishedAnimating: boolean;
  77211. /** Gets the list of attached animations */
  77212. animations: Animation[];
  77213. /** Gets or sets a boolean indicating if the sprite can be picked */
  77214. isPickable: boolean;
  77215. /**
  77216. * Gets or sets the associated action manager
  77217. */
  77218. actionManager: Nullable<ActionManager>;
  77219. private _animationStarted;
  77220. private _loopAnimation;
  77221. private _fromIndex;
  77222. private _toIndex;
  77223. private _delay;
  77224. private _direction;
  77225. private _manager;
  77226. private _time;
  77227. private _onAnimationEnd;
  77228. /**
  77229. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  77230. */
  77231. isVisible: boolean;
  77232. /**
  77233. * Gets or sets the sprite size
  77234. */
  77235. size: number;
  77236. /**
  77237. * Creates a new Sprite
  77238. * @param name defines the name
  77239. * @param manager defines the manager
  77240. */
  77241. constructor(
  77242. /** defines the name */
  77243. name: string, manager: ISpriteManager);
  77244. /**
  77245. * Starts an animation
  77246. * @param from defines the initial key
  77247. * @param to defines the end key
  77248. * @param loop defines if the animation must loop
  77249. * @param delay defines the start delay (in ms)
  77250. * @param onAnimationEnd defines a callback to call when animation ends
  77251. */
  77252. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  77253. /** Stops current animation (if any) */
  77254. stopAnimation(): void;
  77255. /** @hidden */
  77256. _animate(deltaTime: number): void;
  77257. /** Release associated resources */
  77258. dispose(): void;
  77259. }
  77260. }
  77261. declare module BABYLON {
  77262. /**
  77263. * Information about the result of picking within a scene
  77264. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  77265. */
  77266. export class PickingInfo {
  77267. /** @hidden */
  77268. _pickingUnavailable: boolean;
  77269. /**
  77270. * If the pick collided with an object
  77271. */
  77272. hit: boolean;
  77273. /**
  77274. * Distance away where the pick collided
  77275. */
  77276. distance: number;
  77277. /**
  77278. * The location of pick collision
  77279. */
  77280. pickedPoint: Nullable<Vector3>;
  77281. /**
  77282. * The mesh corresponding the the pick collision
  77283. */
  77284. pickedMesh: Nullable<AbstractMesh>;
  77285. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  77286. bu: number;
  77287. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  77288. bv: number;
  77289. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  77290. faceId: number;
  77291. /** Id of the the submesh that was picked */
  77292. subMeshId: number;
  77293. /** If a sprite was picked, this will be the sprite the pick collided with */
  77294. pickedSprite: Nullable<Sprite>;
  77295. /**
  77296. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  77297. */
  77298. originMesh: Nullable<AbstractMesh>;
  77299. /**
  77300. * The ray that was used to perform the picking.
  77301. */
  77302. ray: Nullable<Ray>;
  77303. /**
  77304. * Gets the normal correspodning to the face the pick collided with
  77305. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  77306. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  77307. * @returns The normal correspodning to the face the pick collided with
  77308. */
  77309. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  77310. /**
  77311. * Gets the texture coordinates of where the pick occured
  77312. * @returns the vector containing the coordnates of the texture
  77313. */
  77314. getTextureCoordinates(): Nullable<Vector2>;
  77315. }
  77316. }
  77317. declare module BABYLON {
  77318. /**
  77319. * Gather the list of pointer event types as constants.
  77320. */
  77321. export class PointerEventTypes {
  77322. /**
  77323. * 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.
  77324. */
  77325. static readonly POINTERDOWN: number;
  77326. /**
  77327. * The pointerup event is fired when a pointer is no longer active.
  77328. */
  77329. static readonly POINTERUP: number;
  77330. /**
  77331. * The pointermove event is fired when a pointer changes coordinates.
  77332. */
  77333. static readonly POINTERMOVE: number;
  77334. /**
  77335. * The pointerwheel event is fired when a mouse wheel has been rotated.
  77336. */
  77337. static readonly POINTERWHEEL: number;
  77338. /**
  77339. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  77340. */
  77341. static readonly POINTERPICK: number;
  77342. /**
  77343. * The pointertap event is fired when a the object has been touched and released without drag.
  77344. */
  77345. static readonly POINTERTAP: number;
  77346. /**
  77347. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  77348. */
  77349. static readonly POINTERDOUBLETAP: number;
  77350. }
  77351. /**
  77352. * Base class of pointer info types.
  77353. */
  77354. export class PointerInfoBase {
  77355. /**
  77356. * Defines the type of event (PointerEventTypes)
  77357. */
  77358. type: number;
  77359. /**
  77360. * Defines the related dom event
  77361. */
  77362. event: PointerEvent | MouseWheelEvent;
  77363. /**
  77364. * Instantiates the base class of pointers info.
  77365. * @param type Defines the type of event (PointerEventTypes)
  77366. * @param event Defines the related dom event
  77367. */
  77368. constructor(
  77369. /**
  77370. * Defines the type of event (PointerEventTypes)
  77371. */
  77372. type: number,
  77373. /**
  77374. * Defines the related dom event
  77375. */
  77376. event: PointerEvent | MouseWheelEvent);
  77377. }
  77378. /**
  77379. * This class is used to store pointer related info for the onPrePointerObservable event.
  77380. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  77381. */
  77382. export class PointerInfoPre extends PointerInfoBase {
  77383. /**
  77384. * Ray from a pointer if availible (eg. 6dof controller)
  77385. */
  77386. ray: Nullable<Ray>;
  77387. /**
  77388. * Defines the local position of the pointer on the canvas.
  77389. */
  77390. localPosition: Vector2;
  77391. /**
  77392. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  77393. */
  77394. skipOnPointerObservable: boolean;
  77395. /**
  77396. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  77397. * @param type Defines the type of event (PointerEventTypes)
  77398. * @param event Defines the related dom event
  77399. * @param localX Defines the local x coordinates of the pointer when the event occured
  77400. * @param localY Defines the local y coordinates of the pointer when the event occured
  77401. */
  77402. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  77403. }
  77404. /**
  77405. * This type contains all the data related to a pointer event in Babylon.js.
  77406. * 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.
  77407. */
  77408. export class PointerInfo extends PointerInfoBase {
  77409. /**
  77410. * Defines the picking info associated to the info (if any)\
  77411. */
  77412. pickInfo: Nullable<PickingInfo>;
  77413. /**
  77414. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  77415. * @param type Defines the type of event (PointerEventTypes)
  77416. * @param event Defines the related dom event
  77417. * @param pickInfo Defines the picking info associated to the info (if any)\
  77418. */
  77419. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  77420. /**
  77421. * Defines the picking info associated to the info (if any)\
  77422. */
  77423. pickInfo: Nullable<PickingInfo>);
  77424. }
  77425. /**
  77426. * Data relating to a touch event on the screen.
  77427. */
  77428. export interface PointerTouch {
  77429. /**
  77430. * X coordinate of touch.
  77431. */
  77432. x: number;
  77433. /**
  77434. * Y coordinate of touch.
  77435. */
  77436. y: number;
  77437. /**
  77438. * Id of touch. Unique for each finger.
  77439. */
  77440. pointerId: number;
  77441. /**
  77442. * Event type passed from DOM.
  77443. */
  77444. type: any;
  77445. }
  77446. }
  77447. declare module BABYLON {
  77448. /**
  77449. * Manage the mouse inputs to control the movement of a free camera.
  77450. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77451. */
  77452. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  77453. /**
  77454. * Define if touch is enabled in the mouse input
  77455. */
  77456. touchEnabled: boolean;
  77457. /**
  77458. * Defines the camera the input is attached to.
  77459. */
  77460. camera: FreeCamera;
  77461. /**
  77462. * Defines the buttons associated with the input to handle camera move.
  77463. */
  77464. buttons: number[];
  77465. /**
  77466. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  77467. */
  77468. angularSensibility: number;
  77469. private _pointerInput;
  77470. private _onMouseMove;
  77471. private _observer;
  77472. private previousPosition;
  77473. /**
  77474. * Observable for when a pointer move event occurs containing the move offset
  77475. */
  77476. onPointerMovedObservable: Observable<{
  77477. offsetX: number;
  77478. offsetY: number;
  77479. }>;
  77480. /**
  77481. * @hidden
  77482. * If the camera should be rotated automatically based on pointer movement
  77483. */
  77484. _allowCameraRotation: boolean;
  77485. /**
  77486. * Manage the mouse inputs to control the movement of a free camera.
  77487. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77488. * @param touchEnabled Defines if touch is enabled or not
  77489. */
  77490. constructor(
  77491. /**
  77492. * Define if touch is enabled in the mouse input
  77493. */
  77494. touchEnabled?: boolean);
  77495. /**
  77496. * Attach the input controls to a specific dom element to get the input from.
  77497. * @param element Defines the element the controls should be listened from
  77498. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77499. */
  77500. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77501. /**
  77502. * Called on JS contextmenu event.
  77503. * Override this method to provide functionality.
  77504. */
  77505. protected onContextMenu(evt: PointerEvent): void;
  77506. /**
  77507. * Detach the current controls from the specified dom element.
  77508. * @param element Defines the element to stop listening the inputs from
  77509. */
  77510. detachControl(element: Nullable<HTMLElement>): void;
  77511. /**
  77512. * Gets the class name of the current intput.
  77513. * @returns the class name
  77514. */
  77515. getClassName(): string;
  77516. /**
  77517. * Get the friendly name associated with the input class.
  77518. * @returns the input friendly name
  77519. */
  77520. getSimpleName(): string;
  77521. }
  77522. }
  77523. declare module BABYLON {
  77524. /**
  77525. * Manage the touch inputs to control the movement of a free camera.
  77526. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77527. */
  77528. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  77529. /**
  77530. * Defines the camera the input is attached to.
  77531. */
  77532. camera: FreeCamera;
  77533. /**
  77534. * Defines the touch sensibility for rotation.
  77535. * The higher the faster.
  77536. */
  77537. touchAngularSensibility: number;
  77538. /**
  77539. * Defines the touch sensibility for move.
  77540. * The higher the faster.
  77541. */
  77542. touchMoveSensibility: number;
  77543. private _offsetX;
  77544. private _offsetY;
  77545. private _pointerPressed;
  77546. private _pointerInput;
  77547. private _observer;
  77548. private _onLostFocus;
  77549. /**
  77550. * Attach the input controls to a specific dom element to get the input from.
  77551. * @param element Defines the element the controls should be listened from
  77552. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77553. */
  77554. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77555. /**
  77556. * Detach the current controls from the specified dom element.
  77557. * @param element Defines the element to stop listening the inputs from
  77558. */
  77559. detachControl(element: Nullable<HTMLElement>): void;
  77560. /**
  77561. * Update the current camera state depending on the inputs that have been used this frame.
  77562. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77563. */
  77564. checkInputs(): void;
  77565. /**
  77566. * Gets the class name of the current intput.
  77567. * @returns the class name
  77568. */
  77569. getClassName(): string;
  77570. /**
  77571. * Get the friendly name associated with the input class.
  77572. * @returns the input friendly name
  77573. */
  77574. getSimpleName(): string;
  77575. }
  77576. }
  77577. declare module BABYLON {
  77578. /**
  77579. * Default Inputs manager for the FreeCamera.
  77580. * It groups all the default supported inputs for ease of use.
  77581. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77582. */
  77583. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  77584. /**
  77585. * @hidden
  77586. */
  77587. _mouseInput: Nullable<FreeCameraMouseInput>;
  77588. /**
  77589. * Instantiates a new FreeCameraInputsManager.
  77590. * @param camera Defines the camera the inputs belong to
  77591. */
  77592. constructor(camera: FreeCamera);
  77593. /**
  77594. * Add keyboard input support to the input manager.
  77595. * @returns the current input manager
  77596. */
  77597. addKeyboard(): FreeCameraInputsManager;
  77598. /**
  77599. * Add mouse input support to the input manager.
  77600. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  77601. * @returns the current input manager
  77602. */
  77603. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  77604. /**
  77605. * Removes the mouse input support from the manager
  77606. * @returns the current input manager
  77607. */
  77608. removeMouse(): FreeCameraInputsManager;
  77609. /**
  77610. * Add touch input support to the input manager.
  77611. * @returns the current input manager
  77612. */
  77613. addTouch(): FreeCameraInputsManager;
  77614. /**
  77615. * Remove all attached input methods from a camera
  77616. */
  77617. clear(): void;
  77618. }
  77619. }
  77620. declare module BABYLON {
  77621. /**
  77622. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77623. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  77624. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77625. */
  77626. export class FreeCamera extends TargetCamera {
  77627. /**
  77628. * Define the collision ellipsoid of the camera.
  77629. * This is helpful to simulate a camera body like the player body around the camera
  77630. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  77631. */
  77632. ellipsoid: Vector3;
  77633. /**
  77634. * Define an offset for the position of the ellipsoid around the camera.
  77635. * This can be helpful to determine the center of the body near the gravity center of the body
  77636. * instead of its head.
  77637. */
  77638. ellipsoidOffset: Vector3;
  77639. /**
  77640. * Enable or disable collisions of the camera with the rest of the scene objects.
  77641. */
  77642. checkCollisions: boolean;
  77643. /**
  77644. * Enable or disable gravity on the camera.
  77645. */
  77646. applyGravity: boolean;
  77647. /**
  77648. * Define the input manager associated to the camera.
  77649. */
  77650. inputs: FreeCameraInputsManager;
  77651. /**
  77652. * Gets the input sensibility for a mouse input. (default is 2000.0)
  77653. * Higher values reduce sensitivity.
  77654. */
  77655. /**
  77656. * Sets the input sensibility for a mouse input. (default is 2000.0)
  77657. * Higher values reduce sensitivity.
  77658. */
  77659. angularSensibility: number;
  77660. /**
  77661. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77662. */
  77663. keysUp: number[];
  77664. /**
  77665. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77666. */
  77667. keysDown: number[];
  77668. /**
  77669. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77670. */
  77671. keysLeft: number[];
  77672. /**
  77673. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77674. */
  77675. keysRight: number[];
  77676. /**
  77677. * Event raised when the camera collide with a mesh in the scene.
  77678. */
  77679. onCollide: (collidedMesh: AbstractMesh) => void;
  77680. private _collider;
  77681. private _needMoveForGravity;
  77682. private _oldPosition;
  77683. private _diffPosition;
  77684. private _newPosition;
  77685. /** @hidden */
  77686. _localDirection: Vector3;
  77687. /** @hidden */
  77688. _transformedDirection: Vector3;
  77689. /**
  77690. * Instantiates a Free Camera.
  77691. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77692. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  77693. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77694. * @param name Define the name of the camera in the scene
  77695. * @param position Define the start position of the camera in the scene
  77696. * @param scene Define the scene the camera belongs to
  77697. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77698. */
  77699. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77700. /**
  77701. * Attached controls to the current camera.
  77702. * @param element Defines the element the controls should be listened from
  77703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77704. */
  77705. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77706. /**
  77707. * Detach the current controls from the camera.
  77708. * The camera will stop reacting to inputs.
  77709. * @param element Defines the element to stop listening the inputs from
  77710. */
  77711. detachControl(element: HTMLElement): void;
  77712. private _collisionMask;
  77713. /**
  77714. * Define a collision mask to limit the list of object the camera can collide with
  77715. */
  77716. collisionMask: number;
  77717. /** @hidden */
  77718. _collideWithWorld(displacement: Vector3): void;
  77719. private _onCollisionPositionChange;
  77720. /** @hidden */
  77721. _checkInputs(): void;
  77722. /** @hidden */
  77723. _decideIfNeedsToMove(): boolean;
  77724. /** @hidden */
  77725. _updatePosition(): void;
  77726. /**
  77727. * Destroy the camera and release the current resources hold by it.
  77728. */
  77729. dispose(): void;
  77730. /**
  77731. * Gets the current object class name.
  77732. * @return the class name
  77733. */
  77734. getClassName(): string;
  77735. }
  77736. }
  77737. declare module BABYLON {
  77738. /**
  77739. * Represents a gamepad control stick position
  77740. */
  77741. export class StickValues {
  77742. /**
  77743. * The x component of the control stick
  77744. */
  77745. x: number;
  77746. /**
  77747. * The y component of the control stick
  77748. */
  77749. y: number;
  77750. /**
  77751. * Initializes the gamepad x and y control stick values
  77752. * @param x The x component of the gamepad control stick value
  77753. * @param y The y component of the gamepad control stick value
  77754. */
  77755. constructor(
  77756. /**
  77757. * The x component of the control stick
  77758. */
  77759. x: number,
  77760. /**
  77761. * The y component of the control stick
  77762. */
  77763. y: number);
  77764. }
  77765. /**
  77766. * An interface which manages callbacks for gamepad button changes
  77767. */
  77768. export interface GamepadButtonChanges {
  77769. /**
  77770. * Called when a gamepad has been changed
  77771. */
  77772. changed: boolean;
  77773. /**
  77774. * Called when a gamepad press event has been triggered
  77775. */
  77776. pressChanged: boolean;
  77777. /**
  77778. * Called when a touch event has been triggered
  77779. */
  77780. touchChanged: boolean;
  77781. /**
  77782. * Called when a value has changed
  77783. */
  77784. valueChanged: boolean;
  77785. }
  77786. /**
  77787. * Represents a gamepad
  77788. */
  77789. export class Gamepad {
  77790. /**
  77791. * The id of the gamepad
  77792. */
  77793. id: string;
  77794. /**
  77795. * The index of the gamepad
  77796. */
  77797. index: number;
  77798. /**
  77799. * The browser gamepad
  77800. */
  77801. browserGamepad: any;
  77802. /**
  77803. * Specifies what type of gamepad this represents
  77804. */
  77805. type: number;
  77806. private _leftStick;
  77807. private _rightStick;
  77808. /** @hidden */
  77809. _isConnected: boolean;
  77810. private _leftStickAxisX;
  77811. private _leftStickAxisY;
  77812. private _rightStickAxisX;
  77813. private _rightStickAxisY;
  77814. /**
  77815. * Triggered when the left control stick has been changed
  77816. */
  77817. private _onleftstickchanged;
  77818. /**
  77819. * Triggered when the right control stick has been changed
  77820. */
  77821. private _onrightstickchanged;
  77822. /**
  77823. * Represents a gamepad controller
  77824. */
  77825. static GAMEPAD: number;
  77826. /**
  77827. * Represents a generic controller
  77828. */
  77829. static GENERIC: number;
  77830. /**
  77831. * Represents an XBox controller
  77832. */
  77833. static XBOX: number;
  77834. /**
  77835. * Represents a pose-enabled controller
  77836. */
  77837. static POSE_ENABLED: number;
  77838. /**
  77839. * Represents an Dual Shock controller
  77840. */
  77841. static DUALSHOCK: number;
  77842. /**
  77843. * Specifies whether the left control stick should be Y-inverted
  77844. */
  77845. protected _invertLeftStickY: boolean;
  77846. /**
  77847. * Specifies if the gamepad has been connected
  77848. */
  77849. readonly isConnected: boolean;
  77850. /**
  77851. * Initializes the gamepad
  77852. * @param id The id of the gamepad
  77853. * @param index The index of the gamepad
  77854. * @param browserGamepad The browser gamepad
  77855. * @param leftStickX The x component of the left joystick
  77856. * @param leftStickY The y component of the left joystick
  77857. * @param rightStickX The x component of the right joystick
  77858. * @param rightStickY The y component of the right joystick
  77859. */
  77860. constructor(
  77861. /**
  77862. * The id of the gamepad
  77863. */
  77864. id: string,
  77865. /**
  77866. * The index of the gamepad
  77867. */
  77868. index: number,
  77869. /**
  77870. * The browser gamepad
  77871. */
  77872. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  77873. /**
  77874. * Callback triggered when the left joystick has changed
  77875. * @param callback
  77876. */
  77877. onleftstickchanged(callback: (values: StickValues) => void): void;
  77878. /**
  77879. * Callback triggered when the right joystick has changed
  77880. * @param callback
  77881. */
  77882. onrightstickchanged(callback: (values: StickValues) => void): void;
  77883. /**
  77884. * Gets the left joystick
  77885. */
  77886. /**
  77887. * Sets the left joystick values
  77888. */
  77889. leftStick: StickValues;
  77890. /**
  77891. * Gets the right joystick
  77892. */
  77893. /**
  77894. * Sets the right joystick value
  77895. */
  77896. rightStick: StickValues;
  77897. /**
  77898. * Updates the gamepad joystick positions
  77899. */
  77900. update(): void;
  77901. /**
  77902. * Disposes the gamepad
  77903. */
  77904. dispose(): void;
  77905. }
  77906. /**
  77907. * Represents a generic gamepad
  77908. */
  77909. export class GenericPad extends Gamepad {
  77910. private _buttons;
  77911. private _onbuttondown;
  77912. private _onbuttonup;
  77913. /**
  77914. * Observable triggered when a button has been pressed
  77915. */
  77916. onButtonDownObservable: Observable<number>;
  77917. /**
  77918. * Observable triggered when a button has been released
  77919. */
  77920. onButtonUpObservable: Observable<number>;
  77921. /**
  77922. * Callback triggered when a button has been pressed
  77923. * @param callback Called when a button has been pressed
  77924. */
  77925. onbuttondown(callback: (buttonPressed: number) => void): void;
  77926. /**
  77927. * Callback triggered when a button has been released
  77928. * @param callback Called when a button has been released
  77929. */
  77930. onbuttonup(callback: (buttonReleased: number) => void): void;
  77931. /**
  77932. * Initializes the generic gamepad
  77933. * @param id The id of the generic gamepad
  77934. * @param index The index of the generic gamepad
  77935. * @param browserGamepad The browser gamepad
  77936. */
  77937. constructor(id: string, index: number, browserGamepad: any);
  77938. private _setButtonValue;
  77939. /**
  77940. * Updates the generic gamepad
  77941. */
  77942. update(): void;
  77943. /**
  77944. * Disposes the generic gamepad
  77945. */
  77946. dispose(): void;
  77947. }
  77948. }
  77949. declare module BABYLON {
  77950. interface Engine {
  77951. /**
  77952. * Creates a raw texture
  77953. * @param data defines the data to store in the texture
  77954. * @param width defines the width of the texture
  77955. * @param height defines the height of the texture
  77956. * @param format defines the format of the data
  77957. * @param generateMipMaps defines if the engine should generate the mip levels
  77958. * @param invertY defines if data must be stored with Y axis inverted
  77959. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77960. * @param compression defines the compression used (null by default)
  77961. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77962. * @returns the raw texture inside an InternalTexture
  77963. */
  77964. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  77965. /**
  77966. * Update a raw texture
  77967. * @param texture defines the texture to update
  77968. * @param data defines the data to store in the texture
  77969. * @param format defines the format of the data
  77970. * @param invertY defines if data must be stored with Y axis inverted
  77971. */
  77972. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  77973. /**
  77974. * Update a raw texture
  77975. * @param texture defines the texture to update
  77976. * @param data defines the data to store in the texture
  77977. * @param format defines the format of the data
  77978. * @param invertY defines if data must be stored with Y axis inverted
  77979. * @param compression defines the compression used (null by default)
  77980. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77981. */
  77982. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  77983. /**
  77984. * Creates a new raw cube texture
  77985. * @param data defines the array of data to use to create each face
  77986. * @param size defines the size of the textures
  77987. * @param format defines the format of the data
  77988. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77989. * @param generateMipMaps defines if the engine should generate the mip levels
  77990. * @param invertY defines if data must be stored with Y axis inverted
  77991. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77992. * @param compression defines the compression used (null by default)
  77993. * @returns the cube texture as an InternalTexture
  77994. */
  77995. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  77996. /**
  77997. * Update a raw cube texture
  77998. * @param texture defines the texture to udpdate
  77999. * @param data defines the data to store
  78000. * @param format defines the data format
  78001. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78002. * @param invertY defines if data must be stored with Y axis inverted
  78003. */
  78004. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78005. /**
  78006. * Update a raw cube texture
  78007. * @param texture defines the texture to udpdate
  78008. * @param data defines the data to store
  78009. * @param format defines the data format
  78010. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78011. * @param invertY defines if data must be stored with Y axis inverted
  78012. * @param compression defines the compression used (null by default)
  78013. */
  78014. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78015. /**
  78016. * Update a raw cube texture
  78017. * @param texture defines the texture to udpdate
  78018. * @param data defines the data to store
  78019. * @param format defines the data format
  78020. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78021. * @param invertY defines if data must be stored with Y axis inverted
  78022. * @param compression defines the compression used (null by default)
  78023. * @param level defines which level of the texture to update
  78024. */
  78025. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78026. /**
  78027. * Creates a new raw cube texture from a specified url
  78028. * @param url defines the url where the data is located
  78029. * @param scene defines the current scene
  78030. * @param size defines the size of the textures
  78031. * @param format defines the format of the data
  78032. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78033. * @param noMipmap defines if the engine should avoid generating the mip levels
  78034. * @param callback defines a callback used to extract texture data from loaded data
  78035. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78036. * @param onLoad defines a callback called when texture is loaded
  78037. * @param onError defines a callback called if there is an error
  78038. * @returns the cube texture as an InternalTexture
  78039. */
  78040. 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;
  78041. /**
  78042. * Creates a new raw cube texture from a specified url
  78043. * @param url defines the url where the data is located
  78044. * @param scene defines the current scene
  78045. * @param size defines the size of the textures
  78046. * @param format defines the format of the data
  78047. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78048. * @param noMipmap defines if the engine should avoid generating the mip levels
  78049. * @param callback defines a callback used to extract texture data from loaded data
  78050. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78051. * @param onLoad defines a callback called when texture is loaded
  78052. * @param onError defines a callback called if there is an error
  78053. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78054. * @param invertY defines if data must be stored with Y axis inverted
  78055. * @returns the cube texture as an InternalTexture
  78056. */
  78057. 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;
  78058. /**
  78059. * Creates a new raw 3D texture
  78060. * @param data defines the data used to create the texture
  78061. * @param width defines the width of the texture
  78062. * @param height defines the height of the texture
  78063. * @param depth defines the depth of the texture
  78064. * @param format defines the format of the texture
  78065. * @param generateMipMaps defines if the engine must generate mip levels
  78066. * @param invertY defines if data must be stored with Y axis inverted
  78067. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78068. * @param compression defines the compressed used (can be null)
  78069. * @param textureType defines the compressed used (can be null)
  78070. * @returns a new raw 3D texture (stored in an InternalTexture)
  78071. */
  78072. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78073. /**
  78074. * Update a raw 3D texture
  78075. * @param texture defines the texture to update
  78076. * @param data defines the data to store
  78077. * @param format defines the data format
  78078. * @param invertY defines if data must be stored with Y axis inverted
  78079. */
  78080. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78081. /**
  78082. * Update a raw 3D texture
  78083. * @param texture defines the texture to update
  78084. * @param data defines the data to store
  78085. * @param format defines the data format
  78086. * @param invertY defines if data must be stored with Y axis inverted
  78087. * @param compression defines the used compression (can be null)
  78088. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78089. */
  78090. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78091. }
  78092. }
  78093. declare module BABYLON {
  78094. /**
  78095. * Raw texture can help creating a texture directly from an array of data.
  78096. * This can be super useful if you either get the data from an uncompressed source or
  78097. * if you wish to create your texture pixel by pixel.
  78098. */
  78099. export class RawTexture extends Texture {
  78100. /**
  78101. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78102. */
  78103. format: number;
  78104. private _engine;
  78105. /**
  78106. * Instantiates a new RawTexture.
  78107. * Raw texture can help creating a texture directly from an array of data.
  78108. * This can be super useful if you either get the data from an uncompressed source or
  78109. * if you wish to create your texture pixel by pixel.
  78110. * @param data define the array of data to use to create the texture
  78111. * @param width define the width of the texture
  78112. * @param height define the height of the texture
  78113. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78114. * @param scene define the scene the texture belongs to
  78115. * @param generateMipMaps define whether mip maps should be generated or not
  78116. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78117. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78118. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78119. */
  78120. constructor(data: ArrayBufferView, width: number, height: number,
  78121. /**
  78122. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78123. */
  78124. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78125. /**
  78126. * Updates the texture underlying data.
  78127. * @param data Define the new data of the texture
  78128. */
  78129. update(data: ArrayBufferView): void;
  78130. /**
  78131. * Creates a luminance texture from some data.
  78132. * @param data Define the texture data
  78133. * @param width Define the width of the texture
  78134. * @param height Define the height of the texture
  78135. * @param scene Define the scene the texture belongs to
  78136. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78137. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78138. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78139. * @returns the luminance texture
  78140. */
  78141. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78142. /**
  78143. * Creates a luminance alpha texture from some data.
  78144. * @param data Define the texture data
  78145. * @param width Define the width of the texture
  78146. * @param height Define the height of the texture
  78147. * @param scene Define the scene the texture belongs to
  78148. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78149. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78150. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78151. * @returns the luminance alpha texture
  78152. */
  78153. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78154. /**
  78155. * Creates an alpha texture from some data.
  78156. * @param data Define the texture data
  78157. * @param width Define the width of the texture
  78158. * @param height Define the height of the texture
  78159. * @param scene Define the scene the texture belongs to
  78160. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78161. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78162. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78163. * @returns the alpha texture
  78164. */
  78165. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78166. /**
  78167. * Creates a RGB texture from some data.
  78168. * @param data Define the texture data
  78169. * @param width Define the width of the texture
  78170. * @param height Define the height of the texture
  78171. * @param scene Define the scene the texture belongs to
  78172. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78173. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78174. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78175. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78176. * @returns the RGB alpha texture
  78177. */
  78178. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78179. /**
  78180. * Creates a RGBA texture from some data.
  78181. * @param data Define the texture data
  78182. * @param width Define the width of the texture
  78183. * @param height Define the height of the texture
  78184. * @param scene Define the scene the texture belongs to
  78185. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78186. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78187. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78188. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78189. * @returns the RGBA texture
  78190. */
  78191. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78192. /**
  78193. * Creates a R texture from some data.
  78194. * @param data Define the texture data
  78195. * @param width Define the width of the texture
  78196. * @param height Define the height of the texture
  78197. * @param scene Define the scene the texture belongs to
  78198. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78199. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78200. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78201. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78202. * @returns the R texture
  78203. */
  78204. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78205. }
  78206. }
  78207. declare module BABYLON {
  78208. /**
  78209. * Interface for the size containing width and height
  78210. */
  78211. export interface ISize {
  78212. /**
  78213. * Width
  78214. */
  78215. width: number;
  78216. /**
  78217. * Heighht
  78218. */
  78219. height: number;
  78220. }
  78221. /**
  78222. * Size containing widht and height
  78223. */
  78224. export class Size implements ISize {
  78225. /**
  78226. * Width
  78227. */
  78228. width: number;
  78229. /**
  78230. * Height
  78231. */
  78232. height: number;
  78233. /**
  78234. * Creates a Size object from the given width and height (floats).
  78235. * @param width width of the new size
  78236. * @param height height of the new size
  78237. */
  78238. constructor(width: number, height: number);
  78239. /**
  78240. * Returns a string with the Size width and height
  78241. * @returns a string with the Size width and height
  78242. */
  78243. toString(): string;
  78244. /**
  78245. * "Size"
  78246. * @returns the string "Size"
  78247. */
  78248. getClassName(): string;
  78249. /**
  78250. * Returns the Size hash code.
  78251. * @returns a hash code for a unique width and height
  78252. */
  78253. getHashCode(): number;
  78254. /**
  78255. * Updates the current size from the given one.
  78256. * @param src the given size
  78257. */
  78258. copyFrom(src: Size): void;
  78259. /**
  78260. * Updates in place the current Size from the given floats.
  78261. * @param width width of the new size
  78262. * @param height height of the new size
  78263. * @returns the updated Size.
  78264. */
  78265. copyFromFloats(width: number, height: number): Size;
  78266. /**
  78267. * Updates in place the current Size from the given floats.
  78268. * @param width width to set
  78269. * @param height height to set
  78270. * @returns the updated Size.
  78271. */
  78272. set(width: number, height: number): Size;
  78273. /**
  78274. * Multiplies the width and height by numbers
  78275. * @param w factor to multiple the width by
  78276. * @param h factor to multiple the height by
  78277. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  78278. */
  78279. multiplyByFloats(w: number, h: number): Size;
  78280. /**
  78281. * Clones the size
  78282. * @returns a new Size copied from the given one.
  78283. */
  78284. clone(): Size;
  78285. /**
  78286. * True if the current Size and the given one width and height are strictly equal.
  78287. * @param other the other size to compare against
  78288. * @returns True if the current Size and the given one width and height are strictly equal.
  78289. */
  78290. equals(other: Size): boolean;
  78291. /**
  78292. * The surface of the Size : width * height (float).
  78293. */
  78294. readonly surface: number;
  78295. /**
  78296. * Create a new size of zero
  78297. * @returns a new Size set to (0.0, 0.0)
  78298. */
  78299. static Zero(): Size;
  78300. /**
  78301. * Sums the width and height of two sizes
  78302. * @param otherSize size to add to this size
  78303. * @returns a new Size set as the addition result of the current Size and the given one.
  78304. */
  78305. add(otherSize: Size): Size;
  78306. /**
  78307. * Subtracts the width and height of two
  78308. * @param otherSize size to subtract to this size
  78309. * @returns a new Size set as the subtraction result of the given one from the current Size.
  78310. */
  78311. subtract(otherSize: Size): Size;
  78312. /**
  78313. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  78314. * @param start starting size to lerp between
  78315. * @param end end size to lerp between
  78316. * @param amount amount to lerp between the start and end values
  78317. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  78318. */
  78319. static Lerp(start: Size, end: Size, amount: number): Size;
  78320. }
  78321. }
  78322. declare module BABYLON {
  78323. /**
  78324. * Defines a runtime animation
  78325. */
  78326. export class RuntimeAnimation {
  78327. private _events;
  78328. /**
  78329. * The current frame of the runtime animation
  78330. */
  78331. private _currentFrame;
  78332. /**
  78333. * The animation used by the runtime animation
  78334. */
  78335. private _animation;
  78336. /**
  78337. * The target of the runtime animation
  78338. */
  78339. private _target;
  78340. /**
  78341. * The initiating animatable
  78342. */
  78343. private _host;
  78344. /**
  78345. * The original value of the runtime animation
  78346. */
  78347. private _originalValue;
  78348. /**
  78349. * The original blend value of the runtime animation
  78350. */
  78351. private _originalBlendValue;
  78352. /**
  78353. * The offsets cache of the runtime animation
  78354. */
  78355. private _offsetsCache;
  78356. /**
  78357. * The high limits cache of the runtime animation
  78358. */
  78359. private _highLimitsCache;
  78360. /**
  78361. * Specifies if the runtime animation has been stopped
  78362. */
  78363. private _stopped;
  78364. /**
  78365. * The blending factor of the runtime animation
  78366. */
  78367. private _blendingFactor;
  78368. /**
  78369. * The BabylonJS scene
  78370. */
  78371. private _scene;
  78372. /**
  78373. * The current value of the runtime animation
  78374. */
  78375. private _currentValue;
  78376. /** @hidden */
  78377. _animationState: _IAnimationState;
  78378. /**
  78379. * The active target of the runtime animation
  78380. */
  78381. private _activeTargets;
  78382. private _currentActiveTarget;
  78383. private _directTarget;
  78384. /**
  78385. * The target path of the runtime animation
  78386. */
  78387. private _targetPath;
  78388. /**
  78389. * The weight of the runtime animation
  78390. */
  78391. private _weight;
  78392. /**
  78393. * The ratio offset of the runtime animation
  78394. */
  78395. private _ratioOffset;
  78396. /**
  78397. * The previous delay of the runtime animation
  78398. */
  78399. private _previousDelay;
  78400. /**
  78401. * The previous ratio of the runtime animation
  78402. */
  78403. private _previousRatio;
  78404. private _enableBlending;
  78405. private _keys;
  78406. private _minFrame;
  78407. private _maxFrame;
  78408. private _minValue;
  78409. private _maxValue;
  78410. private _targetIsArray;
  78411. /**
  78412. * Gets the current frame of the runtime animation
  78413. */
  78414. readonly currentFrame: number;
  78415. /**
  78416. * Gets the weight of the runtime animation
  78417. */
  78418. readonly weight: number;
  78419. /**
  78420. * Gets the current value of the runtime animation
  78421. */
  78422. readonly currentValue: any;
  78423. /**
  78424. * Gets the target path of the runtime animation
  78425. */
  78426. readonly targetPath: string;
  78427. /**
  78428. * Gets the actual target of the runtime animation
  78429. */
  78430. readonly target: any;
  78431. /** @hidden */
  78432. _onLoop: () => void;
  78433. /**
  78434. * Create a new RuntimeAnimation object
  78435. * @param target defines the target of the animation
  78436. * @param animation defines the source animation object
  78437. * @param scene defines the hosting scene
  78438. * @param host defines the initiating Animatable
  78439. */
  78440. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78441. private _preparePath;
  78442. /**
  78443. * Gets the animation from the runtime animation
  78444. */
  78445. readonly animation: Animation;
  78446. /**
  78447. * Resets the runtime animation to the beginning
  78448. * @param restoreOriginal defines whether to restore the target property to the original value
  78449. */
  78450. reset(restoreOriginal?: boolean): void;
  78451. /**
  78452. * Specifies if the runtime animation is stopped
  78453. * @returns Boolean specifying if the runtime animation is stopped
  78454. */
  78455. isStopped(): boolean;
  78456. /**
  78457. * Disposes of the runtime animation
  78458. */
  78459. dispose(): void;
  78460. /**
  78461. * Apply the interpolated value to the target
  78462. * @param currentValue defines the value computed by the animation
  78463. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78464. */
  78465. setValue(currentValue: any, weight: number): void;
  78466. private _getOriginalValues;
  78467. private _setValue;
  78468. /**
  78469. * Gets the loop pmode of the runtime animation
  78470. * @returns Loop Mode
  78471. */
  78472. private _getCorrectLoopMode;
  78473. /**
  78474. * Move the current animation to a given frame
  78475. * @param frame defines the frame to move to
  78476. */
  78477. goToFrame(frame: number): void;
  78478. /**
  78479. * @hidden Internal use only
  78480. */
  78481. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78482. /**
  78483. * Execute the current animation
  78484. * @param delay defines the delay to add to the current frame
  78485. * @param from defines the lower bound of the animation range
  78486. * @param to defines the upper bound of the animation range
  78487. * @param loop defines if the current animation must loop
  78488. * @param speedRatio defines the current speed ratio
  78489. * @param weight defines the weight of the animation (default is -1 so no weight)
  78490. * @param onLoop optional callback called when animation loops
  78491. * @returns a boolean indicating if the animation is running
  78492. */
  78493. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78494. }
  78495. }
  78496. declare module BABYLON {
  78497. /**
  78498. * Class used to store an actual running animation
  78499. */
  78500. export class Animatable {
  78501. /** defines the target object */
  78502. target: any;
  78503. /** defines the starting frame number (default is 0) */
  78504. fromFrame: number;
  78505. /** defines the ending frame number (default is 100) */
  78506. toFrame: number;
  78507. /** defines if the animation must loop (default is false) */
  78508. loopAnimation: boolean;
  78509. /** defines a callback to call when animation ends if it is not looping */
  78510. onAnimationEnd?: (() => void) | null | undefined;
  78511. /** defines a callback to call when animation loops */
  78512. onAnimationLoop?: (() => void) | null | undefined;
  78513. private _localDelayOffset;
  78514. private _pausedDelay;
  78515. private _runtimeAnimations;
  78516. private _paused;
  78517. private _scene;
  78518. private _speedRatio;
  78519. private _weight;
  78520. private _syncRoot;
  78521. /**
  78522. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78523. * This will only apply for non looping animation (default is true)
  78524. */
  78525. disposeOnEnd: boolean;
  78526. /**
  78527. * Gets a boolean indicating if the animation has started
  78528. */
  78529. animationStarted: boolean;
  78530. /**
  78531. * Observer raised when the animation ends
  78532. */
  78533. onAnimationEndObservable: Observable<Animatable>;
  78534. /**
  78535. * Observer raised when the animation loops
  78536. */
  78537. onAnimationLoopObservable: Observable<Animatable>;
  78538. /**
  78539. * Gets the root Animatable used to synchronize and normalize animations
  78540. */
  78541. readonly syncRoot: Nullable<Animatable>;
  78542. /**
  78543. * Gets the current frame of the first RuntimeAnimation
  78544. * Used to synchronize Animatables
  78545. */
  78546. readonly masterFrame: number;
  78547. /**
  78548. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78549. */
  78550. weight: number;
  78551. /**
  78552. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78553. */
  78554. speedRatio: number;
  78555. /**
  78556. * Creates a new Animatable
  78557. * @param scene defines the hosting scene
  78558. * @param target defines the target object
  78559. * @param fromFrame defines the starting frame number (default is 0)
  78560. * @param toFrame defines the ending frame number (default is 100)
  78561. * @param loopAnimation defines if the animation must loop (default is false)
  78562. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78563. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78564. * @param animations defines a group of animation to add to the new Animatable
  78565. * @param onAnimationLoop defines a callback to call when animation loops
  78566. */
  78567. constructor(scene: Scene,
  78568. /** defines the target object */
  78569. target: any,
  78570. /** defines the starting frame number (default is 0) */
  78571. fromFrame?: number,
  78572. /** defines the ending frame number (default is 100) */
  78573. toFrame?: number,
  78574. /** defines if the animation must loop (default is false) */
  78575. loopAnimation?: boolean, speedRatio?: number,
  78576. /** defines a callback to call when animation ends if it is not looping */
  78577. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78578. /** defines a callback to call when animation loops */
  78579. onAnimationLoop?: (() => void) | null | undefined);
  78580. /**
  78581. * Synchronize and normalize current Animatable with a source Animatable
  78582. * This is useful when using animation weights and when animations are not of the same length
  78583. * @param root defines the root Animatable to synchronize with
  78584. * @returns the current Animatable
  78585. */
  78586. syncWith(root: Animatable): Animatable;
  78587. /**
  78588. * Gets the list of runtime animations
  78589. * @returns an array of RuntimeAnimation
  78590. */
  78591. getAnimations(): RuntimeAnimation[];
  78592. /**
  78593. * Adds more animations to the current animatable
  78594. * @param target defines the target of the animations
  78595. * @param animations defines the new animations to add
  78596. */
  78597. appendAnimations(target: any, animations: Animation[]): void;
  78598. /**
  78599. * Gets the source animation for a specific property
  78600. * @param property defines the propertyu to look for
  78601. * @returns null or the source animation for the given property
  78602. */
  78603. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78604. /**
  78605. * Gets the runtime animation for a specific property
  78606. * @param property defines the propertyu to look for
  78607. * @returns null or the runtime animation for the given property
  78608. */
  78609. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78610. /**
  78611. * Resets the animatable to its original state
  78612. */
  78613. reset(): void;
  78614. /**
  78615. * Allows the animatable to blend with current running animations
  78616. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78617. * @param blendingSpeed defines the blending speed to use
  78618. */
  78619. enableBlending(blendingSpeed: number): void;
  78620. /**
  78621. * Disable animation blending
  78622. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78623. */
  78624. disableBlending(): void;
  78625. /**
  78626. * Jump directly to a given frame
  78627. * @param frame defines the frame to jump to
  78628. */
  78629. goToFrame(frame: number): void;
  78630. /**
  78631. * Pause the animation
  78632. */
  78633. pause(): void;
  78634. /**
  78635. * Restart the animation
  78636. */
  78637. restart(): void;
  78638. private _raiseOnAnimationEnd;
  78639. /**
  78640. * Stop and delete the current animation
  78641. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78642. * @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)
  78643. */
  78644. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78645. /**
  78646. * Wait asynchronously for the animation to end
  78647. * @returns a promise which will be fullfilled when the animation ends
  78648. */
  78649. waitAsync(): Promise<Animatable>;
  78650. /** @hidden */
  78651. _animate(delay: number): boolean;
  78652. }
  78653. interface Scene {
  78654. /** @hidden */
  78655. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78656. /** @hidden */
  78657. _processLateAnimationBindingsForMatrices(holder: {
  78658. totalWeight: number;
  78659. animations: RuntimeAnimation[];
  78660. originalValue: Matrix;
  78661. }): any;
  78662. /** @hidden */
  78663. _processLateAnimationBindingsForQuaternions(holder: {
  78664. totalWeight: number;
  78665. animations: RuntimeAnimation[];
  78666. originalValue: Quaternion;
  78667. }, refQuaternion: Quaternion): Quaternion;
  78668. /** @hidden */
  78669. _processLateAnimationBindings(): void;
  78670. /**
  78671. * Will start the animation sequence of a given target
  78672. * @param target defines the target
  78673. * @param from defines from which frame should animation start
  78674. * @param to defines until which frame should animation run.
  78675. * @param weight defines the weight to apply to the animation (1.0 by default)
  78676. * @param loop defines if the animation loops
  78677. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78678. * @param onAnimationEnd defines the function to be executed when the animation ends
  78679. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78680. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78681. * @param onAnimationLoop defines the callback to call when an animation loops
  78682. * @returns the animatable object created for this animation
  78683. */
  78684. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78685. /**
  78686. * Will start the animation sequence of a given target
  78687. * @param target defines the target
  78688. * @param from defines from which frame should animation start
  78689. * @param to defines until which frame should animation run.
  78690. * @param loop defines if the animation loops
  78691. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78692. * @param onAnimationEnd defines the function to be executed when the animation ends
  78693. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78694. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78695. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78696. * @param onAnimationLoop defines the callback to call when an animation loops
  78697. * @returns the animatable object created for this animation
  78698. */
  78699. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78700. /**
  78701. * Will start the animation sequence of a given target and its hierarchy
  78702. * @param target defines the target
  78703. * @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.
  78704. * @param from defines from which frame should animation start
  78705. * @param to defines until which frame should animation run.
  78706. * @param loop defines if the animation loops
  78707. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78708. * @param onAnimationEnd defines the function to be executed when the animation ends
  78709. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78710. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78711. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78712. * @param onAnimationLoop defines the callback to call when an animation loops
  78713. * @returns the list of created animatables
  78714. */
  78715. 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[];
  78716. /**
  78717. * Begin a new animation on a given node
  78718. * @param target defines the target where the animation will take place
  78719. * @param animations defines the list of animations to start
  78720. * @param from defines the initial value
  78721. * @param to defines the final value
  78722. * @param loop defines if you want animation to loop (off by default)
  78723. * @param speedRatio defines the speed ratio to apply to all animations
  78724. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78725. * @param onAnimationLoop defines the callback to call when an animation loops
  78726. * @returns the list of created animatables
  78727. */
  78728. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78729. /**
  78730. * Begin a new animation on a given node and its hierarchy
  78731. * @param target defines the root node where the animation will take place
  78732. * @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.
  78733. * @param animations defines the list of animations to start
  78734. * @param from defines the initial value
  78735. * @param to defines the final value
  78736. * @param loop defines if you want animation to loop (off by default)
  78737. * @param speedRatio defines the speed ratio to apply to all animations
  78738. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78739. * @param onAnimationLoop defines the callback to call when an animation loops
  78740. * @returns the list of animatables created for all nodes
  78741. */
  78742. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78743. /**
  78744. * Gets the animatable associated with a specific target
  78745. * @param target defines the target of the animatable
  78746. * @returns the required animatable if found
  78747. */
  78748. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78749. /**
  78750. * Gets all animatables associated with a given target
  78751. * @param target defines the target to look animatables for
  78752. * @returns an array of Animatables
  78753. */
  78754. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78755. /**
  78756. * Stops and removes all animations that have been applied to the scene
  78757. */
  78758. stopAllAnimations(): void;
  78759. }
  78760. interface Bone {
  78761. /**
  78762. * Copy an animation range from another bone
  78763. * @param source defines the source bone
  78764. * @param rangeName defines the range name to copy
  78765. * @param frameOffset defines the frame offset
  78766. * @param rescaleAsRequired defines if rescaling must be applied if required
  78767. * @param skelDimensionsRatio defines the scaling ratio
  78768. * @returns true if operation was successful
  78769. */
  78770. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78771. }
  78772. }
  78773. declare module BABYLON {
  78774. /**
  78775. * Class used to override all child animations of a given target
  78776. */
  78777. export class AnimationPropertiesOverride {
  78778. /**
  78779. * Gets or sets a value indicating if animation blending must be used
  78780. */
  78781. enableBlending: boolean;
  78782. /**
  78783. * Gets or sets the blending speed to use when enableBlending is true
  78784. */
  78785. blendingSpeed: number;
  78786. /**
  78787. * Gets or sets the default loop mode to use
  78788. */
  78789. loopMode: number;
  78790. }
  78791. }
  78792. declare module BABYLON {
  78793. /**
  78794. * Class used to handle skinning animations
  78795. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78796. */
  78797. export class Skeleton implements IAnimatable {
  78798. /** defines the skeleton name */
  78799. name: string;
  78800. /** defines the skeleton Id */
  78801. id: string;
  78802. /**
  78803. * Defines the list of child bones
  78804. */
  78805. bones: Bone[];
  78806. /**
  78807. * Defines an estimate of the dimension of the skeleton at rest
  78808. */
  78809. dimensionsAtRest: Vector3;
  78810. /**
  78811. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78812. */
  78813. needInitialSkinMatrix: boolean;
  78814. /**
  78815. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78816. */
  78817. overrideMesh: Nullable<AbstractMesh>;
  78818. /**
  78819. * Gets the list of animations attached to this skeleton
  78820. */
  78821. animations: Array<Animation>;
  78822. private _scene;
  78823. private _isDirty;
  78824. private _transformMatrices;
  78825. private _transformMatrixTexture;
  78826. private _meshesWithPoseMatrix;
  78827. private _animatables;
  78828. private _identity;
  78829. private _synchronizedWithMesh;
  78830. private _ranges;
  78831. private _lastAbsoluteTransformsUpdateId;
  78832. private _canUseTextureForBones;
  78833. private _uniqueId;
  78834. /** @hidden */
  78835. _numBonesWithLinkedTransformNode: number;
  78836. /** @hidden */
  78837. _hasWaitingData: Nullable<boolean>;
  78838. /**
  78839. * Specifies if the skeleton should be serialized
  78840. */
  78841. doNotSerialize: boolean;
  78842. private _useTextureToStoreBoneMatrices;
  78843. /**
  78844. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78845. * Please note that this option is not available if the hardware does not support it
  78846. */
  78847. useTextureToStoreBoneMatrices: boolean;
  78848. private _animationPropertiesOverride;
  78849. /**
  78850. * Gets or sets the animation properties override
  78851. */
  78852. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78853. /**
  78854. * List of inspectable custom properties (used by the Inspector)
  78855. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78856. */
  78857. inspectableCustomProperties: IInspectable[];
  78858. /**
  78859. * An observable triggered before computing the skeleton's matrices
  78860. */
  78861. onBeforeComputeObservable: Observable<Skeleton>;
  78862. /**
  78863. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78864. */
  78865. readonly isUsingTextureForMatrices: boolean;
  78866. /**
  78867. * Gets the unique ID of this skeleton
  78868. */
  78869. readonly uniqueId: number;
  78870. /**
  78871. * Creates a new skeleton
  78872. * @param name defines the skeleton name
  78873. * @param id defines the skeleton Id
  78874. * @param scene defines the hosting scene
  78875. */
  78876. constructor(
  78877. /** defines the skeleton name */
  78878. name: string,
  78879. /** defines the skeleton Id */
  78880. id: string, scene: Scene);
  78881. /**
  78882. * Gets the current object class name.
  78883. * @return the class name
  78884. */
  78885. getClassName(): string;
  78886. /**
  78887. * Returns an array containing the root bones
  78888. * @returns an array containing the root bones
  78889. */
  78890. getChildren(): Array<Bone>;
  78891. /**
  78892. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78893. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78894. * @returns a Float32Array containing matrices data
  78895. */
  78896. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78897. /**
  78898. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78899. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78900. * @returns a raw texture containing the data
  78901. */
  78902. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  78903. /**
  78904. * Gets the current hosting scene
  78905. * @returns a scene object
  78906. */
  78907. getScene(): Scene;
  78908. /**
  78909. * Gets a string representing the current skeleton data
  78910. * @param fullDetails defines a boolean indicating if we want a verbose version
  78911. * @returns a string representing the current skeleton data
  78912. */
  78913. toString(fullDetails?: boolean): string;
  78914. /**
  78915. * Get bone's index searching by name
  78916. * @param name defines bone's name to search for
  78917. * @return the indice of the bone. Returns -1 if not found
  78918. */
  78919. getBoneIndexByName(name: string): number;
  78920. /**
  78921. * Creater a new animation range
  78922. * @param name defines the name of the range
  78923. * @param from defines the start key
  78924. * @param to defines the end key
  78925. */
  78926. createAnimationRange(name: string, from: number, to: number): void;
  78927. /**
  78928. * Delete a specific animation range
  78929. * @param name defines the name of the range
  78930. * @param deleteFrames defines if frames must be removed as well
  78931. */
  78932. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  78933. /**
  78934. * Gets a specific animation range
  78935. * @param name defines the name of the range to look for
  78936. * @returns the requested animation range or null if not found
  78937. */
  78938. getAnimationRange(name: string): Nullable<AnimationRange>;
  78939. /**
  78940. * Gets the list of all animation ranges defined on this skeleton
  78941. * @returns an array
  78942. */
  78943. getAnimationRanges(): Nullable<AnimationRange>[];
  78944. /**
  78945. * Copy animation range from a source skeleton.
  78946. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  78947. * @param source defines the source skeleton
  78948. * @param name defines the name of the range to copy
  78949. * @param rescaleAsRequired defines if rescaling must be applied if required
  78950. * @returns true if operation was successful
  78951. */
  78952. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  78953. /**
  78954. * Forces the skeleton to go to rest pose
  78955. */
  78956. returnToRest(): void;
  78957. private _getHighestAnimationFrame;
  78958. /**
  78959. * Begin a specific animation range
  78960. * @param name defines the name of the range to start
  78961. * @param loop defines if looping must be turned on (false by default)
  78962. * @param speedRatio defines the speed ratio to apply (1 by default)
  78963. * @param onAnimationEnd defines a callback which will be called when animation will end
  78964. * @returns a new animatable
  78965. */
  78966. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  78967. /** @hidden */
  78968. _markAsDirty(): void;
  78969. /** @hidden */
  78970. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78971. /** @hidden */
  78972. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78973. private _computeTransformMatrices;
  78974. /**
  78975. * Build all resources required to render a skeleton
  78976. */
  78977. prepare(): void;
  78978. /**
  78979. * Gets the list of animatables currently running for this skeleton
  78980. * @returns an array of animatables
  78981. */
  78982. getAnimatables(): IAnimatable[];
  78983. /**
  78984. * Clone the current skeleton
  78985. * @param name defines the name of the new skeleton
  78986. * @param id defines the id of the new skeleton
  78987. * @returns the new skeleton
  78988. */
  78989. clone(name: string, id: string): Skeleton;
  78990. /**
  78991. * Enable animation blending for this skeleton
  78992. * @param blendingSpeed defines the blending speed to apply
  78993. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78994. */
  78995. enableBlending(blendingSpeed?: number): void;
  78996. /**
  78997. * Releases all resources associated with the current skeleton
  78998. */
  78999. dispose(): void;
  79000. /**
  79001. * Serialize the skeleton in a JSON object
  79002. * @returns a JSON object
  79003. */
  79004. serialize(): any;
  79005. /**
  79006. * Creates a new skeleton from serialized data
  79007. * @param parsedSkeleton defines the serialized data
  79008. * @param scene defines the hosting scene
  79009. * @returns a new skeleton
  79010. */
  79011. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79012. /**
  79013. * Compute all node absolute transforms
  79014. * @param forceUpdate defines if computation must be done even if cache is up to date
  79015. */
  79016. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79017. /**
  79018. * Gets the root pose matrix
  79019. * @returns a matrix
  79020. */
  79021. getPoseMatrix(): Nullable<Matrix>;
  79022. /**
  79023. * Sorts bones per internal index
  79024. */
  79025. sortBones(): void;
  79026. private _sortBones;
  79027. }
  79028. }
  79029. declare module BABYLON {
  79030. /**
  79031. * Class used to store bone information
  79032. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79033. */
  79034. export class Bone extends Node {
  79035. /**
  79036. * defines the bone name
  79037. */
  79038. name: string;
  79039. private static _tmpVecs;
  79040. private static _tmpQuat;
  79041. private static _tmpMats;
  79042. /**
  79043. * Gets the list of child bones
  79044. */
  79045. children: Bone[];
  79046. /** Gets the animations associated with this bone */
  79047. animations: Animation[];
  79048. /**
  79049. * Gets or sets bone length
  79050. */
  79051. length: number;
  79052. /**
  79053. * @hidden Internal only
  79054. * Set this value to map this bone to a different index in the transform matrices
  79055. * Set this value to -1 to exclude the bone from the transform matrices
  79056. */
  79057. _index: Nullable<number>;
  79058. private _skeleton;
  79059. private _localMatrix;
  79060. private _restPose;
  79061. private _baseMatrix;
  79062. private _absoluteTransform;
  79063. private _invertedAbsoluteTransform;
  79064. private _parent;
  79065. private _scalingDeterminant;
  79066. private _worldTransform;
  79067. private _localScaling;
  79068. private _localRotation;
  79069. private _localPosition;
  79070. private _needToDecompose;
  79071. private _needToCompose;
  79072. /** @hidden */
  79073. _linkedTransformNode: Nullable<TransformNode>;
  79074. /** @hidden */
  79075. _waitingTransformNodeId: Nullable<string>;
  79076. /** @hidden */
  79077. /** @hidden */
  79078. _matrix: Matrix;
  79079. /**
  79080. * Create a new bone
  79081. * @param name defines the bone name
  79082. * @param skeleton defines the parent skeleton
  79083. * @param parentBone defines the parent (can be null if the bone is the root)
  79084. * @param localMatrix defines the local matrix
  79085. * @param restPose defines the rest pose matrix
  79086. * @param baseMatrix defines the base matrix
  79087. * @param index defines index of the bone in the hiearchy
  79088. */
  79089. constructor(
  79090. /**
  79091. * defines the bone name
  79092. */
  79093. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  79094. /**
  79095. * Gets the current object class name.
  79096. * @return the class name
  79097. */
  79098. getClassName(): string;
  79099. /**
  79100. * Gets the parent skeleton
  79101. * @returns a skeleton
  79102. */
  79103. getSkeleton(): Skeleton;
  79104. /**
  79105. * Gets parent bone
  79106. * @returns a bone or null if the bone is the root of the bone hierarchy
  79107. */
  79108. getParent(): Nullable<Bone>;
  79109. /**
  79110. * Returns an array containing the root bones
  79111. * @returns an array containing the root bones
  79112. */
  79113. getChildren(): Array<Bone>;
  79114. /**
  79115. * Sets the parent bone
  79116. * @param parent defines the parent (can be null if the bone is the root)
  79117. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79118. */
  79119. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  79120. /**
  79121. * Gets the local matrix
  79122. * @returns a matrix
  79123. */
  79124. getLocalMatrix(): Matrix;
  79125. /**
  79126. * Gets the base matrix (initial matrix which remains unchanged)
  79127. * @returns a matrix
  79128. */
  79129. getBaseMatrix(): Matrix;
  79130. /**
  79131. * Gets the rest pose matrix
  79132. * @returns a matrix
  79133. */
  79134. getRestPose(): Matrix;
  79135. /**
  79136. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  79137. */
  79138. getWorldMatrix(): Matrix;
  79139. /**
  79140. * Sets the local matrix to rest pose matrix
  79141. */
  79142. returnToRest(): void;
  79143. /**
  79144. * Gets the inverse of the absolute transform matrix.
  79145. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  79146. * @returns a matrix
  79147. */
  79148. getInvertedAbsoluteTransform(): Matrix;
  79149. /**
  79150. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  79151. * @returns a matrix
  79152. */
  79153. getAbsoluteTransform(): Matrix;
  79154. /**
  79155. * Links with the given transform node.
  79156. * The local matrix of this bone is copied from the transform node every frame.
  79157. * @param transformNode defines the transform node to link to
  79158. */
  79159. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  79160. /**
  79161. * Gets the node used to drive the bone's transformation
  79162. * @returns a transform node or null
  79163. */
  79164. getTransformNode(): Nullable<TransformNode>;
  79165. /** Gets or sets current position (in local space) */
  79166. position: Vector3;
  79167. /** Gets or sets current rotation (in local space) */
  79168. rotation: Vector3;
  79169. /** Gets or sets current rotation quaternion (in local space) */
  79170. rotationQuaternion: Quaternion;
  79171. /** Gets or sets current scaling (in local space) */
  79172. scaling: Vector3;
  79173. /**
  79174. * Gets the animation properties override
  79175. */
  79176. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79177. private _decompose;
  79178. private _compose;
  79179. /**
  79180. * Update the base and local matrices
  79181. * @param matrix defines the new base or local matrix
  79182. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79183. * @param updateLocalMatrix defines if the local matrix should be updated
  79184. */
  79185. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  79186. /** @hidden */
  79187. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  79188. /**
  79189. * Flag the bone as dirty (Forcing it to update everything)
  79190. */
  79191. markAsDirty(): void;
  79192. /** @hidden */
  79193. _markAsDirtyAndCompose(): void;
  79194. private _markAsDirtyAndDecompose;
  79195. /**
  79196. * Translate the bone in local or world space
  79197. * @param vec The amount to translate the bone
  79198. * @param space The space that the translation is in
  79199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79200. */
  79201. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79202. /**
  79203. * Set the postion of the bone in local or world space
  79204. * @param position The position to set the bone
  79205. * @param space The space that the position is in
  79206. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79207. */
  79208. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79209. /**
  79210. * Set the absolute position of the bone (world space)
  79211. * @param position The position to set the bone
  79212. * @param mesh The mesh that this bone is attached to
  79213. */
  79214. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  79215. /**
  79216. * Scale the bone on the x, y and z axes (in local space)
  79217. * @param x The amount to scale the bone on the x axis
  79218. * @param y The amount to scale the bone on the y axis
  79219. * @param z The amount to scale the bone on the z axis
  79220. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  79221. */
  79222. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  79223. /**
  79224. * Set the bone scaling in local space
  79225. * @param scale defines the scaling vector
  79226. */
  79227. setScale(scale: Vector3): void;
  79228. /**
  79229. * Gets the current scaling in local space
  79230. * @returns the current scaling vector
  79231. */
  79232. getScale(): Vector3;
  79233. /**
  79234. * Gets the current scaling in local space and stores it in a target vector
  79235. * @param result defines the target vector
  79236. */
  79237. getScaleToRef(result: Vector3): void;
  79238. /**
  79239. * Set the yaw, pitch, and roll of the bone in local or world space
  79240. * @param yaw The rotation of the bone on the y axis
  79241. * @param pitch The rotation of the bone on the x axis
  79242. * @param roll The rotation of the bone on the z axis
  79243. * @param space The space that the axes of rotation are in
  79244. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79245. */
  79246. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  79247. /**
  79248. * Add a rotation to the bone on an axis in local or world space
  79249. * @param axis The axis to rotate the bone on
  79250. * @param amount The amount to rotate the bone
  79251. * @param space The space that the axis is in
  79252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79253. */
  79254. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  79255. /**
  79256. * Set the rotation of the bone to a particular axis angle in local or world space
  79257. * @param axis The axis to rotate the bone on
  79258. * @param angle The angle that the bone should be rotated to
  79259. * @param space The space that the axis is in
  79260. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79261. */
  79262. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  79263. /**
  79264. * Set the euler rotation of the bone in local of world space
  79265. * @param rotation The euler rotation that the bone should be set to
  79266. * @param space The space that the rotation is in
  79267. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79268. */
  79269. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79270. /**
  79271. * Set the quaternion rotation of the bone in local of world space
  79272. * @param quat The quaternion rotation that the bone should be set to
  79273. * @param space The space that the rotation is in
  79274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79275. */
  79276. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  79277. /**
  79278. * Set the rotation matrix of the bone in local of world space
  79279. * @param rotMat The rotation matrix that the bone should be set to
  79280. * @param space The space that the rotation is in
  79281. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79282. */
  79283. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  79284. private _rotateWithMatrix;
  79285. private _getNegativeRotationToRef;
  79286. /**
  79287. * Get the position of the bone in local or world space
  79288. * @param space The space that the returned position is in
  79289. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79290. * @returns The position of the bone
  79291. */
  79292. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79293. /**
  79294. * Copy the position of the bone to a vector3 in local or world space
  79295. * @param space The space that the returned position is in
  79296. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79297. * @param result The vector3 to copy the position to
  79298. */
  79299. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  79300. /**
  79301. * Get the absolute position of the bone (world space)
  79302. * @param mesh The mesh that this bone is attached to
  79303. * @returns The absolute position of the bone
  79304. */
  79305. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  79306. /**
  79307. * Copy the absolute position of the bone (world space) to the result param
  79308. * @param mesh The mesh that this bone is attached to
  79309. * @param result The vector3 to copy the absolute position to
  79310. */
  79311. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  79312. /**
  79313. * Compute the absolute transforms of this bone and its children
  79314. */
  79315. computeAbsoluteTransforms(): void;
  79316. /**
  79317. * Get the world direction from an axis that is in the local space of the bone
  79318. * @param localAxis The local direction that is used to compute the world direction
  79319. * @param mesh The mesh that this bone is attached to
  79320. * @returns The world direction
  79321. */
  79322. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79323. /**
  79324. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  79325. * @param localAxis The local direction that is used to compute the world direction
  79326. * @param mesh The mesh that this bone is attached to
  79327. * @param result The vector3 that the world direction will be copied to
  79328. */
  79329. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79330. /**
  79331. * Get the euler rotation of the bone in local or world space
  79332. * @param space The space that the rotation should be in
  79333. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79334. * @returns The euler rotation
  79335. */
  79336. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79337. /**
  79338. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  79339. * @param space The space that the rotation should be in
  79340. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79341. * @param result The vector3 that the rotation should be copied to
  79342. */
  79343. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79344. /**
  79345. * Get the quaternion rotation of the bone in either local or world space
  79346. * @param space The space that the rotation should be in
  79347. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79348. * @returns The quaternion rotation
  79349. */
  79350. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  79351. /**
  79352. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  79353. * @param space The space that the rotation should be in
  79354. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79355. * @param result The quaternion that the rotation should be copied to
  79356. */
  79357. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  79358. /**
  79359. * Get the rotation matrix of the bone in local or world space
  79360. * @param space The space that the rotation should be in
  79361. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79362. * @returns The rotation matrix
  79363. */
  79364. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  79365. /**
  79366. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  79367. * @param space The space that the rotation should be in
  79368. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79369. * @param result The quaternion that the rotation should be copied to
  79370. */
  79371. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  79372. /**
  79373. * Get the world position of a point that is in the local space of the bone
  79374. * @param position The local position
  79375. * @param mesh The mesh that this bone is attached to
  79376. * @returns The world position
  79377. */
  79378. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79379. /**
  79380. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  79381. * @param position The local position
  79382. * @param mesh The mesh that this bone is attached to
  79383. * @param result The vector3 that the world position should be copied to
  79384. */
  79385. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79386. /**
  79387. * Get the local position of a point that is in world space
  79388. * @param position The world position
  79389. * @param mesh The mesh that this bone is attached to
  79390. * @returns The local position
  79391. */
  79392. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79393. /**
  79394. * Get the local position of a point that is in world space and copy it to the result param
  79395. * @param position The world position
  79396. * @param mesh The mesh that this bone is attached to
  79397. * @param result The vector3 that the local position should be copied to
  79398. */
  79399. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79400. }
  79401. }
  79402. declare module BABYLON {
  79403. /**
  79404. * 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.
  79405. * @see https://doc.babylonjs.com/how_to/transformnode
  79406. */
  79407. export class TransformNode extends Node {
  79408. /**
  79409. * Object will not rotate to face the camera
  79410. */
  79411. static BILLBOARDMODE_NONE: number;
  79412. /**
  79413. * Object will rotate to face the camera but only on the x axis
  79414. */
  79415. static BILLBOARDMODE_X: number;
  79416. /**
  79417. * Object will rotate to face the camera but only on the y axis
  79418. */
  79419. static BILLBOARDMODE_Y: number;
  79420. /**
  79421. * Object will rotate to face the camera but only on the z axis
  79422. */
  79423. static BILLBOARDMODE_Z: number;
  79424. /**
  79425. * Object will rotate to face the camera
  79426. */
  79427. static BILLBOARDMODE_ALL: number;
  79428. /**
  79429. * Object will rotate to face the camera's position instead of orientation
  79430. */
  79431. static BILLBOARDMODE_USE_POSITION: number;
  79432. private _forward;
  79433. private _forwardInverted;
  79434. private _up;
  79435. private _right;
  79436. private _rightInverted;
  79437. private _position;
  79438. private _rotation;
  79439. private _rotationQuaternion;
  79440. protected _scaling: Vector3;
  79441. protected _isDirty: boolean;
  79442. private _transformToBoneReferal;
  79443. private _isAbsoluteSynced;
  79444. private _billboardMode;
  79445. /**
  79446. * Gets or sets the billboard mode. Default is 0.
  79447. *
  79448. * | Value | Type | Description |
  79449. * | --- | --- | --- |
  79450. * | 0 | BILLBOARDMODE_NONE | |
  79451. * | 1 | BILLBOARDMODE_X | |
  79452. * | 2 | BILLBOARDMODE_Y | |
  79453. * | 4 | BILLBOARDMODE_Z | |
  79454. * | 7 | BILLBOARDMODE_ALL | |
  79455. *
  79456. */
  79457. billboardMode: number;
  79458. private _preserveParentRotationForBillboard;
  79459. /**
  79460. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  79461. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  79462. */
  79463. preserveParentRotationForBillboard: boolean;
  79464. /**
  79465. * 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
  79466. */
  79467. scalingDeterminant: number;
  79468. private _infiniteDistance;
  79469. /**
  79470. * Gets or sets the distance of the object to max, often used by skybox
  79471. */
  79472. infiniteDistance: boolean;
  79473. /**
  79474. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  79475. * By default the system will update normals to compensate
  79476. */
  79477. ignoreNonUniformScaling: boolean;
  79478. /**
  79479. * 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
  79480. */
  79481. reIntegrateRotationIntoRotationQuaternion: boolean;
  79482. /** @hidden */
  79483. _poseMatrix: Nullable<Matrix>;
  79484. /** @hidden */
  79485. _localMatrix: Matrix;
  79486. private _usePivotMatrix;
  79487. private _absolutePosition;
  79488. private _absoluteScaling;
  79489. private _absoluteRotationQuaternion;
  79490. private _pivotMatrix;
  79491. private _pivotMatrixInverse;
  79492. protected _postMultiplyPivotMatrix: boolean;
  79493. protected _isWorldMatrixFrozen: boolean;
  79494. /** @hidden */
  79495. _indexInSceneTransformNodesArray: number;
  79496. /**
  79497. * An event triggered after the world matrix is updated
  79498. */
  79499. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  79500. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  79501. /**
  79502. * Gets a string identifying the name of the class
  79503. * @returns "TransformNode" string
  79504. */
  79505. getClassName(): string;
  79506. /**
  79507. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  79508. */
  79509. position: Vector3;
  79510. /**
  79511. * 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)).
  79512. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  79513. */
  79514. rotation: Vector3;
  79515. /**
  79516. * 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)).
  79517. */
  79518. scaling: Vector3;
  79519. /**
  79520. * 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).
  79521. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  79522. */
  79523. rotationQuaternion: Nullable<Quaternion>;
  79524. /**
  79525. * The forward direction of that transform in world space.
  79526. */
  79527. readonly forward: Vector3;
  79528. /**
  79529. * The up direction of that transform in world space.
  79530. */
  79531. readonly up: Vector3;
  79532. /**
  79533. * The right direction of that transform in world space.
  79534. */
  79535. readonly right: Vector3;
  79536. /**
  79537. * Copies the parameter passed Matrix into the mesh Pose matrix.
  79538. * @param matrix the matrix to copy the pose from
  79539. * @returns this TransformNode.
  79540. */
  79541. updatePoseMatrix(matrix: Matrix): TransformNode;
  79542. /**
  79543. * Returns the mesh Pose matrix.
  79544. * @returns the pose matrix
  79545. */
  79546. getPoseMatrix(): Matrix;
  79547. /** @hidden */
  79548. _isSynchronized(): boolean;
  79549. /** @hidden */
  79550. _initCache(): void;
  79551. /**
  79552. * Flag the transform node as dirty (Forcing it to update everything)
  79553. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  79554. * @returns this transform node
  79555. */
  79556. markAsDirty(property: string): TransformNode;
  79557. /**
  79558. * Returns the current mesh absolute position.
  79559. * Returns a Vector3.
  79560. */
  79561. readonly absolutePosition: Vector3;
  79562. /**
  79563. * Returns the current mesh absolute scaling.
  79564. * Returns a Vector3.
  79565. */
  79566. readonly absoluteScaling: Vector3;
  79567. /**
  79568. * Returns the current mesh absolute rotation.
  79569. * Returns a Quaternion.
  79570. */
  79571. readonly absoluteRotationQuaternion: Quaternion;
  79572. /**
  79573. * Sets a new matrix to apply before all other transformation
  79574. * @param matrix defines the transform matrix
  79575. * @returns the current TransformNode
  79576. */
  79577. setPreTransformMatrix(matrix: Matrix): TransformNode;
  79578. /**
  79579. * Sets a new pivot matrix to the current node
  79580. * @param matrix defines the new pivot matrix to use
  79581. * @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
  79582. * @returns the current TransformNode
  79583. */
  79584. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  79585. /**
  79586. * Returns the mesh pivot matrix.
  79587. * Default : Identity.
  79588. * @returns the matrix
  79589. */
  79590. getPivotMatrix(): Matrix;
  79591. /**
  79592. * Instantiate (when possible) or clone that node with its hierarchy
  79593. * @param newParent defines the new parent to use for the instance (or clone)
  79594. * @returns an instance (or a clone) of the current node with its hiearchy
  79595. */
  79596. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  79597. /**
  79598. * Prevents the World matrix to be computed any longer
  79599. * @param newWorldMatrix defines an optional matrix to use as world matrix
  79600. * @returns the TransformNode.
  79601. */
  79602. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  79603. /**
  79604. * Allows back the World matrix computation.
  79605. * @returns the TransformNode.
  79606. */
  79607. unfreezeWorldMatrix(): this;
  79608. /**
  79609. * True if the World matrix has been frozen.
  79610. */
  79611. readonly isWorldMatrixFrozen: boolean;
  79612. /**
  79613. * Retuns the mesh absolute position in the World.
  79614. * @returns a Vector3.
  79615. */
  79616. getAbsolutePosition(): Vector3;
  79617. /**
  79618. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  79619. * @param absolutePosition the absolute position to set
  79620. * @returns the TransformNode.
  79621. */
  79622. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79623. /**
  79624. * Sets the mesh position in its local space.
  79625. * @param vector3 the position to set in localspace
  79626. * @returns the TransformNode.
  79627. */
  79628. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  79629. /**
  79630. * Returns the mesh position in the local space from the current World matrix values.
  79631. * @returns a new Vector3.
  79632. */
  79633. getPositionExpressedInLocalSpace(): Vector3;
  79634. /**
  79635. * Translates the mesh along the passed Vector3 in its local space.
  79636. * @param vector3 the distance to translate in localspace
  79637. * @returns the TransformNode.
  79638. */
  79639. locallyTranslate(vector3: Vector3): TransformNode;
  79640. private static _lookAtVectorCache;
  79641. /**
  79642. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  79643. * @param targetPoint the position (must be in same space as current mesh) to look at
  79644. * @param yawCor optional yaw (y-axis) correction in radians
  79645. * @param pitchCor optional pitch (x-axis) correction in radians
  79646. * @param rollCor optional roll (z-axis) correction in radians
  79647. * @param space the choosen space of the target
  79648. * @returns the TransformNode.
  79649. */
  79650. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  79651. /**
  79652. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79653. * This Vector3 is expressed in the World space.
  79654. * @param localAxis axis to rotate
  79655. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79656. */
  79657. getDirection(localAxis: Vector3): Vector3;
  79658. /**
  79659. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  79660. * localAxis is expressed in the mesh local space.
  79661. * result is computed in the Wordl space from the mesh World matrix.
  79662. * @param localAxis axis to rotate
  79663. * @param result the resulting transformnode
  79664. * @returns this TransformNode.
  79665. */
  79666. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  79667. /**
  79668. * Sets this transform node rotation to the given local axis.
  79669. * @param localAxis the axis in local space
  79670. * @param yawCor optional yaw (y-axis) correction in radians
  79671. * @param pitchCor optional pitch (x-axis) correction in radians
  79672. * @param rollCor optional roll (z-axis) correction in radians
  79673. * @returns this TransformNode
  79674. */
  79675. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  79676. /**
  79677. * Sets a new pivot point to the current node
  79678. * @param point defines the new pivot point to use
  79679. * @param space defines if the point is in world or local space (local by default)
  79680. * @returns the current TransformNode
  79681. */
  79682. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  79683. /**
  79684. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  79685. * @returns the pivot point
  79686. */
  79687. getPivotPoint(): Vector3;
  79688. /**
  79689. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  79690. * @param result the vector3 to store the result
  79691. * @returns this TransformNode.
  79692. */
  79693. getPivotPointToRef(result: Vector3): TransformNode;
  79694. /**
  79695. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  79696. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  79697. */
  79698. getAbsolutePivotPoint(): Vector3;
  79699. /**
  79700. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  79701. * @param result vector3 to store the result
  79702. * @returns this TransformNode.
  79703. */
  79704. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  79705. /**
  79706. * Defines the passed node as the parent of the current node.
  79707. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  79708. * @see https://doc.babylonjs.com/how_to/parenting
  79709. * @param node the node ot set as the parent
  79710. * @returns this TransformNode.
  79711. */
  79712. setParent(node: Nullable<Node>): TransformNode;
  79713. private _nonUniformScaling;
  79714. /**
  79715. * True if the scaling property of this object is non uniform eg. (1,2,1)
  79716. */
  79717. readonly nonUniformScaling: boolean;
  79718. /** @hidden */
  79719. _updateNonUniformScalingState(value: boolean): boolean;
  79720. /**
  79721. * Attach the current TransformNode to another TransformNode associated with a bone
  79722. * @param bone Bone affecting the TransformNode
  79723. * @param affectedTransformNode TransformNode associated with the bone
  79724. * @returns this object
  79725. */
  79726. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  79727. /**
  79728. * Detach the transform node if its associated with a bone
  79729. * @returns this object
  79730. */
  79731. detachFromBone(): TransformNode;
  79732. private static _rotationAxisCache;
  79733. /**
  79734. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  79735. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79736. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79737. * The passed axis is also normalized.
  79738. * @param axis the axis to rotate around
  79739. * @param amount the amount to rotate in radians
  79740. * @param space Space to rotate in (Default: local)
  79741. * @returns the TransformNode.
  79742. */
  79743. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79744. /**
  79745. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  79746. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79747. * The passed axis is also normalized. .
  79748. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  79749. * @param point the point to rotate around
  79750. * @param axis the axis to rotate around
  79751. * @param amount the amount to rotate in radians
  79752. * @returns the TransformNode
  79753. */
  79754. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  79755. /**
  79756. * Translates the mesh along the axis vector for the passed distance in the given space.
  79757. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79758. * @param axis the axis to translate in
  79759. * @param distance the distance to translate
  79760. * @param space Space to rotate in (Default: local)
  79761. * @returns the TransformNode.
  79762. */
  79763. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79764. /**
  79765. * Adds a rotation step to the mesh current rotation.
  79766. * x, y, z are Euler angles expressed in radians.
  79767. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  79768. * This means this rotation is made in the mesh local space only.
  79769. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  79770. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  79771. * ```javascript
  79772. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  79773. * ```
  79774. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  79775. * 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.
  79776. * @param x Rotation to add
  79777. * @param y Rotation to add
  79778. * @param z Rotation to add
  79779. * @returns the TransformNode.
  79780. */
  79781. addRotation(x: number, y: number, z: number): TransformNode;
  79782. /**
  79783. * @hidden
  79784. */
  79785. protected _getEffectiveParent(): Nullable<Node>;
  79786. /**
  79787. * Computes the world matrix of the node
  79788. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79789. * @returns the world matrix
  79790. */
  79791. computeWorldMatrix(force?: boolean): Matrix;
  79792. protected _afterComputeWorldMatrix(): void;
  79793. /**
  79794. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  79795. * @param func callback function to add
  79796. *
  79797. * @returns the TransformNode.
  79798. */
  79799. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79800. /**
  79801. * Removes a registered callback function.
  79802. * @param func callback function to remove
  79803. * @returns the TransformNode.
  79804. */
  79805. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79806. /**
  79807. * Gets the position of the current mesh in camera space
  79808. * @param camera defines the camera to use
  79809. * @returns a position
  79810. */
  79811. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  79812. /**
  79813. * Returns the distance from the mesh to the active camera
  79814. * @param camera defines the camera to use
  79815. * @returns the distance
  79816. */
  79817. getDistanceToCamera(camera?: Nullable<Camera>): number;
  79818. /**
  79819. * Clone the current transform node
  79820. * @param name Name of the new clone
  79821. * @param newParent New parent for the clone
  79822. * @param doNotCloneChildren Do not clone children hierarchy
  79823. * @returns the new transform node
  79824. */
  79825. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  79826. /**
  79827. * Serializes the objects information.
  79828. * @param currentSerializationObject defines the object to serialize in
  79829. * @returns the serialized object
  79830. */
  79831. serialize(currentSerializationObject?: any): any;
  79832. /**
  79833. * Returns a new TransformNode object parsed from the source provided.
  79834. * @param parsedTransformNode is the source.
  79835. * @param scene the scne the object belongs to
  79836. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  79837. * @returns a new TransformNode object parsed from the source provided.
  79838. */
  79839. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  79840. /**
  79841. * Get all child-transformNodes of this node
  79842. * @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
  79843. * @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
  79844. * @returns an array of TransformNode
  79845. */
  79846. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  79847. /**
  79848. * Releases resources associated with this transform node.
  79849. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79850. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79851. */
  79852. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79853. /**
  79854. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79855. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  79856. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  79857. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  79858. * @returns the current mesh
  79859. */
  79860. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  79861. private _syncAbsoluteScalingAndRotation;
  79862. }
  79863. }
  79864. declare module BABYLON {
  79865. /**
  79866. * Defines the types of pose enabled controllers that are supported
  79867. */
  79868. export enum PoseEnabledControllerType {
  79869. /**
  79870. * HTC Vive
  79871. */
  79872. VIVE = 0,
  79873. /**
  79874. * Oculus Rift
  79875. */
  79876. OCULUS = 1,
  79877. /**
  79878. * Windows mixed reality
  79879. */
  79880. WINDOWS = 2,
  79881. /**
  79882. * Samsung gear VR
  79883. */
  79884. GEAR_VR = 3,
  79885. /**
  79886. * Google Daydream
  79887. */
  79888. DAYDREAM = 4,
  79889. /**
  79890. * Generic
  79891. */
  79892. GENERIC = 5
  79893. }
  79894. /**
  79895. * Defines the MutableGamepadButton interface for the state of a gamepad button
  79896. */
  79897. export interface MutableGamepadButton {
  79898. /**
  79899. * Value of the button/trigger
  79900. */
  79901. value: number;
  79902. /**
  79903. * If the button/trigger is currently touched
  79904. */
  79905. touched: boolean;
  79906. /**
  79907. * If the button/trigger is currently pressed
  79908. */
  79909. pressed: boolean;
  79910. }
  79911. /**
  79912. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  79913. * @hidden
  79914. */
  79915. export interface ExtendedGamepadButton extends GamepadButton {
  79916. /**
  79917. * If the button/trigger is currently pressed
  79918. */
  79919. readonly pressed: boolean;
  79920. /**
  79921. * If the button/trigger is currently touched
  79922. */
  79923. readonly touched: boolean;
  79924. /**
  79925. * Value of the button/trigger
  79926. */
  79927. readonly value: number;
  79928. }
  79929. /** @hidden */
  79930. export interface _GamePadFactory {
  79931. /**
  79932. * Returns wether or not the current gamepad can be created for this type of controller.
  79933. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79934. * @returns true if it can be created, otherwise false
  79935. */
  79936. canCreate(gamepadInfo: any): boolean;
  79937. /**
  79938. * Creates a new instance of the Gamepad.
  79939. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79940. * @returns the new gamepad instance
  79941. */
  79942. create(gamepadInfo: any): Gamepad;
  79943. }
  79944. /**
  79945. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79946. */
  79947. export class PoseEnabledControllerHelper {
  79948. /** @hidden */
  79949. static _ControllerFactories: _GamePadFactory[];
  79950. /** @hidden */
  79951. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  79952. /**
  79953. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79954. * @param vrGamepad the gamepad to initialized
  79955. * @returns a vr controller of the type the gamepad identified as
  79956. */
  79957. static InitiateController(vrGamepad: any): Gamepad;
  79958. }
  79959. /**
  79960. * Defines the PoseEnabledController object that contains state of a vr capable controller
  79961. */
  79962. export class PoseEnabledController extends Gamepad implements PoseControlled {
  79963. /**
  79964. * If the controller is used in a webXR session
  79965. */
  79966. isXR: boolean;
  79967. private _deviceRoomPosition;
  79968. private _deviceRoomRotationQuaternion;
  79969. /**
  79970. * The device position in babylon space
  79971. */
  79972. devicePosition: Vector3;
  79973. /**
  79974. * The device rotation in babylon space
  79975. */
  79976. deviceRotationQuaternion: Quaternion;
  79977. /**
  79978. * The scale factor of the device in babylon space
  79979. */
  79980. deviceScaleFactor: number;
  79981. /**
  79982. * (Likely devicePosition should be used instead) The device position in its room space
  79983. */
  79984. position: Vector3;
  79985. /**
  79986. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  79987. */
  79988. rotationQuaternion: Quaternion;
  79989. /**
  79990. * The type of controller (Eg. Windows mixed reality)
  79991. */
  79992. controllerType: PoseEnabledControllerType;
  79993. protected _calculatedPosition: Vector3;
  79994. private _calculatedRotation;
  79995. /**
  79996. * The raw pose from the device
  79997. */
  79998. rawPose: DevicePose;
  79999. private _trackPosition;
  80000. private _maxRotationDistFromHeadset;
  80001. private _draggedRoomRotation;
  80002. /**
  80003. * @hidden
  80004. */
  80005. _disableTrackPosition(fixedPosition: Vector3): void;
  80006. /**
  80007. * Internal, the mesh attached to the controller
  80008. * @hidden
  80009. */
  80010. _mesh: Nullable<AbstractMesh>;
  80011. private _poseControlledCamera;
  80012. private _leftHandSystemQuaternion;
  80013. /**
  80014. * Internal, matrix used to convert room space to babylon space
  80015. * @hidden
  80016. */
  80017. _deviceToWorld: Matrix;
  80018. /**
  80019. * Node to be used when casting a ray from the controller
  80020. * @hidden
  80021. */
  80022. _pointingPoseNode: Nullable<TransformNode>;
  80023. /**
  80024. * Name of the child mesh that can be used to cast a ray from the controller
  80025. */
  80026. static readonly POINTING_POSE: string;
  80027. /**
  80028. * Creates a new PoseEnabledController from a gamepad
  80029. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  80030. */
  80031. constructor(browserGamepad: any);
  80032. private _workingMatrix;
  80033. /**
  80034. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  80035. */
  80036. update(): void;
  80037. /**
  80038. * Updates only the pose device and mesh without doing any button event checking
  80039. */
  80040. protected _updatePoseAndMesh(): void;
  80041. /**
  80042. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  80043. * @param poseData raw pose fromthe device
  80044. */
  80045. updateFromDevice(poseData: DevicePose): void;
  80046. /**
  80047. * @hidden
  80048. */
  80049. _meshAttachedObservable: Observable<AbstractMesh>;
  80050. /**
  80051. * Attaches a mesh to the controller
  80052. * @param mesh the mesh to be attached
  80053. */
  80054. attachToMesh(mesh: AbstractMesh): void;
  80055. /**
  80056. * Attaches the controllers mesh to a camera
  80057. * @param camera the camera the mesh should be attached to
  80058. */
  80059. attachToPoseControlledCamera(camera: TargetCamera): void;
  80060. /**
  80061. * Disposes of the controller
  80062. */
  80063. dispose(): void;
  80064. /**
  80065. * The mesh that is attached to the controller
  80066. */
  80067. readonly mesh: Nullable<AbstractMesh>;
  80068. /**
  80069. * Gets the ray of the controller in the direction the controller is pointing
  80070. * @param length the length the resulting ray should be
  80071. * @returns a ray in the direction the controller is pointing
  80072. */
  80073. getForwardRay(length?: number): Ray;
  80074. }
  80075. }
  80076. declare module BABYLON {
  80077. /**
  80078. * Defines the WebVRController object that represents controllers tracked in 3D space
  80079. */
  80080. export abstract class WebVRController extends PoseEnabledController {
  80081. /**
  80082. * Internal, the default controller model for the controller
  80083. */
  80084. protected _defaultModel: Nullable<AbstractMesh>;
  80085. /**
  80086. * Fired when the trigger state has changed
  80087. */
  80088. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  80089. /**
  80090. * Fired when the main button state has changed
  80091. */
  80092. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80093. /**
  80094. * Fired when the secondary button state has changed
  80095. */
  80096. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80097. /**
  80098. * Fired when the pad state has changed
  80099. */
  80100. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  80101. /**
  80102. * Fired when controllers stick values have changed
  80103. */
  80104. onPadValuesChangedObservable: Observable<StickValues>;
  80105. /**
  80106. * Array of button availible on the controller
  80107. */
  80108. protected _buttons: Array<MutableGamepadButton>;
  80109. private _onButtonStateChange;
  80110. /**
  80111. * Fired when a controller button's state has changed
  80112. * @param callback the callback containing the button that was modified
  80113. */
  80114. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  80115. /**
  80116. * X and Y axis corresponding to the controllers joystick
  80117. */
  80118. pad: StickValues;
  80119. /**
  80120. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  80121. */
  80122. hand: string;
  80123. /**
  80124. * The default controller model for the controller
  80125. */
  80126. readonly defaultModel: Nullable<AbstractMesh>;
  80127. /**
  80128. * Creates a new WebVRController from a gamepad
  80129. * @param vrGamepad the gamepad that the WebVRController should be created from
  80130. */
  80131. constructor(vrGamepad: any);
  80132. /**
  80133. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  80134. */
  80135. update(): void;
  80136. /**
  80137. * Function to be called when a button is modified
  80138. */
  80139. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  80140. /**
  80141. * Loads a mesh and attaches it to the controller
  80142. * @param scene the scene the mesh should be added to
  80143. * @param meshLoaded callback for when the mesh has been loaded
  80144. */
  80145. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  80146. private _setButtonValue;
  80147. private _changes;
  80148. private _checkChanges;
  80149. /**
  80150. * Disposes of th webVRCOntroller
  80151. */
  80152. dispose(): void;
  80153. }
  80154. }
  80155. declare module BABYLON {
  80156. /**
  80157. * The HemisphericLight simulates the ambient environment light,
  80158. * so the passed direction is the light reflection direction, not the incoming direction.
  80159. */
  80160. export class HemisphericLight extends Light {
  80161. /**
  80162. * The groundColor is the light in the opposite direction to the one specified during creation.
  80163. * 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.
  80164. */
  80165. groundColor: Color3;
  80166. /**
  80167. * The light reflection direction, not the incoming direction.
  80168. */
  80169. direction: Vector3;
  80170. /**
  80171. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  80172. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  80173. * The HemisphericLight can't cast shadows.
  80174. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80175. * @param name The friendly name of the light
  80176. * @param direction The direction of the light reflection
  80177. * @param scene The scene the light belongs to
  80178. */
  80179. constructor(name: string, direction: Vector3, scene: Scene);
  80180. protected _buildUniformLayout(): void;
  80181. /**
  80182. * Returns the string "HemisphericLight".
  80183. * @return The class name
  80184. */
  80185. getClassName(): string;
  80186. /**
  80187. * Sets the HemisphericLight direction towards the passed target (Vector3).
  80188. * Returns the updated direction.
  80189. * @param target The target the direction should point to
  80190. * @return The computed direction
  80191. */
  80192. setDirectionToTarget(target: Vector3): Vector3;
  80193. /**
  80194. * Returns the shadow generator associated to the light.
  80195. * @returns Always null for hemispheric lights because it does not support shadows.
  80196. */
  80197. getShadowGenerator(): Nullable<IShadowGenerator>;
  80198. /**
  80199. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  80200. * @param effect The effect to update
  80201. * @param lightIndex The index of the light in the effect to update
  80202. * @returns The hemispheric light
  80203. */
  80204. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  80205. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  80206. /**
  80207. * Computes the world matrix of the node
  80208. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80209. * @param useWasUpdatedFlag defines a reserved property
  80210. * @returns the world matrix
  80211. */
  80212. computeWorldMatrix(): Matrix;
  80213. /**
  80214. * Returns the integer 3.
  80215. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80216. */
  80217. getTypeID(): number;
  80218. /**
  80219. * Prepares the list of defines specific to the light type.
  80220. * @param defines the list of defines
  80221. * @param lightIndex defines the index of the light for the effect
  80222. */
  80223. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80224. }
  80225. }
  80226. declare module BABYLON {
  80227. /** @hidden */
  80228. export var vrMultiviewToSingleviewPixelShader: {
  80229. name: string;
  80230. shader: string;
  80231. };
  80232. }
  80233. declare module BABYLON {
  80234. /**
  80235. * Renders to multiple views with a single draw call
  80236. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80237. */
  80238. export class MultiviewRenderTarget extends RenderTargetTexture {
  80239. /**
  80240. * Creates a multiview render target
  80241. * @param scene scene used with the render target
  80242. * @param size the size of the render target (used for each view)
  80243. */
  80244. constructor(scene: Scene, size?: number | {
  80245. width: number;
  80246. height: number;
  80247. } | {
  80248. ratio: number;
  80249. });
  80250. /**
  80251. * @hidden
  80252. * @param faceIndex the face index, if its a cube texture
  80253. */
  80254. _bindFrameBuffer(faceIndex?: number): void;
  80255. /**
  80256. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80257. * @returns the view count
  80258. */
  80259. getViewCount(): number;
  80260. }
  80261. }
  80262. declare module BABYLON {
  80263. /**
  80264. * Represents a camera frustum
  80265. */
  80266. export class Frustum {
  80267. /**
  80268. * Gets the planes representing the frustum
  80269. * @param transform matrix to be applied to the returned planes
  80270. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  80271. */
  80272. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  80273. /**
  80274. * Gets the near frustum plane transformed by the transform matrix
  80275. * @param transform transformation matrix to be applied to the resulting frustum plane
  80276. * @param frustumPlane the resuling frustum plane
  80277. */
  80278. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80279. /**
  80280. * Gets the far frustum plane transformed by the transform matrix
  80281. * @param transform transformation matrix to be applied to the resulting frustum plane
  80282. * @param frustumPlane the resuling frustum plane
  80283. */
  80284. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80285. /**
  80286. * Gets the left frustum plane transformed by the transform matrix
  80287. * @param transform transformation matrix to be applied to the resulting frustum plane
  80288. * @param frustumPlane the resuling frustum plane
  80289. */
  80290. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80291. /**
  80292. * Gets the right frustum plane transformed by the transform matrix
  80293. * @param transform transformation matrix to be applied to the resulting frustum plane
  80294. * @param frustumPlane the resuling frustum plane
  80295. */
  80296. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80297. /**
  80298. * Gets the top frustum plane transformed by the transform matrix
  80299. * @param transform transformation matrix to be applied to the resulting frustum plane
  80300. * @param frustumPlane the resuling frustum plane
  80301. */
  80302. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80303. /**
  80304. * Gets the bottom frustum plane transformed by the transform matrix
  80305. * @param transform transformation matrix to be applied to the resulting frustum plane
  80306. * @param frustumPlane the resuling frustum plane
  80307. */
  80308. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80309. /**
  80310. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  80311. * @param transform transformation matrix to be applied to the resulting frustum planes
  80312. * @param frustumPlanes the resuling frustum planes
  80313. */
  80314. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  80315. }
  80316. }
  80317. declare module BABYLON {
  80318. interface Engine {
  80319. /**
  80320. * Creates a new multiview render target
  80321. * @param width defines the width of the texture
  80322. * @param height defines the height of the texture
  80323. * @returns the created multiview texture
  80324. */
  80325. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80326. /**
  80327. * Binds a multiview framebuffer to be drawn to
  80328. * @param multiviewTexture texture to bind
  80329. */
  80330. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80331. }
  80332. interface Camera {
  80333. /**
  80334. * @hidden
  80335. * 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)
  80336. */
  80337. _useMultiviewToSingleView: boolean;
  80338. /**
  80339. * @hidden
  80340. * 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)
  80341. */
  80342. _multiviewTexture: Nullable<RenderTargetTexture>;
  80343. /**
  80344. * @hidden
  80345. * ensures the multiview texture of the camera exists and has the specified width/height
  80346. * @param width height to set on the multiview texture
  80347. * @param height width to set on the multiview texture
  80348. */
  80349. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80350. }
  80351. interface Scene {
  80352. /** @hidden */
  80353. _transformMatrixR: Matrix;
  80354. /** @hidden */
  80355. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80356. /** @hidden */
  80357. _createMultiviewUbo(): void;
  80358. /** @hidden */
  80359. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80360. /** @hidden */
  80361. _renderMultiviewToSingleView(camera: Camera): void;
  80362. }
  80363. }
  80364. declare module BABYLON {
  80365. /**
  80366. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80367. * This will not be used for webXR as it supports displaying texture arrays directly
  80368. */
  80369. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80370. /**
  80371. * Initializes a VRMultiviewToSingleview
  80372. * @param name name of the post process
  80373. * @param camera camera to be applied to
  80374. * @param scaleFactor scaling factor to the size of the output texture
  80375. */
  80376. constructor(name: string, camera: Camera, scaleFactor: number);
  80377. }
  80378. }
  80379. declare module BABYLON {
  80380. interface Engine {
  80381. /** @hidden */
  80382. _vrDisplay: any;
  80383. /** @hidden */
  80384. _vrSupported: boolean;
  80385. /** @hidden */
  80386. _oldSize: Size;
  80387. /** @hidden */
  80388. _oldHardwareScaleFactor: number;
  80389. /** @hidden */
  80390. _vrExclusivePointerMode: boolean;
  80391. /** @hidden */
  80392. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80393. /** @hidden */
  80394. _onVRDisplayPointerRestricted: () => void;
  80395. /** @hidden */
  80396. _onVRDisplayPointerUnrestricted: () => void;
  80397. /** @hidden */
  80398. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80399. /** @hidden */
  80400. _onVrDisplayDisconnect: Nullable<() => void>;
  80401. /** @hidden */
  80402. _onVrDisplayPresentChange: Nullable<() => void>;
  80403. /**
  80404. * Observable signaled when VR display mode changes
  80405. */
  80406. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80407. /**
  80408. * Observable signaled when VR request present is complete
  80409. */
  80410. onVRRequestPresentComplete: Observable<boolean>;
  80411. /**
  80412. * Observable signaled when VR request present starts
  80413. */
  80414. onVRRequestPresentStart: Observable<Engine>;
  80415. /**
  80416. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80417. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80418. */
  80419. isInVRExclusivePointerMode: boolean;
  80420. /**
  80421. * Gets a boolean indicating if a webVR device was detected
  80422. * @returns true if a webVR device was detected
  80423. */
  80424. isVRDevicePresent(): boolean;
  80425. /**
  80426. * Gets the current webVR device
  80427. * @returns the current webVR device (or null)
  80428. */
  80429. getVRDevice(): any;
  80430. /**
  80431. * Initializes a webVR display and starts listening to display change events
  80432. * The onVRDisplayChangedObservable will be notified upon these changes
  80433. * @returns A promise containing a VRDisplay and if vr is supported
  80434. */
  80435. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80436. /** @hidden */
  80437. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80438. /**
  80439. * Call this function to switch to webVR mode
  80440. * Will do nothing if webVR is not supported or if there is no webVR device
  80441. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80442. */
  80443. enableVR(): void;
  80444. /** @hidden */
  80445. _onVRFullScreenTriggered(): void;
  80446. }
  80447. }
  80448. declare module BABYLON {
  80449. /**
  80450. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80451. * IMPORTANT!! The data is right-hand data.
  80452. * @export
  80453. * @interface DevicePose
  80454. */
  80455. export interface DevicePose {
  80456. /**
  80457. * The position of the device, values in array are [x,y,z].
  80458. */
  80459. readonly position: Nullable<Float32Array>;
  80460. /**
  80461. * The linearVelocity of the device, values in array are [x,y,z].
  80462. */
  80463. readonly linearVelocity: Nullable<Float32Array>;
  80464. /**
  80465. * The linearAcceleration of the device, values in array are [x,y,z].
  80466. */
  80467. readonly linearAcceleration: Nullable<Float32Array>;
  80468. /**
  80469. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80470. */
  80471. readonly orientation: Nullable<Float32Array>;
  80472. /**
  80473. * The angularVelocity of the device, values in array are [x,y,z].
  80474. */
  80475. readonly angularVelocity: Nullable<Float32Array>;
  80476. /**
  80477. * The angularAcceleration of the device, values in array are [x,y,z].
  80478. */
  80479. readonly angularAcceleration: Nullable<Float32Array>;
  80480. }
  80481. /**
  80482. * Interface representing a pose controlled object in Babylon.
  80483. * A pose controlled object has both regular pose values as well as pose values
  80484. * from an external device such as a VR head mounted display
  80485. */
  80486. export interface PoseControlled {
  80487. /**
  80488. * The position of the object in babylon space.
  80489. */
  80490. position: Vector3;
  80491. /**
  80492. * The rotation quaternion of the object in babylon space.
  80493. */
  80494. rotationQuaternion: Quaternion;
  80495. /**
  80496. * The position of the device in babylon space.
  80497. */
  80498. devicePosition?: Vector3;
  80499. /**
  80500. * The rotation quaternion of the device in babylon space.
  80501. */
  80502. deviceRotationQuaternion: Quaternion;
  80503. /**
  80504. * The raw pose coming from the device.
  80505. */
  80506. rawPose: Nullable<DevicePose>;
  80507. /**
  80508. * The scale of the device to be used when translating from device space to babylon space.
  80509. */
  80510. deviceScaleFactor: number;
  80511. /**
  80512. * Updates the poseControlled values based on the input device pose.
  80513. * @param poseData the pose data to update the object with
  80514. */
  80515. updateFromDevice(poseData: DevicePose): void;
  80516. }
  80517. /**
  80518. * Set of options to customize the webVRCamera
  80519. */
  80520. export interface WebVROptions {
  80521. /**
  80522. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80523. */
  80524. trackPosition?: boolean;
  80525. /**
  80526. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80527. */
  80528. positionScale?: number;
  80529. /**
  80530. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80531. */
  80532. displayName?: string;
  80533. /**
  80534. * Should the native controller meshes be initialized. (default: true)
  80535. */
  80536. controllerMeshes?: boolean;
  80537. /**
  80538. * Creating a default HemiLight only on controllers. (default: true)
  80539. */
  80540. defaultLightingOnControllers?: boolean;
  80541. /**
  80542. * If you don't want to use the default VR button of the helper. (default: false)
  80543. */
  80544. useCustomVRButton?: boolean;
  80545. /**
  80546. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80547. */
  80548. customVRButton?: HTMLButtonElement;
  80549. /**
  80550. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80551. */
  80552. rayLength?: number;
  80553. /**
  80554. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80555. */
  80556. defaultHeight?: number;
  80557. /**
  80558. * If multiview should be used if availible (default: false)
  80559. */
  80560. useMultiview?: boolean;
  80561. }
  80562. /**
  80563. * This represents a WebVR camera.
  80564. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80565. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80566. */
  80567. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80568. private webVROptions;
  80569. /**
  80570. * @hidden
  80571. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80572. */
  80573. _vrDevice: any;
  80574. /**
  80575. * The rawPose of the vrDevice.
  80576. */
  80577. rawPose: Nullable<DevicePose>;
  80578. private _onVREnabled;
  80579. private _specsVersion;
  80580. private _attached;
  80581. private _frameData;
  80582. protected _descendants: Array<Node>;
  80583. private _deviceRoomPosition;
  80584. /** @hidden */
  80585. _deviceRoomRotationQuaternion: Quaternion;
  80586. private _standingMatrix;
  80587. /**
  80588. * Represents device position in babylon space.
  80589. */
  80590. devicePosition: Vector3;
  80591. /**
  80592. * Represents device rotation in babylon space.
  80593. */
  80594. deviceRotationQuaternion: Quaternion;
  80595. /**
  80596. * The scale of the device to be used when translating from device space to babylon space.
  80597. */
  80598. deviceScaleFactor: number;
  80599. private _deviceToWorld;
  80600. private _worldToDevice;
  80601. /**
  80602. * References to the webVR controllers for the vrDevice.
  80603. */
  80604. controllers: Array<WebVRController>;
  80605. /**
  80606. * Emits an event when a controller is attached.
  80607. */
  80608. onControllersAttachedObservable: Observable<WebVRController[]>;
  80609. /**
  80610. * Emits an event when a controller's mesh has been loaded;
  80611. */
  80612. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80613. /**
  80614. * Emits an event when the HMD's pose has been updated.
  80615. */
  80616. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80617. private _poseSet;
  80618. /**
  80619. * If the rig cameras be used as parent instead of this camera.
  80620. */
  80621. rigParenting: boolean;
  80622. private _lightOnControllers;
  80623. private _defaultHeight?;
  80624. /**
  80625. * Instantiates a WebVRFreeCamera.
  80626. * @param name The name of the WebVRFreeCamera
  80627. * @param position The starting anchor position for the camera
  80628. * @param scene The scene the camera belongs to
  80629. * @param webVROptions a set of customizable options for the webVRCamera
  80630. */
  80631. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80632. /**
  80633. * Gets the device distance from the ground in meters.
  80634. * @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.
  80635. */
  80636. deviceDistanceToRoomGround(): number;
  80637. /**
  80638. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80639. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80640. */
  80641. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80642. /**
  80643. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80644. * @returns A promise with a boolean set to if the standing matrix is supported.
  80645. */
  80646. useStandingMatrixAsync(): Promise<boolean>;
  80647. /**
  80648. * Disposes the camera
  80649. */
  80650. dispose(): void;
  80651. /**
  80652. * Gets a vrController by name.
  80653. * @param name The name of the controller to retreive
  80654. * @returns the controller matching the name specified or null if not found
  80655. */
  80656. getControllerByName(name: string): Nullable<WebVRController>;
  80657. private _leftController;
  80658. /**
  80659. * The controller corresponding to the users left hand.
  80660. */
  80661. readonly leftController: Nullable<WebVRController>;
  80662. private _rightController;
  80663. /**
  80664. * The controller corresponding to the users right hand.
  80665. */
  80666. readonly rightController: Nullable<WebVRController>;
  80667. /**
  80668. * Casts a ray forward from the vrCamera's gaze.
  80669. * @param length Length of the ray (default: 100)
  80670. * @returns the ray corresponding to the gaze
  80671. */
  80672. getForwardRay(length?: number): Ray;
  80673. /**
  80674. * @hidden
  80675. * Updates the camera based on device's frame data
  80676. */
  80677. _checkInputs(): void;
  80678. /**
  80679. * Updates the poseControlled values based on the input device pose.
  80680. * @param poseData Pose coming from the device
  80681. */
  80682. updateFromDevice(poseData: DevicePose): void;
  80683. private _htmlElementAttached;
  80684. private _detachIfAttached;
  80685. /**
  80686. * WebVR's attach control will start broadcasting frames to the device.
  80687. * Note that in certain browsers (chrome for example) this function must be called
  80688. * within a user-interaction callback. Example:
  80689. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80690. *
  80691. * @param element html element to attach the vrDevice to
  80692. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80693. */
  80694. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80695. /**
  80696. * Detaches the camera from the html element and disables VR
  80697. *
  80698. * @param element html element to detach from
  80699. */
  80700. detachControl(element: HTMLElement): void;
  80701. /**
  80702. * @returns the name of this class
  80703. */
  80704. getClassName(): string;
  80705. /**
  80706. * Calls resetPose on the vrDisplay
  80707. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80708. */
  80709. resetToCurrentRotation(): void;
  80710. /**
  80711. * @hidden
  80712. * Updates the rig cameras (left and right eye)
  80713. */
  80714. _updateRigCameras(): void;
  80715. private _workingVector;
  80716. private _oneVector;
  80717. private _workingMatrix;
  80718. private updateCacheCalled;
  80719. private _correctPositionIfNotTrackPosition;
  80720. /**
  80721. * @hidden
  80722. * Updates the cached values of the camera
  80723. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80724. */
  80725. _updateCache(ignoreParentClass?: boolean): void;
  80726. /**
  80727. * @hidden
  80728. * Get current device position in babylon world
  80729. */
  80730. _computeDevicePosition(): void;
  80731. /**
  80732. * Updates the current device position and rotation in the babylon world
  80733. */
  80734. update(): void;
  80735. /**
  80736. * @hidden
  80737. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80738. * @returns an identity matrix
  80739. */
  80740. _getViewMatrix(): Matrix;
  80741. private _tmpMatrix;
  80742. /**
  80743. * This function is called by the two RIG cameras.
  80744. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80745. * @hidden
  80746. */
  80747. _getWebVRViewMatrix(): Matrix;
  80748. /** @hidden */
  80749. _getWebVRProjectionMatrix(): Matrix;
  80750. private _onGamepadConnectedObserver;
  80751. private _onGamepadDisconnectedObserver;
  80752. private _updateCacheWhenTrackingDisabledObserver;
  80753. /**
  80754. * Initializes the controllers and their meshes
  80755. */
  80756. initControllers(): void;
  80757. }
  80758. }
  80759. declare module BABYLON {
  80760. /**
  80761. * Size options for a post process
  80762. */
  80763. export type PostProcessOptions = {
  80764. width: number;
  80765. height: number;
  80766. };
  80767. /**
  80768. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80769. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80770. */
  80771. export class PostProcess {
  80772. /** Name of the PostProcess. */
  80773. name: string;
  80774. /**
  80775. * Gets or sets the unique id of the post process
  80776. */
  80777. uniqueId: number;
  80778. /**
  80779. * Width of the texture to apply the post process on
  80780. */
  80781. width: number;
  80782. /**
  80783. * Height of the texture to apply the post process on
  80784. */
  80785. height: number;
  80786. /**
  80787. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80788. * @hidden
  80789. */
  80790. _outputTexture: Nullable<InternalTexture>;
  80791. /**
  80792. * Sampling mode used by the shader
  80793. * See https://doc.babylonjs.com/classes/3.1/texture
  80794. */
  80795. renderTargetSamplingMode: number;
  80796. /**
  80797. * Clear color to use when screen clearing
  80798. */
  80799. clearColor: Color4;
  80800. /**
  80801. * If the buffer needs to be cleared before applying the post process. (default: true)
  80802. * Should be set to false if shader will overwrite all previous pixels.
  80803. */
  80804. autoClear: boolean;
  80805. /**
  80806. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80807. */
  80808. alphaMode: number;
  80809. /**
  80810. * Sets the setAlphaBlendConstants of the babylon engine
  80811. */
  80812. alphaConstants: Color4;
  80813. /**
  80814. * Animations to be used for the post processing
  80815. */
  80816. animations: Animation[];
  80817. /**
  80818. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80819. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80820. */
  80821. enablePixelPerfectMode: boolean;
  80822. /**
  80823. * Force the postprocess to be applied without taking in account viewport
  80824. */
  80825. forceFullscreenViewport: boolean;
  80826. /**
  80827. * List of inspectable custom properties (used by the Inspector)
  80828. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80829. */
  80830. inspectableCustomProperties: IInspectable[];
  80831. /**
  80832. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80833. *
  80834. * | Value | Type | Description |
  80835. * | ----- | ----------------------------------- | ----------- |
  80836. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80837. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80838. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80839. *
  80840. */
  80841. scaleMode: number;
  80842. /**
  80843. * Force textures to be a power of two (default: false)
  80844. */
  80845. alwaysForcePOT: boolean;
  80846. private _samples;
  80847. /**
  80848. * Number of sample textures (default: 1)
  80849. */
  80850. samples: number;
  80851. /**
  80852. * Modify the scale of the post process to be the same as the viewport (default: false)
  80853. */
  80854. adaptScaleToCurrentViewport: boolean;
  80855. private _camera;
  80856. private _scene;
  80857. private _engine;
  80858. private _options;
  80859. private _reusable;
  80860. private _textureType;
  80861. /**
  80862. * Smart array of input and output textures for the post process.
  80863. * @hidden
  80864. */
  80865. _textures: SmartArray<InternalTexture>;
  80866. /**
  80867. * The index in _textures that corresponds to the output texture.
  80868. * @hidden
  80869. */
  80870. _currentRenderTextureInd: number;
  80871. private _effect;
  80872. private _samplers;
  80873. private _fragmentUrl;
  80874. private _vertexUrl;
  80875. private _parameters;
  80876. private _scaleRatio;
  80877. protected _indexParameters: any;
  80878. private _shareOutputWithPostProcess;
  80879. private _texelSize;
  80880. private _forcedOutputTexture;
  80881. /**
  80882. * Returns the fragment url or shader name used in the post process.
  80883. * @returns the fragment url or name in the shader store.
  80884. */
  80885. getEffectName(): string;
  80886. /**
  80887. * An event triggered when the postprocess is activated.
  80888. */
  80889. onActivateObservable: Observable<Camera>;
  80890. private _onActivateObserver;
  80891. /**
  80892. * A function that is added to the onActivateObservable
  80893. */
  80894. onActivate: Nullable<(camera: Camera) => void>;
  80895. /**
  80896. * An event triggered when the postprocess changes its size.
  80897. */
  80898. onSizeChangedObservable: Observable<PostProcess>;
  80899. private _onSizeChangedObserver;
  80900. /**
  80901. * A function that is added to the onSizeChangedObservable
  80902. */
  80903. onSizeChanged: (postProcess: PostProcess) => void;
  80904. /**
  80905. * An event triggered when the postprocess applies its effect.
  80906. */
  80907. onApplyObservable: Observable<Effect>;
  80908. private _onApplyObserver;
  80909. /**
  80910. * A function that is added to the onApplyObservable
  80911. */
  80912. onApply: (effect: Effect) => void;
  80913. /**
  80914. * An event triggered before rendering the postprocess
  80915. */
  80916. onBeforeRenderObservable: Observable<Effect>;
  80917. private _onBeforeRenderObserver;
  80918. /**
  80919. * A function that is added to the onBeforeRenderObservable
  80920. */
  80921. onBeforeRender: (effect: Effect) => void;
  80922. /**
  80923. * An event triggered after rendering the postprocess
  80924. */
  80925. onAfterRenderObservable: Observable<Effect>;
  80926. private _onAfterRenderObserver;
  80927. /**
  80928. * A function that is added to the onAfterRenderObservable
  80929. */
  80930. onAfterRender: (efect: Effect) => void;
  80931. /**
  80932. * 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
  80933. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  80934. */
  80935. inputTexture: InternalTexture;
  80936. /**
  80937. * Gets the camera which post process is applied to.
  80938. * @returns The camera the post process is applied to.
  80939. */
  80940. getCamera(): Camera;
  80941. /**
  80942. * Gets the texel size of the postprocess.
  80943. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  80944. */
  80945. readonly texelSize: Vector2;
  80946. /**
  80947. * Creates a new instance PostProcess
  80948. * @param name The name of the PostProcess.
  80949. * @param fragmentUrl The url of the fragment shader to be used.
  80950. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  80951. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  80952. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80953. * @param camera The camera to apply the render pass to.
  80954. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80955. * @param engine The engine which the post process will be applied. (default: current engine)
  80956. * @param reusable If the post process can be reused on the same frame. (default: false)
  80957. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  80958. * @param textureType Type of textures used when performing the post process. (default: 0)
  80959. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  80960. * @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
  80961. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  80962. */
  80963. constructor(
  80964. /** Name of the PostProcess. */
  80965. 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);
  80966. /**
  80967. * Gets a string idenfifying the name of the class
  80968. * @returns "PostProcess" string
  80969. */
  80970. getClassName(): string;
  80971. /**
  80972. * Gets the engine which this post process belongs to.
  80973. * @returns The engine the post process was enabled with.
  80974. */
  80975. getEngine(): Engine;
  80976. /**
  80977. * The effect that is created when initializing the post process.
  80978. * @returns The created effect corresponding the the postprocess.
  80979. */
  80980. getEffect(): Effect;
  80981. /**
  80982. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  80983. * @param postProcess The post process to share the output with.
  80984. * @returns This post process.
  80985. */
  80986. shareOutputWith(postProcess: PostProcess): PostProcess;
  80987. /**
  80988. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  80989. * This should be called if the post process that shares output with this post process is disabled/disposed.
  80990. */
  80991. useOwnOutput(): void;
  80992. /**
  80993. * Updates the effect with the current post process compile time values and recompiles the shader.
  80994. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80995. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80996. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80997. * @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
  80998. * @param onCompiled Called when the shader has been compiled.
  80999. * @param onError Called if there is an error when compiling a shader.
  81000. */
  81001. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81002. /**
  81003. * The post process is reusable if it can be used multiple times within one frame.
  81004. * @returns If the post process is reusable
  81005. */
  81006. isReusable(): boolean;
  81007. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  81008. markTextureDirty(): void;
  81009. /**
  81010. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  81011. * 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.
  81012. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  81013. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  81014. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  81015. * @returns The target texture that was bound to be written to.
  81016. */
  81017. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  81018. /**
  81019. * If the post process is supported.
  81020. */
  81021. readonly isSupported: boolean;
  81022. /**
  81023. * The aspect ratio of the output texture.
  81024. */
  81025. readonly aspectRatio: number;
  81026. /**
  81027. * Get a value indicating if the post-process is ready to be used
  81028. * @returns true if the post-process is ready (shader is compiled)
  81029. */
  81030. isReady(): boolean;
  81031. /**
  81032. * Binds all textures and uniforms to the shader, this will be run on every pass.
  81033. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  81034. */
  81035. apply(): Nullable<Effect>;
  81036. private _disposeTextures;
  81037. /**
  81038. * Disposes the post process.
  81039. * @param camera The camera to dispose the post process on.
  81040. */
  81041. dispose(camera?: Camera): void;
  81042. }
  81043. }
  81044. declare module BABYLON {
  81045. /** @hidden */
  81046. export var kernelBlurVaryingDeclaration: {
  81047. name: string;
  81048. shader: string;
  81049. };
  81050. }
  81051. declare module BABYLON {
  81052. /** @hidden */
  81053. export var kernelBlurFragment: {
  81054. name: string;
  81055. shader: string;
  81056. };
  81057. }
  81058. declare module BABYLON {
  81059. /** @hidden */
  81060. export var kernelBlurFragment2: {
  81061. name: string;
  81062. shader: string;
  81063. };
  81064. }
  81065. declare module BABYLON {
  81066. /** @hidden */
  81067. export var kernelBlurPixelShader: {
  81068. name: string;
  81069. shader: string;
  81070. };
  81071. }
  81072. declare module BABYLON {
  81073. /** @hidden */
  81074. export var kernelBlurVertex: {
  81075. name: string;
  81076. shader: string;
  81077. };
  81078. }
  81079. declare module BABYLON {
  81080. /** @hidden */
  81081. export var kernelBlurVertexShader: {
  81082. name: string;
  81083. shader: string;
  81084. };
  81085. }
  81086. declare module BABYLON {
  81087. /**
  81088. * The Blur Post Process which blurs an image based on a kernel and direction.
  81089. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  81090. */
  81091. export class BlurPostProcess extends PostProcess {
  81092. /** The direction in which to blur the image. */
  81093. direction: Vector2;
  81094. private blockCompilation;
  81095. protected _kernel: number;
  81096. protected _idealKernel: number;
  81097. protected _packedFloat: boolean;
  81098. private _staticDefines;
  81099. /**
  81100. * Sets the length in pixels of the blur sample region
  81101. */
  81102. /**
  81103. * Gets the length in pixels of the blur sample region
  81104. */
  81105. kernel: number;
  81106. /**
  81107. * Sets wether or not the blur needs to unpack/repack floats
  81108. */
  81109. /**
  81110. * Gets wether or not the blur is unpacking/repacking floats
  81111. */
  81112. packedFloat: boolean;
  81113. /**
  81114. * Creates a new instance BlurPostProcess
  81115. * @param name The name of the effect.
  81116. * @param direction The direction in which to blur the image.
  81117. * @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.
  81118. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81119. * @param camera The camera to apply the render pass to.
  81120. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81121. * @param engine The engine which the post process will be applied. (default: current engine)
  81122. * @param reusable If the post process can be reused on the same frame. (default: false)
  81123. * @param textureType Type of textures used when performing the post process. (default: 0)
  81124. * @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)
  81125. */
  81126. constructor(name: string,
  81127. /** The direction in which to blur the image. */
  81128. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  81129. /**
  81130. * Updates the effect with the current post process compile time values and recompiles the shader.
  81131. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81132. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81133. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81134. * @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
  81135. * @param onCompiled Called when the shader has been compiled.
  81136. * @param onError Called if there is an error when compiling a shader.
  81137. */
  81138. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81139. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81140. /**
  81141. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  81142. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  81143. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  81144. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  81145. * The gaps between physical kernels are compensated for in the weighting of the samples
  81146. * @param idealKernel Ideal blur kernel.
  81147. * @return Nearest best kernel.
  81148. */
  81149. protected _nearestBestKernel(idealKernel: number): number;
  81150. /**
  81151. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  81152. * @param x The point on the Gaussian distribution to sample.
  81153. * @return the value of the Gaussian function at x.
  81154. */
  81155. protected _gaussianWeight(x: number): number;
  81156. /**
  81157. * Generates a string that can be used as a floating point number in GLSL.
  81158. * @param x Value to print.
  81159. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  81160. * @return GLSL float string.
  81161. */
  81162. protected _glslFloat(x: number, decimalFigures?: number): string;
  81163. }
  81164. }
  81165. declare module BABYLON {
  81166. /**
  81167. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81168. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81169. * You can then easily use it as a reflectionTexture on a flat surface.
  81170. * In case the surface is not a plane, please consider relying on reflection probes.
  81171. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81172. */
  81173. export class MirrorTexture extends RenderTargetTexture {
  81174. private scene;
  81175. /**
  81176. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  81177. * 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.
  81178. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81179. */
  81180. mirrorPlane: Plane;
  81181. /**
  81182. * Define the blur ratio used to blur the reflection if needed.
  81183. */
  81184. blurRatio: number;
  81185. /**
  81186. * Define the adaptive blur kernel used to blur the reflection if needed.
  81187. * This will autocompute the closest best match for the `blurKernel`
  81188. */
  81189. adaptiveBlurKernel: number;
  81190. /**
  81191. * Define the blur kernel used to blur the reflection if needed.
  81192. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81193. */
  81194. blurKernel: number;
  81195. /**
  81196. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  81197. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81198. */
  81199. blurKernelX: number;
  81200. /**
  81201. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  81202. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81203. */
  81204. blurKernelY: number;
  81205. private _autoComputeBlurKernel;
  81206. protected _onRatioRescale(): void;
  81207. private _updateGammaSpace;
  81208. private _imageProcessingConfigChangeObserver;
  81209. private _transformMatrix;
  81210. private _mirrorMatrix;
  81211. private _savedViewMatrix;
  81212. private _blurX;
  81213. private _blurY;
  81214. private _adaptiveBlurKernel;
  81215. private _blurKernelX;
  81216. private _blurKernelY;
  81217. private _blurRatio;
  81218. /**
  81219. * Instantiates a Mirror Texture.
  81220. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81221. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81222. * You can then easily use it as a reflectionTexture on a flat surface.
  81223. * In case the surface is not a plane, please consider relying on reflection probes.
  81224. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81225. * @param name
  81226. * @param size
  81227. * @param scene
  81228. * @param generateMipMaps
  81229. * @param type
  81230. * @param samplingMode
  81231. * @param generateDepthBuffer
  81232. */
  81233. constructor(name: string, size: number | {
  81234. width: number;
  81235. height: number;
  81236. } | {
  81237. ratio: number;
  81238. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81239. private _preparePostProcesses;
  81240. /**
  81241. * Clone the mirror texture.
  81242. * @returns the cloned texture
  81243. */
  81244. clone(): MirrorTexture;
  81245. /**
  81246. * Serialize the texture to a JSON representation you could use in Parse later on
  81247. * @returns the serialized JSON representation
  81248. */
  81249. serialize(): any;
  81250. /**
  81251. * Dispose the texture and release its associated resources.
  81252. */
  81253. dispose(): void;
  81254. }
  81255. }
  81256. declare module BABYLON {
  81257. /**
  81258. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81259. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81260. */
  81261. export class Texture extends BaseTexture {
  81262. /**
  81263. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  81264. */
  81265. static SerializeBuffers: boolean;
  81266. /** @hidden */
  81267. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81268. /** @hidden */
  81269. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81270. /** @hidden */
  81271. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81272. /** nearest is mag = nearest and min = nearest and mip = linear */
  81273. static readonly NEAREST_SAMPLINGMODE: number;
  81274. /** nearest is mag = nearest and min = nearest and mip = linear */
  81275. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81276. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81277. static readonly BILINEAR_SAMPLINGMODE: number;
  81278. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81279. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81280. /** Trilinear is mag = linear and min = linear and mip = linear */
  81281. static readonly TRILINEAR_SAMPLINGMODE: number;
  81282. /** Trilinear is mag = linear and min = linear and mip = linear */
  81283. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81284. /** mag = nearest and min = nearest and mip = nearest */
  81285. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81286. /** mag = nearest and min = linear and mip = nearest */
  81287. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81288. /** mag = nearest and min = linear and mip = linear */
  81289. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81290. /** mag = nearest and min = linear and mip = none */
  81291. static readonly NEAREST_LINEAR: number;
  81292. /** mag = nearest and min = nearest and mip = none */
  81293. static readonly NEAREST_NEAREST: number;
  81294. /** mag = linear and min = nearest and mip = nearest */
  81295. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81296. /** mag = linear and min = nearest and mip = linear */
  81297. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81298. /** mag = linear and min = linear and mip = none */
  81299. static readonly LINEAR_LINEAR: number;
  81300. /** mag = linear and min = nearest and mip = none */
  81301. static readonly LINEAR_NEAREST: number;
  81302. /** Explicit coordinates mode */
  81303. static readonly EXPLICIT_MODE: number;
  81304. /** Spherical coordinates mode */
  81305. static readonly SPHERICAL_MODE: number;
  81306. /** Planar coordinates mode */
  81307. static readonly PLANAR_MODE: number;
  81308. /** Cubic coordinates mode */
  81309. static readonly CUBIC_MODE: number;
  81310. /** Projection coordinates mode */
  81311. static readonly PROJECTION_MODE: number;
  81312. /** Inverse Cubic coordinates mode */
  81313. static readonly SKYBOX_MODE: number;
  81314. /** Inverse Cubic coordinates mode */
  81315. static readonly INVCUBIC_MODE: number;
  81316. /** Equirectangular coordinates mode */
  81317. static readonly EQUIRECTANGULAR_MODE: number;
  81318. /** Equirectangular Fixed coordinates mode */
  81319. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81320. /** Equirectangular Fixed Mirrored coordinates mode */
  81321. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81322. /** Texture is not repeating outside of 0..1 UVs */
  81323. static readonly CLAMP_ADDRESSMODE: number;
  81324. /** Texture is repeating outside of 0..1 UVs */
  81325. static readonly WRAP_ADDRESSMODE: number;
  81326. /** Texture is repeating and mirrored */
  81327. static readonly MIRROR_ADDRESSMODE: number;
  81328. /**
  81329. * 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
  81330. */
  81331. static UseSerializedUrlIfAny: boolean;
  81332. /**
  81333. * Define the url of the texture.
  81334. */
  81335. url: Nullable<string>;
  81336. /**
  81337. * Define an offset on the texture to offset the u coordinates of the UVs
  81338. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81339. */
  81340. uOffset: number;
  81341. /**
  81342. * Define an offset on the texture to offset the v coordinates of the UVs
  81343. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81344. */
  81345. vOffset: number;
  81346. /**
  81347. * Define an offset on the texture to scale the u coordinates of the UVs
  81348. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81349. */
  81350. uScale: number;
  81351. /**
  81352. * Define an offset on the texture to scale the v coordinates of the UVs
  81353. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81354. */
  81355. vScale: number;
  81356. /**
  81357. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81358. * @see http://doc.babylonjs.com/how_to/more_materials
  81359. */
  81360. uAng: number;
  81361. /**
  81362. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81363. * @see http://doc.babylonjs.com/how_to/more_materials
  81364. */
  81365. vAng: number;
  81366. /**
  81367. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81368. * @see http://doc.babylonjs.com/how_to/more_materials
  81369. */
  81370. wAng: number;
  81371. /**
  81372. * Defines the center of rotation (U)
  81373. */
  81374. uRotationCenter: number;
  81375. /**
  81376. * Defines the center of rotation (V)
  81377. */
  81378. vRotationCenter: number;
  81379. /**
  81380. * Defines the center of rotation (W)
  81381. */
  81382. wRotationCenter: number;
  81383. /**
  81384. * Are mip maps generated for this texture or not.
  81385. */
  81386. readonly noMipmap: boolean;
  81387. /**
  81388. * List of inspectable custom properties (used by the Inspector)
  81389. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81390. */
  81391. inspectableCustomProperties: Nullable<IInspectable[]>;
  81392. private _noMipmap;
  81393. /** @hidden */
  81394. _invertY: boolean;
  81395. private _rowGenerationMatrix;
  81396. private _cachedTextureMatrix;
  81397. private _projectionModeMatrix;
  81398. private _t0;
  81399. private _t1;
  81400. private _t2;
  81401. private _cachedUOffset;
  81402. private _cachedVOffset;
  81403. private _cachedUScale;
  81404. private _cachedVScale;
  81405. private _cachedUAng;
  81406. private _cachedVAng;
  81407. private _cachedWAng;
  81408. private _cachedProjectionMatrixId;
  81409. private _cachedCoordinatesMode;
  81410. /** @hidden */
  81411. protected _initialSamplingMode: number;
  81412. /** @hidden */
  81413. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  81414. private _deleteBuffer;
  81415. protected _format: Nullable<number>;
  81416. private _delayedOnLoad;
  81417. private _delayedOnError;
  81418. /**
  81419. * Observable triggered once the texture has been loaded.
  81420. */
  81421. onLoadObservable: Observable<Texture>;
  81422. protected _isBlocking: boolean;
  81423. /**
  81424. * Is the texture preventing material to render while loading.
  81425. * If false, a default texture will be used instead of the loading one during the preparation step.
  81426. */
  81427. isBlocking: boolean;
  81428. /**
  81429. * Get the current sampling mode associated with the texture.
  81430. */
  81431. readonly samplingMode: number;
  81432. /**
  81433. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81434. */
  81435. readonly invertY: boolean;
  81436. /**
  81437. * Instantiates a new texture.
  81438. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81439. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81440. * @param url define the url of the picture to load as a texture
  81441. * @param scene define the scene or engine the texture will belong to
  81442. * @param noMipmap define if the texture will require mip maps or not
  81443. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81444. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81445. * @param onLoad define a callback triggered when the texture has been loaded
  81446. * @param onError define a callback triggered when an error occurred during the loading session
  81447. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81448. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81449. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81450. */
  81451. 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 | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  81452. /**
  81453. * Update the url (and optional buffer) of this texture if url was null during construction.
  81454. * @param url the url of the texture
  81455. * @param buffer the buffer of the texture (defaults to null)
  81456. * @param onLoad callback called when the texture is loaded (defaults to null)
  81457. */
  81458. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81459. /**
  81460. * Finish the loading sequence of a texture flagged as delayed load.
  81461. * @hidden
  81462. */
  81463. delayLoad(): void;
  81464. private _prepareRowForTextureGeneration;
  81465. /**
  81466. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81467. * @returns the transform matrix of the texture.
  81468. */
  81469. getTextureMatrix(): Matrix;
  81470. /**
  81471. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81472. * @returns The reflection texture transform
  81473. */
  81474. getReflectionTextureMatrix(): Matrix;
  81475. /**
  81476. * Clones the texture.
  81477. * @returns the cloned texture
  81478. */
  81479. clone(): Texture;
  81480. /**
  81481. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81482. * @returns The JSON representation of the texture
  81483. */
  81484. serialize(): any;
  81485. /**
  81486. * Get the current class name of the texture useful for serialization or dynamic coding.
  81487. * @returns "Texture"
  81488. */
  81489. getClassName(): string;
  81490. /**
  81491. * Dispose the texture and release its associated resources.
  81492. */
  81493. dispose(): void;
  81494. /**
  81495. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81496. * @param parsedTexture Define the JSON representation of the texture
  81497. * @param scene Define the scene the parsed texture should be instantiated in
  81498. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81499. * @returns The parsed texture if successful
  81500. */
  81501. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81502. /**
  81503. * Creates a texture from its base 64 representation.
  81504. * @param data Define the base64 payload without the data: prefix
  81505. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81506. * @param scene Define the scene the texture should belong to
  81507. * @param noMipmap Forces the texture to not create mip map information if true
  81508. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81509. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81510. * @param onLoad define a callback triggered when the texture has been loaded
  81511. * @param onError define a callback triggered when an error occurred during the loading session
  81512. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81513. * @returns the created texture
  81514. */
  81515. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81516. /**
  81517. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81518. * @param data Define the base64 payload without the data: prefix
  81519. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81520. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81521. * @param scene Define the scene the texture should belong to
  81522. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81523. * @param noMipmap Forces the texture to not create mip map information if true
  81524. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81525. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81526. * @param onLoad define a callback triggered when the texture has been loaded
  81527. * @param onError define a callback triggered when an error occurred during the loading session
  81528. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81529. * @returns the created texture
  81530. */
  81531. 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;
  81532. }
  81533. }
  81534. declare module BABYLON {
  81535. /**
  81536. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81537. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81538. */
  81539. export class PostProcessManager {
  81540. private _scene;
  81541. private _indexBuffer;
  81542. private _vertexBuffers;
  81543. /**
  81544. * Creates a new instance PostProcess
  81545. * @param scene The scene that the post process is associated with.
  81546. */
  81547. constructor(scene: Scene);
  81548. private _prepareBuffers;
  81549. private _buildIndexBuffer;
  81550. /**
  81551. * Rebuilds the vertex buffers of the manager.
  81552. * @hidden
  81553. */
  81554. _rebuild(): void;
  81555. /**
  81556. * Prepares a frame to be run through a post process.
  81557. * @param sourceTexture The input texture to the post procesess. (default: null)
  81558. * @param postProcesses An array of post processes to be run. (default: null)
  81559. * @returns True if the post processes were able to be run.
  81560. * @hidden
  81561. */
  81562. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81563. /**
  81564. * Manually render a set of post processes to a texture.
  81565. * @param postProcesses An array of post processes to be run.
  81566. * @param targetTexture The target texture to render to.
  81567. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81568. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81569. * @param lodLevel defines which lod of the texture to render to
  81570. */
  81571. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81572. /**
  81573. * Finalize the result of the output of the postprocesses.
  81574. * @param doNotPresent If true the result will not be displayed to the screen.
  81575. * @param targetTexture The target texture to render to.
  81576. * @param faceIndex The index of the face to bind the target texture to.
  81577. * @param postProcesses The array of post processes to render.
  81578. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81579. * @hidden
  81580. */
  81581. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81582. /**
  81583. * Disposes of the post process manager.
  81584. */
  81585. dispose(): void;
  81586. }
  81587. }
  81588. declare module BABYLON {
  81589. /** Interface used by value gradients (color, factor, ...) */
  81590. export interface IValueGradient {
  81591. /**
  81592. * Gets or sets the gradient value (between 0 and 1)
  81593. */
  81594. gradient: number;
  81595. }
  81596. /** Class used to store color4 gradient */
  81597. export class ColorGradient implements IValueGradient {
  81598. /**
  81599. * Gets or sets the gradient value (between 0 and 1)
  81600. */
  81601. gradient: number;
  81602. /**
  81603. * Gets or sets first associated color
  81604. */
  81605. color1: Color4;
  81606. /**
  81607. * Gets or sets second associated color
  81608. */
  81609. color2?: Color4;
  81610. /**
  81611. * Will get a color picked randomly between color1 and color2.
  81612. * If color2 is undefined then color1 will be used
  81613. * @param result defines the target Color4 to store the result in
  81614. */
  81615. getColorToRef(result: Color4): void;
  81616. }
  81617. /** Class used to store color 3 gradient */
  81618. export class Color3Gradient implements IValueGradient {
  81619. /**
  81620. * Gets or sets the gradient value (between 0 and 1)
  81621. */
  81622. gradient: number;
  81623. /**
  81624. * Gets or sets the associated color
  81625. */
  81626. color: Color3;
  81627. }
  81628. /** Class used to store factor gradient */
  81629. export class FactorGradient implements IValueGradient {
  81630. /**
  81631. * Gets or sets the gradient value (between 0 and 1)
  81632. */
  81633. gradient: number;
  81634. /**
  81635. * Gets or sets first associated factor
  81636. */
  81637. factor1: number;
  81638. /**
  81639. * Gets or sets second associated factor
  81640. */
  81641. factor2?: number;
  81642. /**
  81643. * Will get a number picked randomly between factor1 and factor2.
  81644. * If factor2 is undefined then factor1 will be used
  81645. * @returns the picked number
  81646. */
  81647. getFactor(): number;
  81648. }
  81649. /**
  81650. * Helper used to simplify some generic gradient tasks
  81651. */
  81652. export class GradientHelper {
  81653. /**
  81654. * Gets the current gradient from an array of IValueGradient
  81655. * @param ratio defines the current ratio to get
  81656. * @param gradients defines the array of IValueGradient
  81657. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  81658. */
  81659. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  81660. }
  81661. }
  81662. declare module BABYLON {
  81663. /**
  81664. * A class extending Texture allowing drawing on a texture
  81665. * @see http://doc.babylonjs.com/how_to/dynamictexture
  81666. */
  81667. export class DynamicTexture extends Texture {
  81668. private _generateMipMaps;
  81669. private _canvas;
  81670. private _context;
  81671. private _engine;
  81672. /**
  81673. * Creates a DynamicTexture
  81674. * @param name defines the name of the texture
  81675. * @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
  81676. * @param scene defines the scene where you want the texture
  81677. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  81678. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  81679. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  81680. */
  81681. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  81682. /**
  81683. * Get the current class name of the texture useful for serialization or dynamic coding.
  81684. * @returns "DynamicTexture"
  81685. */
  81686. getClassName(): string;
  81687. /**
  81688. * Gets the current state of canRescale
  81689. */
  81690. readonly canRescale: boolean;
  81691. private _recreate;
  81692. /**
  81693. * Scales the texture
  81694. * @param ratio the scale factor to apply to both width and height
  81695. */
  81696. scale(ratio: number): void;
  81697. /**
  81698. * Resizes the texture
  81699. * @param width the new width
  81700. * @param height the new height
  81701. */
  81702. scaleTo(width: number, height: number): void;
  81703. /**
  81704. * Gets the context of the canvas used by the texture
  81705. * @returns the canvas context of the dynamic texture
  81706. */
  81707. getContext(): CanvasRenderingContext2D;
  81708. /**
  81709. * Clears the texture
  81710. */
  81711. clear(): void;
  81712. /**
  81713. * Updates the texture
  81714. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  81715. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  81716. */
  81717. update(invertY?: boolean, premulAlpha?: boolean): void;
  81718. /**
  81719. * Draws text onto the texture
  81720. * @param text defines the text to be drawn
  81721. * @param x defines the placement of the text from the left
  81722. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  81723. * @param font defines the font to be used with font-style, font-size, font-name
  81724. * @param color defines the color used for the text
  81725. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  81726. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  81727. * @param update defines whether texture is immediately update (default is true)
  81728. */
  81729. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  81730. /**
  81731. * Clones the texture
  81732. * @returns the clone of the texture.
  81733. */
  81734. clone(): DynamicTexture;
  81735. /**
  81736. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  81737. * @returns a serialized dynamic texture object
  81738. */
  81739. serialize(): any;
  81740. /** @hidden */
  81741. _rebuild(): void;
  81742. }
  81743. }
  81744. declare module BABYLON {
  81745. interface AbstractScene {
  81746. /**
  81747. * The list of procedural textures added to the scene
  81748. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81749. */
  81750. proceduralTextures: Array<ProceduralTexture>;
  81751. }
  81752. /**
  81753. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81754. * in a given scene.
  81755. */
  81756. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81757. /**
  81758. * The component name helpfull to identify the component in the list of scene components.
  81759. */
  81760. readonly name: string;
  81761. /**
  81762. * The scene the component belongs to.
  81763. */
  81764. scene: Scene;
  81765. /**
  81766. * Creates a new instance of the component for the given scene
  81767. * @param scene Defines the scene to register the component in
  81768. */
  81769. constructor(scene: Scene);
  81770. /**
  81771. * Registers the component in a given scene
  81772. */
  81773. register(): void;
  81774. /**
  81775. * Rebuilds the elements related to this component in case of
  81776. * context lost for instance.
  81777. */
  81778. rebuild(): void;
  81779. /**
  81780. * Disposes the component and the associated ressources.
  81781. */
  81782. dispose(): void;
  81783. private _beforeClear;
  81784. }
  81785. }
  81786. declare module BABYLON {
  81787. interface Engine {
  81788. /**
  81789. * Creates a new render target cube texture
  81790. * @param size defines the size of the texture
  81791. * @param options defines the options used to create the texture
  81792. * @returns a new render target cube texture stored in an InternalTexture
  81793. */
  81794. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81795. }
  81796. }
  81797. declare module BABYLON {
  81798. /** @hidden */
  81799. export var proceduralVertexShader: {
  81800. name: string;
  81801. shader: string;
  81802. };
  81803. }
  81804. declare module BABYLON {
  81805. /**
  81806. * 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.
  81807. * This is the base class of any Procedural texture and contains most of the shareable code.
  81808. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81809. */
  81810. export class ProceduralTexture extends Texture {
  81811. isCube: boolean;
  81812. /**
  81813. * Define if the texture is enabled or not (disabled texture will not render)
  81814. */
  81815. isEnabled: boolean;
  81816. /**
  81817. * Define if the texture must be cleared before rendering (default is true)
  81818. */
  81819. autoClear: boolean;
  81820. /**
  81821. * Callback called when the texture is generated
  81822. */
  81823. onGenerated: () => void;
  81824. /**
  81825. * Event raised when the texture is generated
  81826. */
  81827. onGeneratedObservable: Observable<ProceduralTexture>;
  81828. /** @hidden */
  81829. _generateMipMaps: boolean;
  81830. /** @hidden **/
  81831. _effect: Effect;
  81832. /** @hidden */
  81833. _textures: {
  81834. [key: string]: Texture;
  81835. };
  81836. private _size;
  81837. private _currentRefreshId;
  81838. private _refreshRate;
  81839. private _vertexBuffers;
  81840. private _indexBuffer;
  81841. private _uniforms;
  81842. private _samplers;
  81843. private _fragment;
  81844. private _floats;
  81845. private _ints;
  81846. private _floatsArrays;
  81847. private _colors3;
  81848. private _colors4;
  81849. private _vectors2;
  81850. private _vectors3;
  81851. private _matrices;
  81852. private _fallbackTexture;
  81853. private _fallbackTextureUsed;
  81854. private _engine;
  81855. private _cachedDefines;
  81856. private _contentUpdateId;
  81857. private _contentData;
  81858. /**
  81859. * Instantiates a new procedural texture.
  81860. * 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.
  81861. * This is the base class of any Procedural texture and contains most of the shareable code.
  81862. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81863. * @param name Define the name of the texture
  81864. * @param size Define the size of the texture to create
  81865. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81866. * @param scene Define the scene the texture belongs to
  81867. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81868. * @param generateMipMaps Define if the texture should creates mip maps or not
  81869. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81870. */
  81871. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81872. /**
  81873. * The effect that is created when initializing the post process.
  81874. * @returns The created effect corresponding the the postprocess.
  81875. */
  81876. getEffect(): Effect;
  81877. /**
  81878. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81879. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81880. */
  81881. getContent(): Nullable<ArrayBufferView>;
  81882. private _createIndexBuffer;
  81883. /** @hidden */
  81884. _rebuild(): void;
  81885. /**
  81886. * Resets the texture in order to recreate its associated resources.
  81887. * This can be called in case of context loss
  81888. */
  81889. reset(): void;
  81890. protected _getDefines(): string;
  81891. /**
  81892. * Is the texture ready to be used ? (rendered at least once)
  81893. * @returns true if ready, otherwise, false.
  81894. */
  81895. isReady(): boolean;
  81896. /**
  81897. * Resets the refresh counter of the texture and start bak from scratch.
  81898. * Could be useful to regenerate the texture if it is setup to render only once.
  81899. */
  81900. resetRefreshCounter(): void;
  81901. /**
  81902. * Set the fragment shader to use in order to render the texture.
  81903. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81904. */
  81905. setFragment(fragment: any): void;
  81906. /**
  81907. * Define the refresh rate of the texture or the rendering frequency.
  81908. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81909. */
  81910. refreshRate: number;
  81911. /** @hidden */
  81912. _shouldRender(): boolean;
  81913. /**
  81914. * Get the size the texture is rendering at.
  81915. * @returns the size (texture is always squared)
  81916. */
  81917. getRenderSize(): number;
  81918. /**
  81919. * Resize the texture to new value.
  81920. * @param size Define the new size the texture should have
  81921. * @param generateMipMaps Define whether the new texture should create mip maps
  81922. */
  81923. resize(size: number, generateMipMaps: boolean): void;
  81924. private _checkUniform;
  81925. /**
  81926. * Set a texture in the shader program used to render.
  81927. * @param name Define the name of the uniform samplers as defined in the shader
  81928. * @param texture Define the texture to bind to this sampler
  81929. * @return the texture itself allowing "fluent" like uniform updates
  81930. */
  81931. setTexture(name: string, texture: Texture): ProceduralTexture;
  81932. /**
  81933. * Set a float in the shader.
  81934. * @param name Define the name of the uniform as defined in the shader
  81935. * @param value Define the value to give to the uniform
  81936. * @return the texture itself allowing "fluent" like uniform updates
  81937. */
  81938. setFloat(name: string, value: number): ProceduralTexture;
  81939. /**
  81940. * Set a int in the shader.
  81941. * @param name Define the name of the uniform as defined in the shader
  81942. * @param value Define the value to give to the uniform
  81943. * @return the texture itself allowing "fluent" like uniform updates
  81944. */
  81945. setInt(name: string, value: number): ProceduralTexture;
  81946. /**
  81947. * Set an array of floats in the shader.
  81948. * @param name Define the name of the uniform as defined in the shader
  81949. * @param value Define the value to give to the uniform
  81950. * @return the texture itself allowing "fluent" like uniform updates
  81951. */
  81952. setFloats(name: string, value: number[]): ProceduralTexture;
  81953. /**
  81954. * Set a vec3 in the shader from a Color3.
  81955. * @param name Define the name of the uniform as defined in the shader
  81956. * @param value Define the value to give to the uniform
  81957. * @return the texture itself allowing "fluent" like uniform updates
  81958. */
  81959. setColor3(name: string, value: Color3): ProceduralTexture;
  81960. /**
  81961. * Set a vec4 in the shader from a Color4.
  81962. * @param name Define the name of the uniform as defined in the shader
  81963. * @param value Define the value to give to the uniform
  81964. * @return the texture itself allowing "fluent" like uniform updates
  81965. */
  81966. setColor4(name: string, value: Color4): ProceduralTexture;
  81967. /**
  81968. * Set a vec2 in the shader from a Vector2.
  81969. * @param name Define the name of the uniform as defined in the shader
  81970. * @param value Define the value to give to the uniform
  81971. * @return the texture itself allowing "fluent" like uniform updates
  81972. */
  81973. setVector2(name: string, value: Vector2): ProceduralTexture;
  81974. /**
  81975. * Set a vec3 in the shader from a Vector3.
  81976. * @param name Define the name of the uniform as defined in the shader
  81977. * @param value Define the value to give to the uniform
  81978. * @return the texture itself allowing "fluent" like uniform updates
  81979. */
  81980. setVector3(name: string, value: Vector3): ProceduralTexture;
  81981. /**
  81982. * Set a mat4 in the shader from a MAtrix.
  81983. * @param name Define the name of the uniform as defined in the shader
  81984. * @param value Define the value to give to the uniform
  81985. * @return the texture itself allowing "fluent" like uniform updates
  81986. */
  81987. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81988. /**
  81989. * Render the texture to its associated render target.
  81990. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81991. */
  81992. render(useCameraPostProcess?: boolean): void;
  81993. /**
  81994. * Clone the texture.
  81995. * @returns the cloned texture
  81996. */
  81997. clone(): ProceduralTexture;
  81998. /**
  81999. * Dispose the texture and release its asoociated resources.
  82000. */
  82001. dispose(): void;
  82002. }
  82003. }
  82004. declare module BABYLON {
  82005. /**
  82006. * This represents the base class for particle system in Babylon.
  82007. * 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.
  82008. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82009. * @example https://doc.babylonjs.com/babylon101/particles
  82010. */
  82011. export class BaseParticleSystem {
  82012. /**
  82013. * Source color is added to the destination color without alpha affecting the result
  82014. */
  82015. static BLENDMODE_ONEONE: number;
  82016. /**
  82017. * Blend current color and particle color using particle’s alpha
  82018. */
  82019. static BLENDMODE_STANDARD: number;
  82020. /**
  82021. * Add current color and particle color multiplied by particle’s alpha
  82022. */
  82023. static BLENDMODE_ADD: number;
  82024. /**
  82025. * Multiply current color with particle color
  82026. */
  82027. static BLENDMODE_MULTIPLY: number;
  82028. /**
  82029. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  82030. */
  82031. static BLENDMODE_MULTIPLYADD: number;
  82032. /**
  82033. * List of animations used by the particle system.
  82034. */
  82035. animations: Animation[];
  82036. /**
  82037. * The id of the Particle system.
  82038. */
  82039. id: string;
  82040. /**
  82041. * The friendly name of the Particle system.
  82042. */
  82043. name: string;
  82044. /**
  82045. * The rendering group used by the Particle system to chose when to render.
  82046. */
  82047. renderingGroupId: number;
  82048. /**
  82049. * The emitter represents the Mesh or position we are attaching the particle system to.
  82050. */
  82051. emitter: Nullable<AbstractMesh | Vector3>;
  82052. /**
  82053. * The maximum number of particles to emit per frame
  82054. */
  82055. emitRate: number;
  82056. /**
  82057. * If you want to launch only a few particles at once, that can be done, as well.
  82058. */
  82059. manualEmitCount: number;
  82060. /**
  82061. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82062. */
  82063. updateSpeed: number;
  82064. /**
  82065. * The amount of time the particle system is running (depends of the overall update speed).
  82066. */
  82067. targetStopDuration: number;
  82068. /**
  82069. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82070. */
  82071. disposeOnStop: boolean;
  82072. /**
  82073. * Minimum power of emitting particles.
  82074. */
  82075. minEmitPower: number;
  82076. /**
  82077. * Maximum power of emitting particles.
  82078. */
  82079. maxEmitPower: number;
  82080. /**
  82081. * Minimum life time of emitting particles.
  82082. */
  82083. minLifeTime: number;
  82084. /**
  82085. * Maximum life time of emitting particles.
  82086. */
  82087. maxLifeTime: number;
  82088. /**
  82089. * Minimum Size of emitting particles.
  82090. */
  82091. minSize: number;
  82092. /**
  82093. * Maximum Size of emitting particles.
  82094. */
  82095. maxSize: number;
  82096. /**
  82097. * Minimum scale of emitting particles on X axis.
  82098. */
  82099. minScaleX: number;
  82100. /**
  82101. * Maximum scale of emitting particles on X axis.
  82102. */
  82103. maxScaleX: number;
  82104. /**
  82105. * Minimum scale of emitting particles on Y axis.
  82106. */
  82107. minScaleY: number;
  82108. /**
  82109. * Maximum scale of emitting particles on Y axis.
  82110. */
  82111. maxScaleY: number;
  82112. /**
  82113. * Gets or sets the minimal initial rotation in radians.
  82114. */
  82115. minInitialRotation: number;
  82116. /**
  82117. * Gets or sets the maximal initial rotation in radians.
  82118. */
  82119. maxInitialRotation: number;
  82120. /**
  82121. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82122. */
  82123. minAngularSpeed: number;
  82124. /**
  82125. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82126. */
  82127. maxAngularSpeed: number;
  82128. /**
  82129. * The texture used to render each particle. (this can be a spritesheet)
  82130. */
  82131. particleTexture: Nullable<Texture>;
  82132. /**
  82133. * The layer mask we are rendering the particles through.
  82134. */
  82135. layerMask: number;
  82136. /**
  82137. * This can help using your own shader to render the particle system.
  82138. * The according effect will be created
  82139. */
  82140. customShader: any;
  82141. /**
  82142. * By default particle system starts as soon as they are created. This prevents the
  82143. * automatic start to happen and let you decide when to start emitting particles.
  82144. */
  82145. preventAutoStart: boolean;
  82146. private _noiseTexture;
  82147. /**
  82148. * Gets or sets a texture used to add random noise to particle positions
  82149. */
  82150. noiseTexture: Nullable<ProceduralTexture>;
  82151. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82152. noiseStrength: Vector3;
  82153. /**
  82154. * Callback triggered when the particle animation is ending.
  82155. */
  82156. onAnimationEnd: Nullable<() => void>;
  82157. /**
  82158. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  82159. */
  82160. blendMode: number;
  82161. /**
  82162. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  82163. * to override the particles.
  82164. */
  82165. forceDepthWrite: boolean;
  82166. /** 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 */
  82167. preWarmCycles: number;
  82168. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  82169. preWarmStepOffset: number;
  82170. /**
  82171. * 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)
  82172. */
  82173. spriteCellChangeSpeed: number;
  82174. /**
  82175. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82176. */
  82177. startSpriteCellID: number;
  82178. /**
  82179. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82180. */
  82181. endSpriteCellID: number;
  82182. /**
  82183. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82184. */
  82185. spriteCellWidth: number;
  82186. /**
  82187. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82188. */
  82189. spriteCellHeight: number;
  82190. /**
  82191. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82192. */
  82193. spriteRandomStartCell: boolean;
  82194. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82195. translationPivot: Vector2;
  82196. /** @hidden */
  82197. protected _isAnimationSheetEnabled: boolean;
  82198. /**
  82199. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82200. */
  82201. beginAnimationOnStart: boolean;
  82202. /**
  82203. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82204. */
  82205. beginAnimationFrom: number;
  82206. /**
  82207. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82208. */
  82209. beginAnimationTo: number;
  82210. /**
  82211. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82212. */
  82213. beginAnimationLoop: boolean;
  82214. /**
  82215. * Gets or sets a world offset applied to all particles
  82216. */
  82217. worldOffset: Vector3;
  82218. /**
  82219. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  82220. */
  82221. isAnimationSheetEnabled: boolean;
  82222. /**
  82223. * Get hosting scene
  82224. * @returns the scene
  82225. */
  82226. getScene(): Scene;
  82227. /**
  82228. * You can use gravity if you want to give an orientation to your particles.
  82229. */
  82230. gravity: Vector3;
  82231. protected _colorGradients: Nullable<Array<ColorGradient>>;
  82232. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  82233. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  82234. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  82235. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  82236. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  82237. protected _dragGradients: Nullable<Array<FactorGradient>>;
  82238. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  82239. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  82240. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  82241. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  82242. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  82243. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  82244. /**
  82245. * Defines the delay in milliseconds before starting the system (0 by default)
  82246. */
  82247. startDelay: number;
  82248. /**
  82249. * Gets the current list of drag gradients.
  82250. * You must use addDragGradient and removeDragGradient to udpate this list
  82251. * @returns the list of drag gradients
  82252. */
  82253. getDragGradients(): Nullable<Array<FactorGradient>>;
  82254. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82255. limitVelocityDamping: number;
  82256. /**
  82257. * Gets the current list of limit velocity gradients.
  82258. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82259. * @returns the list of limit velocity gradients
  82260. */
  82261. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82262. /**
  82263. * Gets the current list of color gradients.
  82264. * You must use addColorGradient and removeColorGradient to udpate this list
  82265. * @returns the list of color gradients
  82266. */
  82267. getColorGradients(): Nullable<Array<ColorGradient>>;
  82268. /**
  82269. * Gets the current list of size gradients.
  82270. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82271. * @returns the list of size gradients
  82272. */
  82273. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82274. /**
  82275. * Gets the current list of color remap gradients.
  82276. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82277. * @returns the list of color remap gradients
  82278. */
  82279. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82280. /**
  82281. * Gets the current list of alpha remap gradients.
  82282. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82283. * @returns the list of alpha remap gradients
  82284. */
  82285. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82286. /**
  82287. * Gets the current list of life time gradients.
  82288. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82289. * @returns the list of life time gradients
  82290. */
  82291. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82292. /**
  82293. * Gets the current list of angular speed gradients.
  82294. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82295. * @returns the list of angular speed gradients
  82296. */
  82297. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82298. /**
  82299. * Gets the current list of velocity gradients.
  82300. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82301. * @returns the list of velocity gradients
  82302. */
  82303. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82304. /**
  82305. * Gets the current list of start size gradients.
  82306. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82307. * @returns the list of start size gradients
  82308. */
  82309. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82310. /**
  82311. * Gets the current list of emit rate gradients.
  82312. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82313. * @returns the list of emit rate gradients
  82314. */
  82315. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82316. /**
  82317. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82318. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82319. */
  82320. direction1: Vector3;
  82321. /**
  82322. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82323. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82324. */
  82325. direction2: Vector3;
  82326. /**
  82327. * 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.
  82328. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82329. */
  82330. minEmitBox: Vector3;
  82331. /**
  82332. * 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.
  82333. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82334. */
  82335. maxEmitBox: Vector3;
  82336. /**
  82337. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82338. */
  82339. color1: Color4;
  82340. /**
  82341. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82342. */
  82343. color2: Color4;
  82344. /**
  82345. * Color the particle will have at the end of its lifetime
  82346. */
  82347. colorDead: Color4;
  82348. /**
  82349. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  82350. */
  82351. textureMask: Color4;
  82352. /**
  82353. * The particle emitter type defines the emitter used by the particle system.
  82354. * It can be for example box, sphere, or cone...
  82355. */
  82356. particleEmitterType: IParticleEmitterType;
  82357. /** @hidden */
  82358. _isSubEmitter: boolean;
  82359. /**
  82360. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82361. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82362. */
  82363. billboardMode: number;
  82364. protected _isBillboardBased: boolean;
  82365. /**
  82366. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82367. */
  82368. isBillboardBased: boolean;
  82369. /**
  82370. * The scene the particle system belongs to.
  82371. */
  82372. protected _scene: Scene;
  82373. /**
  82374. * Local cache of defines for image processing.
  82375. */
  82376. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  82377. /**
  82378. * Default configuration related to image processing available in the standard Material.
  82379. */
  82380. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  82381. /**
  82382. * Gets the image processing configuration used either in this material.
  82383. */
  82384. /**
  82385. * Sets the Default image processing configuration used either in the this material.
  82386. *
  82387. * If sets to null, the scene one is in use.
  82388. */
  82389. imageProcessingConfiguration: ImageProcessingConfiguration;
  82390. /**
  82391. * Attaches a new image processing configuration to the Standard Material.
  82392. * @param configuration
  82393. */
  82394. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82395. /** @hidden */
  82396. protected _reset(): void;
  82397. /** @hidden */
  82398. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82399. /**
  82400. * Instantiates a particle system.
  82401. * 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.
  82402. * @param name The name of the particle system
  82403. */
  82404. constructor(name: string);
  82405. /**
  82406. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82407. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82408. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82409. * @returns the emitter
  82410. */
  82411. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82412. /**
  82413. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82414. * @param radius The radius of the hemisphere to emit from
  82415. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82416. * @returns the emitter
  82417. */
  82418. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82419. /**
  82420. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82421. * @param radius The radius of the sphere to emit from
  82422. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82423. * @returns the emitter
  82424. */
  82425. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82426. /**
  82427. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82428. * @param radius The radius of the sphere to emit from
  82429. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82430. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82431. * @returns the emitter
  82432. */
  82433. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82434. /**
  82435. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82436. * @param radius The radius of the emission cylinder
  82437. * @param height The height of the emission cylinder
  82438. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82439. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82440. * @returns the emitter
  82441. */
  82442. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82443. /**
  82444. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82445. * @param radius The radius of the cylinder to emit from
  82446. * @param height The height of the emission cylinder
  82447. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82448. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82449. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82450. * @returns the emitter
  82451. */
  82452. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82453. /**
  82454. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82455. * @param radius The radius of the cone to emit from
  82456. * @param angle The base angle of the cone
  82457. * @returns the emitter
  82458. */
  82459. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82460. /**
  82461. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82462. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82463. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82464. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82465. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82466. * @returns the emitter
  82467. */
  82468. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82469. }
  82470. }
  82471. declare module BABYLON {
  82472. /**
  82473. * Type of sub emitter
  82474. */
  82475. export enum SubEmitterType {
  82476. /**
  82477. * Attached to the particle over it's lifetime
  82478. */
  82479. ATTACHED = 0,
  82480. /**
  82481. * Created when the particle dies
  82482. */
  82483. END = 1
  82484. }
  82485. /**
  82486. * Sub emitter class used to emit particles from an existing particle
  82487. */
  82488. export class SubEmitter {
  82489. /**
  82490. * the particle system to be used by the sub emitter
  82491. */
  82492. particleSystem: ParticleSystem;
  82493. /**
  82494. * Type of the submitter (Default: END)
  82495. */
  82496. type: SubEmitterType;
  82497. /**
  82498. * 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)
  82499. * Note: This only is supported when using an emitter of type Mesh
  82500. */
  82501. inheritDirection: boolean;
  82502. /**
  82503. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82504. */
  82505. inheritedVelocityAmount: number;
  82506. /**
  82507. * Creates a sub emitter
  82508. * @param particleSystem the particle system to be used by the sub emitter
  82509. */
  82510. constructor(
  82511. /**
  82512. * the particle system to be used by the sub emitter
  82513. */
  82514. particleSystem: ParticleSystem);
  82515. /**
  82516. * Clones the sub emitter
  82517. * @returns the cloned sub emitter
  82518. */
  82519. clone(): SubEmitter;
  82520. /**
  82521. * Serialize current object to a JSON object
  82522. * @returns the serialized object
  82523. */
  82524. serialize(): any;
  82525. /** @hidden */
  82526. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82527. /**
  82528. * Creates a new SubEmitter from a serialized JSON version
  82529. * @param serializationObject defines the JSON object to read from
  82530. * @param scene defines the hosting scene
  82531. * @param rootUrl defines the rootUrl for data loading
  82532. * @returns a new SubEmitter
  82533. */
  82534. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82535. /** Release associated resources */
  82536. dispose(): void;
  82537. }
  82538. }
  82539. declare module BABYLON {
  82540. /** @hidden */
  82541. export var clipPlaneFragmentDeclaration: {
  82542. name: string;
  82543. shader: string;
  82544. };
  82545. }
  82546. declare module BABYLON {
  82547. /** @hidden */
  82548. export var imageProcessingDeclaration: {
  82549. name: string;
  82550. shader: string;
  82551. };
  82552. }
  82553. declare module BABYLON {
  82554. /** @hidden */
  82555. export var imageProcessingFunctions: {
  82556. name: string;
  82557. shader: string;
  82558. };
  82559. }
  82560. declare module BABYLON {
  82561. /** @hidden */
  82562. export var clipPlaneFragment: {
  82563. name: string;
  82564. shader: string;
  82565. };
  82566. }
  82567. declare module BABYLON {
  82568. /** @hidden */
  82569. export var particlesPixelShader: {
  82570. name: string;
  82571. shader: string;
  82572. };
  82573. }
  82574. declare module BABYLON {
  82575. /** @hidden */
  82576. export var clipPlaneVertexDeclaration: {
  82577. name: string;
  82578. shader: string;
  82579. };
  82580. }
  82581. declare module BABYLON {
  82582. /** @hidden */
  82583. export var clipPlaneVertex: {
  82584. name: string;
  82585. shader: string;
  82586. };
  82587. }
  82588. declare module BABYLON {
  82589. /** @hidden */
  82590. export var particlesVertexShader: {
  82591. name: string;
  82592. shader: string;
  82593. };
  82594. }
  82595. declare module BABYLON {
  82596. /**
  82597. * This represents a particle system in Babylon.
  82598. * 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.
  82599. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82600. * @example https://doc.babylonjs.com/babylon101/particles
  82601. */
  82602. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82603. /**
  82604. * Billboard mode will only apply to Y axis
  82605. */
  82606. static readonly BILLBOARDMODE_Y: number;
  82607. /**
  82608. * Billboard mode will apply to all axes
  82609. */
  82610. static readonly BILLBOARDMODE_ALL: number;
  82611. /**
  82612. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82613. */
  82614. static readonly BILLBOARDMODE_STRETCHED: number;
  82615. /**
  82616. * This function can be defined to provide custom update for active particles.
  82617. * This function will be called instead of regular update (age, position, color, etc.).
  82618. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82619. */
  82620. updateFunction: (particles: Particle[]) => void;
  82621. private _emitterWorldMatrix;
  82622. /**
  82623. * This function can be defined to specify initial direction for every new particle.
  82624. * It by default use the emitterType defined function
  82625. */
  82626. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82627. /**
  82628. * This function can be defined to specify initial position for every new particle.
  82629. * It by default use the emitterType defined function
  82630. */
  82631. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82632. /**
  82633. * @hidden
  82634. */
  82635. _inheritedVelocityOffset: Vector3;
  82636. /**
  82637. * An event triggered when the system is disposed
  82638. */
  82639. onDisposeObservable: Observable<ParticleSystem>;
  82640. private _onDisposeObserver;
  82641. /**
  82642. * Sets a callback that will be triggered when the system is disposed
  82643. */
  82644. onDispose: () => void;
  82645. private _particles;
  82646. private _epsilon;
  82647. private _capacity;
  82648. private _stockParticles;
  82649. private _newPartsExcess;
  82650. private _vertexData;
  82651. private _vertexBuffer;
  82652. private _vertexBuffers;
  82653. private _spriteBuffer;
  82654. private _indexBuffer;
  82655. private _effect;
  82656. private _customEffect;
  82657. private _cachedDefines;
  82658. private _scaledColorStep;
  82659. private _colorDiff;
  82660. private _scaledDirection;
  82661. private _scaledGravity;
  82662. private _currentRenderId;
  82663. private _alive;
  82664. private _useInstancing;
  82665. private _started;
  82666. private _stopped;
  82667. private _actualFrame;
  82668. private _scaledUpdateSpeed;
  82669. private _vertexBufferSize;
  82670. /** @hidden */
  82671. _currentEmitRateGradient: Nullable<FactorGradient>;
  82672. /** @hidden */
  82673. _currentEmitRate1: number;
  82674. /** @hidden */
  82675. _currentEmitRate2: number;
  82676. /** @hidden */
  82677. _currentStartSizeGradient: Nullable<FactorGradient>;
  82678. /** @hidden */
  82679. _currentStartSize1: number;
  82680. /** @hidden */
  82681. _currentStartSize2: number;
  82682. private readonly _rawTextureWidth;
  82683. private _rampGradientsTexture;
  82684. private _useRampGradients;
  82685. /** Gets or sets a boolean indicating that ramp gradients must be used
  82686. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82687. */
  82688. useRampGradients: boolean;
  82689. /**
  82690. * 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.
  82691. * 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: [])
  82692. */
  82693. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82694. private _subEmitters;
  82695. /**
  82696. * @hidden
  82697. * If the particle systems emitter should be disposed when the particle system is disposed
  82698. */
  82699. _disposeEmitterOnDispose: boolean;
  82700. /**
  82701. * The current active Sub-systems, this property is used by the root particle system only.
  82702. */
  82703. activeSubSystems: Array<ParticleSystem>;
  82704. private _rootParticleSystem;
  82705. /**
  82706. * Gets the current list of active particles
  82707. */
  82708. readonly particles: Particle[];
  82709. /**
  82710. * Returns the string "ParticleSystem"
  82711. * @returns a string containing the class name
  82712. */
  82713. getClassName(): string;
  82714. /**
  82715. * Instantiates a particle system.
  82716. * 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.
  82717. * @param name The name of the particle system
  82718. * @param capacity The max number of particles alive at the same time
  82719. * @param scene The scene the particle system belongs to
  82720. * @param customEffect a custom effect used to change the way particles are rendered by default
  82721. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82722. * @param epsilon Offset used to render the particles
  82723. */
  82724. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82725. private _addFactorGradient;
  82726. private _removeFactorGradient;
  82727. /**
  82728. * Adds a new life time gradient
  82729. * @param gradient defines the gradient to use (between 0 and 1)
  82730. * @param factor defines the life time factor to affect to the specified gradient
  82731. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82732. * @returns the current particle system
  82733. */
  82734. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82735. /**
  82736. * Remove a specific life time gradient
  82737. * @param gradient defines the gradient to remove
  82738. * @returns the current particle system
  82739. */
  82740. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82741. /**
  82742. * Adds a new size gradient
  82743. * @param gradient defines the gradient to use (between 0 and 1)
  82744. * @param factor defines the size factor to affect to the specified gradient
  82745. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82746. * @returns the current particle system
  82747. */
  82748. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82749. /**
  82750. * Remove a specific size gradient
  82751. * @param gradient defines the gradient to remove
  82752. * @returns the current particle system
  82753. */
  82754. removeSizeGradient(gradient: number): IParticleSystem;
  82755. /**
  82756. * Adds a new color remap gradient
  82757. * @param gradient defines the gradient to use (between 0 and 1)
  82758. * @param min defines the color remap minimal range
  82759. * @param max defines the color remap maximal range
  82760. * @returns the current particle system
  82761. */
  82762. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82763. /**
  82764. * Remove a specific color remap gradient
  82765. * @param gradient defines the gradient to remove
  82766. * @returns the current particle system
  82767. */
  82768. removeColorRemapGradient(gradient: number): IParticleSystem;
  82769. /**
  82770. * Adds a new alpha remap gradient
  82771. * @param gradient defines the gradient to use (between 0 and 1)
  82772. * @param min defines the alpha remap minimal range
  82773. * @param max defines the alpha remap maximal range
  82774. * @returns the current particle system
  82775. */
  82776. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82777. /**
  82778. * Remove a specific alpha remap gradient
  82779. * @param gradient defines the gradient to remove
  82780. * @returns the current particle system
  82781. */
  82782. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82783. /**
  82784. * Adds a new angular speed gradient
  82785. * @param gradient defines the gradient to use (between 0 and 1)
  82786. * @param factor defines the angular speed to affect to the specified gradient
  82787. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82788. * @returns the current particle system
  82789. */
  82790. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82791. /**
  82792. * Remove a specific angular speed gradient
  82793. * @param gradient defines the gradient to remove
  82794. * @returns the current particle system
  82795. */
  82796. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82797. /**
  82798. * Adds a new velocity gradient
  82799. * @param gradient defines the gradient to use (between 0 and 1)
  82800. * @param factor defines the velocity to affect to the specified gradient
  82801. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82802. * @returns the current particle system
  82803. */
  82804. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82805. /**
  82806. * Remove a specific velocity gradient
  82807. * @param gradient defines the gradient to remove
  82808. * @returns the current particle system
  82809. */
  82810. removeVelocityGradient(gradient: number): IParticleSystem;
  82811. /**
  82812. * Adds a new limit velocity gradient
  82813. * @param gradient defines the gradient to use (between 0 and 1)
  82814. * @param factor defines the limit velocity value to affect to the specified gradient
  82815. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82816. * @returns the current particle system
  82817. */
  82818. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82819. /**
  82820. * Remove a specific limit velocity gradient
  82821. * @param gradient defines the gradient to remove
  82822. * @returns the current particle system
  82823. */
  82824. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82825. /**
  82826. * Adds a new drag gradient
  82827. * @param gradient defines the gradient to use (between 0 and 1)
  82828. * @param factor defines the drag value to affect to the specified gradient
  82829. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82830. * @returns the current particle system
  82831. */
  82832. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82833. /**
  82834. * Remove a specific drag gradient
  82835. * @param gradient defines the gradient to remove
  82836. * @returns the current particle system
  82837. */
  82838. removeDragGradient(gradient: number): IParticleSystem;
  82839. /**
  82840. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82841. * @param gradient defines the gradient to use (between 0 and 1)
  82842. * @param factor defines the emit rate value to affect to the specified gradient
  82843. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82844. * @returns the current particle system
  82845. */
  82846. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82847. /**
  82848. * Remove a specific emit rate gradient
  82849. * @param gradient defines the gradient to remove
  82850. * @returns the current particle system
  82851. */
  82852. removeEmitRateGradient(gradient: number): IParticleSystem;
  82853. /**
  82854. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82855. * @param gradient defines the gradient to use (between 0 and 1)
  82856. * @param factor defines the start size value to affect to the specified gradient
  82857. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82858. * @returns the current particle system
  82859. */
  82860. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82861. /**
  82862. * Remove a specific start size gradient
  82863. * @param gradient defines the gradient to remove
  82864. * @returns the current particle system
  82865. */
  82866. removeStartSizeGradient(gradient: number): IParticleSystem;
  82867. private _createRampGradientTexture;
  82868. /**
  82869. * Gets the current list of ramp gradients.
  82870. * You must use addRampGradient and removeRampGradient to udpate this list
  82871. * @returns the list of ramp gradients
  82872. */
  82873. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82874. /**
  82875. * Adds a new ramp gradient used to remap particle colors
  82876. * @param gradient defines the gradient to use (between 0 and 1)
  82877. * @param color defines the color to affect to the specified gradient
  82878. * @returns the current particle system
  82879. */
  82880. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82881. /**
  82882. * Remove a specific ramp gradient
  82883. * @param gradient defines the gradient to remove
  82884. * @returns the current particle system
  82885. */
  82886. removeRampGradient(gradient: number): ParticleSystem;
  82887. /**
  82888. * Adds a new color gradient
  82889. * @param gradient defines the gradient to use (between 0 and 1)
  82890. * @param color1 defines the color to affect to the specified gradient
  82891. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82892. * @returns this particle system
  82893. */
  82894. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82895. /**
  82896. * Remove a specific color gradient
  82897. * @param gradient defines the gradient to remove
  82898. * @returns this particle system
  82899. */
  82900. removeColorGradient(gradient: number): IParticleSystem;
  82901. private _fetchR;
  82902. protected _reset(): void;
  82903. private _resetEffect;
  82904. private _createVertexBuffers;
  82905. private _createIndexBuffer;
  82906. /**
  82907. * Gets the maximum number of particles active at the same time.
  82908. * @returns The max number of active particles.
  82909. */
  82910. getCapacity(): number;
  82911. /**
  82912. * Gets whether there are still active particles in the system.
  82913. * @returns True if it is alive, otherwise false.
  82914. */
  82915. isAlive(): boolean;
  82916. /**
  82917. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82918. * @returns True if it has been started, otherwise false.
  82919. */
  82920. isStarted(): boolean;
  82921. private _prepareSubEmitterInternalArray;
  82922. /**
  82923. * Starts the particle system and begins to emit
  82924. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82925. */
  82926. start(delay?: number): void;
  82927. /**
  82928. * Stops the particle system.
  82929. * @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.
  82930. */
  82931. stop(stopSubEmitters?: boolean): void;
  82932. /**
  82933. * Remove all active particles
  82934. */
  82935. reset(): void;
  82936. /**
  82937. * @hidden (for internal use only)
  82938. */
  82939. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82940. /**
  82941. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82942. * Its lifetime will start back at 0.
  82943. */
  82944. recycleParticle: (particle: Particle) => void;
  82945. private _stopSubEmitters;
  82946. private _createParticle;
  82947. private _removeFromRoot;
  82948. private _emitFromParticle;
  82949. private _update;
  82950. /** @hidden */
  82951. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82952. /** @hidden */
  82953. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82954. /** @hidden */
  82955. private _getEffect;
  82956. /**
  82957. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82958. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82959. */
  82960. animate(preWarmOnly?: boolean): void;
  82961. private _appendParticleVertices;
  82962. /**
  82963. * Rebuilds the particle system.
  82964. */
  82965. rebuild(): void;
  82966. /**
  82967. * Is this system ready to be used/rendered
  82968. * @return true if the system is ready
  82969. */
  82970. isReady(): boolean;
  82971. private _render;
  82972. /**
  82973. * Renders the particle system in its current state.
  82974. * @returns the current number of particles
  82975. */
  82976. render(): number;
  82977. /**
  82978. * Disposes the particle system and free the associated resources
  82979. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82980. */
  82981. dispose(disposeTexture?: boolean): void;
  82982. /**
  82983. * Clones the particle system.
  82984. * @param name The name of the cloned object
  82985. * @param newEmitter The new emitter to use
  82986. * @returns the cloned particle system
  82987. */
  82988. clone(name: string, newEmitter: any): ParticleSystem;
  82989. /**
  82990. * Serializes the particle system to a JSON object.
  82991. * @returns the JSON object
  82992. */
  82993. serialize(): any;
  82994. /** @hidden */
  82995. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82996. /** @hidden */
  82997. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82998. /**
  82999. * Parses a JSON object to create a particle system.
  83000. * @param parsedParticleSystem The JSON object to parse
  83001. * @param scene The scene to create the particle system in
  83002. * @param rootUrl The root url to use to load external dependencies like texture
  83003. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  83004. * @returns the Parsed particle system
  83005. */
  83006. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  83007. }
  83008. }
  83009. declare module BABYLON {
  83010. /**
  83011. * A particle represents one of the element emitted by a particle system.
  83012. * This is mainly define by its coordinates, direction, velocity and age.
  83013. */
  83014. export class Particle {
  83015. /**
  83016. * The particle system the particle belongs to.
  83017. */
  83018. particleSystem: ParticleSystem;
  83019. private static _Count;
  83020. /**
  83021. * Unique ID of the particle
  83022. */
  83023. id: number;
  83024. /**
  83025. * The world position of the particle in the scene.
  83026. */
  83027. position: Vector3;
  83028. /**
  83029. * The world direction of the particle in the scene.
  83030. */
  83031. direction: Vector3;
  83032. /**
  83033. * The color of the particle.
  83034. */
  83035. color: Color4;
  83036. /**
  83037. * The color change of the particle per step.
  83038. */
  83039. colorStep: Color4;
  83040. /**
  83041. * Defines how long will the life of the particle be.
  83042. */
  83043. lifeTime: number;
  83044. /**
  83045. * The current age of the particle.
  83046. */
  83047. age: number;
  83048. /**
  83049. * The current size of the particle.
  83050. */
  83051. size: number;
  83052. /**
  83053. * The current scale of the particle.
  83054. */
  83055. scale: Vector2;
  83056. /**
  83057. * The current angle of the particle.
  83058. */
  83059. angle: number;
  83060. /**
  83061. * Defines how fast is the angle changing.
  83062. */
  83063. angularSpeed: number;
  83064. /**
  83065. * Defines the cell index used by the particle to be rendered from a sprite.
  83066. */
  83067. cellIndex: number;
  83068. /**
  83069. * The information required to support color remapping
  83070. */
  83071. remapData: Vector4;
  83072. /** @hidden */
  83073. _randomCellOffset?: number;
  83074. /** @hidden */
  83075. _initialDirection: Nullable<Vector3>;
  83076. /** @hidden */
  83077. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  83078. /** @hidden */
  83079. _initialStartSpriteCellID: number;
  83080. /** @hidden */
  83081. _initialEndSpriteCellID: number;
  83082. /** @hidden */
  83083. _currentColorGradient: Nullable<ColorGradient>;
  83084. /** @hidden */
  83085. _currentColor1: Color4;
  83086. /** @hidden */
  83087. _currentColor2: Color4;
  83088. /** @hidden */
  83089. _currentSizeGradient: Nullable<FactorGradient>;
  83090. /** @hidden */
  83091. _currentSize1: number;
  83092. /** @hidden */
  83093. _currentSize2: number;
  83094. /** @hidden */
  83095. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  83096. /** @hidden */
  83097. _currentAngularSpeed1: number;
  83098. /** @hidden */
  83099. _currentAngularSpeed2: number;
  83100. /** @hidden */
  83101. _currentVelocityGradient: Nullable<FactorGradient>;
  83102. /** @hidden */
  83103. _currentVelocity1: number;
  83104. /** @hidden */
  83105. _currentVelocity2: number;
  83106. /** @hidden */
  83107. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  83108. /** @hidden */
  83109. _currentLimitVelocity1: number;
  83110. /** @hidden */
  83111. _currentLimitVelocity2: number;
  83112. /** @hidden */
  83113. _currentDragGradient: Nullable<FactorGradient>;
  83114. /** @hidden */
  83115. _currentDrag1: number;
  83116. /** @hidden */
  83117. _currentDrag2: number;
  83118. /** @hidden */
  83119. _randomNoiseCoordinates1: Vector3;
  83120. /** @hidden */
  83121. _randomNoiseCoordinates2: Vector3;
  83122. /**
  83123. * Creates a new instance Particle
  83124. * @param particleSystem the particle system the particle belongs to
  83125. */
  83126. constructor(
  83127. /**
  83128. * The particle system the particle belongs to.
  83129. */
  83130. particleSystem: ParticleSystem);
  83131. private updateCellInfoFromSystem;
  83132. /**
  83133. * Defines how the sprite cell index is updated for the particle
  83134. */
  83135. updateCellIndex(): void;
  83136. /** @hidden */
  83137. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  83138. /** @hidden */
  83139. _inheritParticleInfoToSubEmitters(): void;
  83140. /** @hidden */
  83141. _reset(): void;
  83142. /**
  83143. * Copy the properties of particle to another one.
  83144. * @param other the particle to copy the information to.
  83145. */
  83146. copyTo(other: Particle): void;
  83147. }
  83148. }
  83149. declare module BABYLON {
  83150. /**
  83151. * Particle emitter represents a volume emitting particles.
  83152. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  83153. */
  83154. export interface IParticleEmitterType {
  83155. /**
  83156. * Called by the particle System when the direction is computed for the created particle.
  83157. * @param worldMatrix is the world matrix of the particle system
  83158. * @param directionToUpdate is the direction vector to update with the result
  83159. * @param particle is the particle we are computed the direction for
  83160. */
  83161. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83162. /**
  83163. * Called by the particle System when the position is computed for the created particle.
  83164. * @param worldMatrix is the world matrix of the particle system
  83165. * @param positionToUpdate is the position vector to update with the result
  83166. * @param particle is the particle we are computed the position for
  83167. */
  83168. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83169. /**
  83170. * Clones the current emitter and returns a copy of it
  83171. * @returns the new emitter
  83172. */
  83173. clone(): IParticleEmitterType;
  83174. /**
  83175. * Called by the GPUParticleSystem to setup the update shader
  83176. * @param effect defines the update shader
  83177. */
  83178. applyToShader(effect: Effect): void;
  83179. /**
  83180. * Returns a string to use to update the GPU particles update shader
  83181. * @returns the effect defines string
  83182. */
  83183. getEffectDefines(): string;
  83184. /**
  83185. * Returns a string representing the class name
  83186. * @returns a string containing the class name
  83187. */
  83188. getClassName(): string;
  83189. /**
  83190. * Serializes the particle system to a JSON object.
  83191. * @returns the JSON object
  83192. */
  83193. serialize(): any;
  83194. /**
  83195. * Parse properties from a JSON object
  83196. * @param serializationObject defines the JSON object
  83197. */
  83198. parse(serializationObject: any): void;
  83199. }
  83200. }
  83201. declare module BABYLON {
  83202. /**
  83203. * Particle emitter emitting particles from the inside of a box.
  83204. * It emits the particles randomly between 2 given directions.
  83205. */
  83206. export class BoxParticleEmitter implements IParticleEmitterType {
  83207. /**
  83208. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83209. */
  83210. direction1: Vector3;
  83211. /**
  83212. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83213. */
  83214. direction2: Vector3;
  83215. /**
  83216. * 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.
  83217. */
  83218. minEmitBox: Vector3;
  83219. /**
  83220. * 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.
  83221. */
  83222. maxEmitBox: Vector3;
  83223. /**
  83224. * Creates a new instance BoxParticleEmitter
  83225. */
  83226. constructor();
  83227. /**
  83228. * Called by the particle System when the direction is computed for the created particle.
  83229. * @param worldMatrix is the world matrix of the particle system
  83230. * @param directionToUpdate is the direction vector to update with the result
  83231. * @param particle is the particle we are computed the direction for
  83232. */
  83233. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83234. /**
  83235. * Called by the particle System when the position is computed for the created particle.
  83236. * @param worldMatrix is the world matrix of the particle system
  83237. * @param positionToUpdate is the position vector to update with the result
  83238. * @param particle is the particle we are computed the position for
  83239. */
  83240. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83241. /**
  83242. * Clones the current emitter and returns a copy of it
  83243. * @returns the new emitter
  83244. */
  83245. clone(): BoxParticleEmitter;
  83246. /**
  83247. * Called by the GPUParticleSystem to setup the update shader
  83248. * @param effect defines the update shader
  83249. */
  83250. applyToShader(effect: Effect): void;
  83251. /**
  83252. * Returns a string to use to update the GPU particles update shader
  83253. * @returns a string containng the defines string
  83254. */
  83255. getEffectDefines(): string;
  83256. /**
  83257. * Returns the string "BoxParticleEmitter"
  83258. * @returns a string containing the class name
  83259. */
  83260. getClassName(): string;
  83261. /**
  83262. * Serializes the particle system to a JSON object.
  83263. * @returns the JSON object
  83264. */
  83265. serialize(): any;
  83266. /**
  83267. * Parse properties from a JSON object
  83268. * @param serializationObject defines the JSON object
  83269. */
  83270. parse(serializationObject: any): void;
  83271. }
  83272. }
  83273. declare module BABYLON {
  83274. /**
  83275. * Particle emitter emitting particles from the inside of a cone.
  83276. * It emits the particles alongside the cone volume from the base to the particle.
  83277. * The emission direction might be randomized.
  83278. */
  83279. export class ConeParticleEmitter implements IParticleEmitterType {
  83280. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83281. directionRandomizer: number;
  83282. private _radius;
  83283. private _angle;
  83284. private _height;
  83285. /**
  83286. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  83287. */
  83288. radiusRange: number;
  83289. /**
  83290. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  83291. */
  83292. heightRange: number;
  83293. /**
  83294. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  83295. */
  83296. emitFromSpawnPointOnly: boolean;
  83297. /**
  83298. * Gets or sets the radius of the emission cone
  83299. */
  83300. radius: number;
  83301. /**
  83302. * Gets or sets the angle of the emission cone
  83303. */
  83304. angle: number;
  83305. private _buildHeight;
  83306. /**
  83307. * Creates a new instance ConeParticleEmitter
  83308. * @param radius the radius of the emission cone (1 by default)
  83309. * @param angle the cone base angle (PI by default)
  83310. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  83311. */
  83312. constructor(radius?: number, angle?: number,
  83313. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83314. directionRandomizer?: number);
  83315. /**
  83316. * Called by the particle System when the direction is computed for the created particle.
  83317. * @param worldMatrix is the world matrix of the particle system
  83318. * @param directionToUpdate is the direction vector to update with the result
  83319. * @param particle is the particle we are computed the direction for
  83320. */
  83321. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83322. /**
  83323. * Called by the particle System when the position is computed for the created particle.
  83324. * @param worldMatrix is the world matrix of the particle system
  83325. * @param positionToUpdate is the position vector to update with the result
  83326. * @param particle is the particle we are computed the position for
  83327. */
  83328. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83329. /**
  83330. * Clones the current emitter and returns a copy of it
  83331. * @returns the new emitter
  83332. */
  83333. clone(): ConeParticleEmitter;
  83334. /**
  83335. * Called by the GPUParticleSystem to setup the update shader
  83336. * @param effect defines the update shader
  83337. */
  83338. applyToShader(effect: Effect): void;
  83339. /**
  83340. * Returns a string to use to update the GPU particles update shader
  83341. * @returns a string containng the defines string
  83342. */
  83343. getEffectDefines(): string;
  83344. /**
  83345. * Returns the string "ConeParticleEmitter"
  83346. * @returns a string containing the class name
  83347. */
  83348. getClassName(): string;
  83349. /**
  83350. * Serializes the particle system to a JSON object.
  83351. * @returns the JSON object
  83352. */
  83353. serialize(): any;
  83354. /**
  83355. * Parse properties from a JSON object
  83356. * @param serializationObject defines the JSON object
  83357. */
  83358. parse(serializationObject: any): void;
  83359. }
  83360. }
  83361. declare module BABYLON {
  83362. /**
  83363. * Particle emitter emitting particles from the inside of a cylinder.
  83364. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  83365. */
  83366. export class CylinderParticleEmitter implements IParticleEmitterType {
  83367. /**
  83368. * The radius of the emission cylinder.
  83369. */
  83370. radius: number;
  83371. /**
  83372. * The height of the emission cylinder.
  83373. */
  83374. height: number;
  83375. /**
  83376. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83377. */
  83378. radiusRange: number;
  83379. /**
  83380. * How much to randomize the particle direction [0-1].
  83381. */
  83382. directionRandomizer: number;
  83383. /**
  83384. * Creates a new instance CylinderParticleEmitter
  83385. * @param radius the radius of the emission cylinder (1 by default)
  83386. * @param height the height of the emission cylinder (1 by default)
  83387. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83388. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83389. */
  83390. constructor(
  83391. /**
  83392. * The radius of the emission cylinder.
  83393. */
  83394. radius?: number,
  83395. /**
  83396. * The height of the emission cylinder.
  83397. */
  83398. height?: number,
  83399. /**
  83400. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83401. */
  83402. radiusRange?: number,
  83403. /**
  83404. * How much to randomize the particle direction [0-1].
  83405. */
  83406. directionRandomizer?: number);
  83407. /**
  83408. * Called by the particle System when the direction is computed for the created particle.
  83409. * @param worldMatrix is the world matrix of the particle system
  83410. * @param directionToUpdate is the direction vector to update with the result
  83411. * @param particle is the particle we are computed the direction for
  83412. */
  83413. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83414. /**
  83415. * Called by the particle System when the position is computed for the created particle.
  83416. * @param worldMatrix is the world matrix of the particle system
  83417. * @param positionToUpdate is the position vector to update with the result
  83418. * @param particle is the particle we are computed the position for
  83419. */
  83420. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83421. /**
  83422. * Clones the current emitter and returns a copy of it
  83423. * @returns the new emitter
  83424. */
  83425. clone(): CylinderParticleEmitter;
  83426. /**
  83427. * Called by the GPUParticleSystem to setup the update shader
  83428. * @param effect defines the update shader
  83429. */
  83430. applyToShader(effect: Effect): void;
  83431. /**
  83432. * Returns a string to use to update the GPU particles update shader
  83433. * @returns a string containng the defines string
  83434. */
  83435. getEffectDefines(): string;
  83436. /**
  83437. * Returns the string "CylinderParticleEmitter"
  83438. * @returns a string containing the class name
  83439. */
  83440. getClassName(): string;
  83441. /**
  83442. * Serializes the particle system to a JSON object.
  83443. * @returns the JSON object
  83444. */
  83445. serialize(): any;
  83446. /**
  83447. * Parse properties from a JSON object
  83448. * @param serializationObject defines the JSON object
  83449. */
  83450. parse(serializationObject: any): void;
  83451. }
  83452. /**
  83453. * Particle emitter emitting particles from the inside of a cylinder.
  83454. * It emits the particles randomly between two vectors.
  83455. */
  83456. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83457. /**
  83458. * The min limit of the emission direction.
  83459. */
  83460. direction1: Vector3;
  83461. /**
  83462. * The max limit of the emission direction.
  83463. */
  83464. direction2: Vector3;
  83465. /**
  83466. * Creates a new instance CylinderDirectedParticleEmitter
  83467. * @param radius the radius of the emission cylinder (1 by default)
  83468. * @param height the height of the emission cylinder (1 by default)
  83469. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83470. * @param direction1 the min limit of the emission direction (up vector by default)
  83471. * @param direction2 the max limit of the emission direction (up vector by default)
  83472. */
  83473. constructor(radius?: number, height?: number, radiusRange?: number,
  83474. /**
  83475. * The min limit of the emission direction.
  83476. */
  83477. direction1?: Vector3,
  83478. /**
  83479. * The max limit of the emission direction.
  83480. */
  83481. direction2?: Vector3);
  83482. /**
  83483. * Called by the particle System when the direction is computed for the created particle.
  83484. * @param worldMatrix is the world matrix of the particle system
  83485. * @param directionToUpdate is the direction vector to update with the result
  83486. * @param particle is the particle we are computed the direction for
  83487. */
  83488. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83489. /**
  83490. * Clones the current emitter and returns a copy of it
  83491. * @returns the new emitter
  83492. */
  83493. clone(): CylinderDirectedParticleEmitter;
  83494. /**
  83495. * Called by the GPUParticleSystem to setup the update shader
  83496. * @param effect defines the update shader
  83497. */
  83498. applyToShader(effect: Effect): void;
  83499. /**
  83500. * Returns a string to use to update the GPU particles update shader
  83501. * @returns a string containng the defines string
  83502. */
  83503. getEffectDefines(): string;
  83504. /**
  83505. * Returns the string "CylinderDirectedParticleEmitter"
  83506. * @returns a string containing the class name
  83507. */
  83508. getClassName(): string;
  83509. /**
  83510. * Serializes the particle system to a JSON object.
  83511. * @returns the JSON object
  83512. */
  83513. serialize(): any;
  83514. /**
  83515. * Parse properties from a JSON object
  83516. * @param serializationObject defines the JSON object
  83517. */
  83518. parse(serializationObject: any): void;
  83519. }
  83520. }
  83521. declare module BABYLON {
  83522. /**
  83523. * Particle emitter emitting particles from the inside of a hemisphere.
  83524. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83525. */
  83526. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83527. /**
  83528. * The radius of the emission hemisphere.
  83529. */
  83530. radius: number;
  83531. /**
  83532. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83533. */
  83534. radiusRange: number;
  83535. /**
  83536. * How much to randomize the particle direction [0-1].
  83537. */
  83538. directionRandomizer: number;
  83539. /**
  83540. * Creates a new instance HemisphericParticleEmitter
  83541. * @param radius the radius of the emission hemisphere (1 by default)
  83542. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83543. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83544. */
  83545. constructor(
  83546. /**
  83547. * The radius of the emission hemisphere.
  83548. */
  83549. radius?: number,
  83550. /**
  83551. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83552. */
  83553. radiusRange?: number,
  83554. /**
  83555. * How much to randomize the particle direction [0-1].
  83556. */
  83557. directionRandomizer?: number);
  83558. /**
  83559. * Called by the particle System when the direction is computed for the created particle.
  83560. * @param worldMatrix is the world matrix of the particle system
  83561. * @param directionToUpdate is the direction vector to update with the result
  83562. * @param particle is the particle we are computed the direction for
  83563. */
  83564. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83565. /**
  83566. * Called by the particle System when the position is computed for the created particle.
  83567. * @param worldMatrix is the world matrix of the particle system
  83568. * @param positionToUpdate is the position vector to update with the result
  83569. * @param particle is the particle we are computed the position for
  83570. */
  83571. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83572. /**
  83573. * Clones the current emitter and returns a copy of it
  83574. * @returns the new emitter
  83575. */
  83576. clone(): HemisphericParticleEmitter;
  83577. /**
  83578. * Called by the GPUParticleSystem to setup the update shader
  83579. * @param effect defines the update shader
  83580. */
  83581. applyToShader(effect: Effect): void;
  83582. /**
  83583. * Returns a string to use to update the GPU particles update shader
  83584. * @returns a string containng the defines string
  83585. */
  83586. getEffectDefines(): string;
  83587. /**
  83588. * Returns the string "HemisphericParticleEmitter"
  83589. * @returns a string containing the class name
  83590. */
  83591. getClassName(): string;
  83592. /**
  83593. * Serializes the particle system to a JSON object.
  83594. * @returns the JSON object
  83595. */
  83596. serialize(): any;
  83597. /**
  83598. * Parse properties from a JSON object
  83599. * @param serializationObject defines the JSON object
  83600. */
  83601. parse(serializationObject: any): void;
  83602. }
  83603. }
  83604. declare module BABYLON {
  83605. /**
  83606. * Particle emitter emitting particles from a point.
  83607. * It emits the particles randomly between 2 given directions.
  83608. */
  83609. export class PointParticleEmitter implements IParticleEmitterType {
  83610. /**
  83611. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83612. */
  83613. direction1: Vector3;
  83614. /**
  83615. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83616. */
  83617. direction2: Vector3;
  83618. /**
  83619. * Creates a new instance PointParticleEmitter
  83620. */
  83621. constructor();
  83622. /**
  83623. * Called by the particle System when the direction is computed for the created particle.
  83624. * @param worldMatrix is the world matrix of the particle system
  83625. * @param directionToUpdate is the direction vector to update with the result
  83626. * @param particle is the particle we are computed the direction for
  83627. */
  83628. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83629. /**
  83630. * Called by the particle System when the position is computed for the created particle.
  83631. * @param worldMatrix is the world matrix of the particle system
  83632. * @param positionToUpdate is the position vector to update with the result
  83633. * @param particle is the particle we are computed the position for
  83634. */
  83635. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83636. /**
  83637. * Clones the current emitter and returns a copy of it
  83638. * @returns the new emitter
  83639. */
  83640. clone(): PointParticleEmitter;
  83641. /**
  83642. * Called by the GPUParticleSystem to setup the update shader
  83643. * @param effect defines the update shader
  83644. */
  83645. applyToShader(effect: Effect): void;
  83646. /**
  83647. * Returns a string to use to update the GPU particles update shader
  83648. * @returns a string containng the defines string
  83649. */
  83650. getEffectDefines(): string;
  83651. /**
  83652. * Returns the string "PointParticleEmitter"
  83653. * @returns a string containing the class name
  83654. */
  83655. getClassName(): string;
  83656. /**
  83657. * Serializes the particle system to a JSON object.
  83658. * @returns the JSON object
  83659. */
  83660. serialize(): any;
  83661. /**
  83662. * Parse properties from a JSON object
  83663. * @param serializationObject defines the JSON object
  83664. */
  83665. parse(serializationObject: any): void;
  83666. }
  83667. }
  83668. declare module BABYLON {
  83669. /**
  83670. * Particle emitter emitting particles from the inside of a sphere.
  83671. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83672. */
  83673. export class SphereParticleEmitter implements IParticleEmitterType {
  83674. /**
  83675. * The radius of the emission sphere.
  83676. */
  83677. radius: number;
  83678. /**
  83679. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83680. */
  83681. radiusRange: number;
  83682. /**
  83683. * How much to randomize the particle direction [0-1].
  83684. */
  83685. directionRandomizer: number;
  83686. /**
  83687. * Creates a new instance SphereParticleEmitter
  83688. * @param radius the radius of the emission sphere (1 by default)
  83689. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83690. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83691. */
  83692. constructor(
  83693. /**
  83694. * The radius of the emission sphere.
  83695. */
  83696. radius?: number,
  83697. /**
  83698. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83699. */
  83700. radiusRange?: number,
  83701. /**
  83702. * How much to randomize the particle direction [0-1].
  83703. */
  83704. directionRandomizer?: number);
  83705. /**
  83706. * Called by the particle System when the direction is computed for the created particle.
  83707. * @param worldMatrix is the world matrix of the particle system
  83708. * @param directionToUpdate is the direction vector to update with the result
  83709. * @param particle is the particle we are computed the direction for
  83710. */
  83711. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83712. /**
  83713. * Called by the particle System when the position is computed for the created particle.
  83714. * @param worldMatrix is the world matrix of the particle system
  83715. * @param positionToUpdate is the position vector to update with the result
  83716. * @param particle is the particle we are computed the position for
  83717. */
  83718. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83719. /**
  83720. * Clones the current emitter and returns a copy of it
  83721. * @returns the new emitter
  83722. */
  83723. clone(): SphereParticleEmitter;
  83724. /**
  83725. * Called by the GPUParticleSystem to setup the update shader
  83726. * @param effect defines the update shader
  83727. */
  83728. applyToShader(effect: Effect): void;
  83729. /**
  83730. * Returns a string to use to update the GPU particles update shader
  83731. * @returns a string containng the defines string
  83732. */
  83733. getEffectDefines(): string;
  83734. /**
  83735. * Returns the string "SphereParticleEmitter"
  83736. * @returns a string containing the class name
  83737. */
  83738. getClassName(): string;
  83739. /**
  83740. * Serializes the particle system to a JSON object.
  83741. * @returns the JSON object
  83742. */
  83743. serialize(): any;
  83744. /**
  83745. * Parse properties from a JSON object
  83746. * @param serializationObject defines the JSON object
  83747. */
  83748. parse(serializationObject: any): void;
  83749. }
  83750. /**
  83751. * Particle emitter emitting particles from the inside of a sphere.
  83752. * It emits the particles randomly between two vectors.
  83753. */
  83754. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83755. /**
  83756. * The min limit of the emission direction.
  83757. */
  83758. direction1: Vector3;
  83759. /**
  83760. * The max limit of the emission direction.
  83761. */
  83762. direction2: Vector3;
  83763. /**
  83764. * Creates a new instance SphereDirectedParticleEmitter
  83765. * @param radius the radius of the emission sphere (1 by default)
  83766. * @param direction1 the min limit of the emission direction (up vector by default)
  83767. * @param direction2 the max limit of the emission direction (up vector by default)
  83768. */
  83769. constructor(radius?: number,
  83770. /**
  83771. * The min limit of the emission direction.
  83772. */
  83773. direction1?: Vector3,
  83774. /**
  83775. * The max limit of the emission direction.
  83776. */
  83777. direction2?: Vector3);
  83778. /**
  83779. * Called by the particle System when the direction is computed for the created particle.
  83780. * @param worldMatrix is the world matrix of the particle system
  83781. * @param directionToUpdate is the direction vector to update with the result
  83782. * @param particle is the particle we are computed the direction for
  83783. */
  83784. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83785. /**
  83786. * Clones the current emitter and returns a copy of it
  83787. * @returns the new emitter
  83788. */
  83789. clone(): SphereDirectedParticleEmitter;
  83790. /**
  83791. * Called by the GPUParticleSystem to setup the update shader
  83792. * @param effect defines the update shader
  83793. */
  83794. applyToShader(effect: Effect): void;
  83795. /**
  83796. * Returns a string to use to update the GPU particles update shader
  83797. * @returns a string containng the defines string
  83798. */
  83799. getEffectDefines(): string;
  83800. /**
  83801. * Returns the string "SphereDirectedParticleEmitter"
  83802. * @returns a string containing the class name
  83803. */
  83804. getClassName(): string;
  83805. /**
  83806. * Serializes the particle system to a JSON object.
  83807. * @returns the JSON object
  83808. */
  83809. serialize(): any;
  83810. /**
  83811. * Parse properties from a JSON object
  83812. * @param serializationObject defines the JSON object
  83813. */
  83814. parse(serializationObject: any): void;
  83815. }
  83816. }
  83817. declare module BABYLON {
  83818. /**
  83819. * Interface representing a particle system in Babylon.js.
  83820. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83821. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83822. */
  83823. export interface IParticleSystem {
  83824. /**
  83825. * List of animations used by the particle system.
  83826. */
  83827. animations: Animation[];
  83828. /**
  83829. * The id of the Particle system.
  83830. */
  83831. id: string;
  83832. /**
  83833. * The name of the Particle system.
  83834. */
  83835. name: string;
  83836. /**
  83837. * The emitter represents the Mesh or position we are attaching the particle system to.
  83838. */
  83839. emitter: Nullable<AbstractMesh | Vector3>;
  83840. /**
  83841. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83842. */
  83843. isBillboardBased: boolean;
  83844. /**
  83845. * The rendering group used by the Particle system to chose when to render.
  83846. */
  83847. renderingGroupId: number;
  83848. /**
  83849. * The layer mask we are rendering the particles through.
  83850. */
  83851. layerMask: number;
  83852. /**
  83853. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83854. */
  83855. updateSpeed: number;
  83856. /**
  83857. * The amount of time the particle system is running (depends of the overall update speed).
  83858. */
  83859. targetStopDuration: number;
  83860. /**
  83861. * The texture used to render each particle. (this can be a spritesheet)
  83862. */
  83863. particleTexture: Nullable<Texture>;
  83864. /**
  83865. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83866. */
  83867. blendMode: number;
  83868. /**
  83869. * Minimum life time of emitting particles.
  83870. */
  83871. minLifeTime: number;
  83872. /**
  83873. * Maximum life time of emitting particles.
  83874. */
  83875. maxLifeTime: number;
  83876. /**
  83877. * Minimum Size of emitting particles.
  83878. */
  83879. minSize: number;
  83880. /**
  83881. * Maximum Size of emitting particles.
  83882. */
  83883. maxSize: number;
  83884. /**
  83885. * Minimum scale of emitting particles on X axis.
  83886. */
  83887. minScaleX: number;
  83888. /**
  83889. * Maximum scale of emitting particles on X axis.
  83890. */
  83891. maxScaleX: number;
  83892. /**
  83893. * Minimum scale of emitting particles on Y axis.
  83894. */
  83895. minScaleY: number;
  83896. /**
  83897. * Maximum scale of emitting particles on Y axis.
  83898. */
  83899. maxScaleY: number;
  83900. /**
  83901. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83902. */
  83903. color1: Color4;
  83904. /**
  83905. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83906. */
  83907. color2: Color4;
  83908. /**
  83909. * Color the particle will have at the end of its lifetime.
  83910. */
  83911. colorDead: Color4;
  83912. /**
  83913. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83914. */
  83915. emitRate: number;
  83916. /**
  83917. * You can use gravity if you want to give an orientation to your particles.
  83918. */
  83919. gravity: Vector3;
  83920. /**
  83921. * Minimum power of emitting particles.
  83922. */
  83923. minEmitPower: number;
  83924. /**
  83925. * Maximum power of emitting particles.
  83926. */
  83927. maxEmitPower: number;
  83928. /**
  83929. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83930. */
  83931. minAngularSpeed: number;
  83932. /**
  83933. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83934. */
  83935. maxAngularSpeed: number;
  83936. /**
  83937. * Gets or sets the minimal initial rotation in radians.
  83938. */
  83939. minInitialRotation: number;
  83940. /**
  83941. * Gets or sets the maximal initial rotation in radians.
  83942. */
  83943. maxInitialRotation: number;
  83944. /**
  83945. * The particle emitter type defines the emitter used by the particle system.
  83946. * It can be for example box, sphere, or cone...
  83947. */
  83948. particleEmitterType: Nullable<IParticleEmitterType>;
  83949. /**
  83950. * Defines the delay in milliseconds before starting the system (0 by default)
  83951. */
  83952. startDelay: number;
  83953. /**
  83954. * 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
  83955. */
  83956. preWarmCycles: number;
  83957. /**
  83958. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83959. */
  83960. preWarmStepOffset: number;
  83961. /**
  83962. * 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)
  83963. */
  83964. spriteCellChangeSpeed: number;
  83965. /**
  83966. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83967. */
  83968. startSpriteCellID: number;
  83969. /**
  83970. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83971. */
  83972. endSpriteCellID: number;
  83973. /**
  83974. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83975. */
  83976. spriteCellWidth: number;
  83977. /**
  83978. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83979. */
  83980. spriteCellHeight: number;
  83981. /**
  83982. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83983. */
  83984. spriteRandomStartCell: boolean;
  83985. /**
  83986. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83987. */
  83988. isAnimationSheetEnabled: boolean;
  83989. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83990. translationPivot: Vector2;
  83991. /**
  83992. * Gets or sets a texture used to add random noise to particle positions
  83993. */
  83994. noiseTexture: Nullable<BaseTexture>;
  83995. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83996. noiseStrength: Vector3;
  83997. /**
  83998. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83999. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84000. */
  84001. billboardMode: number;
  84002. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84003. limitVelocityDamping: number;
  84004. /**
  84005. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84006. */
  84007. beginAnimationOnStart: boolean;
  84008. /**
  84009. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84010. */
  84011. beginAnimationFrom: number;
  84012. /**
  84013. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84014. */
  84015. beginAnimationTo: number;
  84016. /**
  84017. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84018. */
  84019. beginAnimationLoop: boolean;
  84020. /**
  84021. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84022. */
  84023. disposeOnStop: boolean;
  84024. /**
  84025. * Gets the maximum number of particles active at the same time.
  84026. * @returns The max number of active particles.
  84027. */
  84028. getCapacity(): number;
  84029. /**
  84030. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84031. * @returns True if it has been started, otherwise false.
  84032. */
  84033. isStarted(): boolean;
  84034. /**
  84035. * Animates the particle system for this frame.
  84036. */
  84037. animate(): void;
  84038. /**
  84039. * Renders the particle system in its current state.
  84040. * @returns the current number of particles
  84041. */
  84042. render(): number;
  84043. /**
  84044. * Dispose the particle system and frees its associated resources.
  84045. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84046. */
  84047. dispose(disposeTexture?: boolean): void;
  84048. /**
  84049. * Clones the particle system.
  84050. * @param name The name of the cloned object
  84051. * @param newEmitter The new emitter to use
  84052. * @returns the cloned particle system
  84053. */
  84054. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  84055. /**
  84056. * Serializes the particle system to a JSON object.
  84057. * @returns the JSON object
  84058. */
  84059. serialize(): any;
  84060. /**
  84061. * Rebuild the particle system
  84062. */
  84063. rebuild(): void;
  84064. /**
  84065. * Starts the particle system and begins to emit
  84066. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  84067. */
  84068. start(delay?: number): void;
  84069. /**
  84070. * Stops the particle system.
  84071. */
  84072. stop(): void;
  84073. /**
  84074. * Remove all active particles
  84075. */
  84076. reset(): void;
  84077. /**
  84078. * Is this system ready to be used/rendered
  84079. * @return true if the system is ready
  84080. */
  84081. isReady(): boolean;
  84082. /**
  84083. * Adds a new color gradient
  84084. * @param gradient defines the gradient to use (between 0 and 1)
  84085. * @param color1 defines the color to affect to the specified gradient
  84086. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84087. * @returns the current particle system
  84088. */
  84089. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84090. /**
  84091. * Remove a specific color gradient
  84092. * @param gradient defines the gradient to remove
  84093. * @returns the current particle system
  84094. */
  84095. removeColorGradient(gradient: number): IParticleSystem;
  84096. /**
  84097. * Adds a new size gradient
  84098. * @param gradient defines the gradient to use (between 0 and 1)
  84099. * @param factor defines the size factor to affect to the specified gradient
  84100. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84101. * @returns the current particle system
  84102. */
  84103. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84104. /**
  84105. * Remove a specific size gradient
  84106. * @param gradient defines the gradient to remove
  84107. * @returns the current particle system
  84108. */
  84109. removeSizeGradient(gradient: number): IParticleSystem;
  84110. /**
  84111. * Gets the current list of color gradients.
  84112. * You must use addColorGradient and removeColorGradient to udpate this list
  84113. * @returns the list of color gradients
  84114. */
  84115. getColorGradients(): Nullable<Array<ColorGradient>>;
  84116. /**
  84117. * Gets the current list of size gradients.
  84118. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84119. * @returns the list of size gradients
  84120. */
  84121. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84122. /**
  84123. * Gets the current list of angular speed gradients.
  84124. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84125. * @returns the list of angular speed gradients
  84126. */
  84127. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84128. /**
  84129. * Adds a new angular speed gradient
  84130. * @param gradient defines the gradient to use (between 0 and 1)
  84131. * @param factor defines the angular speed to affect to the specified gradient
  84132. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84133. * @returns the current particle system
  84134. */
  84135. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84136. /**
  84137. * Remove a specific angular speed gradient
  84138. * @param gradient defines the gradient to remove
  84139. * @returns the current particle system
  84140. */
  84141. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84142. /**
  84143. * Gets the current list of velocity gradients.
  84144. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84145. * @returns the list of velocity gradients
  84146. */
  84147. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84148. /**
  84149. * Adds a new velocity gradient
  84150. * @param gradient defines the gradient to use (between 0 and 1)
  84151. * @param factor defines the velocity to affect to the specified gradient
  84152. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84153. * @returns the current particle system
  84154. */
  84155. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84156. /**
  84157. * Remove a specific velocity gradient
  84158. * @param gradient defines the gradient to remove
  84159. * @returns the current particle system
  84160. */
  84161. removeVelocityGradient(gradient: number): IParticleSystem;
  84162. /**
  84163. * Gets the current list of limit velocity gradients.
  84164. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84165. * @returns the list of limit velocity gradients
  84166. */
  84167. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84168. /**
  84169. * Adds a new limit velocity gradient
  84170. * @param gradient defines the gradient to use (between 0 and 1)
  84171. * @param factor defines the limit velocity to affect to the specified gradient
  84172. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84173. * @returns the current particle system
  84174. */
  84175. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84176. /**
  84177. * Remove a specific limit velocity gradient
  84178. * @param gradient defines the gradient to remove
  84179. * @returns the current particle system
  84180. */
  84181. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84182. /**
  84183. * Adds a new drag gradient
  84184. * @param gradient defines the gradient to use (between 0 and 1)
  84185. * @param factor defines the drag to affect to the specified gradient
  84186. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84187. * @returns the current particle system
  84188. */
  84189. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84190. /**
  84191. * Remove a specific drag gradient
  84192. * @param gradient defines the gradient to remove
  84193. * @returns the current particle system
  84194. */
  84195. removeDragGradient(gradient: number): IParticleSystem;
  84196. /**
  84197. * Gets the current list of drag gradients.
  84198. * You must use addDragGradient and removeDragGradient to udpate this list
  84199. * @returns the list of drag gradients
  84200. */
  84201. getDragGradients(): Nullable<Array<FactorGradient>>;
  84202. /**
  84203. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84204. * @param gradient defines the gradient to use (between 0 and 1)
  84205. * @param factor defines the emit rate to affect to the specified gradient
  84206. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84207. * @returns the current particle system
  84208. */
  84209. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84210. /**
  84211. * Remove a specific emit rate gradient
  84212. * @param gradient defines the gradient to remove
  84213. * @returns the current particle system
  84214. */
  84215. removeEmitRateGradient(gradient: number): IParticleSystem;
  84216. /**
  84217. * Gets the current list of emit rate gradients.
  84218. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84219. * @returns the list of emit rate gradients
  84220. */
  84221. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84222. /**
  84223. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84224. * @param gradient defines the gradient to use (between 0 and 1)
  84225. * @param factor defines the start size to affect to the specified gradient
  84226. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84227. * @returns the current particle system
  84228. */
  84229. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84230. /**
  84231. * Remove a specific start size gradient
  84232. * @param gradient defines the gradient to remove
  84233. * @returns the current particle system
  84234. */
  84235. removeStartSizeGradient(gradient: number): IParticleSystem;
  84236. /**
  84237. * Gets the current list of start size gradients.
  84238. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84239. * @returns the list of start size gradients
  84240. */
  84241. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84242. /**
  84243. * Adds a new life time gradient
  84244. * @param gradient defines the gradient to use (between 0 and 1)
  84245. * @param factor defines the life time factor to affect to the specified gradient
  84246. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84247. * @returns the current particle system
  84248. */
  84249. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84250. /**
  84251. * Remove a specific life time gradient
  84252. * @param gradient defines the gradient to remove
  84253. * @returns the current particle system
  84254. */
  84255. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84256. /**
  84257. * Gets the current list of life time gradients.
  84258. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84259. * @returns the list of life time gradients
  84260. */
  84261. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84262. /**
  84263. * Gets the current list of color gradients.
  84264. * You must use addColorGradient and removeColorGradient to udpate this list
  84265. * @returns the list of color gradients
  84266. */
  84267. getColorGradients(): Nullable<Array<ColorGradient>>;
  84268. /**
  84269. * Adds a new ramp gradient used to remap particle colors
  84270. * @param gradient defines the gradient to use (between 0 and 1)
  84271. * @param color defines the color to affect to the specified gradient
  84272. * @returns the current particle system
  84273. */
  84274. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  84275. /**
  84276. * Gets the current list of ramp gradients.
  84277. * You must use addRampGradient and removeRampGradient to udpate this list
  84278. * @returns the list of ramp gradients
  84279. */
  84280. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84281. /** Gets or sets a boolean indicating that ramp gradients must be used
  84282. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84283. */
  84284. useRampGradients: boolean;
  84285. /**
  84286. * Adds a new color remap gradient
  84287. * @param gradient defines the gradient to use (between 0 and 1)
  84288. * @param min defines the color remap minimal range
  84289. * @param max defines the color remap maximal range
  84290. * @returns the current particle system
  84291. */
  84292. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84293. /**
  84294. * Gets the current list of color remap gradients.
  84295. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84296. * @returns the list of color remap gradients
  84297. */
  84298. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84299. /**
  84300. * Adds a new alpha remap gradient
  84301. * @param gradient defines the gradient to use (between 0 and 1)
  84302. * @param min defines the alpha remap minimal range
  84303. * @param max defines the alpha remap maximal range
  84304. * @returns the current particle system
  84305. */
  84306. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84307. /**
  84308. * Gets the current list of alpha remap gradients.
  84309. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84310. * @returns the list of alpha remap gradients
  84311. */
  84312. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84313. /**
  84314. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84315. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84316. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84317. * @returns the emitter
  84318. */
  84319. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84320. /**
  84321. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84322. * @param radius The radius of the hemisphere to emit from
  84323. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84324. * @returns the emitter
  84325. */
  84326. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  84327. /**
  84328. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84329. * @param radius The radius of the sphere to emit from
  84330. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84331. * @returns the emitter
  84332. */
  84333. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  84334. /**
  84335. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84336. * @param radius The radius of the sphere to emit from
  84337. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84338. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84339. * @returns the emitter
  84340. */
  84341. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84342. /**
  84343. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84344. * @param radius The radius of the emission cylinder
  84345. * @param height The height of the emission cylinder
  84346. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84347. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84348. * @returns the emitter
  84349. */
  84350. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  84351. /**
  84352. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84353. * @param radius The radius of the cylinder to emit from
  84354. * @param height The height of the emission cylinder
  84355. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84356. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84357. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84358. * @returns the emitter
  84359. */
  84360. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84361. /**
  84362. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84363. * @param radius The radius of the cone to emit from
  84364. * @param angle The base angle of the cone
  84365. * @returns the emitter
  84366. */
  84367. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  84368. /**
  84369. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84370. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84371. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84372. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84373. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84374. * @returns the emitter
  84375. */
  84376. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84377. /**
  84378. * Get hosting scene
  84379. * @returns the scene
  84380. */
  84381. getScene(): Scene;
  84382. }
  84383. }
  84384. declare module BABYLON {
  84385. /**
  84386. * Creates an instance based on a source mesh.
  84387. */
  84388. export class InstancedMesh extends AbstractMesh {
  84389. private _sourceMesh;
  84390. private _currentLOD;
  84391. /** @hidden */
  84392. _indexInSourceMeshInstanceArray: number;
  84393. constructor(name: string, source: Mesh);
  84394. /**
  84395. * Returns the string "InstancedMesh".
  84396. */
  84397. getClassName(): string;
  84398. /** Gets the list of lights affecting that mesh */
  84399. readonly lightSources: Light[];
  84400. _resyncLightSources(): void;
  84401. _resyncLighSource(light: Light): void;
  84402. _removeLightSource(light: Light, dispose: boolean): void;
  84403. /**
  84404. * If the source mesh receives shadows
  84405. */
  84406. readonly receiveShadows: boolean;
  84407. /**
  84408. * The material of the source mesh
  84409. */
  84410. readonly material: Nullable<Material>;
  84411. /**
  84412. * Visibility of the source mesh
  84413. */
  84414. readonly visibility: number;
  84415. /**
  84416. * Skeleton of the source mesh
  84417. */
  84418. readonly skeleton: Nullable<Skeleton>;
  84419. /**
  84420. * Rendering ground id of the source mesh
  84421. */
  84422. renderingGroupId: number;
  84423. /**
  84424. * Returns the total number of vertices (integer).
  84425. */
  84426. getTotalVertices(): number;
  84427. /**
  84428. * Returns a positive integer : the total number of indices in this mesh geometry.
  84429. * @returns the numner of indices or zero if the mesh has no geometry.
  84430. */
  84431. getTotalIndices(): number;
  84432. /**
  84433. * The source mesh of the instance
  84434. */
  84435. readonly sourceMesh: Mesh;
  84436. /**
  84437. * Is this node ready to be used/rendered
  84438. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84439. * @return {boolean} is it ready
  84440. */
  84441. isReady(completeCheck?: boolean): boolean;
  84442. /**
  84443. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84444. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  84445. * @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.
  84446. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  84447. */
  84448. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  84449. /**
  84450. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84451. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84452. * The `data` are either a numeric array either a Float32Array.
  84453. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  84454. * 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).
  84455. * Note that a new underlying VertexBuffer object is created each call.
  84456. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84457. *
  84458. * Possible `kind` values :
  84459. * - VertexBuffer.PositionKind
  84460. * - VertexBuffer.UVKind
  84461. * - VertexBuffer.UV2Kind
  84462. * - VertexBuffer.UV3Kind
  84463. * - VertexBuffer.UV4Kind
  84464. * - VertexBuffer.UV5Kind
  84465. * - VertexBuffer.UV6Kind
  84466. * - VertexBuffer.ColorKind
  84467. * - VertexBuffer.MatricesIndicesKind
  84468. * - VertexBuffer.MatricesIndicesExtraKind
  84469. * - VertexBuffer.MatricesWeightsKind
  84470. * - VertexBuffer.MatricesWeightsExtraKind
  84471. *
  84472. * Returns the Mesh.
  84473. */
  84474. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84475. /**
  84476. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84477. * If the mesh has no geometry, it is simply returned as it is.
  84478. * The `data` are either a numeric array either a Float32Array.
  84479. * No new underlying VertexBuffer object is created.
  84480. * 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.
  84481. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  84482. *
  84483. * Possible `kind` values :
  84484. * - VertexBuffer.PositionKind
  84485. * - VertexBuffer.UVKind
  84486. * - VertexBuffer.UV2Kind
  84487. * - VertexBuffer.UV3Kind
  84488. * - VertexBuffer.UV4Kind
  84489. * - VertexBuffer.UV5Kind
  84490. * - VertexBuffer.UV6Kind
  84491. * - VertexBuffer.ColorKind
  84492. * - VertexBuffer.MatricesIndicesKind
  84493. * - VertexBuffer.MatricesIndicesExtraKind
  84494. * - VertexBuffer.MatricesWeightsKind
  84495. * - VertexBuffer.MatricesWeightsExtraKind
  84496. *
  84497. * Returns the Mesh.
  84498. */
  84499. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  84500. /**
  84501. * Sets the mesh indices.
  84502. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  84503. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84504. * This method creates a new index buffer each call.
  84505. * Returns the Mesh.
  84506. */
  84507. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  84508. /**
  84509. * Boolean : True if the mesh owns the requested kind of data.
  84510. */
  84511. isVerticesDataPresent(kind: string): boolean;
  84512. /**
  84513. * Returns an array of indices (IndicesArray).
  84514. */
  84515. getIndices(): Nullable<IndicesArray>;
  84516. readonly _positions: Nullable<Vector3[]>;
  84517. /**
  84518. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84519. * This means the mesh underlying bounding box and sphere are recomputed.
  84520. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84521. * @returns the current mesh
  84522. */
  84523. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  84524. /** @hidden */
  84525. _preActivate(): InstancedMesh;
  84526. /** @hidden */
  84527. _activate(renderId: number, intermediateRendering: boolean): boolean;
  84528. /** @hidden */
  84529. _postActivate(): void;
  84530. getWorldMatrix(): Matrix;
  84531. readonly isAnInstance: boolean;
  84532. /**
  84533. * Returns the current associated LOD AbstractMesh.
  84534. */
  84535. getLOD(camera: Camera): AbstractMesh;
  84536. /** @hidden */
  84537. _syncSubMeshes(): InstancedMesh;
  84538. /** @hidden */
  84539. _generatePointsArray(): boolean;
  84540. /**
  84541. * Creates a new InstancedMesh from the current mesh.
  84542. * - name (string) : the cloned mesh name
  84543. * - newParent (optional Node) : the optional Node to parent the clone to.
  84544. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  84545. *
  84546. * Returns the clone.
  84547. */
  84548. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84549. /**
  84550. * Disposes the InstancedMesh.
  84551. * Returns nothing.
  84552. */
  84553. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84554. }
  84555. }
  84556. declare module BABYLON {
  84557. /**
  84558. * Defines the options associated with the creation of a shader material.
  84559. */
  84560. export interface IShaderMaterialOptions {
  84561. /**
  84562. * Does the material work in alpha blend mode
  84563. */
  84564. needAlphaBlending: boolean;
  84565. /**
  84566. * Does the material work in alpha test mode
  84567. */
  84568. needAlphaTesting: boolean;
  84569. /**
  84570. * The list of attribute names used in the shader
  84571. */
  84572. attributes: string[];
  84573. /**
  84574. * The list of unifrom names used in the shader
  84575. */
  84576. uniforms: string[];
  84577. /**
  84578. * The list of UBO names used in the shader
  84579. */
  84580. uniformBuffers: string[];
  84581. /**
  84582. * The list of sampler names used in the shader
  84583. */
  84584. samplers: string[];
  84585. /**
  84586. * The list of defines used in the shader
  84587. */
  84588. defines: string[];
  84589. }
  84590. /**
  84591. * 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.
  84592. *
  84593. * This returned material effects how the mesh will look based on the code in the shaders.
  84594. *
  84595. * @see http://doc.babylonjs.com/how_to/shader_material
  84596. */
  84597. export class ShaderMaterial extends Material {
  84598. private _shaderPath;
  84599. private _options;
  84600. private _textures;
  84601. private _textureArrays;
  84602. private _floats;
  84603. private _ints;
  84604. private _floatsArrays;
  84605. private _colors3;
  84606. private _colors3Arrays;
  84607. private _colors4;
  84608. private _colors4Arrays;
  84609. private _vectors2;
  84610. private _vectors3;
  84611. private _vectors4;
  84612. private _matrices;
  84613. private _matrices3x3;
  84614. private _matrices2x2;
  84615. private _vectors2Arrays;
  84616. private _vectors3Arrays;
  84617. private _vectors4Arrays;
  84618. private _cachedWorldViewMatrix;
  84619. private _cachedWorldViewProjectionMatrix;
  84620. private _renderId;
  84621. /**
  84622. * Instantiate a new shader material.
  84623. * 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.
  84624. * This returned material effects how the mesh will look based on the code in the shaders.
  84625. * @see http://doc.babylonjs.com/how_to/shader_material
  84626. * @param name Define the name of the material in the scene
  84627. * @param scene Define the scene the material belongs to
  84628. * @param shaderPath Defines the route to the shader code in one of three ways:
  84629. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  84630. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  84631. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  84632. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  84633. * @param options Define the options used to create the shader
  84634. */
  84635. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  84636. /**
  84637. * Gets the options used to compile the shader.
  84638. * They can be modified to trigger a new compilation
  84639. */
  84640. readonly options: IShaderMaterialOptions;
  84641. /**
  84642. * Gets the current class name of the material e.g. "ShaderMaterial"
  84643. * Mainly use in serialization.
  84644. * @returns the class name
  84645. */
  84646. getClassName(): string;
  84647. /**
  84648. * Specifies if the material will require alpha blending
  84649. * @returns a boolean specifying if alpha blending is needed
  84650. */
  84651. needAlphaBlending(): boolean;
  84652. /**
  84653. * Specifies if this material should be rendered in alpha test mode
  84654. * @returns a boolean specifying if an alpha test is needed.
  84655. */
  84656. needAlphaTesting(): boolean;
  84657. private _checkUniform;
  84658. /**
  84659. * Set a texture in the shader.
  84660. * @param name Define the name of the uniform samplers as defined in the shader
  84661. * @param texture Define the texture to bind to this sampler
  84662. * @return the material itself allowing "fluent" like uniform updates
  84663. */
  84664. setTexture(name: string, texture: Texture): ShaderMaterial;
  84665. /**
  84666. * Set a texture array in the shader.
  84667. * @param name Define the name of the uniform sampler array as defined in the shader
  84668. * @param textures Define the list of textures to bind to this sampler
  84669. * @return the material itself allowing "fluent" like uniform updates
  84670. */
  84671. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  84672. /**
  84673. * Set a float in the shader.
  84674. * @param name Define the name of the uniform as defined in the shader
  84675. * @param value Define the value to give to the uniform
  84676. * @return the material itself allowing "fluent" like uniform updates
  84677. */
  84678. setFloat(name: string, value: number): ShaderMaterial;
  84679. /**
  84680. * Set a int in the shader.
  84681. * @param name Define the name of the uniform as defined in the shader
  84682. * @param value Define the value to give to the uniform
  84683. * @return the material itself allowing "fluent" like uniform updates
  84684. */
  84685. setInt(name: string, value: number): ShaderMaterial;
  84686. /**
  84687. * Set an array of floats in the shader.
  84688. * @param name Define the name of the uniform as defined in the shader
  84689. * @param value Define the value to give to the uniform
  84690. * @return the material itself allowing "fluent" like uniform updates
  84691. */
  84692. setFloats(name: string, value: number[]): ShaderMaterial;
  84693. /**
  84694. * Set a vec3 in the shader from a Color3.
  84695. * @param name Define the name of the uniform as defined in the shader
  84696. * @param value Define the value to give to the uniform
  84697. * @return the material itself allowing "fluent" like uniform updates
  84698. */
  84699. setColor3(name: string, value: Color3): ShaderMaterial;
  84700. /**
  84701. * Set a vec3 array in the shader from a Color3 array.
  84702. * @param name Define the name of the uniform as defined in the shader
  84703. * @param value Define the value to give to the uniform
  84704. * @return the material itself allowing "fluent" like uniform updates
  84705. */
  84706. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  84707. /**
  84708. * Set a vec4 in the shader from a Color4.
  84709. * @param name Define the name of the uniform as defined in the shader
  84710. * @param value Define the value to give to the uniform
  84711. * @return the material itself allowing "fluent" like uniform updates
  84712. */
  84713. setColor4(name: string, value: Color4): ShaderMaterial;
  84714. /**
  84715. * Set a vec4 array in the shader from a Color4 array.
  84716. * @param name Define the name of the uniform as defined in the shader
  84717. * @param value Define the value to give to the uniform
  84718. * @return the material itself allowing "fluent" like uniform updates
  84719. */
  84720. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  84721. /**
  84722. * Set a vec2 in the shader from a Vector2.
  84723. * @param name Define the name of the uniform as defined in the shader
  84724. * @param value Define the value to give to the uniform
  84725. * @return the material itself allowing "fluent" like uniform updates
  84726. */
  84727. setVector2(name: string, value: Vector2): ShaderMaterial;
  84728. /**
  84729. * Set a vec3 in the shader from a Vector3.
  84730. * @param name Define the name of the uniform as defined in the shader
  84731. * @param value Define the value to give to the uniform
  84732. * @return the material itself allowing "fluent" like uniform updates
  84733. */
  84734. setVector3(name: string, value: Vector3): ShaderMaterial;
  84735. /**
  84736. * Set a vec4 in the shader from a Vector4.
  84737. * @param name Define the name of the uniform as defined in the shader
  84738. * @param value Define the value to give to the uniform
  84739. * @return the material itself allowing "fluent" like uniform updates
  84740. */
  84741. setVector4(name: string, value: Vector4): ShaderMaterial;
  84742. /**
  84743. * Set a mat4 in the shader from a Matrix.
  84744. * @param name Define the name of the uniform as defined in the shader
  84745. * @param value Define the value to give to the uniform
  84746. * @return the material itself allowing "fluent" like uniform updates
  84747. */
  84748. setMatrix(name: string, value: Matrix): ShaderMaterial;
  84749. /**
  84750. * Set a mat3 in the shader from a Float32Array.
  84751. * @param name Define the name of the uniform as defined in the shader
  84752. * @param value Define the value to give to the uniform
  84753. * @return the material itself allowing "fluent" like uniform updates
  84754. */
  84755. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  84756. /**
  84757. * Set a mat2 in the shader from a Float32Array.
  84758. * @param name Define the name of the uniform as defined in the shader
  84759. * @param value Define the value to give to the uniform
  84760. * @return the material itself allowing "fluent" like uniform updates
  84761. */
  84762. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  84763. /**
  84764. * Set a vec2 array in the shader from a number array.
  84765. * @param name Define the name of the uniform as defined in the shader
  84766. * @param value Define the value to give to the uniform
  84767. * @return the material itself allowing "fluent" like uniform updates
  84768. */
  84769. setArray2(name: string, value: number[]): ShaderMaterial;
  84770. /**
  84771. * Set a vec3 array in the shader from a number array.
  84772. * @param name Define the name of the uniform as defined in the shader
  84773. * @param value Define the value to give to the uniform
  84774. * @return the material itself allowing "fluent" like uniform updates
  84775. */
  84776. setArray3(name: string, value: number[]): ShaderMaterial;
  84777. /**
  84778. * Set a vec4 array in the shader from a number array.
  84779. * @param name Define the name of the uniform as defined in the shader
  84780. * @param value Define the value to give to the uniform
  84781. * @return the material itself allowing "fluent" like uniform updates
  84782. */
  84783. setArray4(name: string, value: number[]): ShaderMaterial;
  84784. private _checkCache;
  84785. /**
  84786. * Specifies that the submesh is ready to be used
  84787. * @param mesh defines the mesh to check
  84788. * @param subMesh defines which submesh to check
  84789. * @param useInstances specifies that instances should be used
  84790. * @returns a boolean indicating that the submesh is ready or not
  84791. */
  84792. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84793. /**
  84794. * Checks if the material is ready to render the requested mesh
  84795. * @param mesh Define the mesh to render
  84796. * @param useInstances Define whether or not the material is used with instances
  84797. * @returns true if ready, otherwise false
  84798. */
  84799. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84800. /**
  84801. * Binds the world matrix to the material
  84802. * @param world defines the world transformation matrix
  84803. */
  84804. bindOnlyWorldMatrix(world: Matrix): void;
  84805. /**
  84806. * Binds the material to the mesh
  84807. * @param world defines the world transformation matrix
  84808. * @param mesh defines the mesh to bind the material to
  84809. */
  84810. bind(world: Matrix, mesh?: Mesh): void;
  84811. /**
  84812. * Gets the active textures from the material
  84813. * @returns an array of textures
  84814. */
  84815. getActiveTextures(): BaseTexture[];
  84816. /**
  84817. * Specifies if the material uses a texture
  84818. * @param texture defines the texture to check against the material
  84819. * @returns a boolean specifying if the material uses the texture
  84820. */
  84821. hasTexture(texture: BaseTexture): boolean;
  84822. /**
  84823. * Makes a duplicate of the material, and gives it a new name
  84824. * @param name defines the new name for the duplicated material
  84825. * @returns the cloned material
  84826. */
  84827. clone(name: string): ShaderMaterial;
  84828. /**
  84829. * Disposes the material
  84830. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84831. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84832. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84833. */
  84834. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84835. /**
  84836. * Serializes this material in a JSON representation
  84837. * @returns the serialized material object
  84838. */
  84839. serialize(): any;
  84840. /**
  84841. * Creates a shader material from parsed shader material data
  84842. * @param source defines the JSON represnetation of the material
  84843. * @param scene defines the hosting scene
  84844. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84845. * @returns a new material
  84846. */
  84847. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  84848. }
  84849. }
  84850. declare module BABYLON {
  84851. /** @hidden */
  84852. export var colorPixelShader: {
  84853. name: string;
  84854. shader: string;
  84855. };
  84856. }
  84857. declare module BABYLON {
  84858. /** @hidden */
  84859. export var colorVertexShader: {
  84860. name: string;
  84861. shader: string;
  84862. };
  84863. }
  84864. declare module BABYLON {
  84865. /**
  84866. * Line mesh
  84867. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  84868. */
  84869. export class LinesMesh extends Mesh {
  84870. /**
  84871. * If vertex color should be applied to the mesh
  84872. */
  84873. readonly useVertexColor?: boolean | undefined;
  84874. /**
  84875. * If vertex alpha should be applied to the mesh
  84876. */
  84877. readonly useVertexAlpha?: boolean | undefined;
  84878. /**
  84879. * Color of the line (Default: White)
  84880. */
  84881. color: Color3;
  84882. /**
  84883. * Alpha of the line (Default: 1)
  84884. */
  84885. alpha: number;
  84886. /**
  84887. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  84888. * This margin is expressed in world space coordinates, so its value may vary.
  84889. * Default value is 0.1
  84890. */
  84891. intersectionThreshold: number;
  84892. private _colorShader;
  84893. private color4;
  84894. /**
  84895. * Creates a new LinesMesh
  84896. * @param name defines the name
  84897. * @param scene defines the hosting scene
  84898. * @param parent defines the parent mesh if any
  84899. * @param source defines the optional source LinesMesh used to clone data from
  84900. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  84901. * When false, achieved by calling a clone(), also passing False.
  84902. * This will make creation of children, recursive.
  84903. * @param useVertexColor defines if this LinesMesh supports vertex color
  84904. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  84905. */
  84906. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  84907. /**
  84908. * If vertex color should be applied to the mesh
  84909. */
  84910. useVertexColor?: boolean | undefined,
  84911. /**
  84912. * If vertex alpha should be applied to the mesh
  84913. */
  84914. useVertexAlpha?: boolean | undefined);
  84915. private _addClipPlaneDefine;
  84916. private _removeClipPlaneDefine;
  84917. isReady(): boolean;
  84918. /**
  84919. * Returns the string "LineMesh"
  84920. */
  84921. getClassName(): string;
  84922. /**
  84923. * @hidden
  84924. */
  84925. /**
  84926. * @hidden
  84927. */
  84928. material: Material;
  84929. /**
  84930. * @hidden
  84931. */
  84932. readonly checkCollisions: boolean;
  84933. /** @hidden */
  84934. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  84935. /** @hidden */
  84936. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  84937. /**
  84938. * Disposes of the line mesh
  84939. * @param doNotRecurse If children should be disposed
  84940. */
  84941. dispose(doNotRecurse?: boolean): void;
  84942. /**
  84943. * Returns a new LineMesh object cloned from the current one.
  84944. */
  84945. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84946. /**
  84947. * Creates a new InstancedLinesMesh object from the mesh model.
  84948. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  84949. * @param name defines the name of the new instance
  84950. * @returns a new InstancedLinesMesh
  84951. */
  84952. createInstance(name: string): InstancedLinesMesh;
  84953. }
  84954. /**
  84955. * Creates an instance based on a source LinesMesh
  84956. */
  84957. export class InstancedLinesMesh extends InstancedMesh {
  84958. /**
  84959. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  84960. * This margin is expressed in world space coordinates, so its value may vary.
  84961. * Initilized with the intersectionThreshold value of the source LinesMesh
  84962. */
  84963. intersectionThreshold: number;
  84964. constructor(name: string, source: LinesMesh);
  84965. /**
  84966. * Returns the string "InstancedLinesMesh".
  84967. */
  84968. getClassName(): string;
  84969. }
  84970. }
  84971. declare module BABYLON {
  84972. /** @hidden */
  84973. export var linePixelShader: {
  84974. name: string;
  84975. shader: string;
  84976. };
  84977. }
  84978. declare module BABYLON {
  84979. /** @hidden */
  84980. export var lineVertexShader: {
  84981. name: string;
  84982. shader: string;
  84983. };
  84984. }
  84985. declare module BABYLON {
  84986. interface AbstractMesh {
  84987. /**
  84988. * Gets the edgesRenderer associated with the mesh
  84989. */
  84990. edgesRenderer: Nullable<EdgesRenderer>;
  84991. }
  84992. interface LinesMesh {
  84993. /**
  84994. * Enables the edge rendering mode on the mesh.
  84995. * This mode makes the mesh edges visible
  84996. * @param epsilon defines the maximal distance between two angles to detect a face
  84997. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  84998. * @returns the currentAbstractMesh
  84999. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85000. */
  85001. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  85002. }
  85003. interface InstancedLinesMesh {
  85004. /**
  85005. * Enables the edge rendering mode on the mesh.
  85006. * This mode makes the mesh edges visible
  85007. * @param epsilon defines the maximal distance between two angles to detect a face
  85008. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85009. * @returns the current InstancedLinesMesh
  85010. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85011. */
  85012. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  85013. }
  85014. /**
  85015. * Defines the minimum contract an Edges renderer should follow.
  85016. */
  85017. export interface IEdgesRenderer extends IDisposable {
  85018. /**
  85019. * Gets or sets a boolean indicating if the edgesRenderer is active
  85020. */
  85021. isEnabled: boolean;
  85022. /**
  85023. * Renders the edges of the attached mesh,
  85024. */
  85025. render(): void;
  85026. /**
  85027. * Checks wether or not the edges renderer is ready to render.
  85028. * @return true if ready, otherwise false.
  85029. */
  85030. isReady(): boolean;
  85031. }
  85032. /**
  85033. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  85034. */
  85035. export class EdgesRenderer implements IEdgesRenderer {
  85036. /**
  85037. * Define the size of the edges with an orthographic camera
  85038. */
  85039. edgesWidthScalerForOrthographic: number;
  85040. /**
  85041. * Define the size of the edges with a perspective camera
  85042. */
  85043. edgesWidthScalerForPerspective: number;
  85044. protected _source: AbstractMesh;
  85045. protected _linesPositions: number[];
  85046. protected _linesNormals: number[];
  85047. protected _linesIndices: number[];
  85048. protected _epsilon: number;
  85049. protected _indicesCount: number;
  85050. protected _lineShader: ShaderMaterial;
  85051. protected _ib: DataBuffer;
  85052. protected _buffers: {
  85053. [key: string]: Nullable<VertexBuffer>;
  85054. };
  85055. protected _checkVerticesInsteadOfIndices: boolean;
  85056. private _meshRebuildObserver;
  85057. private _meshDisposeObserver;
  85058. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  85059. isEnabled: boolean;
  85060. /**
  85061. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  85062. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  85063. * @param source Mesh used to create edges
  85064. * @param epsilon sum of angles in adjacency to check for edge
  85065. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  85066. * @param generateEdgesLines - should generate Lines or only prepare resources.
  85067. */
  85068. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  85069. protected _prepareRessources(): void;
  85070. /** @hidden */
  85071. _rebuild(): void;
  85072. /**
  85073. * Releases the required resources for the edges renderer
  85074. */
  85075. dispose(): void;
  85076. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  85077. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  85078. /**
  85079. * Checks if the pair of p0 and p1 is en edge
  85080. * @param faceIndex
  85081. * @param edge
  85082. * @param faceNormals
  85083. * @param p0
  85084. * @param p1
  85085. * @private
  85086. */
  85087. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  85088. /**
  85089. * push line into the position, normal and index buffer
  85090. * @protected
  85091. */
  85092. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  85093. /**
  85094. * Generates lines edges from adjacencjes
  85095. * @private
  85096. */
  85097. _generateEdgesLines(): void;
  85098. /**
  85099. * Checks wether or not the edges renderer is ready to render.
  85100. * @return true if ready, otherwise false.
  85101. */
  85102. isReady(): boolean;
  85103. /**
  85104. * Renders the edges of the attached mesh,
  85105. */
  85106. render(): void;
  85107. }
  85108. /**
  85109. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  85110. */
  85111. export class LineEdgesRenderer extends EdgesRenderer {
  85112. /**
  85113. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  85114. * @param source LineMesh used to generate edges
  85115. * @param epsilon not important (specified angle for edge detection)
  85116. * @param checkVerticesInsteadOfIndices not important for LineMesh
  85117. */
  85118. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  85119. /**
  85120. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  85121. */
  85122. _generateEdgesLines(): void;
  85123. }
  85124. }
  85125. declare module BABYLON {
  85126. /**
  85127. * This represents the object necessary to create a rendering group.
  85128. * This is exclusively used and created by the rendering manager.
  85129. * To modify the behavior, you use the available helpers in your scene or meshes.
  85130. * @hidden
  85131. */
  85132. export class RenderingGroup {
  85133. index: number;
  85134. private static _zeroVector;
  85135. private _scene;
  85136. private _opaqueSubMeshes;
  85137. private _transparentSubMeshes;
  85138. private _alphaTestSubMeshes;
  85139. private _depthOnlySubMeshes;
  85140. private _particleSystems;
  85141. private _spriteManagers;
  85142. private _opaqueSortCompareFn;
  85143. private _alphaTestSortCompareFn;
  85144. private _transparentSortCompareFn;
  85145. private _renderOpaque;
  85146. private _renderAlphaTest;
  85147. private _renderTransparent;
  85148. /** @hidden */
  85149. _edgesRenderers: SmartArray<IEdgesRenderer>;
  85150. onBeforeTransparentRendering: () => void;
  85151. /**
  85152. * Set the opaque sort comparison function.
  85153. * If null the sub meshes will be render in the order they were created
  85154. */
  85155. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85156. /**
  85157. * Set the alpha test sort comparison function.
  85158. * If null the sub meshes will be render in the order they were created
  85159. */
  85160. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85161. /**
  85162. * Set the transparent sort comparison function.
  85163. * If null the sub meshes will be render in the order they were created
  85164. */
  85165. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85166. /**
  85167. * Creates a new rendering group.
  85168. * @param index The rendering group index
  85169. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  85170. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  85171. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  85172. */
  85173. 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>);
  85174. /**
  85175. * Render all the sub meshes contained in the group.
  85176. * @param customRenderFunction Used to override the default render behaviour of the group.
  85177. * @returns true if rendered some submeshes.
  85178. */
  85179. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  85180. /**
  85181. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  85182. * @param subMeshes The submeshes to render
  85183. */
  85184. private renderOpaqueSorted;
  85185. /**
  85186. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  85187. * @param subMeshes The submeshes to render
  85188. */
  85189. private renderAlphaTestSorted;
  85190. /**
  85191. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  85192. * @param subMeshes The submeshes to render
  85193. */
  85194. private renderTransparentSorted;
  85195. /**
  85196. * Renders the submeshes in a specified order.
  85197. * @param subMeshes The submeshes to sort before render
  85198. * @param sortCompareFn The comparison function use to sort
  85199. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  85200. * @param transparent Specifies to activate blending if true
  85201. */
  85202. private static renderSorted;
  85203. /**
  85204. * Renders the submeshes in the order they were dispatched (no sort applied).
  85205. * @param subMeshes The submeshes to render
  85206. */
  85207. private static renderUnsorted;
  85208. /**
  85209. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85210. * are rendered back to front if in the same alpha index.
  85211. *
  85212. * @param a The first submesh
  85213. * @param b The second submesh
  85214. * @returns The result of the comparison
  85215. */
  85216. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  85217. /**
  85218. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85219. * are rendered back to front.
  85220. *
  85221. * @param a The first submesh
  85222. * @param b The second submesh
  85223. * @returns The result of the comparison
  85224. */
  85225. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  85226. /**
  85227. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85228. * are rendered front to back (prevent overdraw).
  85229. *
  85230. * @param a The first submesh
  85231. * @param b The second submesh
  85232. * @returns The result of the comparison
  85233. */
  85234. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  85235. /**
  85236. * Resets the different lists of submeshes to prepare a new frame.
  85237. */
  85238. prepare(): void;
  85239. dispose(): void;
  85240. /**
  85241. * Inserts the submesh in its correct queue depending on its material.
  85242. * @param subMesh The submesh to dispatch
  85243. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85244. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85245. */
  85246. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85247. dispatchSprites(spriteManager: ISpriteManager): void;
  85248. dispatchParticles(particleSystem: IParticleSystem): void;
  85249. private _renderParticles;
  85250. private _renderSprites;
  85251. }
  85252. }
  85253. declare module BABYLON {
  85254. /**
  85255. * Interface describing the different options available in the rendering manager
  85256. * regarding Auto Clear between groups.
  85257. */
  85258. export interface IRenderingManagerAutoClearSetup {
  85259. /**
  85260. * Defines whether or not autoclear is enable.
  85261. */
  85262. autoClear: boolean;
  85263. /**
  85264. * Defines whether or not to autoclear the depth buffer.
  85265. */
  85266. depth: boolean;
  85267. /**
  85268. * Defines whether or not to autoclear the stencil buffer.
  85269. */
  85270. stencil: boolean;
  85271. }
  85272. /**
  85273. * This class is used by the onRenderingGroupObservable
  85274. */
  85275. export class RenderingGroupInfo {
  85276. /**
  85277. * The Scene that being rendered
  85278. */
  85279. scene: Scene;
  85280. /**
  85281. * The camera currently used for the rendering pass
  85282. */
  85283. camera: Nullable<Camera>;
  85284. /**
  85285. * The ID of the renderingGroup being processed
  85286. */
  85287. renderingGroupId: number;
  85288. }
  85289. /**
  85290. * This is the manager responsible of all the rendering for meshes sprites and particles.
  85291. * It is enable to manage the different groups as well as the different necessary sort functions.
  85292. * This should not be used directly aside of the few static configurations
  85293. */
  85294. export class RenderingManager {
  85295. /**
  85296. * The max id used for rendering groups (not included)
  85297. */
  85298. static MAX_RENDERINGGROUPS: number;
  85299. /**
  85300. * The min id used for rendering groups (included)
  85301. */
  85302. static MIN_RENDERINGGROUPS: number;
  85303. /**
  85304. * Used to globally prevent autoclearing scenes.
  85305. */
  85306. static AUTOCLEAR: boolean;
  85307. /**
  85308. * @hidden
  85309. */
  85310. _useSceneAutoClearSetup: boolean;
  85311. private _scene;
  85312. private _renderingGroups;
  85313. private _depthStencilBufferAlreadyCleaned;
  85314. private _autoClearDepthStencil;
  85315. private _customOpaqueSortCompareFn;
  85316. private _customAlphaTestSortCompareFn;
  85317. private _customTransparentSortCompareFn;
  85318. private _renderingGroupInfo;
  85319. /**
  85320. * Instantiates a new rendering group for a particular scene
  85321. * @param scene Defines the scene the groups belongs to
  85322. */
  85323. constructor(scene: Scene);
  85324. private _clearDepthStencilBuffer;
  85325. /**
  85326. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  85327. * @hidden
  85328. */
  85329. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  85330. /**
  85331. * Resets the different information of the group to prepare a new frame
  85332. * @hidden
  85333. */
  85334. reset(): void;
  85335. /**
  85336. * Dispose and release the group and its associated resources.
  85337. * @hidden
  85338. */
  85339. dispose(): void;
  85340. /**
  85341. * Clear the info related to rendering groups preventing retention points during dispose.
  85342. */
  85343. freeRenderingGroups(): void;
  85344. private _prepareRenderingGroup;
  85345. /**
  85346. * Add a sprite manager to the rendering manager in order to render it this frame.
  85347. * @param spriteManager Define the sprite manager to render
  85348. */
  85349. dispatchSprites(spriteManager: ISpriteManager): void;
  85350. /**
  85351. * Add a particle system to the rendering manager in order to render it this frame.
  85352. * @param particleSystem Define the particle system to render
  85353. */
  85354. dispatchParticles(particleSystem: IParticleSystem): void;
  85355. /**
  85356. * Add a submesh to the manager in order to render it this frame
  85357. * @param subMesh The submesh to dispatch
  85358. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85359. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85360. */
  85361. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85362. /**
  85363. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85364. * This allowed control for front to back rendering or reversly depending of the special needs.
  85365. *
  85366. * @param renderingGroupId The rendering group id corresponding to its index
  85367. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85368. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85369. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85370. */
  85371. 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;
  85372. /**
  85373. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85374. *
  85375. * @param renderingGroupId The rendering group id corresponding to its index
  85376. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85377. * @param depth Automatically clears depth between groups if true and autoClear is true.
  85378. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  85379. */
  85380. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  85381. /**
  85382. * Gets the current auto clear configuration for one rendering group of the rendering
  85383. * manager.
  85384. * @param index the rendering group index to get the information for
  85385. * @returns The auto clear setup for the requested rendering group
  85386. */
  85387. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  85388. }
  85389. }
  85390. declare module BABYLON {
  85391. /**
  85392. * This Helps creating a texture that will be created from a camera in your scene.
  85393. * It is basically a dynamic texture that could be used to create special effects for instance.
  85394. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  85395. */
  85396. export class RenderTargetTexture extends Texture {
  85397. isCube: boolean;
  85398. /**
  85399. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  85400. */
  85401. static readonly REFRESHRATE_RENDER_ONCE: number;
  85402. /**
  85403. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  85404. */
  85405. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  85406. /**
  85407. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  85408. * the central point of your effect and can save a lot of performances.
  85409. */
  85410. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  85411. /**
  85412. * Use this predicate to dynamically define the list of mesh you want to render.
  85413. * If set, the renderList property will be overwritten.
  85414. */
  85415. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  85416. private _renderList;
  85417. /**
  85418. * Use this list to define the list of mesh you want to render.
  85419. */
  85420. renderList: Nullable<Array<AbstractMesh>>;
  85421. private _hookArray;
  85422. /**
  85423. * Define if particles should be rendered in your texture.
  85424. */
  85425. renderParticles: boolean;
  85426. /**
  85427. * Define if sprites should be rendered in your texture.
  85428. */
  85429. renderSprites: boolean;
  85430. /**
  85431. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  85432. */
  85433. coordinatesMode: number;
  85434. /**
  85435. * Define the camera used to render the texture.
  85436. */
  85437. activeCamera: Nullable<Camera>;
  85438. /**
  85439. * Override the render function of the texture with your own one.
  85440. */
  85441. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  85442. /**
  85443. * Define if camera post processes should be use while rendering the texture.
  85444. */
  85445. useCameraPostProcesses: boolean;
  85446. /**
  85447. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  85448. */
  85449. ignoreCameraViewport: boolean;
  85450. private _postProcessManager;
  85451. private _postProcesses;
  85452. private _resizeObserver;
  85453. /**
  85454. * An event triggered when the texture is unbind.
  85455. */
  85456. onBeforeBindObservable: Observable<RenderTargetTexture>;
  85457. /**
  85458. * An event triggered when the texture is unbind.
  85459. */
  85460. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  85461. private _onAfterUnbindObserver;
  85462. /**
  85463. * Set a after unbind callback in the texture.
  85464. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  85465. */
  85466. onAfterUnbind: () => void;
  85467. /**
  85468. * An event triggered before rendering the texture
  85469. */
  85470. onBeforeRenderObservable: Observable<number>;
  85471. private _onBeforeRenderObserver;
  85472. /**
  85473. * Set a before render callback in the texture.
  85474. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  85475. */
  85476. onBeforeRender: (faceIndex: number) => void;
  85477. /**
  85478. * An event triggered after rendering the texture
  85479. */
  85480. onAfterRenderObservable: Observable<number>;
  85481. private _onAfterRenderObserver;
  85482. /**
  85483. * Set a after render callback in the texture.
  85484. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  85485. */
  85486. onAfterRender: (faceIndex: number) => void;
  85487. /**
  85488. * An event triggered after the texture clear
  85489. */
  85490. onClearObservable: Observable<Engine>;
  85491. private _onClearObserver;
  85492. /**
  85493. * Set a clear callback in the texture.
  85494. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  85495. */
  85496. onClear: (Engine: Engine) => void;
  85497. /**
  85498. * An event triggered when the texture is resized.
  85499. */
  85500. onResizeObservable: Observable<RenderTargetTexture>;
  85501. /**
  85502. * Define the clear color of the Render Target if it should be different from the scene.
  85503. */
  85504. clearColor: Color4;
  85505. protected _size: number | {
  85506. width: number;
  85507. height: number;
  85508. };
  85509. protected _initialSizeParameter: number | {
  85510. width: number;
  85511. height: number;
  85512. } | {
  85513. ratio: number;
  85514. };
  85515. protected _sizeRatio: Nullable<number>;
  85516. /** @hidden */
  85517. _generateMipMaps: boolean;
  85518. protected _renderingManager: RenderingManager;
  85519. /** @hidden */
  85520. _waitingRenderList: string[];
  85521. protected _doNotChangeAspectRatio: boolean;
  85522. protected _currentRefreshId: number;
  85523. protected _refreshRate: number;
  85524. protected _textureMatrix: Matrix;
  85525. protected _samples: number;
  85526. protected _renderTargetOptions: RenderTargetCreationOptions;
  85527. /**
  85528. * Gets render target creation options that were used.
  85529. */
  85530. readonly renderTargetOptions: RenderTargetCreationOptions;
  85531. protected _engine: Engine;
  85532. protected _onRatioRescale(): void;
  85533. /**
  85534. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  85535. * It must define where the camera used to render the texture is set
  85536. */
  85537. boundingBoxPosition: Vector3;
  85538. private _boundingBoxSize;
  85539. /**
  85540. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  85541. * When defined, the cubemap will switch to local mode
  85542. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85543. * @example https://www.babylonjs-playground.com/#RNASML
  85544. */
  85545. boundingBoxSize: Vector3;
  85546. /**
  85547. * In case the RTT has been created with a depth texture, get the associated
  85548. * depth texture.
  85549. * Otherwise, return null.
  85550. */
  85551. depthStencilTexture: Nullable<InternalTexture>;
  85552. /**
  85553. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  85554. * or used a shadow, depth texture...
  85555. * @param name The friendly name of the texture
  85556. * @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)
  85557. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  85558. * @param generateMipMaps True if mip maps need to be generated after render.
  85559. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  85560. * @param type The type of the buffer in the RTT (int, half float, float...)
  85561. * @param isCube True if a cube texture needs to be created
  85562. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  85563. * @param generateDepthBuffer True to generate a depth buffer
  85564. * @param generateStencilBuffer True to generate a stencil buffer
  85565. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  85566. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  85567. * @param delayAllocation if the texture allocation should be delayed (default: false)
  85568. */
  85569. constructor(name: string, size: number | {
  85570. width: number;
  85571. height: number;
  85572. } | {
  85573. ratio: number;
  85574. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  85575. /**
  85576. * Creates a depth stencil texture.
  85577. * This is only available in WebGL 2 or with the depth texture extension available.
  85578. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  85579. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  85580. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  85581. */
  85582. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  85583. private _processSizeParameter;
  85584. /**
  85585. * Define the number of samples to use in case of MSAA.
  85586. * It defaults to one meaning no MSAA has been enabled.
  85587. */
  85588. samples: number;
  85589. /**
  85590. * Resets the refresh counter of the texture and start bak from scratch.
  85591. * Could be useful to regenerate the texture if it is setup to render only once.
  85592. */
  85593. resetRefreshCounter(): void;
  85594. /**
  85595. * Define the refresh rate of the texture or the rendering frequency.
  85596. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85597. */
  85598. refreshRate: number;
  85599. /**
  85600. * Adds a post process to the render target rendering passes.
  85601. * @param postProcess define the post process to add
  85602. */
  85603. addPostProcess(postProcess: PostProcess): void;
  85604. /**
  85605. * Clear all the post processes attached to the render target
  85606. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  85607. */
  85608. clearPostProcesses(dispose?: boolean): void;
  85609. /**
  85610. * Remove one of the post process from the list of attached post processes to the texture
  85611. * @param postProcess define the post process to remove from the list
  85612. */
  85613. removePostProcess(postProcess: PostProcess): void;
  85614. /** @hidden */
  85615. _shouldRender(): boolean;
  85616. /**
  85617. * Gets the actual render size of the texture.
  85618. * @returns the width of the render size
  85619. */
  85620. getRenderSize(): number;
  85621. /**
  85622. * Gets the actual render width of the texture.
  85623. * @returns the width of the render size
  85624. */
  85625. getRenderWidth(): number;
  85626. /**
  85627. * Gets the actual render height of the texture.
  85628. * @returns the height of the render size
  85629. */
  85630. getRenderHeight(): number;
  85631. /**
  85632. * Get if the texture can be rescaled or not.
  85633. */
  85634. readonly canRescale: boolean;
  85635. /**
  85636. * Resize the texture using a ratio.
  85637. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  85638. */
  85639. scale(ratio: number): void;
  85640. /**
  85641. * Get the texture reflection matrix used to rotate/transform the reflection.
  85642. * @returns the reflection matrix
  85643. */
  85644. getReflectionTextureMatrix(): Matrix;
  85645. /**
  85646. * Resize the texture to a new desired size.
  85647. * Be carrefull as it will recreate all the data in the new texture.
  85648. * @param size Define the new size. It can be:
  85649. * - a number for squared texture,
  85650. * - an object containing { width: number, height: number }
  85651. * - or an object containing a ratio { ratio: number }
  85652. */
  85653. resize(size: number | {
  85654. width: number;
  85655. height: number;
  85656. } | {
  85657. ratio: number;
  85658. }): void;
  85659. /**
  85660. * Renders all the objects from the render list into the texture.
  85661. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  85662. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  85663. */
  85664. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  85665. private _bestReflectionRenderTargetDimension;
  85666. /**
  85667. * @hidden
  85668. * @param faceIndex face index to bind to if this is a cubetexture
  85669. */
  85670. _bindFrameBuffer(faceIndex?: number): void;
  85671. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85672. private renderToTarget;
  85673. /**
  85674. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85675. * This allowed control for front to back rendering or reversly depending of the special needs.
  85676. *
  85677. * @param renderingGroupId The rendering group id corresponding to its index
  85678. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85679. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85680. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85681. */
  85682. 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;
  85683. /**
  85684. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85685. *
  85686. * @param renderingGroupId The rendering group id corresponding to its index
  85687. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85688. */
  85689. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  85690. /**
  85691. * Clones the texture.
  85692. * @returns the cloned texture
  85693. */
  85694. clone(): RenderTargetTexture;
  85695. /**
  85696. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85697. * @returns The JSON representation of the texture
  85698. */
  85699. serialize(): any;
  85700. /**
  85701. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  85702. */
  85703. disposeFramebufferObjects(): void;
  85704. /**
  85705. * Dispose the texture and release its associated resources.
  85706. */
  85707. dispose(): void;
  85708. /** @hidden */
  85709. _rebuild(): void;
  85710. /**
  85711. * Clear the info related to rendering groups preventing retention point in material dispose.
  85712. */
  85713. freeRenderingGroups(): void;
  85714. /**
  85715. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85716. * @returns the view count
  85717. */
  85718. getViewCount(): number;
  85719. }
  85720. }
  85721. declare module BABYLON {
  85722. /**
  85723. * Base class for the main features of a material in Babylon.js
  85724. */
  85725. export class Material implements IAnimatable {
  85726. /**
  85727. * Returns the triangle fill mode
  85728. */
  85729. static readonly TriangleFillMode: number;
  85730. /**
  85731. * Returns the wireframe mode
  85732. */
  85733. static readonly WireFrameFillMode: number;
  85734. /**
  85735. * Returns the point fill mode
  85736. */
  85737. static readonly PointFillMode: number;
  85738. /**
  85739. * Returns the point list draw mode
  85740. */
  85741. static readonly PointListDrawMode: number;
  85742. /**
  85743. * Returns the line list draw mode
  85744. */
  85745. static readonly LineListDrawMode: number;
  85746. /**
  85747. * Returns the line loop draw mode
  85748. */
  85749. static readonly LineLoopDrawMode: number;
  85750. /**
  85751. * Returns the line strip draw mode
  85752. */
  85753. static readonly LineStripDrawMode: number;
  85754. /**
  85755. * Returns the triangle strip draw mode
  85756. */
  85757. static readonly TriangleStripDrawMode: number;
  85758. /**
  85759. * Returns the triangle fan draw mode
  85760. */
  85761. static readonly TriangleFanDrawMode: number;
  85762. /**
  85763. * Stores the clock-wise side orientation
  85764. */
  85765. static readonly ClockWiseSideOrientation: number;
  85766. /**
  85767. * Stores the counter clock-wise side orientation
  85768. */
  85769. static readonly CounterClockWiseSideOrientation: number;
  85770. /**
  85771. * The dirty texture flag value
  85772. */
  85773. static readonly TextureDirtyFlag: number;
  85774. /**
  85775. * The dirty light flag value
  85776. */
  85777. static readonly LightDirtyFlag: number;
  85778. /**
  85779. * The dirty fresnel flag value
  85780. */
  85781. static readonly FresnelDirtyFlag: number;
  85782. /**
  85783. * The dirty attribute flag value
  85784. */
  85785. static readonly AttributesDirtyFlag: number;
  85786. /**
  85787. * The dirty misc flag value
  85788. */
  85789. static readonly MiscDirtyFlag: number;
  85790. /**
  85791. * The all dirty flag value
  85792. */
  85793. static readonly AllDirtyFlag: number;
  85794. /**
  85795. * The ID of the material
  85796. */
  85797. id: string;
  85798. /**
  85799. * Gets or sets the unique id of the material
  85800. */
  85801. uniqueId: number;
  85802. /**
  85803. * The name of the material
  85804. */
  85805. name: string;
  85806. /**
  85807. * Gets or sets user defined metadata
  85808. */
  85809. metadata: any;
  85810. /**
  85811. * For internal use only. Please do not use.
  85812. */
  85813. reservedDataStore: any;
  85814. /**
  85815. * Specifies if the ready state should be checked on each call
  85816. */
  85817. checkReadyOnEveryCall: boolean;
  85818. /**
  85819. * Specifies if the ready state should be checked once
  85820. */
  85821. checkReadyOnlyOnce: boolean;
  85822. /**
  85823. * The state of the material
  85824. */
  85825. state: string;
  85826. /**
  85827. * The alpha value of the material
  85828. */
  85829. protected _alpha: number;
  85830. /**
  85831. * List of inspectable custom properties (used by the Inspector)
  85832. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85833. */
  85834. inspectableCustomProperties: IInspectable[];
  85835. /**
  85836. * Sets the alpha value of the material
  85837. */
  85838. /**
  85839. * Gets the alpha value of the material
  85840. */
  85841. alpha: number;
  85842. /**
  85843. * Specifies if back face culling is enabled
  85844. */
  85845. protected _backFaceCulling: boolean;
  85846. /**
  85847. * Sets the back-face culling state
  85848. */
  85849. /**
  85850. * Gets the back-face culling state
  85851. */
  85852. backFaceCulling: boolean;
  85853. /**
  85854. * Stores the value for side orientation
  85855. */
  85856. sideOrientation: number;
  85857. /**
  85858. * Callback triggered when the material is compiled
  85859. */
  85860. onCompiled: Nullable<(effect: Effect) => void>;
  85861. /**
  85862. * Callback triggered when an error occurs
  85863. */
  85864. onError: Nullable<(effect: Effect, errors: string) => void>;
  85865. /**
  85866. * Callback triggered to get the render target textures
  85867. */
  85868. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  85869. /**
  85870. * Gets a boolean indicating that current material needs to register RTT
  85871. */
  85872. readonly hasRenderTargetTextures: boolean;
  85873. /**
  85874. * Specifies if the material should be serialized
  85875. */
  85876. doNotSerialize: boolean;
  85877. /**
  85878. * @hidden
  85879. */
  85880. _storeEffectOnSubMeshes: boolean;
  85881. /**
  85882. * Stores the animations for the material
  85883. */
  85884. animations: Nullable<Array<Animation>>;
  85885. /**
  85886. * An event triggered when the material is disposed
  85887. */
  85888. onDisposeObservable: Observable<Material>;
  85889. /**
  85890. * An observer which watches for dispose events
  85891. */
  85892. private _onDisposeObserver;
  85893. private _onUnBindObservable;
  85894. /**
  85895. * Called during a dispose event
  85896. */
  85897. onDispose: () => void;
  85898. private _onBindObservable;
  85899. /**
  85900. * An event triggered when the material is bound
  85901. */
  85902. readonly onBindObservable: Observable<AbstractMesh>;
  85903. /**
  85904. * An observer which watches for bind events
  85905. */
  85906. private _onBindObserver;
  85907. /**
  85908. * Called during a bind event
  85909. */
  85910. onBind: (Mesh: AbstractMesh) => void;
  85911. /**
  85912. * An event triggered when the material is unbound
  85913. */
  85914. readonly onUnBindObservable: Observable<Material>;
  85915. /**
  85916. * Stores the value of the alpha mode
  85917. */
  85918. private _alphaMode;
  85919. /**
  85920. * Sets the value of the alpha mode.
  85921. *
  85922. * | Value | Type | Description |
  85923. * | --- | --- | --- |
  85924. * | 0 | ALPHA_DISABLE | |
  85925. * | 1 | ALPHA_ADD | |
  85926. * | 2 | ALPHA_COMBINE | |
  85927. * | 3 | ALPHA_SUBTRACT | |
  85928. * | 4 | ALPHA_MULTIPLY | |
  85929. * | 5 | ALPHA_MAXIMIZED | |
  85930. * | 6 | ALPHA_ONEONE | |
  85931. * | 7 | ALPHA_PREMULTIPLIED | |
  85932. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  85933. * | 9 | ALPHA_INTERPOLATE | |
  85934. * | 10 | ALPHA_SCREENMODE | |
  85935. *
  85936. */
  85937. /**
  85938. * Gets the value of the alpha mode
  85939. */
  85940. alphaMode: number;
  85941. /**
  85942. * Stores the state of the need depth pre-pass value
  85943. */
  85944. private _needDepthPrePass;
  85945. /**
  85946. * Sets the need depth pre-pass value
  85947. */
  85948. /**
  85949. * Gets the depth pre-pass value
  85950. */
  85951. needDepthPrePass: boolean;
  85952. /**
  85953. * Specifies if depth writing should be disabled
  85954. */
  85955. disableDepthWrite: boolean;
  85956. /**
  85957. * Specifies if depth writing should be forced
  85958. */
  85959. forceDepthWrite: boolean;
  85960. /**
  85961. * Specifies if there should be a separate pass for culling
  85962. */
  85963. separateCullingPass: boolean;
  85964. /**
  85965. * Stores the state specifing if fog should be enabled
  85966. */
  85967. private _fogEnabled;
  85968. /**
  85969. * Sets the state for enabling fog
  85970. */
  85971. /**
  85972. * Gets the value of the fog enabled state
  85973. */
  85974. fogEnabled: boolean;
  85975. /**
  85976. * Stores the size of points
  85977. */
  85978. pointSize: number;
  85979. /**
  85980. * Stores the z offset value
  85981. */
  85982. zOffset: number;
  85983. /**
  85984. * Gets a value specifying if wireframe mode is enabled
  85985. */
  85986. /**
  85987. * Sets the state of wireframe mode
  85988. */
  85989. wireframe: boolean;
  85990. /**
  85991. * Gets the value specifying if point clouds are enabled
  85992. */
  85993. /**
  85994. * Sets the state of point cloud mode
  85995. */
  85996. pointsCloud: boolean;
  85997. /**
  85998. * Gets the material fill mode
  85999. */
  86000. /**
  86001. * Sets the material fill mode
  86002. */
  86003. fillMode: number;
  86004. /**
  86005. * @hidden
  86006. * Stores the effects for the material
  86007. */
  86008. _effect: Nullable<Effect>;
  86009. /**
  86010. * @hidden
  86011. * Specifies if the material was previously ready
  86012. */
  86013. _wasPreviouslyReady: boolean;
  86014. /**
  86015. * Specifies if uniform buffers should be used
  86016. */
  86017. private _useUBO;
  86018. /**
  86019. * Stores a reference to the scene
  86020. */
  86021. private _scene;
  86022. /**
  86023. * Stores the fill mode state
  86024. */
  86025. private _fillMode;
  86026. /**
  86027. * Specifies if the depth write state should be cached
  86028. */
  86029. private _cachedDepthWriteState;
  86030. /**
  86031. * Stores the uniform buffer
  86032. */
  86033. protected _uniformBuffer: UniformBuffer;
  86034. /** @hidden */
  86035. _indexInSceneMaterialArray: number;
  86036. /** @hidden */
  86037. meshMap: Nullable<{
  86038. [id: string]: AbstractMesh | undefined;
  86039. }>;
  86040. /**
  86041. * Creates a material instance
  86042. * @param name defines the name of the material
  86043. * @param scene defines the scene to reference
  86044. * @param doNotAdd specifies if the material should be added to the scene
  86045. */
  86046. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  86047. /**
  86048. * Returns a string representation of the current material
  86049. * @param fullDetails defines a boolean indicating which levels of logging is desired
  86050. * @returns a string with material information
  86051. */
  86052. toString(fullDetails?: boolean): string;
  86053. /**
  86054. * Gets the class name of the material
  86055. * @returns a string with the class name of the material
  86056. */
  86057. getClassName(): string;
  86058. /**
  86059. * Specifies if updates for the material been locked
  86060. */
  86061. readonly isFrozen: boolean;
  86062. /**
  86063. * Locks updates for the material
  86064. */
  86065. freeze(): void;
  86066. /**
  86067. * Unlocks updates for the material
  86068. */
  86069. unfreeze(): void;
  86070. /**
  86071. * Specifies if the material is ready to be used
  86072. * @param mesh defines the mesh to check
  86073. * @param useInstances specifies if instances should be used
  86074. * @returns a boolean indicating if the material is ready to be used
  86075. */
  86076. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86077. /**
  86078. * Specifies that the submesh is ready to be used
  86079. * @param mesh defines the mesh to check
  86080. * @param subMesh defines which submesh to check
  86081. * @param useInstances specifies that instances should be used
  86082. * @returns a boolean indicating that the submesh is ready or not
  86083. */
  86084. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86085. /**
  86086. * Returns the material effect
  86087. * @returns the effect associated with the material
  86088. */
  86089. getEffect(): Nullable<Effect>;
  86090. /**
  86091. * Returns the current scene
  86092. * @returns a Scene
  86093. */
  86094. getScene(): Scene;
  86095. /**
  86096. * Specifies if the material will require alpha blending
  86097. * @returns a boolean specifying if alpha blending is needed
  86098. */
  86099. needAlphaBlending(): boolean;
  86100. /**
  86101. * Specifies if the mesh will require alpha blending
  86102. * @param mesh defines the mesh to check
  86103. * @returns a boolean specifying if alpha blending is needed for the mesh
  86104. */
  86105. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  86106. /**
  86107. * Specifies if this material should be rendered in alpha test mode
  86108. * @returns a boolean specifying if an alpha test is needed.
  86109. */
  86110. needAlphaTesting(): boolean;
  86111. /**
  86112. * Gets the texture used for the alpha test
  86113. * @returns the texture to use for alpha testing
  86114. */
  86115. getAlphaTestTexture(): Nullable<BaseTexture>;
  86116. /**
  86117. * Marks the material to indicate that it needs to be re-calculated
  86118. */
  86119. markDirty(): void;
  86120. /** @hidden */
  86121. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  86122. /**
  86123. * Binds the material to the mesh
  86124. * @param world defines the world transformation matrix
  86125. * @param mesh defines the mesh to bind the material to
  86126. */
  86127. bind(world: Matrix, mesh?: Mesh): void;
  86128. /**
  86129. * Binds the submesh to the material
  86130. * @param world defines the world transformation matrix
  86131. * @param mesh defines the mesh containing the submesh
  86132. * @param subMesh defines the submesh to bind the material to
  86133. */
  86134. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  86135. /**
  86136. * Binds the world matrix to the material
  86137. * @param world defines the world transformation matrix
  86138. */
  86139. bindOnlyWorldMatrix(world: Matrix): void;
  86140. /**
  86141. * Binds the scene's uniform buffer to the effect.
  86142. * @param effect defines the effect to bind to the scene uniform buffer
  86143. * @param sceneUbo defines the uniform buffer storing scene data
  86144. */
  86145. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  86146. /**
  86147. * Binds the view matrix to the effect
  86148. * @param effect defines the effect to bind the view matrix to
  86149. */
  86150. bindView(effect: Effect): void;
  86151. /**
  86152. * Binds the view projection matrix to the effect
  86153. * @param effect defines the effect to bind the view projection matrix to
  86154. */
  86155. bindViewProjection(effect: Effect): void;
  86156. /**
  86157. * Specifies if material alpha testing should be turned on for the mesh
  86158. * @param mesh defines the mesh to check
  86159. */
  86160. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  86161. /**
  86162. * Processes to execute after binding the material to a mesh
  86163. * @param mesh defines the rendered mesh
  86164. */
  86165. protected _afterBind(mesh?: Mesh): void;
  86166. /**
  86167. * Unbinds the material from the mesh
  86168. */
  86169. unbind(): void;
  86170. /**
  86171. * Gets the active textures from the material
  86172. * @returns an array of textures
  86173. */
  86174. getActiveTextures(): BaseTexture[];
  86175. /**
  86176. * Specifies if the material uses a texture
  86177. * @param texture defines the texture to check against the material
  86178. * @returns a boolean specifying if the material uses the texture
  86179. */
  86180. hasTexture(texture: BaseTexture): boolean;
  86181. /**
  86182. * Makes a duplicate of the material, and gives it a new name
  86183. * @param name defines the new name for the duplicated material
  86184. * @returns the cloned material
  86185. */
  86186. clone(name: string): Nullable<Material>;
  86187. /**
  86188. * Gets the meshes bound to the material
  86189. * @returns an array of meshes bound to the material
  86190. */
  86191. getBindedMeshes(): AbstractMesh[];
  86192. /**
  86193. * Force shader compilation
  86194. * @param mesh defines the mesh associated with this material
  86195. * @param onCompiled defines a function to execute once the material is compiled
  86196. * @param options defines the options to configure the compilation
  86197. */
  86198. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  86199. clipPlane: boolean;
  86200. }>): void;
  86201. /**
  86202. * Force shader compilation
  86203. * @param mesh defines the mesh that will use this material
  86204. * @param options defines additional options for compiling the shaders
  86205. * @returns a promise that resolves when the compilation completes
  86206. */
  86207. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  86208. clipPlane: boolean;
  86209. }>): Promise<void>;
  86210. private static readonly _AllDirtyCallBack;
  86211. private static readonly _ImageProcessingDirtyCallBack;
  86212. private static readonly _TextureDirtyCallBack;
  86213. private static readonly _FresnelDirtyCallBack;
  86214. private static readonly _MiscDirtyCallBack;
  86215. private static readonly _LightsDirtyCallBack;
  86216. private static readonly _AttributeDirtyCallBack;
  86217. private static _FresnelAndMiscDirtyCallBack;
  86218. private static _TextureAndMiscDirtyCallBack;
  86219. private static readonly _DirtyCallbackArray;
  86220. private static readonly _RunDirtyCallBacks;
  86221. /**
  86222. * Marks a define in the material to indicate that it needs to be re-computed
  86223. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  86224. */
  86225. markAsDirty(flag: number): void;
  86226. /**
  86227. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  86228. * @param func defines a function which checks material defines against the submeshes
  86229. */
  86230. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  86231. /**
  86232. * Indicates that we need to re-calculated for all submeshes
  86233. */
  86234. protected _markAllSubMeshesAsAllDirty(): void;
  86235. /**
  86236. * Indicates that image processing needs to be re-calculated for all submeshes
  86237. */
  86238. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  86239. /**
  86240. * Indicates that textures need to be re-calculated for all submeshes
  86241. */
  86242. protected _markAllSubMeshesAsTexturesDirty(): void;
  86243. /**
  86244. * Indicates that fresnel needs to be re-calculated for all submeshes
  86245. */
  86246. protected _markAllSubMeshesAsFresnelDirty(): void;
  86247. /**
  86248. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  86249. */
  86250. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  86251. /**
  86252. * Indicates that lights need to be re-calculated for all submeshes
  86253. */
  86254. protected _markAllSubMeshesAsLightsDirty(): void;
  86255. /**
  86256. * Indicates that attributes need to be re-calculated for all submeshes
  86257. */
  86258. protected _markAllSubMeshesAsAttributesDirty(): void;
  86259. /**
  86260. * Indicates that misc needs to be re-calculated for all submeshes
  86261. */
  86262. protected _markAllSubMeshesAsMiscDirty(): void;
  86263. /**
  86264. * Indicates that textures and misc need to be re-calculated for all submeshes
  86265. */
  86266. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  86267. /**
  86268. * Disposes the material
  86269. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86270. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86271. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86272. */
  86273. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86274. /** @hidden */
  86275. private releaseVertexArrayObject;
  86276. /**
  86277. * Serializes this material
  86278. * @returns the serialized material object
  86279. */
  86280. serialize(): any;
  86281. /**
  86282. * Creates a material from parsed material data
  86283. * @param parsedMaterial defines parsed material data
  86284. * @param scene defines the hosting scene
  86285. * @param rootUrl defines the root URL to use to load textures
  86286. * @returns a new material
  86287. */
  86288. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  86289. }
  86290. }
  86291. declare module BABYLON {
  86292. /**
  86293. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86294. * separate meshes. This can be use to improve performances.
  86295. * @see http://doc.babylonjs.com/how_to/multi_materials
  86296. */
  86297. export class MultiMaterial extends Material {
  86298. private _subMaterials;
  86299. /**
  86300. * Gets or Sets the list of Materials used within the multi material.
  86301. * They need to be ordered according to the submeshes order in the associated mesh
  86302. */
  86303. subMaterials: Nullable<Material>[];
  86304. /**
  86305. * Function used to align with Node.getChildren()
  86306. * @returns the list of Materials used within the multi material
  86307. */
  86308. getChildren(): Nullable<Material>[];
  86309. /**
  86310. * Instantiates a new Multi Material
  86311. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86312. * separate meshes. This can be use to improve performances.
  86313. * @see http://doc.babylonjs.com/how_to/multi_materials
  86314. * @param name Define the name in the scene
  86315. * @param scene Define the scene the material belongs to
  86316. */
  86317. constructor(name: string, scene: Scene);
  86318. private _hookArray;
  86319. /**
  86320. * Get one of the submaterial by its index in the submaterials array
  86321. * @param index The index to look the sub material at
  86322. * @returns The Material if the index has been defined
  86323. */
  86324. getSubMaterial(index: number): Nullable<Material>;
  86325. /**
  86326. * Get the list of active textures for the whole sub materials list.
  86327. * @returns All the textures that will be used during the rendering
  86328. */
  86329. getActiveTextures(): BaseTexture[];
  86330. /**
  86331. * Gets the current class name of the material e.g. "MultiMaterial"
  86332. * Mainly use in serialization.
  86333. * @returns the class name
  86334. */
  86335. getClassName(): string;
  86336. /**
  86337. * Checks if the material is ready to render the requested sub mesh
  86338. * @param mesh Define the mesh the submesh belongs to
  86339. * @param subMesh Define the sub mesh to look readyness for
  86340. * @param useInstances Define whether or not the material is used with instances
  86341. * @returns true if ready, otherwise false
  86342. */
  86343. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86344. /**
  86345. * Clones the current material and its related sub materials
  86346. * @param name Define the name of the newly cloned material
  86347. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  86348. * @returns the cloned material
  86349. */
  86350. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  86351. /**
  86352. * Serializes the materials into a JSON representation.
  86353. * @returns the JSON representation
  86354. */
  86355. serialize(): any;
  86356. /**
  86357. * Dispose the material and release its associated resources
  86358. * @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)
  86359. * @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)
  86360. * @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)
  86361. */
  86362. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  86363. /**
  86364. * Creates a MultiMaterial from parsed MultiMaterial data.
  86365. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  86366. * @param scene defines the hosting scene
  86367. * @returns a new MultiMaterial
  86368. */
  86369. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  86370. }
  86371. }
  86372. declare module BABYLON {
  86373. /**
  86374. * Base class for submeshes
  86375. */
  86376. export class BaseSubMesh {
  86377. /** @hidden */
  86378. _materialDefines: Nullable<MaterialDefines>;
  86379. /** @hidden */
  86380. _materialEffect: Nullable<Effect>;
  86381. /**
  86382. * Gets associated effect
  86383. */
  86384. readonly effect: Nullable<Effect>;
  86385. /**
  86386. * Sets associated effect (effect used to render this submesh)
  86387. * @param effect defines the effect to associate with
  86388. * @param defines defines the set of defines used to compile this effect
  86389. */
  86390. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  86391. }
  86392. /**
  86393. * Defines a subdivision inside a mesh
  86394. */
  86395. export class SubMesh extends BaseSubMesh implements ICullable {
  86396. /** the material index to use */
  86397. materialIndex: number;
  86398. /** vertex index start */
  86399. verticesStart: number;
  86400. /** vertices count */
  86401. verticesCount: number;
  86402. /** index start */
  86403. indexStart: number;
  86404. /** indices count */
  86405. indexCount: number;
  86406. /** @hidden */
  86407. _linesIndexCount: number;
  86408. private _mesh;
  86409. private _renderingMesh;
  86410. private _boundingInfo;
  86411. private _linesIndexBuffer;
  86412. /** @hidden */
  86413. _lastColliderWorldVertices: Nullable<Vector3[]>;
  86414. /** @hidden */
  86415. _trianglePlanes: Plane[];
  86416. /** @hidden */
  86417. _lastColliderTransformMatrix: Nullable<Matrix>;
  86418. /** @hidden */
  86419. _renderId: number;
  86420. /** @hidden */
  86421. _alphaIndex: number;
  86422. /** @hidden */
  86423. _distanceToCamera: number;
  86424. /** @hidden */
  86425. _id: number;
  86426. private _currentMaterial;
  86427. /**
  86428. * Add a new submesh to a mesh
  86429. * @param materialIndex defines the material index to use
  86430. * @param verticesStart defines vertex index start
  86431. * @param verticesCount defines vertices count
  86432. * @param indexStart defines index start
  86433. * @param indexCount defines indices count
  86434. * @param mesh defines the parent mesh
  86435. * @param renderingMesh defines an optional rendering mesh
  86436. * @param createBoundingBox defines if bounding box should be created for this submesh
  86437. * @returns the new submesh
  86438. */
  86439. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  86440. /**
  86441. * Creates a new submesh
  86442. * @param materialIndex defines the material index to use
  86443. * @param verticesStart defines vertex index start
  86444. * @param verticesCount defines vertices count
  86445. * @param indexStart defines index start
  86446. * @param indexCount defines indices count
  86447. * @param mesh defines the parent mesh
  86448. * @param renderingMesh defines an optional rendering mesh
  86449. * @param createBoundingBox defines if bounding box should be created for this submesh
  86450. */
  86451. constructor(
  86452. /** the material index to use */
  86453. materialIndex: number,
  86454. /** vertex index start */
  86455. verticesStart: number,
  86456. /** vertices count */
  86457. verticesCount: number,
  86458. /** index start */
  86459. indexStart: number,
  86460. /** indices count */
  86461. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  86462. /**
  86463. * Returns true if this submesh covers the entire parent mesh
  86464. * @ignorenaming
  86465. */
  86466. readonly IsGlobal: boolean;
  86467. /**
  86468. * Returns the submesh BoudingInfo object
  86469. * @returns current bounding info (or mesh's one if the submesh is global)
  86470. */
  86471. getBoundingInfo(): BoundingInfo;
  86472. /**
  86473. * Sets the submesh BoundingInfo
  86474. * @param boundingInfo defines the new bounding info to use
  86475. * @returns the SubMesh
  86476. */
  86477. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  86478. /**
  86479. * Returns the mesh of the current submesh
  86480. * @return the parent mesh
  86481. */
  86482. getMesh(): AbstractMesh;
  86483. /**
  86484. * Returns the rendering mesh of the submesh
  86485. * @returns the rendering mesh (could be different from parent mesh)
  86486. */
  86487. getRenderingMesh(): Mesh;
  86488. /**
  86489. * Returns the submesh material
  86490. * @returns null or the current material
  86491. */
  86492. getMaterial(): Nullable<Material>;
  86493. /**
  86494. * Sets a new updated BoundingInfo object to the submesh
  86495. * @param data defines an optional position array to use to determine the bounding info
  86496. * @returns the SubMesh
  86497. */
  86498. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  86499. /** @hidden */
  86500. _checkCollision(collider: Collider): boolean;
  86501. /**
  86502. * Updates the submesh BoundingInfo
  86503. * @param world defines the world matrix to use to update the bounding info
  86504. * @returns the submesh
  86505. */
  86506. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  86507. /**
  86508. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  86509. * @param frustumPlanes defines the frustum planes
  86510. * @returns true if the submesh is intersecting with the frustum
  86511. */
  86512. isInFrustum(frustumPlanes: Plane[]): boolean;
  86513. /**
  86514. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  86515. * @param frustumPlanes defines the frustum planes
  86516. * @returns true if the submesh is inside the frustum
  86517. */
  86518. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86519. /**
  86520. * Renders the submesh
  86521. * @param enableAlphaMode defines if alpha needs to be used
  86522. * @returns the submesh
  86523. */
  86524. render(enableAlphaMode: boolean): SubMesh;
  86525. /**
  86526. * @hidden
  86527. */
  86528. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  86529. /**
  86530. * Checks if the submesh intersects with a ray
  86531. * @param ray defines the ray to test
  86532. * @returns true is the passed ray intersects the submesh bounding box
  86533. */
  86534. canIntersects(ray: Ray): boolean;
  86535. /**
  86536. * Intersects current submesh with a ray
  86537. * @param ray defines the ray to test
  86538. * @param positions defines mesh's positions array
  86539. * @param indices defines mesh's indices array
  86540. * @param fastCheck defines if only bounding info should be used
  86541. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  86542. * @returns intersection info or null if no intersection
  86543. */
  86544. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  86545. /** @hidden */
  86546. private _intersectLines;
  86547. /** @hidden */
  86548. private _intersectUnIndexedLines;
  86549. /** @hidden */
  86550. private _intersectTriangles;
  86551. /** @hidden */
  86552. private _intersectUnIndexedTriangles;
  86553. /** @hidden */
  86554. _rebuild(): void;
  86555. /**
  86556. * Creates a new submesh from the passed mesh
  86557. * @param newMesh defines the new hosting mesh
  86558. * @param newRenderingMesh defines an optional rendering mesh
  86559. * @returns the new submesh
  86560. */
  86561. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  86562. /**
  86563. * Release associated resources
  86564. */
  86565. dispose(): void;
  86566. /**
  86567. * Gets the class name
  86568. * @returns the string "SubMesh".
  86569. */
  86570. getClassName(): string;
  86571. /**
  86572. * Creates a new submesh from indices data
  86573. * @param materialIndex the index of the main mesh material
  86574. * @param startIndex the index where to start the copy in the mesh indices array
  86575. * @param indexCount the number of indices to copy then from the startIndex
  86576. * @param mesh the main mesh to create the submesh from
  86577. * @param renderingMesh the optional rendering mesh
  86578. * @returns a new submesh
  86579. */
  86580. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  86581. }
  86582. }
  86583. declare module BABYLON {
  86584. /**
  86585. * Class used to represent data loading progression
  86586. */
  86587. export class SceneLoaderFlags {
  86588. private static _ForceFullSceneLoadingForIncremental;
  86589. private static _ShowLoadingScreen;
  86590. private static _CleanBoneMatrixWeights;
  86591. private static _loggingLevel;
  86592. /**
  86593. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  86594. */
  86595. static ForceFullSceneLoadingForIncremental: boolean;
  86596. /**
  86597. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  86598. */
  86599. static ShowLoadingScreen: boolean;
  86600. /**
  86601. * Defines the current logging level (while loading the scene)
  86602. * @ignorenaming
  86603. */
  86604. static loggingLevel: number;
  86605. /**
  86606. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  86607. */
  86608. static CleanBoneMatrixWeights: boolean;
  86609. }
  86610. }
  86611. declare module BABYLON {
  86612. /**
  86613. * Class used to store geometry data (vertex buffers + index buffer)
  86614. */
  86615. export class Geometry implements IGetSetVerticesData {
  86616. /**
  86617. * Gets or sets the ID of the geometry
  86618. */
  86619. id: string;
  86620. /**
  86621. * Gets or sets the unique ID of the geometry
  86622. */
  86623. uniqueId: number;
  86624. /**
  86625. * Gets the delay loading state of the geometry (none by default which means not delayed)
  86626. */
  86627. delayLoadState: number;
  86628. /**
  86629. * Gets the file containing the data to load when running in delay load state
  86630. */
  86631. delayLoadingFile: Nullable<string>;
  86632. /**
  86633. * Callback called when the geometry is updated
  86634. */
  86635. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  86636. private _scene;
  86637. private _engine;
  86638. private _meshes;
  86639. private _totalVertices;
  86640. /** @hidden */
  86641. _indices: IndicesArray;
  86642. /** @hidden */
  86643. _vertexBuffers: {
  86644. [key: string]: VertexBuffer;
  86645. };
  86646. private _isDisposed;
  86647. private _extend;
  86648. private _boundingBias;
  86649. /** @hidden */
  86650. _delayInfo: Array<string>;
  86651. private _indexBuffer;
  86652. private _indexBufferIsUpdatable;
  86653. /** @hidden */
  86654. _boundingInfo: Nullable<BoundingInfo>;
  86655. /** @hidden */
  86656. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  86657. /** @hidden */
  86658. _softwareSkinningFrameId: number;
  86659. private _vertexArrayObjects;
  86660. private _updatable;
  86661. /** @hidden */
  86662. _positions: Nullable<Vector3[]>;
  86663. /**
  86664. * 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
  86665. */
  86666. /**
  86667. * 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
  86668. */
  86669. boundingBias: Vector2;
  86670. /**
  86671. * Static function used to attach a new empty geometry to a mesh
  86672. * @param mesh defines the mesh to attach the geometry to
  86673. * @returns the new Geometry
  86674. */
  86675. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  86676. /**
  86677. * Creates a new geometry
  86678. * @param id defines the unique ID
  86679. * @param scene defines the hosting scene
  86680. * @param vertexData defines the VertexData used to get geometry data
  86681. * @param updatable defines if geometry must be updatable (false by default)
  86682. * @param mesh defines the mesh that will be associated with the geometry
  86683. */
  86684. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  86685. /**
  86686. * Gets the current extend of the geometry
  86687. */
  86688. readonly extend: {
  86689. minimum: Vector3;
  86690. maximum: Vector3;
  86691. };
  86692. /**
  86693. * Gets the hosting scene
  86694. * @returns the hosting Scene
  86695. */
  86696. getScene(): Scene;
  86697. /**
  86698. * Gets the hosting engine
  86699. * @returns the hosting Engine
  86700. */
  86701. getEngine(): Engine;
  86702. /**
  86703. * Defines if the geometry is ready to use
  86704. * @returns true if the geometry is ready to be used
  86705. */
  86706. isReady(): boolean;
  86707. /**
  86708. * Gets a value indicating that the geometry should not be serialized
  86709. */
  86710. readonly doNotSerialize: boolean;
  86711. /** @hidden */
  86712. _rebuild(): void;
  86713. /**
  86714. * Affects all geometry data in one call
  86715. * @param vertexData defines the geometry data
  86716. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  86717. */
  86718. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  86719. /**
  86720. * Set specific vertex data
  86721. * @param kind defines the data kind (Position, normal, etc...)
  86722. * @param data defines the vertex data to use
  86723. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86724. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86725. */
  86726. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  86727. /**
  86728. * Removes a specific vertex data
  86729. * @param kind defines the data kind (Position, normal, etc...)
  86730. */
  86731. removeVerticesData(kind: string): void;
  86732. /**
  86733. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  86734. * @param buffer defines the vertex buffer to use
  86735. * @param totalVertices defines the total number of vertices for position kind (could be null)
  86736. */
  86737. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  86738. /**
  86739. * Update a specific vertex buffer
  86740. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  86741. * It will do nothing if the buffer is not updatable
  86742. * @param kind defines the data kind (Position, normal, etc...)
  86743. * @param data defines the data to use
  86744. * @param offset defines the offset in the target buffer where to store the data
  86745. * @param useBytes set to true if the offset is in bytes
  86746. */
  86747. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  86748. /**
  86749. * Update a specific vertex buffer
  86750. * This function will create a new buffer if the current one is not updatable
  86751. * @param kind defines the data kind (Position, normal, etc...)
  86752. * @param data defines the data to use
  86753. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  86754. */
  86755. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  86756. private _updateBoundingInfo;
  86757. /** @hidden */
  86758. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  86759. /**
  86760. * Gets total number of vertices
  86761. * @returns the total number of vertices
  86762. */
  86763. getTotalVertices(): number;
  86764. /**
  86765. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86766. * @param kind defines the data kind (Position, normal, etc...)
  86767. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86768. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86769. * @returns a float array containing vertex data
  86770. */
  86771. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86772. /**
  86773. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  86774. * @param kind defines the data kind (Position, normal, etc...)
  86775. * @returns true if the vertex buffer with the specified kind is updatable
  86776. */
  86777. isVertexBufferUpdatable(kind: string): boolean;
  86778. /**
  86779. * Gets a specific vertex buffer
  86780. * @param kind defines the data kind (Position, normal, etc...)
  86781. * @returns a VertexBuffer
  86782. */
  86783. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  86784. /**
  86785. * Returns all vertex buffers
  86786. * @return an object holding all vertex buffers indexed by kind
  86787. */
  86788. getVertexBuffers(): Nullable<{
  86789. [key: string]: VertexBuffer;
  86790. }>;
  86791. /**
  86792. * Gets a boolean indicating if specific vertex buffer is present
  86793. * @param kind defines the data kind (Position, normal, etc...)
  86794. * @returns true if data is present
  86795. */
  86796. isVerticesDataPresent(kind: string): boolean;
  86797. /**
  86798. * Gets a list of all attached data kinds (Position, normal, etc...)
  86799. * @returns a list of string containing all kinds
  86800. */
  86801. getVerticesDataKinds(): string[];
  86802. /**
  86803. * Update index buffer
  86804. * @param indices defines the indices to store in the index buffer
  86805. * @param offset defines the offset in the target buffer where to store the data
  86806. * @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)
  86807. */
  86808. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  86809. /**
  86810. * Creates a new index buffer
  86811. * @param indices defines the indices to store in the index buffer
  86812. * @param totalVertices defines the total number of vertices (could be null)
  86813. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86814. */
  86815. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  86816. /**
  86817. * Return the total number of indices
  86818. * @returns the total number of indices
  86819. */
  86820. getTotalIndices(): number;
  86821. /**
  86822. * Gets the index buffer array
  86823. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86824. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86825. * @returns the index buffer array
  86826. */
  86827. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86828. /**
  86829. * Gets the index buffer
  86830. * @return the index buffer
  86831. */
  86832. getIndexBuffer(): Nullable<DataBuffer>;
  86833. /** @hidden */
  86834. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  86835. /**
  86836. * Release the associated resources for a specific mesh
  86837. * @param mesh defines the source mesh
  86838. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  86839. */
  86840. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  86841. /**
  86842. * Apply current geometry to a given mesh
  86843. * @param mesh defines the mesh to apply geometry to
  86844. */
  86845. applyToMesh(mesh: Mesh): void;
  86846. private _updateExtend;
  86847. private _applyToMesh;
  86848. private notifyUpdate;
  86849. /**
  86850. * Load the geometry if it was flagged as delay loaded
  86851. * @param scene defines the hosting scene
  86852. * @param onLoaded defines a callback called when the geometry is loaded
  86853. */
  86854. load(scene: Scene, onLoaded?: () => void): void;
  86855. private _queueLoad;
  86856. /**
  86857. * Invert the geometry to move from a right handed system to a left handed one.
  86858. */
  86859. toLeftHanded(): void;
  86860. /** @hidden */
  86861. _resetPointsArrayCache(): void;
  86862. /** @hidden */
  86863. _generatePointsArray(): boolean;
  86864. /**
  86865. * Gets a value indicating if the geometry is disposed
  86866. * @returns true if the geometry was disposed
  86867. */
  86868. isDisposed(): boolean;
  86869. private _disposeVertexArrayObjects;
  86870. /**
  86871. * Free all associated resources
  86872. */
  86873. dispose(): void;
  86874. /**
  86875. * Clone the current geometry into a new geometry
  86876. * @param id defines the unique ID of the new geometry
  86877. * @returns a new geometry object
  86878. */
  86879. copy(id: string): Geometry;
  86880. /**
  86881. * Serialize the current geometry info (and not the vertices data) into a JSON object
  86882. * @return a JSON representation of the current geometry data (without the vertices data)
  86883. */
  86884. serialize(): any;
  86885. private toNumberArray;
  86886. /**
  86887. * Serialize all vertices data into a JSON oject
  86888. * @returns a JSON representation of the current geometry data
  86889. */
  86890. serializeVerticeData(): any;
  86891. /**
  86892. * Extracts a clone of a mesh geometry
  86893. * @param mesh defines the source mesh
  86894. * @param id defines the unique ID of the new geometry object
  86895. * @returns the new geometry object
  86896. */
  86897. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  86898. /**
  86899. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  86900. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86901. * Be aware Math.random() could cause collisions, but:
  86902. * "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"
  86903. * @returns a string containing a new GUID
  86904. */
  86905. static RandomId(): string;
  86906. /** @hidden */
  86907. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  86908. private static _CleanMatricesWeights;
  86909. /**
  86910. * Create a new geometry from persisted data (Using .babylon file format)
  86911. * @param parsedVertexData defines the persisted data
  86912. * @param scene defines the hosting scene
  86913. * @param rootUrl defines the root url to use to load assets (like delayed data)
  86914. * @returns the new geometry object
  86915. */
  86916. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  86917. }
  86918. }
  86919. declare module BABYLON {
  86920. /**
  86921. * Define an interface for all classes that will get and set the data on vertices
  86922. */
  86923. export interface IGetSetVerticesData {
  86924. /**
  86925. * Gets a boolean indicating if specific vertex data is present
  86926. * @param kind defines the vertex data kind to use
  86927. * @returns true is data kind is present
  86928. */
  86929. isVerticesDataPresent(kind: string): boolean;
  86930. /**
  86931. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86932. * @param kind defines the data kind (Position, normal, etc...)
  86933. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86934. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86935. * @returns a float array containing vertex data
  86936. */
  86937. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86938. /**
  86939. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86940. * @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.
  86941. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86942. * @returns the indices array or an empty array if the mesh has no geometry
  86943. */
  86944. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86945. /**
  86946. * Set specific vertex data
  86947. * @param kind defines the data kind (Position, normal, etc...)
  86948. * @param data defines the vertex data to use
  86949. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86950. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86951. */
  86952. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  86953. /**
  86954. * Update a specific associated vertex buffer
  86955. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  86956. * - VertexBuffer.PositionKind
  86957. * - VertexBuffer.UVKind
  86958. * - VertexBuffer.UV2Kind
  86959. * - VertexBuffer.UV3Kind
  86960. * - VertexBuffer.UV4Kind
  86961. * - VertexBuffer.UV5Kind
  86962. * - VertexBuffer.UV6Kind
  86963. * - VertexBuffer.ColorKind
  86964. * - VertexBuffer.MatricesIndicesKind
  86965. * - VertexBuffer.MatricesIndicesExtraKind
  86966. * - VertexBuffer.MatricesWeightsKind
  86967. * - VertexBuffer.MatricesWeightsExtraKind
  86968. * @param data defines the data source
  86969. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  86970. * @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)
  86971. */
  86972. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  86973. /**
  86974. * Creates a new index buffer
  86975. * @param indices defines the indices to store in the index buffer
  86976. * @param totalVertices defines the total number of vertices (could be null)
  86977. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86978. */
  86979. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  86980. }
  86981. /**
  86982. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  86983. */
  86984. export class VertexData {
  86985. /**
  86986. * Mesh side orientation : usually the external or front surface
  86987. */
  86988. static readonly FRONTSIDE: number;
  86989. /**
  86990. * Mesh side orientation : usually the internal or back surface
  86991. */
  86992. static readonly BACKSIDE: number;
  86993. /**
  86994. * Mesh side orientation : both internal and external or front and back surfaces
  86995. */
  86996. static readonly DOUBLESIDE: number;
  86997. /**
  86998. * Mesh side orientation : by default, `FRONTSIDE`
  86999. */
  87000. static readonly DEFAULTSIDE: number;
  87001. /**
  87002. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  87003. */
  87004. positions: Nullable<FloatArray>;
  87005. /**
  87006. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  87007. */
  87008. normals: Nullable<FloatArray>;
  87009. /**
  87010. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  87011. */
  87012. tangents: Nullable<FloatArray>;
  87013. /**
  87014. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87015. */
  87016. uvs: Nullable<FloatArray>;
  87017. /**
  87018. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87019. */
  87020. uvs2: Nullable<FloatArray>;
  87021. /**
  87022. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87023. */
  87024. uvs3: Nullable<FloatArray>;
  87025. /**
  87026. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87027. */
  87028. uvs4: Nullable<FloatArray>;
  87029. /**
  87030. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87031. */
  87032. uvs5: Nullable<FloatArray>;
  87033. /**
  87034. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87035. */
  87036. uvs6: Nullable<FloatArray>;
  87037. /**
  87038. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  87039. */
  87040. colors: Nullable<FloatArray>;
  87041. /**
  87042. * 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).
  87043. */
  87044. matricesIndices: Nullable<FloatArray>;
  87045. /**
  87046. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  87047. */
  87048. matricesWeights: Nullable<FloatArray>;
  87049. /**
  87050. * An array extending the number of possible indices
  87051. */
  87052. matricesIndicesExtra: Nullable<FloatArray>;
  87053. /**
  87054. * An array extending the number of possible weights when the number of indices is extended
  87055. */
  87056. matricesWeightsExtra: Nullable<FloatArray>;
  87057. /**
  87058. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  87059. */
  87060. indices: Nullable<IndicesArray>;
  87061. /**
  87062. * Uses the passed data array to set the set the values for the specified kind of data
  87063. * @param data a linear array of floating numbers
  87064. * @param kind the type of data that is being set, eg positions, colors etc
  87065. */
  87066. set(data: FloatArray, kind: string): void;
  87067. /**
  87068. * Associates the vertexData to the passed Mesh.
  87069. * Sets it as updatable or not (default `false`)
  87070. * @param mesh the mesh the vertexData is applied to
  87071. * @param updatable when used and having the value true allows new data to update the vertexData
  87072. * @returns the VertexData
  87073. */
  87074. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  87075. /**
  87076. * Associates the vertexData to the passed Geometry.
  87077. * Sets it as updatable or not (default `false`)
  87078. * @param geometry the geometry the vertexData is applied to
  87079. * @param updatable when used and having the value true allows new data to update the vertexData
  87080. * @returns VertexData
  87081. */
  87082. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  87083. /**
  87084. * Updates the associated mesh
  87085. * @param mesh the mesh to be updated
  87086. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87087. * @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
  87088. * @returns VertexData
  87089. */
  87090. updateMesh(mesh: Mesh): VertexData;
  87091. /**
  87092. * Updates the associated geometry
  87093. * @param geometry the geometry to be updated
  87094. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87095. * @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
  87096. * @returns VertexData.
  87097. */
  87098. updateGeometry(geometry: Geometry): VertexData;
  87099. private _applyTo;
  87100. private _update;
  87101. /**
  87102. * Transforms each position and each normal of the vertexData according to the passed Matrix
  87103. * @param matrix the transforming matrix
  87104. * @returns the VertexData
  87105. */
  87106. transform(matrix: Matrix): VertexData;
  87107. /**
  87108. * Merges the passed VertexData into the current one
  87109. * @param other the VertexData to be merged into the current one
  87110. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  87111. * @returns the modified VertexData
  87112. */
  87113. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  87114. private _mergeElement;
  87115. private _validate;
  87116. /**
  87117. * Serializes the VertexData
  87118. * @returns a serialized object
  87119. */
  87120. serialize(): any;
  87121. /**
  87122. * Extracts the vertexData from a mesh
  87123. * @param mesh the mesh from which to extract the VertexData
  87124. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  87125. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87126. * @returns the object VertexData associated to the passed mesh
  87127. */
  87128. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87129. /**
  87130. * Extracts the vertexData from the geometry
  87131. * @param geometry the geometry from which to extract the VertexData
  87132. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  87133. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87134. * @returns the object VertexData associated to the passed mesh
  87135. */
  87136. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87137. private static _ExtractFrom;
  87138. /**
  87139. * Creates the VertexData for a Ribbon
  87140. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  87141. * * pathArray array of paths, each of which an array of successive Vector3
  87142. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  87143. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  87144. * * 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
  87145. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87146. * * 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)
  87147. * * 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)
  87148. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  87149. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  87150. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  87151. * @returns the VertexData of the ribbon
  87152. */
  87153. static CreateRibbon(options: {
  87154. pathArray: Vector3[][];
  87155. closeArray?: boolean;
  87156. closePath?: boolean;
  87157. offset?: number;
  87158. sideOrientation?: number;
  87159. frontUVs?: Vector4;
  87160. backUVs?: Vector4;
  87161. invertUV?: boolean;
  87162. uvs?: Vector2[];
  87163. colors?: Color4[];
  87164. }): VertexData;
  87165. /**
  87166. * Creates the VertexData for a box
  87167. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87168. * * size sets the width, height and depth of the box to the value of size, optional default 1
  87169. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  87170. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  87171. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  87172. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87173. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87174. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87175. * * 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)
  87176. * * 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)
  87177. * @returns the VertexData of the box
  87178. */
  87179. static CreateBox(options: {
  87180. size?: number;
  87181. width?: number;
  87182. height?: number;
  87183. depth?: number;
  87184. faceUV?: Vector4[];
  87185. faceColors?: Color4[];
  87186. sideOrientation?: number;
  87187. frontUVs?: Vector4;
  87188. backUVs?: Vector4;
  87189. }): VertexData;
  87190. /**
  87191. * Creates the VertexData for a tiled box
  87192. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87193. * * faceTiles sets the pattern, tile size and number of tiles for a face
  87194. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87195. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87196. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87197. * @returns the VertexData of the box
  87198. */
  87199. static CreateTiledBox(options: {
  87200. pattern?: number;
  87201. width?: number;
  87202. height?: number;
  87203. depth?: number;
  87204. tileSize?: number;
  87205. tileWidth?: number;
  87206. tileHeight?: number;
  87207. alignHorizontal?: number;
  87208. alignVertical?: number;
  87209. faceUV?: Vector4[];
  87210. faceColors?: Color4[];
  87211. sideOrientation?: number;
  87212. }): VertexData;
  87213. /**
  87214. * Creates the VertexData for a tiled plane
  87215. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87216. * * pattern a limited pattern arrangement depending on the number
  87217. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  87218. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  87219. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  87220. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87221. * * 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)
  87222. * * 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)
  87223. * @returns the VertexData of the tiled plane
  87224. */
  87225. static CreateTiledPlane(options: {
  87226. pattern?: number;
  87227. tileSize?: number;
  87228. tileWidth?: number;
  87229. tileHeight?: number;
  87230. size?: number;
  87231. width?: number;
  87232. height?: number;
  87233. alignHorizontal?: number;
  87234. alignVertical?: number;
  87235. sideOrientation?: number;
  87236. frontUVs?: Vector4;
  87237. backUVs?: Vector4;
  87238. }): VertexData;
  87239. /**
  87240. * Creates the VertexData for an ellipsoid, defaults to a sphere
  87241. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87242. * * segments sets the number of horizontal strips optional, default 32
  87243. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  87244. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  87245. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  87246. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  87247. * * 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
  87248. * * 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
  87249. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87250. * * 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)
  87251. * * 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)
  87252. * @returns the VertexData of the ellipsoid
  87253. */
  87254. static CreateSphere(options: {
  87255. segments?: number;
  87256. diameter?: number;
  87257. diameterX?: number;
  87258. diameterY?: number;
  87259. diameterZ?: number;
  87260. arc?: number;
  87261. slice?: number;
  87262. sideOrientation?: number;
  87263. frontUVs?: Vector4;
  87264. backUVs?: Vector4;
  87265. }): VertexData;
  87266. /**
  87267. * Creates the VertexData for a cylinder, cone or prism
  87268. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87269. * * height sets the height (y direction) of the cylinder, optional, default 2
  87270. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  87271. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  87272. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  87273. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87274. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  87275. * * 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
  87276. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87277. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87278. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  87279. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  87280. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87281. * * 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)
  87282. * * 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)
  87283. * @returns the VertexData of the cylinder, cone or prism
  87284. */
  87285. static CreateCylinder(options: {
  87286. height?: number;
  87287. diameterTop?: number;
  87288. diameterBottom?: number;
  87289. diameter?: number;
  87290. tessellation?: number;
  87291. subdivisions?: number;
  87292. arc?: number;
  87293. faceColors?: Color4[];
  87294. faceUV?: Vector4[];
  87295. hasRings?: boolean;
  87296. enclose?: boolean;
  87297. sideOrientation?: number;
  87298. frontUVs?: Vector4;
  87299. backUVs?: Vector4;
  87300. }): VertexData;
  87301. /**
  87302. * Creates the VertexData for a torus
  87303. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87304. * * diameter the diameter of the torus, optional default 1
  87305. * * thickness the diameter of the tube forming the torus, optional default 0.5
  87306. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87307. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87308. * * 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)
  87309. * * 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)
  87310. * @returns the VertexData of the torus
  87311. */
  87312. static CreateTorus(options: {
  87313. diameter?: number;
  87314. thickness?: number;
  87315. tessellation?: number;
  87316. sideOrientation?: number;
  87317. frontUVs?: Vector4;
  87318. backUVs?: Vector4;
  87319. }): VertexData;
  87320. /**
  87321. * Creates the VertexData of the LineSystem
  87322. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  87323. * - lines an array of lines, each line being an array of successive Vector3
  87324. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  87325. * @returns the VertexData of the LineSystem
  87326. */
  87327. static CreateLineSystem(options: {
  87328. lines: Vector3[][];
  87329. colors?: Nullable<Color4[][]>;
  87330. }): VertexData;
  87331. /**
  87332. * Create the VertexData for a DashedLines
  87333. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  87334. * - points an array successive Vector3
  87335. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  87336. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  87337. * - dashNb the intended total number of dashes, optional, default 200
  87338. * @returns the VertexData for the DashedLines
  87339. */
  87340. static CreateDashedLines(options: {
  87341. points: Vector3[];
  87342. dashSize?: number;
  87343. gapSize?: number;
  87344. dashNb?: number;
  87345. }): VertexData;
  87346. /**
  87347. * Creates the VertexData for a Ground
  87348. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87349. * - width the width (x direction) of the ground, optional, default 1
  87350. * - height the height (z direction) of the ground, optional, default 1
  87351. * - subdivisions the number of subdivisions per side, optional, default 1
  87352. * @returns the VertexData of the Ground
  87353. */
  87354. static CreateGround(options: {
  87355. width?: number;
  87356. height?: number;
  87357. subdivisions?: number;
  87358. subdivisionsX?: number;
  87359. subdivisionsY?: number;
  87360. }): VertexData;
  87361. /**
  87362. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  87363. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87364. * * xmin the ground minimum X coordinate, optional, default -1
  87365. * * zmin the ground minimum Z coordinate, optional, default -1
  87366. * * xmax the ground maximum X coordinate, optional, default 1
  87367. * * zmax the ground maximum Z coordinate, optional, default 1
  87368. * * 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}
  87369. * * 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}
  87370. * @returns the VertexData of the TiledGround
  87371. */
  87372. static CreateTiledGround(options: {
  87373. xmin: number;
  87374. zmin: number;
  87375. xmax: number;
  87376. zmax: number;
  87377. subdivisions?: {
  87378. w: number;
  87379. h: number;
  87380. };
  87381. precision?: {
  87382. w: number;
  87383. h: number;
  87384. };
  87385. }): VertexData;
  87386. /**
  87387. * Creates the VertexData of the Ground designed from a heightmap
  87388. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  87389. * * width the width (x direction) of the ground
  87390. * * height the height (z direction) of the ground
  87391. * * subdivisions the number of subdivisions per side
  87392. * * minHeight the minimum altitude on the ground, optional, default 0
  87393. * * maxHeight the maximum altitude on the ground, optional default 1
  87394. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  87395. * * buffer the array holding the image color data
  87396. * * bufferWidth the width of image
  87397. * * bufferHeight the height of image
  87398. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  87399. * @returns the VertexData of the Ground designed from a heightmap
  87400. */
  87401. static CreateGroundFromHeightMap(options: {
  87402. width: number;
  87403. height: number;
  87404. subdivisions: number;
  87405. minHeight: number;
  87406. maxHeight: number;
  87407. colorFilter: Color3;
  87408. buffer: Uint8Array;
  87409. bufferWidth: number;
  87410. bufferHeight: number;
  87411. alphaFilter: number;
  87412. }): VertexData;
  87413. /**
  87414. * Creates the VertexData for a Plane
  87415. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  87416. * * size sets the width and height of the plane to the value of size, optional default 1
  87417. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  87418. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  87419. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87420. * * 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)
  87421. * * 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)
  87422. * @returns the VertexData of the box
  87423. */
  87424. static CreatePlane(options: {
  87425. size?: number;
  87426. width?: number;
  87427. height?: number;
  87428. sideOrientation?: number;
  87429. frontUVs?: Vector4;
  87430. backUVs?: Vector4;
  87431. }): VertexData;
  87432. /**
  87433. * Creates the VertexData of the Disc or regular Polygon
  87434. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  87435. * * radius the radius of the disc, optional default 0.5
  87436. * * tessellation the number of polygon sides, optional, default 64
  87437. * * 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
  87438. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87439. * * 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)
  87440. * * 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)
  87441. * @returns the VertexData of the box
  87442. */
  87443. static CreateDisc(options: {
  87444. radius?: number;
  87445. tessellation?: number;
  87446. arc?: number;
  87447. sideOrientation?: number;
  87448. frontUVs?: Vector4;
  87449. backUVs?: Vector4;
  87450. }): VertexData;
  87451. /**
  87452. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  87453. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  87454. * @param polygon a mesh built from polygonTriangulation.build()
  87455. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87456. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87457. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87458. * @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)
  87459. * @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)
  87460. * @returns the VertexData of the Polygon
  87461. */
  87462. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  87463. /**
  87464. * Creates the VertexData of the IcoSphere
  87465. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  87466. * * radius the radius of the IcoSphere, optional default 1
  87467. * * radiusX allows stretching in the x direction, optional, default radius
  87468. * * radiusY allows stretching in the y direction, optional, default radius
  87469. * * radiusZ allows stretching in the z direction, optional, default radius
  87470. * * flat when true creates a flat shaded mesh, optional, default true
  87471. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87472. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87473. * * 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)
  87474. * * 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)
  87475. * @returns the VertexData of the IcoSphere
  87476. */
  87477. static CreateIcoSphere(options: {
  87478. radius?: number;
  87479. radiusX?: number;
  87480. radiusY?: number;
  87481. radiusZ?: number;
  87482. flat?: boolean;
  87483. subdivisions?: number;
  87484. sideOrientation?: number;
  87485. frontUVs?: Vector4;
  87486. backUVs?: Vector4;
  87487. }): VertexData;
  87488. /**
  87489. * Creates the VertexData for a Polyhedron
  87490. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  87491. * * type provided types are:
  87492. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  87493. * * 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)
  87494. * * size the size of the IcoSphere, optional default 1
  87495. * * sizeX allows stretching in the x direction, optional, default size
  87496. * * sizeY allows stretching in the y direction, optional, default size
  87497. * * sizeZ allows stretching in the z direction, optional, default size
  87498. * * 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
  87499. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87500. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87501. * * flat when true creates a flat shaded mesh, optional, default true
  87502. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87503. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87504. * * 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)
  87505. * * 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)
  87506. * @returns the VertexData of the Polyhedron
  87507. */
  87508. static CreatePolyhedron(options: {
  87509. type?: number;
  87510. size?: number;
  87511. sizeX?: number;
  87512. sizeY?: number;
  87513. sizeZ?: number;
  87514. custom?: any;
  87515. faceUV?: Vector4[];
  87516. faceColors?: Color4[];
  87517. flat?: boolean;
  87518. sideOrientation?: number;
  87519. frontUVs?: Vector4;
  87520. backUVs?: Vector4;
  87521. }): VertexData;
  87522. /**
  87523. * Creates the VertexData for a TorusKnot
  87524. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  87525. * * radius the radius of the torus knot, optional, default 2
  87526. * * tube the thickness of the tube, optional, default 0.5
  87527. * * radialSegments the number of sides on each tube segments, optional, default 32
  87528. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  87529. * * p the number of windings around the z axis, optional, default 2
  87530. * * q the number of windings around the x axis, optional, default 3
  87531. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87532. * * 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)
  87533. * * 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)
  87534. * @returns the VertexData of the Torus Knot
  87535. */
  87536. static CreateTorusKnot(options: {
  87537. radius?: number;
  87538. tube?: number;
  87539. radialSegments?: number;
  87540. tubularSegments?: number;
  87541. p?: number;
  87542. q?: number;
  87543. sideOrientation?: number;
  87544. frontUVs?: Vector4;
  87545. backUVs?: Vector4;
  87546. }): VertexData;
  87547. /**
  87548. * Compute normals for given positions and indices
  87549. * @param positions an array of vertex positions, [...., x, y, z, ......]
  87550. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  87551. * @param normals an array of vertex normals, [...., x, y, z, ......]
  87552. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  87553. * * facetNormals : optional array of facet normals (vector3)
  87554. * * facetPositions : optional array of facet positions (vector3)
  87555. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  87556. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  87557. * * bInfo : optional bounding info, required for facetPartitioning computation
  87558. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  87559. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  87560. * * useRightHandedSystem: optional boolean to for right handed system computation
  87561. * * depthSort : optional boolean to enable the facet depth sort computation
  87562. * * distanceTo : optional Vector3 to compute the facet depth from this location
  87563. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  87564. */
  87565. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  87566. facetNormals?: any;
  87567. facetPositions?: any;
  87568. facetPartitioning?: any;
  87569. ratio?: number;
  87570. bInfo?: any;
  87571. bbSize?: Vector3;
  87572. subDiv?: any;
  87573. useRightHandedSystem?: boolean;
  87574. depthSort?: boolean;
  87575. distanceTo?: Vector3;
  87576. depthSortedFacets?: any;
  87577. }): void;
  87578. /** @hidden */
  87579. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  87580. /**
  87581. * Applies VertexData created from the imported parameters to the geometry
  87582. * @param parsedVertexData the parsed data from an imported file
  87583. * @param geometry the geometry to apply the VertexData to
  87584. */
  87585. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  87586. }
  87587. }
  87588. declare module BABYLON {
  87589. /**
  87590. * Defines a target to use with MorphTargetManager
  87591. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87592. */
  87593. export class MorphTarget implements IAnimatable {
  87594. /** defines the name of the target */
  87595. name: string;
  87596. /**
  87597. * Gets or sets the list of animations
  87598. */
  87599. animations: Animation[];
  87600. private _scene;
  87601. private _positions;
  87602. private _normals;
  87603. private _tangents;
  87604. private _uvs;
  87605. private _influence;
  87606. /**
  87607. * Observable raised when the influence changes
  87608. */
  87609. onInfluenceChanged: Observable<boolean>;
  87610. /** @hidden */
  87611. _onDataLayoutChanged: Observable<void>;
  87612. /**
  87613. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  87614. */
  87615. influence: number;
  87616. /**
  87617. * Gets or sets the id of the morph Target
  87618. */
  87619. id: string;
  87620. private _animationPropertiesOverride;
  87621. /**
  87622. * Gets or sets the animation properties override
  87623. */
  87624. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87625. /**
  87626. * Creates a new MorphTarget
  87627. * @param name defines the name of the target
  87628. * @param influence defines the influence to use
  87629. * @param scene defines the scene the morphtarget belongs to
  87630. */
  87631. constructor(
  87632. /** defines the name of the target */
  87633. name: string, influence?: number, scene?: Nullable<Scene>);
  87634. /**
  87635. * Gets a boolean defining if the target contains position data
  87636. */
  87637. readonly hasPositions: boolean;
  87638. /**
  87639. * Gets a boolean defining if the target contains normal data
  87640. */
  87641. readonly hasNormals: boolean;
  87642. /**
  87643. * Gets a boolean defining if the target contains tangent data
  87644. */
  87645. readonly hasTangents: boolean;
  87646. /**
  87647. * Gets a boolean defining if the target contains texture coordinates data
  87648. */
  87649. readonly hasUVs: boolean;
  87650. /**
  87651. * Affects position data to this target
  87652. * @param data defines the position data to use
  87653. */
  87654. setPositions(data: Nullable<FloatArray>): void;
  87655. /**
  87656. * Gets the position data stored in this target
  87657. * @returns a FloatArray containing the position data (or null if not present)
  87658. */
  87659. getPositions(): Nullable<FloatArray>;
  87660. /**
  87661. * Affects normal data to this target
  87662. * @param data defines the normal data to use
  87663. */
  87664. setNormals(data: Nullable<FloatArray>): void;
  87665. /**
  87666. * Gets the normal data stored in this target
  87667. * @returns a FloatArray containing the normal data (or null if not present)
  87668. */
  87669. getNormals(): Nullable<FloatArray>;
  87670. /**
  87671. * Affects tangent data to this target
  87672. * @param data defines the tangent data to use
  87673. */
  87674. setTangents(data: Nullable<FloatArray>): void;
  87675. /**
  87676. * Gets the tangent data stored in this target
  87677. * @returns a FloatArray containing the tangent data (or null if not present)
  87678. */
  87679. getTangents(): Nullable<FloatArray>;
  87680. /**
  87681. * Affects texture coordinates data to this target
  87682. * @param data defines the texture coordinates data to use
  87683. */
  87684. setUVs(data: Nullable<FloatArray>): void;
  87685. /**
  87686. * Gets the texture coordinates data stored in this target
  87687. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  87688. */
  87689. getUVs(): Nullable<FloatArray>;
  87690. /**
  87691. * Serializes the current target into a Serialization object
  87692. * @returns the serialized object
  87693. */
  87694. serialize(): any;
  87695. /**
  87696. * Returns the string "MorphTarget"
  87697. * @returns "MorphTarget"
  87698. */
  87699. getClassName(): string;
  87700. /**
  87701. * Creates a new target from serialized data
  87702. * @param serializationObject defines the serialized data to use
  87703. * @returns a new MorphTarget
  87704. */
  87705. static Parse(serializationObject: any): MorphTarget;
  87706. /**
  87707. * Creates a MorphTarget from mesh data
  87708. * @param mesh defines the source mesh
  87709. * @param name defines the name to use for the new target
  87710. * @param influence defines the influence to attach to the target
  87711. * @returns a new MorphTarget
  87712. */
  87713. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  87714. }
  87715. }
  87716. declare module BABYLON {
  87717. /**
  87718. * This class is used to deform meshes using morphing between different targets
  87719. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87720. */
  87721. export class MorphTargetManager {
  87722. private _targets;
  87723. private _targetInfluenceChangedObservers;
  87724. private _targetDataLayoutChangedObservers;
  87725. private _activeTargets;
  87726. private _scene;
  87727. private _influences;
  87728. private _supportsNormals;
  87729. private _supportsTangents;
  87730. private _supportsUVs;
  87731. private _vertexCount;
  87732. private _uniqueId;
  87733. private _tempInfluences;
  87734. /**
  87735. * Gets or sets a boolean indicating if normals must be morphed
  87736. */
  87737. enableNormalMorphing: boolean;
  87738. /**
  87739. * Gets or sets a boolean indicating if tangents must be morphed
  87740. */
  87741. enableTangentMorphing: boolean;
  87742. /**
  87743. * Gets or sets a boolean indicating if UV must be morphed
  87744. */
  87745. enableUVMorphing: boolean;
  87746. /**
  87747. * Creates a new MorphTargetManager
  87748. * @param scene defines the current scene
  87749. */
  87750. constructor(scene?: Nullable<Scene>);
  87751. /**
  87752. * Gets the unique ID of this manager
  87753. */
  87754. readonly uniqueId: number;
  87755. /**
  87756. * Gets the number of vertices handled by this manager
  87757. */
  87758. readonly vertexCount: number;
  87759. /**
  87760. * Gets a boolean indicating if this manager supports morphing of normals
  87761. */
  87762. readonly supportsNormals: boolean;
  87763. /**
  87764. * Gets a boolean indicating if this manager supports morphing of tangents
  87765. */
  87766. readonly supportsTangents: boolean;
  87767. /**
  87768. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  87769. */
  87770. readonly supportsUVs: boolean;
  87771. /**
  87772. * Gets the number of targets stored in this manager
  87773. */
  87774. readonly numTargets: number;
  87775. /**
  87776. * Gets the number of influencers (ie. the number of targets with influences > 0)
  87777. */
  87778. readonly numInfluencers: number;
  87779. /**
  87780. * Gets the list of influences (one per target)
  87781. */
  87782. readonly influences: Float32Array;
  87783. /**
  87784. * Gets the active target at specified index. An active target is a target with an influence > 0
  87785. * @param index defines the index to check
  87786. * @returns the requested target
  87787. */
  87788. getActiveTarget(index: number): MorphTarget;
  87789. /**
  87790. * Gets the target at specified index
  87791. * @param index defines the index to check
  87792. * @returns the requested target
  87793. */
  87794. getTarget(index: number): MorphTarget;
  87795. /**
  87796. * Add a new target to this manager
  87797. * @param target defines the target to add
  87798. */
  87799. addTarget(target: MorphTarget): void;
  87800. /**
  87801. * Removes a target from the manager
  87802. * @param target defines the target to remove
  87803. */
  87804. removeTarget(target: MorphTarget): void;
  87805. /**
  87806. * Serializes the current manager into a Serialization object
  87807. * @returns the serialized object
  87808. */
  87809. serialize(): any;
  87810. private _syncActiveTargets;
  87811. /**
  87812. * Syncrhonize the targets with all the meshes using this morph target manager
  87813. */
  87814. synchronize(): void;
  87815. /**
  87816. * Creates a new MorphTargetManager from serialized data
  87817. * @param serializationObject defines the serialized data
  87818. * @param scene defines the hosting scene
  87819. * @returns the new MorphTargetManager
  87820. */
  87821. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  87822. }
  87823. }
  87824. declare module BABYLON {
  87825. /**
  87826. * Class used to represent a specific level of detail of a mesh
  87827. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87828. */
  87829. export class MeshLODLevel {
  87830. /** Defines the distance where this level should start being displayed */
  87831. distance: number;
  87832. /** Defines the mesh to use to render this level */
  87833. mesh: Nullable<Mesh>;
  87834. /**
  87835. * Creates a new LOD level
  87836. * @param distance defines the distance where this level should star being displayed
  87837. * @param mesh defines the mesh to use to render this level
  87838. */
  87839. constructor(
  87840. /** Defines the distance where this level should start being displayed */
  87841. distance: number,
  87842. /** Defines the mesh to use to render this level */
  87843. mesh: Nullable<Mesh>);
  87844. }
  87845. }
  87846. declare module BABYLON {
  87847. /**
  87848. * Mesh representing the gorund
  87849. */
  87850. export class GroundMesh extends Mesh {
  87851. /** If octree should be generated */
  87852. generateOctree: boolean;
  87853. private _heightQuads;
  87854. /** @hidden */
  87855. _subdivisionsX: number;
  87856. /** @hidden */
  87857. _subdivisionsY: number;
  87858. /** @hidden */
  87859. _width: number;
  87860. /** @hidden */
  87861. _height: number;
  87862. /** @hidden */
  87863. _minX: number;
  87864. /** @hidden */
  87865. _maxX: number;
  87866. /** @hidden */
  87867. _minZ: number;
  87868. /** @hidden */
  87869. _maxZ: number;
  87870. constructor(name: string, scene: Scene);
  87871. /**
  87872. * "GroundMesh"
  87873. * @returns "GroundMesh"
  87874. */
  87875. getClassName(): string;
  87876. /**
  87877. * The minimum of x and y subdivisions
  87878. */
  87879. readonly subdivisions: number;
  87880. /**
  87881. * X subdivisions
  87882. */
  87883. readonly subdivisionsX: number;
  87884. /**
  87885. * Y subdivisions
  87886. */
  87887. readonly subdivisionsY: number;
  87888. /**
  87889. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  87890. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  87891. * @param chunksCount the number of subdivisions for x and y
  87892. * @param octreeBlocksSize (Default: 32)
  87893. */
  87894. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  87895. /**
  87896. * Returns a height (y) value in the Worl system :
  87897. * the ground altitude at the coordinates (x, z) expressed in the World system.
  87898. * @param x x coordinate
  87899. * @param z z coordinate
  87900. * @returns the ground y position if (x, z) are outside the ground surface.
  87901. */
  87902. getHeightAtCoordinates(x: number, z: number): number;
  87903. /**
  87904. * Returns a normalized vector (Vector3) orthogonal to the ground
  87905. * at the ground coordinates (x, z) expressed in the World system.
  87906. * @param x x coordinate
  87907. * @param z z coordinate
  87908. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  87909. */
  87910. getNormalAtCoordinates(x: number, z: number): Vector3;
  87911. /**
  87912. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  87913. * at the ground coordinates (x, z) expressed in the World system.
  87914. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  87915. * @param x x coordinate
  87916. * @param z z coordinate
  87917. * @param ref vector to store the result
  87918. * @returns the GroundMesh.
  87919. */
  87920. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  87921. /**
  87922. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  87923. * if the ground has been updated.
  87924. * This can be used in the render loop.
  87925. * @returns the GroundMesh.
  87926. */
  87927. updateCoordinateHeights(): GroundMesh;
  87928. private _getFacetAt;
  87929. private _initHeightQuads;
  87930. private _computeHeightQuads;
  87931. /**
  87932. * Serializes this ground mesh
  87933. * @param serializationObject object to write serialization to
  87934. */
  87935. serialize(serializationObject: any): void;
  87936. /**
  87937. * Parses a serialized ground mesh
  87938. * @param parsedMesh the serialized mesh
  87939. * @param scene the scene to create the ground mesh in
  87940. * @returns the created ground mesh
  87941. */
  87942. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  87943. }
  87944. }
  87945. declare module BABYLON {
  87946. /**
  87947. * Interface for Physics-Joint data
  87948. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87949. */
  87950. export interface PhysicsJointData {
  87951. /**
  87952. * The main pivot of the joint
  87953. */
  87954. mainPivot?: Vector3;
  87955. /**
  87956. * The connected pivot of the joint
  87957. */
  87958. connectedPivot?: Vector3;
  87959. /**
  87960. * The main axis of the joint
  87961. */
  87962. mainAxis?: Vector3;
  87963. /**
  87964. * The connected axis of the joint
  87965. */
  87966. connectedAxis?: Vector3;
  87967. /**
  87968. * The collision of the joint
  87969. */
  87970. collision?: boolean;
  87971. /**
  87972. * Native Oimo/Cannon/Energy data
  87973. */
  87974. nativeParams?: any;
  87975. }
  87976. /**
  87977. * This is a holder class for the physics joint created by the physics plugin
  87978. * It holds a set of functions to control the underlying joint
  87979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  87980. */
  87981. export class PhysicsJoint {
  87982. /**
  87983. * The type of the physics joint
  87984. */
  87985. type: number;
  87986. /**
  87987. * The data for the physics joint
  87988. */
  87989. jointData: PhysicsJointData;
  87990. private _physicsJoint;
  87991. protected _physicsPlugin: IPhysicsEnginePlugin;
  87992. /**
  87993. * Initializes the physics joint
  87994. * @param type The type of the physics joint
  87995. * @param jointData The data for the physics joint
  87996. */
  87997. constructor(
  87998. /**
  87999. * The type of the physics joint
  88000. */
  88001. type: number,
  88002. /**
  88003. * The data for the physics joint
  88004. */
  88005. jointData: PhysicsJointData);
  88006. /**
  88007. * Gets the physics joint
  88008. */
  88009. /**
  88010. * Sets the physics joint
  88011. */
  88012. physicsJoint: any;
  88013. /**
  88014. * Sets the physics plugin
  88015. */
  88016. physicsPlugin: IPhysicsEnginePlugin;
  88017. /**
  88018. * Execute a function that is physics-plugin specific.
  88019. * @param {Function} func the function that will be executed.
  88020. * It accepts two parameters: the physics world and the physics joint
  88021. */
  88022. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  88023. /**
  88024. * Distance-Joint type
  88025. */
  88026. static DistanceJoint: number;
  88027. /**
  88028. * Hinge-Joint type
  88029. */
  88030. static HingeJoint: number;
  88031. /**
  88032. * Ball-and-Socket joint type
  88033. */
  88034. static BallAndSocketJoint: number;
  88035. /**
  88036. * Wheel-Joint type
  88037. */
  88038. static WheelJoint: number;
  88039. /**
  88040. * Slider-Joint type
  88041. */
  88042. static SliderJoint: number;
  88043. /**
  88044. * Prismatic-Joint type
  88045. */
  88046. static PrismaticJoint: number;
  88047. /**
  88048. * Universal-Joint type
  88049. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  88050. */
  88051. static UniversalJoint: number;
  88052. /**
  88053. * Hinge-Joint 2 type
  88054. */
  88055. static Hinge2Joint: number;
  88056. /**
  88057. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  88058. */
  88059. static PointToPointJoint: number;
  88060. /**
  88061. * Spring-Joint type
  88062. */
  88063. static SpringJoint: number;
  88064. /**
  88065. * Lock-Joint type
  88066. */
  88067. static LockJoint: number;
  88068. }
  88069. /**
  88070. * A class representing a physics distance joint
  88071. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88072. */
  88073. export class DistanceJoint extends PhysicsJoint {
  88074. /**
  88075. *
  88076. * @param jointData The data for the Distance-Joint
  88077. */
  88078. constructor(jointData: DistanceJointData);
  88079. /**
  88080. * Update the predefined distance.
  88081. * @param maxDistance The maximum preferred distance
  88082. * @param minDistance The minimum preferred distance
  88083. */
  88084. updateDistance(maxDistance: number, minDistance?: number): void;
  88085. }
  88086. /**
  88087. * Represents a Motor-Enabled Joint
  88088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88089. */
  88090. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  88091. /**
  88092. * Initializes the Motor-Enabled Joint
  88093. * @param type The type of the joint
  88094. * @param jointData The physica joint data for the joint
  88095. */
  88096. constructor(type: number, jointData: PhysicsJointData);
  88097. /**
  88098. * Set the motor values.
  88099. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88100. * @param force the force to apply
  88101. * @param maxForce max force for this motor.
  88102. */
  88103. setMotor(force?: number, maxForce?: number): void;
  88104. /**
  88105. * Set the motor's limits.
  88106. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88107. * @param upperLimit The upper limit of the motor
  88108. * @param lowerLimit The lower limit of the motor
  88109. */
  88110. setLimit(upperLimit: number, lowerLimit?: number): void;
  88111. }
  88112. /**
  88113. * This class represents a single physics Hinge-Joint
  88114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88115. */
  88116. export class HingeJoint extends MotorEnabledJoint {
  88117. /**
  88118. * Initializes the Hinge-Joint
  88119. * @param jointData The joint data for the Hinge-Joint
  88120. */
  88121. constructor(jointData: PhysicsJointData);
  88122. /**
  88123. * Set the motor values.
  88124. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88125. * @param {number} force the force to apply
  88126. * @param {number} maxForce max force for this motor.
  88127. */
  88128. setMotor(force?: number, maxForce?: number): void;
  88129. /**
  88130. * Set the motor's limits.
  88131. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88132. * @param upperLimit The upper limit of the motor
  88133. * @param lowerLimit The lower limit of the motor
  88134. */
  88135. setLimit(upperLimit: number, lowerLimit?: number): void;
  88136. }
  88137. /**
  88138. * This class represents a dual hinge physics joint (same as wheel joint)
  88139. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88140. */
  88141. export class Hinge2Joint extends MotorEnabledJoint {
  88142. /**
  88143. * Initializes the Hinge2-Joint
  88144. * @param jointData The joint data for the Hinge2-Joint
  88145. */
  88146. constructor(jointData: PhysicsJointData);
  88147. /**
  88148. * Set the motor values.
  88149. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88150. * @param {number} targetSpeed the speed the motor is to reach
  88151. * @param {number} maxForce max force for this motor.
  88152. * @param {motorIndex} the motor's index, 0 or 1.
  88153. */
  88154. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  88155. /**
  88156. * Set the motor limits.
  88157. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88158. * @param {number} upperLimit the upper limit
  88159. * @param {number} lowerLimit lower limit
  88160. * @param {motorIndex} the motor's index, 0 or 1.
  88161. */
  88162. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88163. }
  88164. /**
  88165. * Interface for a motor enabled joint
  88166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88167. */
  88168. export interface IMotorEnabledJoint {
  88169. /**
  88170. * Physics joint
  88171. */
  88172. physicsJoint: any;
  88173. /**
  88174. * Sets the motor of the motor-enabled joint
  88175. * @param force The force of the motor
  88176. * @param maxForce The maximum force of the motor
  88177. * @param motorIndex The index of the motor
  88178. */
  88179. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  88180. /**
  88181. * Sets the limit of the motor
  88182. * @param upperLimit The upper limit of the motor
  88183. * @param lowerLimit The lower limit of the motor
  88184. * @param motorIndex The index of the motor
  88185. */
  88186. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88187. }
  88188. /**
  88189. * Joint data for a Distance-Joint
  88190. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88191. */
  88192. export interface DistanceJointData extends PhysicsJointData {
  88193. /**
  88194. * Max distance the 2 joint objects can be apart
  88195. */
  88196. maxDistance: number;
  88197. }
  88198. /**
  88199. * Joint data from a spring joint
  88200. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88201. */
  88202. export interface SpringJointData extends PhysicsJointData {
  88203. /**
  88204. * Length of the spring
  88205. */
  88206. length: number;
  88207. /**
  88208. * Stiffness of the spring
  88209. */
  88210. stiffness: number;
  88211. /**
  88212. * Damping of the spring
  88213. */
  88214. damping: number;
  88215. /** this callback will be called when applying the force to the impostors. */
  88216. forceApplicationCallback: () => void;
  88217. }
  88218. }
  88219. declare module BABYLON {
  88220. /**
  88221. * Holds the data for the raycast result
  88222. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88223. */
  88224. export class PhysicsRaycastResult {
  88225. private _hasHit;
  88226. private _hitDistance;
  88227. private _hitNormalWorld;
  88228. private _hitPointWorld;
  88229. private _rayFromWorld;
  88230. private _rayToWorld;
  88231. /**
  88232. * Gets if there was a hit
  88233. */
  88234. readonly hasHit: boolean;
  88235. /**
  88236. * Gets the distance from the hit
  88237. */
  88238. readonly hitDistance: number;
  88239. /**
  88240. * Gets the hit normal/direction in the world
  88241. */
  88242. readonly hitNormalWorld: Vector3;
  88243. /**
  88244. * Gets the hit point in the world
  88245. */
  88246. readonly hitPointWorld: Vector3;
  88247. /**
  88248. * Gets the ray "start point" of the ray in the world
  88249. */
  88250. readonly rayFromWorld: Vector3;
  88251. /**
  88252. * Gets the ray "end point" of the ray in the world
  88253. */
  88254. readonly rayToWorld: Vector3;
  88255. /**
  88256. * Sets the hit data (normal & point in world space)
  88257. * @param hitNormalWorld defines the normal in world space
  88258. * @param hitPointWorld defines the point in world space
  88259. */
  88260. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  88261. /**
  88262. * Sets the distance from the start point to the hit point
  88263. * @param distance
  88264. */
  88265. setHitDistance(distance: number): void;
  88266. /**
  88267. * Calculates the distance manually
  88268. */
  88269. calculateHitDistance(): void;
  88270. /**
  88271. * Resets all the values to default
  88272. * @param from The from point on world space
  88273. * @param to The to point on world space
  88274. */
  88275. reset(from?: Vector3, to?: Vector3): void;
  88276. }
  88277. /**
  88278. * Interface for the size containing width and height
  88279. */
  88280. interface IXYZ {
  88281. /**
  88282. * X
  88283. */
  88284. x: number;
  88285. /**
  88286. * Y
  88287. */
  88288. y: number;
  88289. /**
  88290. * Z
  88291. */
  88292. z: number;
  88293. }
  88294. }
  88295. declare module BABYLON {
  88296. /**
  88297. * Interface used to describe a physics joint
  88298. */
  88299. export interface PhysicsImpostorJoint {
  88300. /** Defines the main impostor to which the joint is linked */
  88301. mainImpostor: PhysicsImpostor;
  88302. /** Defines the impostor that is connected to the main impostor using this joint */
  88303. connectedImpostor: PhysicsImpostor;
  88304. /** Defines the joint itself */
  88305. joint: PhysicsJoint;
  88306. }
  88307. /** @hidden */
  88308. export interface IPhysicsEnginePlugin {
  88309. world: any;
  88310. name: string;
  88311. setGravity(gravity: Vector3): void;
  88312. setTimeStep(timeStep: number): void;
  88313. getTimeStep(): number;
  88314. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  88315. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88316. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88317. generatePhysicsBody(impostor: PhysicsImpostor): void;
  88318. removePhysicsBody(impostor: PhysicsImpostor): void;
  88319. generateJoint(joint: PhysicsImpostorJoint): void;
  88320. removeJoint(joint: PhysicsImpostorJoint): void;
  88321. isSupported(): boolean;
  88322. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  88323. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  88324. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88325. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88326. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88327. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88328. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  88329. getBodyMass(impostor: PhysicsImpostor): number;
  88330. getBodyFriction(impostor: PhysicsImpostor): number;
  88331. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  88332. getBodyRestitution(impostor: PhysicsImpostor): number;
  88333. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  88334. getBodyPressure?(impostor: PhysicsImpostor): number;
  88335. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  88336. getBodyStiffness?(impostor: PhysicsImpostor): number;
  88337. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  88338. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  88339. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  88340. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  88341. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  88342. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88343. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88344. sleepBody(impostor: PhysicsImpostor): void;
  88345. wakeUpBody(impostor: PhysicsImpostor): void;
  88346. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88347. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  88348. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  88349. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88350. getRadius(impostor: PhysicsImpostor): number;
  88351. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  88352. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  88353. dispose(): void;
  88354. }
  88355. /**
  88356. * Interface used to define a physics engine
  88357. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  88358. */
  88359. export interface IPhysicsEngine {
  88360. /**
  88361. * Gets the gravity vector used by the simulation
  88362. */
  88363. gravity: Vector3;
  88364. /**
  88365. * Sets the gravity vector used by the simulation
  88366. * @param gravity defines the gravity vector to use
  88367. */
  88368. setGravity(gravity: Vector3): void;
  88369. /**
  88370. * Set the time step of the physics engine.
  88371. * Default is 1/60.
  88372. * To slow it down, enter 1/600 for example.
  88373. * To speed it up, 1/30
  88374. * @param newTimeStep the new timestep to apply to this world.
  88375. */
  88376. setTimeStep(newTimeStep: number): void;
  88377. /**
  88378. * Get the time step of the physics engine.
  88379. * @returns the current time step
  88380. */
  88381. getTimeStep(): number;
  88382. /**
  88383. * Release all resources
  88384. */
  88385. dispose(): void;
  88386. /**
  88387. * Gets the name of the current physics plugin
  88388. * @returns the name of the plugin
  88389. */
  88390. getPhysicsPluginName(): string;
  88391. /**
  88392. * Adding a new impostor for the impostor tracking.
  88393. * This will be done by the impostor itself.
  88394. * @param impostor the impostor to add
  88395. */
  88396. addImpostor(impostor: PhysicsImpostor): void;
  88397. /**
  88398. * Remove an impostor from the engine.
  88399. * This impostor and its mesh will not longer be updated by the physics engine.
  88400. * @param impostor the impostor to remove
  88401. */
  88402. removeImpostor(impostor: PhysicsImpostor): void;
  88403. /**
  88404. * Add a joint to the physics engine
  88405. * @param mainImpostor defines the main impostor to which the joint is added.
  88406. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  88407. * @param joint defines the joint that will connect both impostors.
  88408. */
  88409. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88410. /**
  88411. * Removes a joint from the simulation
  88412. * @param mainImpostor defines the impostor used with the joint
  88413. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  88414. * @param joint defines the joint to remove
  88415. */
  88416. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88417. /**
  88418. * Gets the current plugin used to run the simulation
  88419. * @returns current plugin
  88420. */
  88421. getPhysicsPlugin(): IPhysicsEnginePlugin;
  88422. /**
  88423. * Gets the list of physic impostors
  88424. * @returns an array of PhysicsImpostor
  88425. */
  88426. getImpostors(): Array<PhysicsImpostor>;
  88427. /**
  88428. * Gets the impostor for a physics enabled object
  88429. * @param object defines the object impersonated by the impostor
  88430. * @returns the PhysicsImpostor or null if not found
  88431. */
  88432. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88433. /**
  88434. * Gets the impostor for a physics body object
  88435. * @param body defines physics body used by the impostor
  88436. * @returns the PhysicsImpostor or null if not found
  88437. */
  88438. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  88439. /**
  88440. * Does a raycast in the physics world
  88441. * @param from when should the ray start?
  88442. * @param to when should the ray end?
  88443. * @returns PhysicsRaycastResult
  88444. */
  88445. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88446. /**
  88447. * Called by the scene. No need to call it.
  88448. * @param delta defines the timespam between frames
  88449. */
  88450. _step(delta: number): void;
  88451. }
  88452. }
  88453. declare module BABYLON {
  88454. /**
  88455. * The interface for the physics imposter parameters
  88456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88457. */
  88458. export interface PhysicsImpostorParameters {
  88459. /**
  88460. * The mass of the physics imposter
  88461. */
  88462. mass: number;
  88463. /**
  88464. * The friction of the physics imposter
  88465. */
  88466. friction?: number;
  88467. /**
  88468. * The coefficient of restitution of the physics imposter
  88469. */
  88470. restitution?: number;
  88471. /**
  88472. * The native options of the physics imposter
  88473. */
  88474. nativeOptions?: any;
  88475. /**
  88476. * Specifies if the parent should be ignored
  88477. */
  88478. ignoreParent?: boolean;
  88479. /**
  88480. * Specifies if bi-directional transformations should be disabled
  88481. */
  88482. disableBidirectionalTransformation?: boolean;
  88483. /**
  88484. * The pressure inside the physics imposter, soft object only
  88485. */
  88486. pressure?: number;
  88487. /**
  88488. * The stiffness the physics imposter, soft object only
  88489. */
  88490. stiffness?: number;
  88491. /**
  88492. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  88493. */
  88494. velocityIterations?: number;
  88495. /**
  88496. * The number of iterations used in maintaining consistent vertex positions, soft object only
  88497. */
  88498. positionIterations?: number;
  88499. /**
  88500. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  88501. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  88502. * Add to fix multiple points
  88503. */
  88504. fixedPoints?: number;
  88505. /**
  88506. * The collision margin around a soft object
  88507. */
  88508. margin?: number;
  88509. /**
  88510. * The collision margin around a soft object
  88511. */
  88512. damping?: number;
  88513. /**
  88514. * The path for a rope based on an extrusion
  88515. */
  88516. path?: any;
  88517. /**
  88518. * The shape of an extrusion used for a rope based on an extrusion
  88519. */
  88520. shape?: any;
  88521. }
  88522. /**
  88523. * Interface for a physics-enabled object
  88524. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88525. */
  88526. export interface IPhysicsEnabledObject {
  88527. /**
  88528. * The position of the physics-enabled object
  88529. */
  88530. position: Vector3;
  88531. /**
  88532. * The rotation of the physics-enabled object
  88533. */
  88534. rotationQuaternion: Nullable<Quaternion>;
  88535. /**
  88536. * The scale of the physics-enabled object
  88537. */
  88538. scaling: Vector3;
  88539. /**
  88540. * The rotation of the physics-enabled object
  88541. */
  88542. rotation?: Vector3;
  88543. /**
  88544. * The parent of the physics-enabled object
  88545. */
  88546. parent?: any;
  88547. /**
  88548. * The bounding info of the physics-enabled object
  88549. * @returns The bounding info of the physics-enabled object
  88550. */
  88551. getBoundingInfo(): BoundingInfo;
  88552. /**
  88553. * Computes the world matrix
  88554. * @param force Specifies if the world matrix should be computed by force
  88555. * @returns A world matrix
  88556. */
  88557. computeWorldMatrix(force: boolean): Matrix;
  88558. /**
  88559. * Gets the world matrix
  88560. * @returns A world matrix
  88561. */
  88562. getWorldMatrix?(): Matrix;
  88563. /**
  88564. * Gets the child meshes
  88565. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  88566. * @returns An array of abstract meshes
  88567. */
  88568. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  88569. /**
  88570. * Gets the vertex data
  88571. * @param kind The type of vertex data
  88572. * @returns A nullable array of numbers, or a float32 array
  88573. */
  88574. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  88575. /**
  88576. * Gets the indices from the mesh
  88577. * @returns A nullable array of index arrays
  88578. */
  88579. getIndices?(): Nullable<IndicesArray>;
  88580. /**
  88581. * Gets the scene from the mesh
  88582. * @returns the indices array or null
  88583. */
  88584. getScene?(): Scene;
  88585. /**
  88586. * Gets the absolute position from the mesh
  88587. * @returns the absolute position
  88588. */
  88589. getAbsolutePosition(): Vector3;
  88590. /**
  88591. * Gets the absolute pivot point from the mesh
  88592. * @returns the absolute pivot point
  88593. */
  88594. getAbsolutePivotPoint(): Vector3;
  88595. /**
  88596. * Rotates the mesh
  88597. * @param axis The axis of rotation
  88598. * @param amount The amount of rotation
  88599. * @param space The space of the rotation
  88600. * @returns The rotation transform node
  88601. */
  88602. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  88603. /**
  88604. * Translates the mesh
  88605. * @param axis The axis of translation
  88606. * @param distance The distance of translation
  88607. * @param space The space of the translation
  88608. * @returns The transform node
  88609. */
  88610. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  88611. /**
  88612. * Sets the absolute position of the mesh
  88613. * @param absolutePosition The absolute position of the mesh
  88614. * @returns The transform node
  88615. */
  88616. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  88617. /**
  88618. * Gets the class name of the mesh
  88619. * @returns The class name
  88620. */
  88621. getClassName(): string;
  88622. }
  88623. /**
  88624. * Represents a physics imposter
  88625. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88626. */
  88627. export class PhysicsImpostor {
  88628. /**
  88629. * The physics-enabled object used as the physics imposter
  88630. */
  88631. object: IPhysicsEnabledObject;
  88632. /**
  88633. * The type of the physics imposter
  88634. */
  88635. type: number;
  88636. private _options;
  88637. private _scene?;
  88638. /**
  88639. * The default object size of the imposter
  88640. */
  88641. static DEFAULT_OBJECT_SIZE: Vector3;
  88642. /**
  88643. * The identity quaternion of the imposter
  88644. */
  88645. static IDENTITY_QUATERNION: Quaternion;
  88646. /** @hidden */
  88647. _pluginData: any;
  88648. private _physicsEngine;
  88649. private _physicsBody;
  88650. private _bodyUpdateRequired;
  88651. private _onBeforePhysicsStepCallbacks;
  88652. private _onAfterPhysicsStepCallbacks;
  88653. /** @hidden */
  88654. _onPhysicsCollideCallbacks: Array<{
  88655. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  88656. otherImpostors: Array<PhysicsImpostor>;
  88657. }>;
  88658. private _deltaPosition;
  88659. private _deltaRotation;
  88660. private _deltaRotationConjugated;
  88661. /** @hidden */
  88662. _isFromLine: boolean;
  88663. private _parent;
  88664. private _isDisposed;
  88665. private static _tmpVecs;
  88666. private static _tmpQuat;
  88667. /**
  88668. * Specifies if the physics imposter is disposed
  88669. */
  88670. readonly isDisposed: boolean;
  88671. /**
  88672. * Gets the mass of the physics imposter
  88673. */
  88674. mass: number;
  88675. /**
  88676. * Gets the coefficient of friction
  88677. */
  88678. /**
  88679. * Sets the coefficient of friction
  88680. */
  88681. friction: number;
  88682. /**
  88683. * Gets the coefficient of restitution
  88684. */
  88685. /**
  88686. * Sets the coefficient of restitution
  88687. */
  88688. restitution: number;
  88689. /**
  88690. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  88691. */
  88692. /**
  88693. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  88694. */
  88695. pressure: number;
  88696. /**
  88697. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88698. */
  88699. /**
  88700. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88701. */
  88702. stiffness: number;
  88703. /**
  88704. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88705. */
  88706. /**
  88707. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88708. */
  88709. velocityIterations: number;
  88710. /**
  88711. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88712. */
  88713. /**
  88714. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88715. */
  88716. positionIterations: number;
  88717. /**
  88718. * The unique id of the physics imposter
  88719. * set by the physics engine when adding this impostor to the array
  88720. */
  88721. uniqueId: number;
  88722. /**
  88723. * @hidden
  88724. */
  88725. soft: boolean;
  88726. /**
  88727. * @hidden
  88728. */
  88729. segments: number;
  88730. private _joints;
  88731. /**
  88732. * Initializes the physics imposter
  88733. * @param object The physics-enabled object used as the physics imposter
  88734. * @param type The type of the physics imposter
  88735. * @param _options The options for the physics imposter
  88736. * @param _scene The Babylon scene
  88737. */
  88738. constructor(
  88739. /**
  88740. * The physics-enabled object used as the physics imposter
  88741. */
  88742. object: IPhysicsEnabledObject,
  88743. /**
  88744. * The type of the physics imposter
  88745. */
  88746. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  88747. /**
  88748. * This function will completly initialize this impostor.
  88749. * It will create a new body - but only if this mesh has no parent.
  88750. * If it has, this impostor will not be used other than to define the impostor
  88751. * of the child mesh.
  88752. * @hidden
  88753. */
  88754. _init(): void;
  88755. private _getPhysicsParent;
  88756. /**
  88757. * Should a new body be generated.
  88758. * @returns boolean specifying if body initialization is required
  88759. */
  88760. isBodyInitRequired(): boolean;
  88761. /**
  88762. * Sets the updated scaling
  88763. * @param updated Specifies if the scaling is updated
  88764. */
  88765. setScalingUpdated(): void;
  88766. /**
  88767. * Force a regeneration of this or the parent's impostor's body.
  88768. * Use under cautious - This will remove all joints already implemented.
  88769. */
  88770. forceUpdate(): void;
  88771. /**
  88772. * Gets the body that holds this impostor. Either its own, or its parent.
  88773. */
  88774. /**
  88775. * Set the physics body. Used mainly by the physics engine/plugin
  88776. */
  88777. physicsBody: any;
  88778. /**
  88779. * Get the parent of the physics imposter
  88780. * @returns Physics imposter or null
  88781. */
  88782. /**
  88783. * Sets the parent of the physics imposter
  88784. */
  88785. parent: Nullable<PhysicsImpostor>;
  88786. /**
  88787. * Resets the update flags
  88788. */
  88789. resetUpdateFlags(): void;
  88790. /**
  88791. * Gets the object extend size
  88792. * @returns the object extend size
  88793. */
  88794. getObjectExtendSize(): Vector3;
  88795. /**
  88796. * Gets the object center
  88797. * @returns The object center
  88798. */
  88799. getObjectCenter(): Vector3;
  88800. /**
  88801. * Get a specific parametes from the options parameter
  88802. * @param paramName The object parameter name
  88803. * @returns The object parameter
  88804. */
  88805. getParam(paramName: string): any;
  88806. /**
  88807. * Sets a specific parameter in the options given to the physics plugin
  88808. * @param paramName The parameter name
  88809. * @param value The value of the parameter
  88810. */
  88811. setParam(paramName: string, value: number): void;
  88812. /**
  88813. * Specifically change the body's mass option. Won't recreate the physics body object
  88814. * @param mass The mass of the physics imposter
  88815. */
  88816. setMass(mass: number): void;
  88817. /**
  88818. * Gets the linear velocity
  88819. * @returns linear velocity or null
  88820. */
  88821. getLinearVelocity(): Nullable<Vector3>;
  88822. /**
  88823. * Sets the linear velocity
  88824. * @param velocity linear velocity or null
  88825. */
  88826. setLinearVelocity(velocity: Nullable<Vector3>): void;
  88827. /**
  88828. * Gets the angular velocity
  88829. * @returns angular velocity or null
  88830. */
  88831. getAngularVelocity(): Nullable<Vector3>;
  88832. /**
  88833. * Sets the angular velocity
  88834. * @param velocity The velocity or null
  88835. */
  88836. setAngularVelocity(velocity: Nullable<Vector3>): void;
  88837. /**
  88838. * Execute a function with the physics plugin native code
  88839. * Provide a function the will have two variables - the world object and the physics body object
  88840. * @param func The function to execute with the physics plugin native code
  88841. */
  88842. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  88843. /**
  88844. * Register a function that will be executed before the physics world is stepping forward
  88845. * @param func The function to execute before the physics world is stepped forward
  88846. */
  88847. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88848. /**
  88849. * Unregister a function that will be executed before the physics world is stepping forward
  88850. * @param func The function to execute before the physics world is stepped forward
  88851. */
  88852. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88853. /**
  88854. * Register a function that will be executed after the physics step
  88855. * @param func The function to execute after physics step
  88856. */
  88857. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88858. /**
  88859. * Unregisters a function that will be executed after the physics step
  88860. * @param func The function to execute after physics step
  88861. */
  88862. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88863. /**
  88864. * register a function that will be executed when this impostor collides against a different body
  88865. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  88866. * @param func Callback that is executed on collision
  88867. */
  88868. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  88869. /**
  88870. * Unregisters the physics imposter on contact
  88871. * @param collideAgainst The physics object to collide against
  88872. * @param func Callback to execute on collision
  88873. */
  88874. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  88875. private _tmpQuat;
  88876. private _tmpQuat2;
  88877. /**
  88878. * Get the parent rotation
  88879. * @returns The parent rotation
  88880. */
  88881. getParentsRotation(): Quaternion;
  88882. /**
  88883. * this function is executed by the physics engine.
  88884. */
  88885. beforeStep: () => void;
  88886. /**
  88887. * this function is executed by the physics engine
  88888. */
  88889. afterStep: () => void;
  88890. /**
  88891. * Legacy collision detection event support
  88892. */
  88893. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  88894. /**
  88895. * event and body object due to cannon's event-based architecture.
  88896. */
  88897. onCollide: (e: {
  88898. body: any;
  88899. }) => void;
  88900. /**
  88901. * Apply a force
  88902. * @param force The force to apply
  88903. * @param contactPoint The contact point for the force
  88904. * @returns The physics imposter
  88905. */
  88906. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  88907. /**
  88908. * Apply an impulse
  88909. * @param force The impulse force
  88910. * @param contactPoint The contact point for the impulse force
  88911. * @returns The physics imposter
  88912. */
  88913. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  88914. /**
  88915. * A help function to create a joint
  88916. * @param otherImpostor A physics imposter used to create a joint
  88917. * @param jointType The type of joint
  88918. * @param jointData The data for the joint
  88919. * @returns The physics imposter
  88920. */
  88921. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  88922. /**
  88923. * Add a joint to this impostor with a different impostor
  88924. * @param otherImpostor A physics imposter used to add a joint
  88925. * @param joint The joint to add
  88926. * @returns The physics imposter
  88927. */
  88928. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  88929. /**
  88930. * Add an anchor to a cloth impostor
  88931. * @param otherImpostor rigid impostor to anchor to
  88932. * @param width ratio across width from 0 to 1
  88933. * @param height ratio up height from 0 to 1
  88934. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  88935. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  88936. * @returns impostor the soft imposter
  88937. */
  88938. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  88939. /**
  88940. * Add a hook to a rope impostor
  88941. * @param otherImpostor rigid impostor to anchor to
  88942. * @param length ratio across rope from 0 to 1
  88943. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  88944. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  88945. * @returns impostor the rope imposter
  88946. */
  88947. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  88948. /**
  88949. * Will keep this body still, in a sleep mode.
  88950. * @returns the physics imposter
  88951. */
  88952. sleep(): PhysicsImpostor;
  88953. /**
  88954. * Wake the body up.
  88955. * @returns The physics imposter
  88956. */
  88957. wakeUp(): PhysicsImpostor;
  88958. /**
  88959. * Clones the physics imposter
  88960. * @param newObject The physics imposter clones to this physics-enabled object
  88961. * @returns A nullable physics imposter
  88962. */
  88963. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88964. /**
  88965. * Disposes the physics imposter
  88966. */
  88967. dispose(): void;
  88968. /**
  88969. * Sets the delta position
  88970. * @param position The delta position amount
  88971. */
  88972. setDeltaPosition(position: Vector3): void;
  88973. /**
  88974. * Sets the delta rotation
  88975. * @param rotation The delta rotation amount
  88976. */
  88977. setDeltaRotation(rotation: Quaternion): void;
  88978. /**
  88979. * Gets the box size of the physics imposter and stores the result in the input parameter
  88980. * @param result Stores the box size
  88981. * @returns The physics imposter
  88982. */
  88983. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  88984. /**
  88985. * Gets the radius of the physics imposter
  88986. * @returns Radius of the physics imposter
  88987. */
  88988. getRadius(): number;
  88989. /**
  88990. * Sync a bone with this impostor
  88991. * @param bone The bone to sync to the impostor.
  88992. * @param boneMesh The mesh that the bone is influencing.
  88993. * @param jointPivot The pivot of the joint / bone in local space.
  88994. * @param distToJoint Optional distance from the impostor to the joint.
  88995. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  88996. */
  88997. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  88998. /**
  88999. * Sync impostor to a bone
  89000. * @param bone The bone that the impostor will be synced to.
  89001. * @param boneMesh The mesh that the bone is influencing.
  89002. * @param jointPivot The pivot of the joint / bone in local space.
  89003. * @param distToJoint Optional distance from the impostor to the joint.
  89004. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89005. * @param boneAxis Optional vector3 axis the bone is aligned with
  89006. */
  89007. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  89008. /**
  89009. * No-Imposter type
  89010. */
  89011. static NoImpostor: number;
  89012. /**
  89013. * Sphere-Imposter type
  89014. */
  89015. static SphereImpostor: number;
  89016. /**
  89017. * Box-Imposter type
  89018. */
  89019. static BoxImpostor: number;
  89020. /**
  89021. * Plane-Imposter type
  89022. */
  89023. static PlaneImpostor: number;
  89024. /**
  89025. * Mesh-imposter type
  89026. */
  89027. static MeshImpostor: number;
  89028. /**
  89029. * Capsule-Impostor type (Ammo.js plugin only)
  89030. */
  89031. static CapsuleImpostor: number;
  89032. /**
  89033. * Cylinder-Imposter type
  89034. */
  89035. static CylinderImpostor: number;
  89036. /**
  89037. * Particle-Imposter type
  89038. */
  89039. static ParticleImpostor: number;
  89040. /**
  89041. * Heightmap-Imposter type
  89042. */
  89043. static HeightmapImpostor: number;
  89044. /**
  89045. * ConvexHull-Impostor type (Ammo.js plugin only)
  89046. */
  89047. static ConvexHullImpostor: number;
  89048. /**
  89049. * Rope-Imposter type
  89050. */
  89051. static RopeImpostor: number;
  89052. /**
  89053. * Cloth-Imposter type
  89054. */
  89055. static ClothImpostor: number;
  89056. /**
  89057. * Softbody-Imposter type
  89058. */
  89059. static SoftbodyImpostor: number;
  89060. }
  89061. }
  89062. declare module BABYLON {
  89063. /**
  89064. * @hidden
  89065. **/
  89066. export class _CreationDataStorage {
  89067. closePath?: boolean;
  89068. closeArray?: boolean;
  89069. idx: number[];
  89070. dashSize: number;
  89071. gapSize: number;
  89072. path3D: Path3D;
  89073. pathArray: Vector3[][];
  89074. arc: number;
  89075. radius: number;
  89076. cap: number;
  89077. tessellation: number;
  89078. }
  89079. /**
  89080. * @hidden
  89081. **/
  89082. class _InstanceDataStorage {
  89083. visibleInstances: any;
  89084. batchCache: _InstancesBatch;
  89085. instancesBufferSize: number;
  89086. instancesBuffer: Nullable<Buffer>;
  89087. instancesData: Float32Array;
  89088. overridenInstanceCount: number;
  89089. isFrozen: boolean;
  89090. previousBatch: Nullable<_InstancesBatch>;
  89091. hardwareInstancedRendering: boolean;
  89092. sideOrientation: number;
  89093. }
  89094. /**
  89095. * @hidden
  89096. **/
  89097. export class _InstancesBatch {
  89098. mustReturn: boolean;
  89099. visibleInstances: Nullable<InstancedMesh[]>[];
  89100. renderSelf: boolean[];
  89101. hardwareInstancedRendering: boolean[];
  89102. }
  89103. /**
  89104. * Class used to represent renderable models
  89105. */
  89106. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  89107. /**
  89108. * Mesh side orientation : usually the external or front surface
  89109. */
  89110. static readonly FRONTSIDE: number;
  89111. /**
  89112. * Mesh side orientation : usually the internal or back surface
  89113. */
  89114. static readonly BACKSIDE: number;
  89115. /**
  89116. * Mesh side orientation : both internal and external or front and back surfaces
  89117. */
  89118. static readonly DOUBLESIDE: number;
  89119. /**
  89120. * Mesh side orientation : by default, `FRONTSIDE`
  89121. */
  89122. static readonly DEFAULTSIDE: number;
  89123. /**
  89124. * Mesh cap setting : no cap
  89125. */
  89126. static readonly NO_CAP: number;
  89127. /**
  89128. * Mesh cap setting : one cap at the beginning of the mesh
  89129. */
  89130. static readonly CAP_START: number;
  89131. /**
  89132. * Mesh cap setting : one cap at the end of the mesh
  89133. */
  89134. static readonly CAP_END: number;
  89135. /**
  89136. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  89137. */
  89138. static readonly CAP_ALL: number;
  89139. /**
  89140. * Mesh pattern setting : no flip or rotate
  89141. */
  89142. static readonly NO_FLIP: number;
  89143. /**
  89144. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  89145. */
  89146. static readonly FLIP_TILE: number;
  89147. /**
  89148. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  89149. */
  89150. static readonly ROTATE_TILE: number;
  89151. /**
  89152. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  89153. */
  89154. static readonly FLIP_ROW: number;
  89155. /**
  89156. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  89157. */
  89158. static readonly ROTATE_ROW: number;
  89159. /**
  89160. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  89161. */
  89162. static readonly FLIP_N_ROTATE_TILE: number;
  89163. /**
  89164. * Mesh pattern setting : rotate pattern and rotate
  89165. */
  89166. static readonly FLIP_N_ROTATE_ROW: number;
  89167. /**
  89168. * Mesh tile positioning : part tiles same on left/right or top/bottom
  89169. */
  89170. static readonly CENTER: number;
  89171. /**
  89172. * Mesh tile positioning : part tiles on left
  89173. */
  89174. static readonly LEFT: number;
  89175. /**
  89176. * Mesh tile positioning : part tiles on right
  89177. */
  89178. static readonly RIGHT: number;
  89179. /**
  89180. * Mesh tile positioning : part tiles on top
  89181. */
  89182. static readonly TOP: number;
  89183. /**
  89184. * Mesh tile positioning : part tiles on bottom
  89185. */
  89186. static readonly BOTTOM: number;
  89187. /**
  89188. * Gets the default side orientation.
  89189. * @param orientation the orientation to value to attempt to get
  89190. * @returns the default orientation
  89191. * @hidden
  89192. */
  89193. static _GetDefaultSideOrientation(orientation?: number): number;
  89194. private _internalMeshDataInfo;
  89195. /**
  89196. * An event triggered before rendering the mesh
  89197. */
  89198. readonly onBeforeRenderObservable: Observable<Mesh>;
  89199. /**
  89200. * An event triggered before binding the mesh
  89201. */
  89202. readonly onBeforeBindObservable: Observable<Mesh>;
  89203. /**
  89204. * An event triggered after rendering the mesh
  89205. */
  89206. readonly onAfterRenderObservable: Observable<Mesh>;
  89207. /**
  89208. * An event triggered before drawing the mesh
  89209. */
  89210. readonly onBeforeDrawObservable: Observable<Mesh>;
  89211. private _onBeforeDrawObserver;
  89212. /**
  89213. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  89214. */
  89215. onBeforeDraw: () => void;
  89216. readonly hasInstances: boolean;
  89217. /**
  89218. * Gets the delay loading state of the mesh (when delay loading is turned on)
  89219. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  89220. */
  89221. delayLoadState: number;
  89222. /**
  89223. * Gets the list of instances created from this mesh
  89224. * it is not supposed to be modified manually.
  89225. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  89226. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89227. */
  89228. instances: InstancedMesh[];
  89229. /**
  89230. * Gets the file containing delay loading data for this mesh
  89231. */
  89232. delayLoadingFile: string;
  89233. /** @hidden */
  89234. _binaryInfo: any;
  89235. /**
  89236. * User defined function used to change how LOD level selection is done
  89237. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89238. */
  89239. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  89240. /**
  89241. * Gets or sets the morph target manager
  89242. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89243. */
  89244. morphTargetManager: Nullable<MorphTargetManager>;
  89245. /** @hidden */
  89246. _creationDataStorage: Nullable<_CreationDataStorage>;
  89247. /** @hidden */
  89248. _geometry: Nullable<Geometry>;
  89249. /** @hidden */
  89250. _delayInfo: Array<string>;
  89251. /** @hidden */
  89252. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  89253. /** @hidden */
  89254. _instanceDataStorage: _InstanceDataStorage;
  89255. private _effectiveMaterial;
  89256. /** @hidden */
  89257. _shouldGenerateFlatShading: boolean;
  89258. /** @hidden */
  89259. _originalBuilderSideOrientation: number;
  89260. /**
  89261. * Use this property to change the original side orientation defined at construction time
  89262. */
  89263. overrideMaterialSideOrientation: Nullable<number>;
  89264. /**
  89265. * Gets the source mesh (the one used to clone this one from)
  89266. */
  89267. readonly source: Nullable<Mesh>;
  89268. /**
  89269. * Gets or sets a boolean indicating that this mesh does not use index buffer
  89270. */
  89271. isUnIndexed: boolean;
  89272. /**
  89273. * @constructor
  89274. * @param name The value used by scene.getMeshByName() to do a lookup.
  89275. * @param scene The scene to add this mesh to.
  89276. * @param parent The parent of this mesh, if it has one
  89277. * @param source An optional Mesh from which geometry is shared, cloned.
  89278. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89279. * When false, achieved by calling a clone(), also passing False.
  89280. * This will make creation of children, recursive.
  89281. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  89282. */
  89283. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  89284. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  89285. /**
  89286. * Gets the class name
  89287. * @returns the string "Mesh".
  89288. */
  89289. getClassName(): string;
  89290. /** @hidden */
  89291. readonly _isMesh: boolean;
  89292. /**
  89293. * Returns a description of this mesh
  89294. * @param fullDetails define if full details about this mesh must be used
  89295. * @returns a descriptive string representing this mesh
  89296. */
  89297. toString(fullDetails?: boolean): string;
  89298. /** @hidden */
  89299. _unBindEffect(): void;
  89300. /**
  89301. * Gets a boolean indicating if this mesh has LOD
  89302. */
  89303. readonly hasLODLevels: boolean;
  89304. /**
  89305. * Gets the list of MeshLODLevel associated with the current mesh
  89306. * @returns an array of MeshLODLevel
  89307. */
  89308. getLODLevels(): MeshLODLevel[];
  89309. private _sortLODLevels;
  89310. /**
  89311. * Add a mesh as LOD level triggered at the given distance.
  89312. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89313. * @param distance The distance from the center of the object to show this level
  89314. * @param mesh The mesh to be added as LOD level (can be null)
  89315. * @return This mesh (for chaining)
  89316. */
  89317. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  89318. /**
  89319. * Returns the LOD level mesh at the passed distance or null if not found.
  89320. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89321. * @param distance The distance from the center of the object to show this level
  89322. * @returns a Mesh or `null`
  89323. */
  89324. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  89325. /**
  89326. * Remove a mesh from the LOD array
  89327. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89328. * @param mesh defines the mesh to be removed
  89329. * @return This mesh (for chaining)
  89330. */
  89331. removeLODLevel(mesh: Mesh): Mesh;
  89332. /**
  89333. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  89334. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89335. * @param camera defines the camera to use to compute distance
  89336. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  89337. * @return This mesh (for chaining)
  89338. */
  89339. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  89340. /**
  89341. * Gets the mesh internal Geometry object
  89342. */
  89343. readonly geometry: Nullable<Geometry>;
  89344. /**
  89345. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  89346. * @returns the total number of vertices
  89347. */
  89348. getTotalVertices(): number;
  89349. /**
  89350. * Returns the content of an associated vertex buffer
  89351. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89352. * - VertexBuffer.PositionKind
  89353. * - VertexBuffer.UVKind
  89354. * - VertexBuffer.UV2Kind
  89355. * - VertexBuffer.UV3Kind
  89356. * - VertexBuffer.UV4Kind
  89357. * - VertexBuffer.UV5Kind
  89358. * - VertexBuffer.UV6Kind
  89359. * - VertexBuffer.ColorKind
  89360. * - VertexBuffer.MatricesIndicesKind
  89361. * - VertexBuffer.MatricesIndicesExtraKind
  89362. * - VertexBuffer.MatricesWeightsKind
  89363. * - VertexBuffer.MatricesWeightsExtraKind
  89364. * @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
  89365. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  89366. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  89367. */
  89368. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89369. /**
  89370. * Returns the mesh VertexBuffer object from the requested `kind`
  89371. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89372. * - VertexBuffer.PositionKind
  89373. * - VertexBuffer.NormalKind
  89374. * - VertexBuffer.UVKind
  89375. * - VertexBuffer.UV2Kind
  89376. * - VertexBuffer.UV3Kind
  89377. * - VertexBuffer.UV4Kind
  89378. * - VertexBuffer.UV5Kind
  89379. * - VertexBuffer.UV6Kind
  89380. * - VertexBuffer.ColorKind
  89381. * - VertexBuffer.MatricesIndicesKind
  89382. * - VertexBuffer.MatricesIndicesExtraKind
  89383. * - VertexBuffer.MatricesWeightsKind
  89384. * - VertexBuffer.MatricesWeightsExtraKind
  89385. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  89386. */
  89387. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89388. /**
  89389. * Tests if a specific vertex buffer is associated with this mesh
  89390. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89391. * - VertexBuffer.PositionKind
  89392. * - VertexBuffer.NormalKind
  89393. * - VertexBuffer.UVKind
  89394. * - VertexBuffer.UV2Kind
  89395. * - VertexBuffer.UV3Kind
  89396. * - VertexBuffer.UV4Kind
  89397. * - VertexBuffer.UV5Kind
  89398. * - VertexBuffer.UV6Kind
  89399. * - VertexBuffer.ColorKind
  89400. * - VertexBuffer.MatricesIndicesKind
  89401. * - VertexBuffer.MatricesIndicesExtraKind
  89402. * - VertexBuffer.MatricesWeightsKind
  89403. * - VertexBuffer.MatricesWeightsExtraKind
  89404. * @returns a boolean
  89405. */
  89406. isVerticesDataPresent(kind: string): boolean;
  89407. /**
  89408. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  89409. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89410. * - VertexBuffer.PositionKind
  89411. * - VertexBuffer.UVKind
  89412. * - VertexBuffer.UV2Kind
  89413. * - VertexBuffer.UV3Kind
  89414. * - VertexBuffer.UV4Kind
  89415. * - VertexBuffer.UV5Kind
  89416. * - VertexBuffer.UV6Kind
  89417. * - VertexBuffer.ColorKind
  89418. * - VertexBuffer.MatricesIndicesKind
  89419. * - VertexBuffer.MatricesIndicesExtraKind
  89420. * - VertexBuffer.MatricesWeightsKind
  89421. * - VertexBuffer.MatricesWeightsExtraKind
  89422. * @returns a boolean
  89423. */
  89424. isVertexBufferUpdatable(kind: string): boolean;
  89425. /**
  89426. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  89427. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89428. * - VertexBuffer.PositionKind
  89429. * - VertexBuffer.NormalKind
  89430. * - VertexBuffer.UVKind
  89431. * - VertexBuffer.UV2Kind
  89432. * - VertexBuffer.UV3Kind
  89433. * - VertexBuffer.UV4Kind
  89434. * - VertexBuffer.UV5Kind
  89435. * - VertexBuffer.UV6Kind
  89436. * - VertexBuffer.ColorKind
  89437. * - VertexBuffer.MatricesIndicesKind
  89438. * - VertexBuffer.MatricesIndicesExtraKind
  89439. * - VertexBuffer.MatricesWeightsKind
  89440. * - VertexBuffer.MatricesWeightsExtraKind
  89441. * @returns an array of strings
  89442. */
  89443. getVerticesDataKinds(): string[];
  89444. /**
  89445. * Returns a positive integer : the total number of indices in this mesh geometry.
  89446. * @returns the numner of indices or zero if the mesh has no geometry.
  89447. */
  89448. getTotalIndices(): number;
  89449. /**
  89450. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89451. * @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.
  89452. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89453. * @returns the indices array or an empty array if the mesh has no geometry
  89454. */
  89455. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89456. readonly isBlocked: boolean;
  89457. /**
  89458. * Determine if the current mesh is ready to be rendered
  89459. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89460. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  89461. * @returns true if all associated assets are ready (material, textures, shaders)
  89462. */
  89463. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  89464. /**
  89465. * 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.
  89466. */
  89467. readonly areNormalsFrozen: boolean;
  89468. /**
  89469. * 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.
  89470. * @returns the current mesh
  89471. */
  89472. freezeNormals(): Mesh;
  89473. /**
  89474. * 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
  89475. * @returns the current mesh
  89476. */
  89477. unfreezeNormals(): Mesh;
  89478. /**
  89479. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  89480. */
  89481. overridenInstanceCount: number;
  89482. /** @hidden */
  89483. _preActivate(): Mesh;
  89484. /** @hidden */
  89485. _preActivateForIntermediateRendering(renderId: number): Mesh;
  89486. /** @hidden */
  89487. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  89488. /**
  89489. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89490. * This means the mesh underlying bounding box and sphere are recomputed.
  89491. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89492. * @returns the current mesh
  89493. */
  89494. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  89495. /** @hidden */
  89496. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  89497. /**
  89498. * This function will subdivide the mesh into multiple submeshes
  89499. * @param count defines the expected number of submeshes
  89500. */
  89501. subdivide(count: number): void;
  89502. /**
  89503. * Copy a FloatArray into a specific associated vertex buffer
  89504. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89505. * - VertexBuffer.PositionKind
  89506. * - VertexBuffer.UVKind
  89507. * - VertexBuffer.UV2Kind
  89508. * - VertexBuffer.UV3Kind
  89509. * - VertexBuffer.UV4Kind
  89510. * - VertexBuffer.UV5Kind
  89511. * - VertexBuffer.UV6Kind
  89512. * - VertexBuffer.ColorKind
  89513. * - VertexBuffer.MatricesIndicesKind
  89514. * - VertexBuffer.MatricesIndicesExtraKind
  89515. * - VertexBuffer.MatricesWeightsKind
  89516. * - VertexBuffer.MatricesWeightsExtraKind
  89517. * @param data defines the data source
  89518. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89519. * @param stride defines the data stride size (can be null)
  89520. * @returns the current mesh
  89521. */
  89522. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89523. /**
  89524. * Flags an associated vertex buffer as updatable
  89525. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  89526. * - VertexBuffer.PositionKind
  89527. * - VertexBuffer.UVKind
  89528. * - VertexBuffer.UV2Kind
  89529. * - VertexBuffer.UV3Kind
  89530. * - VertexBuffer.UV4Kind
  89531. * - VertexBuffer.UV5Kind
  89532. * - VertexBuffer.UV6Kind
  89533. * - VertexBuffer.ColorKind
  89534. * - VertexBuffer.MatricesIndicesKind
  89535. * - VertexBuffer.MatricesIndicesExtraKind
  89536. * - VertexBuffer.MatricesWeightsKind
  89537. * - VertexBuffer.MatricesWeightsExtraKind
  89538. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89539. */
  89540. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  89541. /**
  89542. * Sets the mesh global Vertex Buffer
  89543. * @param buffer defines the buffer to use
  89544. * @returns the current mesh
  89545. */
  89546. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  89547. /**
  89548. * Update a specific associated vertex buffer
  89549. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89550. * - VertexBuffer.PositionKind
  89551. * - VertexBuffer.UVKind
  89552. * - VertexBuffer.UV2Kind
  89553. * - VertexBuffer.UV3Kind
  89554. * - VertexBuffer.UV4Kind
  89555. * - VertexBuffer.UV5Kind
  89556. * - VertexBuffer.UV6Kind
  89557. * - VertexBuffer.ColorKind
  89558. * - VertexBuffer.MatricesIndicesKind
  89559. * - VertexBuffer.MatricesIndicesExtraKind
  89560. * - VertexBuffer.MatricesWeightsKind
  89561. * - VertexBuffer.MatricesWeightsExtraKind
  89562. * @param data defines the data source
  89563. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89564. * @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)
  89565. * @returns the current mesh
  89566. */
  89567. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  89568. /**
  89569. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  89570. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  89571. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  89572. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  89573. * @returns the current mesh
  89574. */
  89575. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  89576. /**
  89577. * Creates a un-shared specific occurence of the geometry for the mesh.
  89578. * @returns the current mesh
  89579. */
  89580. makeGeometryUnique(): Mesh;
  89581. /**
  89582. * Set the index buffer of this mesh
  89583. * @param indices defines the source data
  89584. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  89585. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  89586. * @returns the current mesh
  89587. */
  89588. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  89589. /**
  89590. * Update the current index buffer
  89591. * @param indices defines the source data
  89592. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  89593. * @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)
  89594. * @returns the current mesh
  89595. */
  89596. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  89597. /**
  89598. * Invert the geometry to move from a right handed system to a left handed one.
  89599. * @returns the current mesh
  89600. */
  89601. toLeftHanded(): Mesh;
  89602. /** @hidden */
  89603. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  89604. /** @hidden */
  89605. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  89606. /**
  89607. * Registers for this mesh a javascript function called just before the rendering process
  89608. * @param func defines the function to call before rendering this mesh
  89609. * @returns the current mesh
  89610. */
  89611. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89612. /**
  89613. * Disposes a previously registered javascript function called before the rendering
  89614. * @param func defines the function to remove
  89615. * @returns the current mesh
  89616. */
  89617. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89618. /**
  89619. * Registers for this mesh a javascript function called just after the rendering is complete
  89620. * @param func defines the function to call after rendering this mesh
  89621. * @returns the current mesh
  89622. */
  89623. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89624. /**
  89625. * Disposes a previously registered javascript function called after the rendering.
  89626. * @param func defines the function to remove
  89627. * @returns the current mesh
  89628. */
  89629. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89630. /** @hidden */
  89631. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  89632. /** @hidden */
  89633. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  89634. /** @hidden */
  89635. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  89636. /** @hidden */
  89637. _rebuild(): void;
  89638. /** @hidden */
  89639. _freeze(): void;
  89640. /** @hidden */
  89641. _unFreeze(): void;
  89642. /**
  89643. * 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
  89644. * @param subMesh defines the subMesh to render
  89645. * @param enableAlphaMode defines if alpha mode can be changed
  89646. * @returns the current mesh
  89647. */
  89648. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  89649. private _onBeforeDraw;
  89650. /**
  89651. * Renormalize the mesh and patch it up if there are no weights
  89652. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  89653. * However in the case of zero weights then we set just a single influence to 1.
  89654. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  89655. */
  89656. cleanMatrixWeights(): void;
  89657. private normalizeSkinFourWeights;
  89658. private normalizeSkinWeightsAndExtra;
  89659. /**
  89660. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  89661. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  89662. * the user know there was an issue with importing the mesh
  89663. * @returns a validation object with skinned, valid and report string
  89664. */
  89665. validateSkinning(): {
  89666. skinned: boolean;
  89667. valid: boolean;
  89668. report: string;
  89669. };
  89670. /** @hidden */
  89671. _checkDelayState(): Mesh;
  89672. private _queueLoad;
  89673. /**
  89674. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  89675. * A mesh is in the frustum if its bounding box intersects the frustum
  89676. * @param frustumPlanes defines the frustum to test
  89677. * @returns true if the mesh is in the frustum planes
  89678. */
  89679. isInFrustum(frustumPlanes: Plane[]): boolean;
  89680. /**
  89681. * Sets the mesh material by the material or multiMaterial `id` property
  89682. * @param id is a string identifying the material or the multiMaterial
  89683. * @returns the current mesh
  89684. */
  89685. setMaterialByID(id: string): Mesh;
  89686. /**
  89687. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  89688. * @returns an array of IAnimatable
  89689. */
  89690. getAnimatables(): IAnimatable[];
  89691. /**
  89692. * Modifies the mesh geometry according to the passed transformation matrix.
  89693. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  89694. * The mesh normals are modified using the same transformation.
  89695. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89696. * @param transform defines the transform matrix to use
  89697. * @see http://doc.babylonjs.com/resources/baking_transformations
  89698. * @returns the current mesh
  89699. */
  89700. bakeTransformIntoVertices(transform: Matrix): Mesh;
  89701. /**
  89702. * Modifies the mesh geometry according to its own current World Matrix.
  89703. * The mesh World Matrix is then reset.
  89704. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  89705. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89706. * @see http://doc.babylonjs.com/resources/baking_transformations
  89707. * @returns the current mesh
  89708. */
  89709. bakeCurrentTransformIntoVertices(): Mesh;
  89710. /** @hidden */
  89711. readonly _positions: Nullable<Vector3[]>;
  89712. /** @hidden */
  89713. _resetPointsArrayCache(): Mesh;
  89714. /** @hidden */
  89715. _generatePointsArray(): boolean;
  89716. /**
  89717. * Returns a new Mesh object generated from the current mesh properties.
  89718. * This method must not get confused with createInstance()
  89719. * @param name is a string, the name given to the new mesh
  89720. * @param newParent can be any Node object (default `null`)
  89721. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  89722. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  89723. * @returns a new mesh
  89724. */
  89725. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  89726. /**
  89727. * Releases resources associated with this mesh.
  89728. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89729. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89730. */
  89731. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89732. /**
  89733. * Modifies the mesh geometry according to a displacement map.
  89734. * 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.
  89735. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89736. * @param url is a string, the URL from the image file is to be downloaded.
  89737. * @param minHeight is the lower limit of the displacement.
  89738. * @param maxHeight is the upper limit of the displacement.
  89739. * @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.
  89740. * @param uvOffset is an optional vector2 used to offset UV.
  89741. * @param uvScale is an optional vector2 used to scale UV.
  89742. * @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.
  89743. * @returns the Mesh.
  89744. */
  89745. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89746. /**
  89747. * Modifies the mesh geometry according to a displacementMap buffer.
  89748. * 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.
  89749. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89750. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  89751. * @param heightMapWidth is the width of the buffer image.
  89752. * @param heightMapHeight is the height of the buffer image.
  89753. * @param minHeight is the lower limit of the displacement.
  89754. * @param maxHeight is the upper limit of the displacement.
  89755. * @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.
  89756. * @param uvOffset is an optional vector2 used to offset UV.
  89757. * @param uvScale is an optional vector2 used to scale UV.
  89758. * @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.
  89759. * @returns the Mesh.
  89760. */
  89761. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89762. /**
  89763. * Modify the mesh to get a flat shading rendering.
  89764. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  89765. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  89766. * @returns current mesh
  89767. */
  89768. convertToFlatShadedMesh(): Mesh;
  89769. /**
  89770. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  89771. * In other words, more vertices, no more indices and a single bigger VBO.
  89772. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  89773. * @returns current mesh
  89774. */
  89775. convertToUnIndexedMesh(): Mesh;
  89776. /**
  89777. * Inverses facet orientations.
  89778. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89779. * @param flipNormals will also inverts the normals
  89780. * @returns current mesh
  89781. */
  89782. flipFaces(flipNormals?: boolean): Mesh;
  89783. /**
  89784. * Increase the number of facets and hence vertices in a mesh
  89785. * Vertex normals are interpolated from existing vertex normals
  89786. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89787. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  89788. */
  89789. increaseVertices(numberPerEdge: number): void;
  89790. /**
  89791. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  89792. * This will undo any application of covertToFlatShadedMesh
  89793. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89794. */
  89795. forceSharedVertices(): void;
  89796. /** @hidden */
  89797. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  89798. /** @hidden */
  89799. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  89800. /**
  89801. * Creates a new InstancedMesh object from the mesh model.
  89802. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89803. * @param name defines the name of the new instance
  89804. * @returns a new InstancedMesh
  89805. */
  89806. createInstance(name: string): InstancedMesh;
  89807. /**
  89808. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  89809. * After this call, all the mesh instances have the same submeshes than the current mesh.
  89810. * @returns the current mesh
  89811. */
  89812. synchronizeInstances(): Mesh;
  89813. /**
  89814. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  89815. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  89816. * This should be used together with the simplification to avoid disappearing triangles.
  89817. * @param successCallback an optional success callback to be called after the optimization finished.
  89818. * @returns the current mesh
  89819. */
  89820. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  89821. /**
  89822. * Serialize current mesh
  89823. * @param serializationObject defines the object which will receive the serialization data
  89824. */
  89825. serialize(serializationObject: any): void;
  89826. /** @hidden */
  89827. _syncGeometryWithMorphTargetManager(): void;
  89828. /** @hidden */
  89829. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  89830. /**
  89831. * Returns a new Mesh object parsed from the source provided.
  89832. * @param parsedMesh is the source
  89833. * @param scene defines the hosting scene
  89834. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  89835. * @returns a new Mesh
  89836. */
  89837. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  89838. /**
  89839. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  89840. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89841. * @param name defines the name of the mesh to create
  89842. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  89843. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  89844. * @param closePath creates a seam between the first and the last points of each path of the path array
  89845. * @param offset is taken in account only if the `pathArray` is containing a single path
  89846. * @param scene defines the hosting scene
  89847. * @param updatable defines if the mesh must be flagged as updatable
  89848. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89849. * @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)
  89850. * @returns a new Mesh
  89851. */
  89852. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89853. /**
  89854. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  89855. * @param name defines the name of the mesh to create
  89856. * @param radius sets the radius size (float) of the polygon (default 0.5)
  89857. * @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
  89858. * @param scene defines the hosting scene
  89859. * @param updatable defines if the mesh must be flagged as updatable
  89860. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89861. * @returns a new Mesh
  89862. */
  89863. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89864. /**
  89865. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  89866. * @param name defines the name of the mesh to create
  89867. * @param size sets the size (float) of each box side (default 1)
  89868. * @param scene defines the hosting scene
  89869. * @param updatable defines if the mesh must be flagged as updatable
  89870. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89871. * @returns a new Mesh
  89872. */
  89873. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89874. /**
  89875. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  89876. * @param name defines the name of the mesh to create
  89877. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89878. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89879. * @param scene defines the hosting scene
  89880. * @param updatable defines if the mesh must be flagged as updatable
  89881. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89882. * @returns a new Mesh
  89883. */
  89884. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89885. /**
  89886. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  89887. * @param name defines the name of the mesh to create
  89888. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89889. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89890. * @param scene defines the hosting scene
  89891. * @returns a new Mesh
  89892. */
  89893. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  89894. /**
  89895. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  89896. * @param name defines the name of the mesh to create
  89897. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  89898. * @param diameterTop set the top cap diameter (floats, default 1)
  89899. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  89900. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  89901. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  89902. * @param scene defines the hosting scene
  89903. * @param updatable defines if the mesh must be flagged as updatable
  89904. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89905. * @returns a new Mesh
  89906. */
  89907. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  89908. /**
  89909. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  89910. * @param name defines the name of the mesh to create
  89911. * @param diameter sets the diameter size (float) of the torus (default 1)
  89912. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  89913. * @param tessellation sets the number of torus sides (postive integer, default 16)
  89914. * @param scene defines the hosting scene
  89915. * @param updatable defines if the mesh must be flagged as updatable
  89916. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89917. * @returns a new Mesh
  89918. */
  89919. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89920. /**
  89921. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  89922. * @param name defines the name of the mesh to create
  89923. * @param radius sets the global radius size (float) of the torus knot (default 2)
  89924. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  89925. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  89926. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  89927. * @param p the number of windings on X axis (positive integers, default 2)
  89928. * @param q the number of windings on Y axis (positive integers, default 3)
  89929. * @param scene defines the hosting scene
  89930. * @param updatable defines if the mesh must be flagged as updatable
  89931. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89932. * @returns a new Mesh
  89933. */
  89934. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89935. /**
  89936. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  89937. * @param name defines the name of the mesh to create
  89938. * @param points is an array successive Vector3
  89939. * @param scene defines the hosting scene
  89940. * @param updatable defines if the mesh must be flagged as updatable
  89941. * @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).
  89942. * @returns a new Mesh
  89943. */
  89944. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  89945. /**
  89946. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  89947. * @param name defines the name of the mesh to create
  89948. * @param points is an array successive Vector3
  89949. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  89950. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  89951. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  89952. * @param scene defines the hosting scene
  89953. * @param updatable defines if the mesh must be flagged as updatable
  89954. * @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)
  89955. * @returns a new Mesh
  89956. */
  89957. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  89958. /**
  89959. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  89960. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  89961. * 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.
  89962. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  89963. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  89964. * Remember you can only change the shape positions, not their number when updating a polygon.
  89965. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  89966. * @param name defines the name of the mesh to create
  89967. * @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
  89968. * @param scene defines the hosting scene
  89969. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  89970. * @param updatable defines if the mesh must be flagged as updatable
  89971. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89972. * @param earcutInjection can be used to inject your own earcut reference
  89973. * @returns a new Mesh
  89974. */
  89975. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  89976. /**
  89977. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  89978. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  89979. * @param name defines the name of the mesh to create
  89980. * @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
  89981. * @param depth defines the height of extrusion
  89982. * @param scene defines the hosting scene
  89983. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  89984. * @param updatable defines if the mesh must be flagged as updatable
  89985. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89986. * @param earcutInjection can be used to inject your own earcut reference
  89987. * @returns a new Mesh
  89988. */
  89989. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  89990. /**
  89991. * Creates an extruded shape mesh.
  89992. * 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
  89993. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89994. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  89995. * @param name defines the name of the mesh to create
  89996. * @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
  89997. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  89998. * @param scale is the value to scale the shape
  89999. * @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
  90000. * @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
  90001. * @param scene defines the hosting scene
  90002. * @param updatable defines if the mesh must be flagged as updatable
  90003. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90004. * @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)
  90005. * @returns a new Mesh
  90006. */
  90007. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90008. /**
  90009. * Creates an custom extruded shape mesh.
  90010. * The custom extrusion is a parametric shape.
  90011. * It has no predefined shape. Its final shape will depend on the input parameters.
  90012. * Please consider using the same method from the MeshBuilder class instead
  90013. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90014. * @param name defines the name of the mesh to create
  90015. * @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
  90016. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90017. * @param scaleFunction is a custom Javascript function called on each path point
  90018. * @param rotationFunction is a custom Javascript function called on each path point
  90019. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  90020. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  90021. * @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
  90022. * @param scene defines the hosting scene
  90023. * @param updatable defines if the mesh must be flagged as updatable
  90024. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90025. * @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)
  90026. * @returns a new Mesh
  90027. */
  90028. 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;
  90029. /**
  90030. * Creates lathe mesh.
  90031. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  90032. * Please consider using the same method from the MeshBuilder class instead
  90033. * @param name defines the name of the mesh to create
  90034. * @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
  90035. * @param radius is the radius value of the lathe
  90036. * @param tessellation is the side number of the lathe.
  90037. * @param scene defines the hosting scene
  90038. * @param updatable defines if the mesh must be flagged as updatable
  90039. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90040. * @returns a new Mesh
  90041. */
  90042. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90043. /**
  90044. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  90045. * @param name defines the name of the mesh to create
  90046. * @param size sets the size (float) of both sides of the plane at once (default 1)
  90047. * @param scene defines the hosting scene
  90048. * @param updatable defines if the mesh must be flagged as updatable
  90049. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90050. * @returns a new Mesh
  90051. */
  90052. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90053. /**
  90054. * Creates a ground mesh.
  90055. * Please consider using the same method from the MeshBuilder class instead
  90056. * @param name defines the name of the mesh to create
  90057. * @param width set the width of the ground
  90058. * @param height set the height of the ground
  90059. * @param subdivisions sets the number of subdivisions per side
  90060. * @param scene defines the hosting scene
  90061. * @param updatable defines if the mesh must be flagged as updatable
  90062. * @returns a new Mesh
  90063. */
  90064. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  90065. /**
  90066. * Creates a tiled ground mesh.
  90067. * Please consider using the same method from the MeshBuilder class instead
  90068. * @param name defines the name of the mesh to create
  90069. * @param xmin set the ground minimum X coordinate
  90070. * @param zmin set the ground minimum Y coordinate
  90071. * @param xmax set the ground maximum X coordinate
  90072. * @param zmax set the ground maximum Z coordinate
  90073. * @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
  90074. * @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
  90075. * @param scene defines the hosting scene
  90076. * @param updatable defines if the mesh must be flagged as updatable
  90077. * @returns a new Mesh
  90078. */
  90079. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  90080. w: number;
  90081. h: number;
  90082. }, precision: {
  90083. w: number;
  90084. h: number;
  90085. }, scene: Scene, updatable?: boolean): Mesh;
  90086. /**
  90087. * Creates a ground mesh from a height map.
  90088. * Please consider using the same method from the MeshBuilder class instead
  90089. * @see http://doc.babylonjs.com/babylon101/height_map
  90090. * @param name defines the name of the mesh to create
  90091. * @param url sets the URL of the height map image resource
  90092. * @param width set the ground width size
  90093. * @param height set the ground height size
  90094. * @param subdivisions sets the number of subdivision per side
  90095. * @param minHeight is the minimum altitude on the ground
  90096. * @param maxHeight is the maximum altitude on the ground
  90097. * @param scene defines the hosting scene
  90098. * @param updatable defines if the mesh must be flagged as updatable
  90099. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  90100. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  90101. * @returns a new Mesh
  90102. */
  90103. 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;
  90104. /**
  90105. * Creates a tube mesh.
  90106. * The tube is a parametric shape.
  90107. * It has no predefined shape. Its final shape will depend on the input parameters.
  90108. * Please consider using the same method from the MeshBuilder class instead
  90109. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90110. * @param name defines the name of the mesh to create
  90111. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  90112. * @param radius sets the tube radius size
  90113. * @param tessellation is the number of sides on the tubular surface
  90114. * @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
  90115. * @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
  90116. * @param scene defines the hosting scene
  90117. * @param updatable defines if the mesh must be flagged as updatable
  90118. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90119. * @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)
  90120. * @returns a new Mesh
  90121. */
  90122. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  90123. (i: number, distance: number): number;
  90124. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90125. /**
  90126. * Creates a polyhedron mesh.
  90127. * Please consider using the same method from the MeshBuilder class instead.
  90128. * * 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
  90129. * * The parameter `size` (positive float, default 1) sets the polygon size
  90130. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  90131. * * 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`
  90132. * * 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
  90133. * * 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)`)
  90134. * * 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
  90135. * * 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
  90136. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90137. * * If you create a double-sided mesh, you can choose what parts of 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
  90138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90139. * @param name defines the name of the mesh to create
  90140. * @param options defines the options used to create the mesh
  90141. * @param scene defines the hosting scene
  90142. * @returns a new Mesh
  90143. */
  90144. static CreatePolyhedron(name: string, options: {
  90145. type?: number;
  90146. size?: number;
  90147. sizeX?: number;
  90148. sizeY?: number;
  90149. sizeZ?: number;
  90150. custom?: any;
  90151. faceUV?: Vector4[];
  90152. faceColors?: Color4[];
  90153. updatable?: boolean;
  90154. sideOrientation?: number;
  90155. }, scene: Scene): Mesh;
  90156. /**
  90157. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  90158. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  90159. * * 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`)
  90160. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  90161. * * 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
  90162. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90163. * * If you create a double-sided mesh, you can choose what parts of 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
  90164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90165. * @param name defines the name of the mesh
  90166. * @param options defines the options used to create the mesh
  90167. * @param scene defines the hosting scene
  90168. * @returns a new Mesh
  90169. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  90170. */
  90171. static CreateIcoSphere(name: string, options: {
  90172. radius?: number;
  90173. flat?: boolean;
  90174. subdivisions?: number;
  90175. sideOrientation?: number;
  90176. updatable?: boolean;
  90177. }, scene: Scene): Mesh;
  90178. /**
  90179. * Creates a decal mesh.
  90180. * Please consider using the same method from the MeshBuilder class instead.
  90181. * A decal is a mesh usually applied as a model onto the surface of another mesh
  90182. * @param name defines the name of the mesh
  90183. * @param sourceMesh defines the mesh receiving the decal
  90184. * @param position sets the position of the decal in world coordinates
  90185. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  90186. * @param size sets the decal scaling
  90187. * @param angle sets the angle to rotate the decal
  90188. * @returns a new Mesh
  90189. */
  90190. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  90191. /**
  90192. * Prepare internal position array for software CPU skinning
  90193. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  90194. */
  90195. setPositionsForCPUSkinning(): Float32Array;
  90196. /**
  90197. * Prepare internal normal array for software CPU skinning
  90198. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  90199. */
  90200. setNormalsForCPUSkinning(): Float32Array;
  90201. /**
  90202. * Updates the vertex buffer by applying transformation from the bones
  90203. * @param skeleton defines the skeleton to apply to current mesh
  90204. * @returns the current mesh
  90205. */
  90206. applySkeleton(skeleton: Skeleton): Mesh;
  90207. /**
  90208. * 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
  90209. * @param meshes defines the list of meshes to scan
  90210. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  90211. */
  90212. static MinMax(meshes: AbstractMesh[]): {
  90213. min: Vector3;
  90214. max: Vector3;
  90215. };
  90216. /**
  90217. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  90218. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  90219. * @returns a vector3
  90220. */
  90221. static Center(meshesOrMinMaxVector: {
  90222. min: Vector3;
  90223. max: Vector3;
  90224. } | AbstractMesh[]): Vector3;
  90225. /**
  90226. * Merge the array of meshes into a single mesh for performance reasons.
  90227. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  90228. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  90229. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  90230. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  90231. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  90232. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  90233. * @returns a new mesh
  90234. */
  90235. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  90236. /** @hidden */
  90237. addInstance(instance: InstancedMesh): void;
  90238. /** @hidden */
  90239. removeInstance(instance: InstancedMesh): void;
  90240. }
  90241. }
  90242. declare module BABYLON {
  90243. /**
  90244. * This is the base class of all the camera used in the application.
  90245. * @see http://doc.babylonjs.com/features/cameras
  90246. */
  90247. export class Camera extends Node {
  90248. /** @hidden */
  90249. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90250. /**
  90251. * This is the default projection mode used by the cameras.
  90252. * It helps recreating a feeling of perspective and better appreciate depth.
  90253. * This is the best way to simulate real life cameras.
  90254. */
  90255. static readonly PERSPECTIVE_CAMERA: number;
  90256. /**
  90257. * This helps creating camera with an orthographic mode.
  90258. * 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.
  90259. */
  90260. static readonly ORTHOGRAPHIC_CAMERA: number;
  90261. /**
  90262. * This is the default FOV mode for perspective cameras.
  90263. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90264. */
  90265. static readonly FOVMODE_VERTICAL_FIXED: number;
  90266. /**
  90267. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90268. */
  90269. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90270. /**
  90271. * This specifies ther is no need for a camera rig.
  90272. * Basically only one eye is rendered corresponding to the camera.
  90273. */
  90274. static readonly RIG_MODE_NONE: number;
  90275. /**
  90276. * Simulates a camera Rig with one blue eye and one red eye.
  90277. * This can be use with 3d blue and red glasses.
  90278. */
  90279. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90280. /**
  90281. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90282. */
  90283. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90284. /**
  90285. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90286. */
  90287. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90288. /**
  90289. * Defines that both eyes of the camera will be rendered over under each other.
  90290. */
  90291. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90292. /**
  90293. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90294. */
  90295. static readonly RIG_MODE_VR: number;
  90296. /**
  90297. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90298. */
  90299. static readonly RIG_MODE_WEBVR: number;
  90300. /**
  90301. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90302. */
  90303. static readonly RIG_MODE_CUSTOM: number;
  90304. /**
  90305. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90306. */
  90307. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90308. /**
  90309. * Define the input manager associated with the camera.
  90310. */
  90311. inputs: CameraInputsManager<Camera>;
  90312. /** @hidden */
  90313. _position: Vector3;
  90314. /**
  90315. * Define the current local position of the camera in the scene
  90316. */
  90317. position: Vector3;
  90318. /**
  90319. * The vector the camera should consider as up.
  90320. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90321. */
  90322. upVector: Vector3;
  90323. /**
  90324. * Define the current limit on the left side for an orthographic camera
  90325. * In scene unit
  90326. */
  90327. orthoLeft: Nullable<number>;
  90328. /**
  90329. * Define the current limit on the right side for an orthographic camera
  90330. * In scene unit
  90331. */
  90332. orthoRight: Nullable<number>;
  90333. /**
  90334. * Define the current limit on the bottom side for an orthographic camera
  90335. * In scene unit
  90336. */
  90337. orthoBottom: Nullable<number>;
  90338. /**
  90339. * Define the current limit on the top side for an orthographic camera
  90340. * In scene unit
  90341. */
  90342. orthoTop: Nullable<number>;
  90343. /**
  90344. * Field Of View is set in Radians. (default is 0.8)
  90345. */
  90346. fov: number;
  90347. /**
  90348. * Define the minimum distance the camera can see from.
  90349. * This is important to note that the depth buffer are not infinite and the closer it starts
  90350. * the more your scene might encounter depth fighting issue.
  90351. */
  90352. minZ: number;
  90353. /**
  90354. * Define the maximum distance the camera can see to.
  90355. * This is important to note that the depth buffer are not infinite and the further it end
  90356. * the more your scene might encounter depth fighting issue.
  90357. */
  90358. maxZ: number;
  90359. /**
  90360. * Define the default inertia of the camera.
  90361. * This helps giving a smooth feeling to the camera movement.
  90362. */
  90363. inertia: number;
  90364. /**
  90365. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  90366. */
  90367. mode: number;
  90368. /**
  90369. * Define wether the camera is intermediate.
  90370. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90371. */
  90372. isIntermediate: boolean;
  90373. /**
  90374. * Define the viewport of the camera.
  90375. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90376. */
  90377. viewport: Viewport;
  90378. /**
  90379. * Restricts the camera to viewing objects with the same layerMask.
  90380. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90381. */
  90382. layerMask: number;
  90383. /**
  90384. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90385. */
  90386. fovMode: number;
  90387. /**
  90388. * Rig mode of the camera.
  90389. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90390. * This is normally controlled byt the camera themselves as internal use.
  90391. */
  90392. cameraRigMode: number;
  90393. /**
  90394. * Defines the distance between both "eyes" in case of a RIG
  90395. */
  90396. interaxialDistance: number;
  90397. /**
  90398. * Defines if stereoscopic rendering is done side by side or over under.
  90399. */
  90400. isStereoscopicSideBySide: boolean;
  90401. /**
  90402. * 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
  90403. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90404. * else in the scene. (Eg. security camera)
  90405. *
  90406. * 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)
  90407. */
  90408. customRenderTargets: RenderTargetTexture[];
  90409. /**
  90410. * When set, the camera will render to this render target instead of the default canvas
  90411. *
  90412. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  90413. */
  90414. outputRenderTarget: Nullable<RenderTargetTexture>;
  90415. /**
  90416. * Observable triggered when the camera view matrix has changed.
  90417. */
  90418. onViewMatrixChangedObservable: Observable<Camera>;
  90419. /**
  90420. * Observable triggered when the camera Projection matrix has changed.
  90421. */
  90422. onProjectionMatrixChangedObservable: Observable<Camera>;
  90423. /**
  90424. * Observable triggered when the inputs have been processed.
  90425. */
  90426. onAfterCheckInputsObservable: Observable<Camera>;
  90427. /**
  90428. * Observable triggered when reset has been called and applied to the camera.
  90429. */
  90430. onRestoreStateObservable: Observable<Camera>;
  90431. /** @hidden */
  90432. _cameraRigParams: any;
  90433. /** @hidden */
  90434. _rigCameras: Camera[];
  90435. /** @hidden */
  90436. _rigPostProcess: Nullable<PostProcess>;
  90437. protected _webvrViewMatrix: Matrix;
  90438. /** @hidden */
  90439. _skipRendering: boolean;
  90440. /** @hidden */
  90441. _projectionMatrix: Matrix;
  90442. /** @hidden */
  90443. _postProcesses: Nullable<PostProcess>[];
  90444. /** @hidden */
  90445. _activeMeshes: SmartArray<AbstractMesh>;
  90446. protected _globalPosition: Vector3;
  90447. /** @hidden */
  90448. _computedViewMatrix: Matrix;
  90449. private _doNotComputeProjectionMatrix;
  90450. private _transformMatrix;
  90451. private _frustumPlanes;
  90452. private _refreshFrustumPlanes;
  90453. private _storedFov;
  90454. private _stateStored;
  90455. /**
  90456. * Instantiates a new camera object.
  90457. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90458. * @see http://doc.babylonjs.com/features/cameras
  90459. * @param name Defines the name of the camera in the scene
  90460. * @param position Defines the position of the camera
  90461. * @param scene Defines the scene the camera belongs too
  90462. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90463. */
  90464. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90465. /**
  90466. * Store current camera state (fov, position, etc..)
  90467. * @returns the camera
  90468. */
  90469. storeState(): Camera;
  90470. /**
  90471. * Restores the camera state values if it has been stored. You must call storeState() first
  90472. */
  90473. protected _restoreStateValues(): boolean;
  90474. /**
  90475. * Restored camera state. You must call storeState() first.
  90476. * @returns true if restored and false otherwise
  90477. */
  90478. restoreState(): boolean;
  90479. /**
  90480. * Gets the class name of the camera.
  90481. * @returns the class name
  90482. */
  90483. getClassName(): string;
  90484. /** @hidden */
  90485. readonly _isCamera: boolean;
  90486. /**
  90487. * Gets a string representation of the camera useful for debug purpose.
  90488. * @param fullDetails Defines that a more verboe level of logging is required
  90489. * @returns the string representation
  90490. */
  90491. toString(fullDetails?: boolean): string;
  90492. /**
  90493. * Gets the current world space position of the camera.
  90494. */
  90495. readonly globalPosition: Vector3;
  90496. /**
  90497. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90498. * @returns the active meshe list
  90499. */
  90500. getActiveMeshes(): SmartArray<AbstractMesh>;
  90501. /**
  90502. * Check wether a mesh is part of the current active mesh list of the camera
  90503. * @param mesh Defines the mesh to check
  90504. * @returns true if active, false otherwise
  90505. */
  90506. isActiveMesh(mesh: Mesh): boolean;
  90507. /**
  90508. * Is this camera ready to be used/rendered
  90509. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90510. * @return true if the camera is ready
  90511. */
  90512. isReady(completeCheck?: boolean): boolean;
  90513. /** @hidden */
  90514. _initCache(): void;
  90515. /** @hidden */
  90516. _updateCache(ignoreParentClass?: boolean): void;
  90517. /** @hidden */
  90518. _isSynchronized(): boolean;
  90519. /** @hidden */
  90520. _isSynchronizedViewMatrix(): boolean;
  90521. /** @hidden */
  90522. _isSynchronizedProjectionMatrix(): boolean;
  90523. /**
  90524. * Attach the input controls to a specific dom element to get the input from.
  90525. * @param element Defines the element the controls should be listened from
  90526. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90527. */
  90528. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90529. /**
  90530. * Detach the current controls from the specified dom element.
  90531. * @param element Defines the element to stop listening the inputs from
  90532. */
  90533. detachControl(element: HTMLElement): void;
  90534. /**
  90535. * Update the camera state according to the different inputs gathered during the frame.
  90536. */
  90537. update(): void;
  90538. /** @hidden */
  90539. _checkInputs(): void;
  90540. /** @hidden */
  90541. readonly rigCameras: Camera[];
  90542. /**
  90543. * Gets the post process used by the rig cameras
  90544. */
  90545. readonly rigPostProcess: Nullable<PostProcess>;
  90546. /**
  90547. * Internal, gets the first post proces.
  90548. * @returns the first post process to be run on this camera.
  90549. */
  90550. _getFirstPostProcess(): Nullable<PostProcess>;
  90551. private _cascadePostProcessesToRigCams;
  90552. /**
  90553. * Attach a post process to the camera.
  90554. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90555. * @param postProcess The post process to attach to the camera
  90556. * @param insertAt The position of the post process in case several of them are in use in the scene
  90557. * @returns the position the post process has been inserted at
  90558. */
  90559. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90560. /**
  90561. * Detach a post process to the camera.
  90562. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90563. * @param postProcess The post process to detach from the camera
  90564. */
  90565. detachPostProcess(postProcess: PostProcess): void;
  90566. /**
  90567. * Gets the current world matrix of the camera
  90568. */
  90569. getWorldMatrix(): Matrix;
  90570. /** @hidden */
  90571. _getViewMatrix(): Matrix;
  90572. /**
  90573. * Gets the current view matrix of the camera.
  90574. * @param force forces the camera to recompute the matrix without looking at the cached state
  90575. * @returns the view matrix
  90576. */
  90577. getViewMatrix(force?: boolean): Matrix;
  90578. /**
  90579. * Freeze the projection matrix.
  90580. * It will prevent the cache check of the camera projection compute and can speed up perf
  90581. * if no parameter of the camera are meant to change
  90582. * @param projection Defines manually a projection if necessary
  90583. */
  90584. freezeProjectionMatrix(projection?: Matrix): void;
  90585. /**
  90586. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90587. */
  90588. unfreezeProjectionMatrix(): void;
  90589. /**
  90590. * Gets the current projection matrix of the camera.
  90591. * @param force forces the camera to recompute the matrix without looking at the cached state
  90592. * @returns the projection matrix
  90593. */
  90594. getProjectionMatrix(force?: boolean): Matrix;
  90595. /**
  90596. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90597. * @returns a Matrix
  90598. */
  90599. getTransformationMatrix(): Matrix;
  90600. private _updateFrustumPlanes;
  90601. /**
  90602. * Checks if a cullable object (mesh...) is in the camera frustum
  90603. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90604. * @param target The object to check
  90605. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  90606. * @returns true if the object is in frustum otherwise false
  90607. */
  90608. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  90609. /**
  90610. * Checks if a cullable object (mesh...) is in the camera frustum
  90611. * Unlike isInFrustum this cheks the full bounding box
  90612. * @param target The object to check
  90613. * @returns true if the object is in frustum otherwise false
  90614. */
  90615. isCompletelyInFrustum(target: ICullable): boolean;
  90616. /**
  90617. * Gets a ray in the forward direction from the camera.
  90618. * @param length Defines the length of the ray to create
  90619. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90620. * @param origin Defines the start point of the ray which defaults to the camera position
  90621. * @returns the forward ray
  90622. */
  90623. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90624. /**
  90625. * Releases resources associated with this node.
  90626. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90627. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90628. */
  90629. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90630. /** @hidden */
  90631. _isLeftCamera: boolean;
  90632. /**
  90633. * Gets the left camera of a rig setup in case of Rigged Camera
  90634. */
  90635. readonly isLeftCamera: boolean;
  90636. /** @hidden */
  90637. _isRightCamera: boolean;
  90638. /**
  90639. * Gets the right camera of a rig setup in case of Rigged Camera
  90640. */
  90641. readonly isRightCamera: boolean;
  90642. /**
  90643. * Gets the left camera of a rig setup in case of Rigged Camera
  90644. */
  90645. readonly leftCamera: Nullable<FreeCamera>;
  90646. /**
  90647. * Gets the right camera of a rig setup in case of Rigged Camera
  90648. */
  90649. readonly rightCamera: Nullable<FreeCamera>;
  90650. /**
  90651. * Gets the left camera target of a rig setup in case of Rigged Camera
  90652. * @returns the target position
  90653. */
  90654. getLeftTarget(): Nullable<Vector3>;
  90655. /**
  90656. * Gets the right camera target of a rig setup in case of Rigged Camera
  90657. * @returns the target position
  90658. */
  90659. getRightTarget(): Nullable<Vector3>;
  90660. /**
  90661. * @hidden
  90662. */
  90663. setCameraRigMode(mode: number, rigParams: any): void;
  90664. /** @hidden */
  90665. static _setStereoscopicRigMode(camera: Camera): void;
  90666. /** @hidden */
  90667. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90668. /** @hidden */
  90669. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90670. /** @hidden */
  90671. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90672. /** @hidden */
  90673. _getVRProjectionMatrix(): Matrix;
  90674. protected _updateCameraRotationMatrix(): void;
  90675. protected _updateWebVRCameraRotationMatrix(): void;
  90676. /**
  90677. * This function MUST be overwritten by the different WebVR cameras available.
  90678. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90679. * @hidden
  90680. */
  90681. _getWebVRProjectionMatrix(): Matrix;
  90682. /**
  90683. * This function MUST be overwritten by the different WebVR cameras available.
  90684. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90685. * @hidden
  90686. */
  90687. _getWebVRViewMatrix(): Matrix;
  90688. /** @hidden */
  90689. setCameraRigParameter(name: string, value: any): void;
  90690. /**
  90691. * needs to be overridden by children so sub has required properties to be copied
  90692. * @hidden
  90693. */
  90694. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90695. /**
  90696. * May need to be overridden by children
  90697. * @hidden
  90698. */
  90699. _updateRigCameras(): void;
  90700. /** @hidden */
  90701. _setupInputs(): void;
  90702. /**
  90703. * Serialiaze the camera setup to a json represention
  90704. * @returns the JSON representation
  90705. */
  90706. serialize(): any;
  90707. /**
  90708. * Clones the current camera.
  90709. * @param name The cloned camera name
  90710. * @returns the cloned camera
  90711. */
  90712. clone(name: string): Camera;
  90713. /**
  90714. * Gets the direction of the camera relative to a given local axis.
  90715. * @param localAxis Defines the reference axis to provide a relative direction.
  90716. * @return the direction
  90717. */
  90718. getDirection(localAxis: Vector3): Vector3;
  90719. /**
  90720. * Returns the current camera absolute rotation
  90721. */
  90722. readonly absoluteRotation: Quaternion;
  90723. /**
  90724. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90725. * @param localAxis Defines the reference axis to provide a relative direction.
  90726. * @param result Defines the vector to store the result in
  90727. */
  90728. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90729. /**
  90730. * Gets a camera constructor for a given camera type
  90731. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90732. * @param name The name of the camera the result will be able to instantiate
  90733. * @param scene The scene the result will construct the camera in
  90734. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90735. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90736. * @returns a factory method to construc the camera
  90737. */
  90738. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90739. /**
  90740. * Compute the world matrix of the camera.
  90741. * @returns the camera workd matrix
  90742. */
  90743. computeWorldMatrix(): Matrix;
  90744. /**
  90745. * Parse a JSON and creates the camera from the parsed information
  90746. * @param parsedCamera The JSON to parse
  90747. * @param scene The scene to instantiate the camera in
  90748. * @returns the newly constructed camera
  90749. */
  90750. static Parse(parsedCamera: any, scene: Scene): Camera;
  90751. }
  90752. }
  90753. declare module BABYLON {
  90754. /**
  90755. * Class containing static functions to help procedurally build meshes
  90756. */
  90757. export class DiscBuilder {
  90758. /**
  90759. * Creates a plane polygonal mesh. By default, this is a disc
  90760. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  90761. * * 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
  90762. * * 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
  90763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90764. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  90765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90766. * @param name defines the name of the mesh
  90767. * @param options defines the options used to create the mesh
  90768. * @param scene defines the hosting scene
  90769. * @returns the plane polygonal mesh
  90770. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  90771. */
  90772. static CreateDisc(name: string, options: {
  90773. radius?: number;
  90774. tessellation?: number;
  90775. arc?: number;
  90776. updatable?: boolean;
  90777. sideOrientation?: number;
  90778. frontUVs?: Vector4;
  90779. backUVs?: Vector4;
  90780. }, scene?: Nullable<Scene>): Mesh;
  90781. }
  90782. }
  90783. declare module BABYLON {
  90784. /**
  90785. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  90786. *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.
  90787. * The SPS is also a particle system. It provides some methods to manage the particles.
  90788. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  90789. *
  90790. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  90791. */
  90792. export class SolidParticleSystem implements IDisposable {
  90793. /**
  90794. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  90795. * Example : var p = SPS.particles[i];
  90796. */
  90797. particles: SolidParticle[];
  90798. /**
  90799. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  90800. */
  90801. nbParticles: number;
  90802. /**
  90803. * If the particles must ever face the camera (default false). Useful for planar particles.
  90804. */
  90805. billboard: boolean;
  90806. /**
  90807. * Recompute normals when adding a shape
  90808. */
  90809. recomputeNormals: boolean;
  90810. /**
  90811. * This a counter ofr your own usage. It's not set by any SPS functions.
  90812. */
  90813. counter: number;
  90814. /**
  90815. * The SPS name. This name is also given to the underlying mesh.
  90816. */
  90817. name: string;
  90818. /**
  90819. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  90820. */
  90821. mesh: Mesh;
  90822. /**
  90823. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  90824. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  90825. */
  90826. vars: any;
  90827. /**
  90828. * This array is populated when the SPS is set as 'pickable'.
  90829. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  90830. * Each element of this array is an object `{idx: int, faceId: int}`.
  90831. * `idx` is the picked particle index in the `SPS.particles` array
  90832. * `faceId` is the picked face index counted within this particle.
  90833. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  90834. */
  90835. pickedParticles: {
  90836. idx: number;
  90837. faceId: number;
  90838. }[];
  90839. /**
  90840. * This array is populated when `enableDepthSort` is set to true.
  90841. * Each element of this array is an instance of the class DepthSortedParticle.
  90842. */
  90843. depthSortedParticles: DepthSortedParticle[];
  90844. /**
  90845. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  90846. * @hidden
  90847. */
  90848. _bSphereOnly: boolean;
  90849. /**
  90850. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  90851. * @hidden
  90852. */
  90853. _bSphereRadiusFactor: number;
  90854. private _scene;
  90855. private _positions;
  90856. private _indices;
  90857. private _normals;
  90858. private _colors;
  90859. private _uvs;
  90860. private _indices32;
  90861. private _positions32;
  90862. private _normals32;
  90863. private _fixedNormal32;
  90864. private _colors32;
  90865. private _uvs32;
  90866. private _index;
  90867. private _updatable;
  90868. private _pickable;
  90869. private _isVisibilityBoxLocked;
  90870. private _alwaysVisible;
  90871. private _depthSort;
  90872. private _shapeCounter;
  90873. private _copy;
  90874. private _color;
  90875. private _computeParticleColor;
  90876. private _computeParticleTexture;
  90877. private _computeParticleRotation;
  90878. private _computeParticleVertex;
  90879. private _computeBoundingBox;
  90880. private _depthSortParticles;
  90881. private _camera;
  90882. private _mustUnrotateFixedNormals;
  90883. private _particlesIntersect;
  90884. private _needs32Bits;
  90885. /**
  90886. * Creates a SPS (Solid Particle System) object.
  90887. * @param name (String) is the SPS name, this will be the underlying mesh name.
  90888. * @param scene (Scene) is the scene in which the SPS is added.
  90889. * @param options defines the options of the sps e.g.
  90890. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  90891. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  90892. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  90893. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  90894. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  90895. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  90896. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  90897. */
  90898. constructor(name: string, scene: Scene, options?: {
  90899. updatable?: boolean;
  90900. isPickable?: boolean;
  90901. enableDepthSort?: boolean;
  90902. particleIntersection?: boolean;
  90903. boundingSphereOnly?: boolean;
  90904. bSphereRadiusFactor?: number;
  90905. });
  90906. /**
  90907. * Builds the SPS underlying mesh. Returns a standard Mesh.
  90908. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  90909. * @returns the created mesh
  90910. */
  90911. buildMesh(): Mesh;
  90912. /**
  90913. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  90914. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  90915. * Thus the particles generated from `digest()` have their property `position` set yet.
  90916. * @param mesh ( Mesh ) is the mesh to be digested
  90917. * @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
  90918. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  90919. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  90920. * @returns the current SPS
  90921. */
  90922. digest(mesh: Mesh, options?: {
  90923. facetNb?: number;
  90924. number?: number;
  90925. delta?: number;
  90926. }): SolidParticleSystem;
  90927. private _unrotateFixedNormals;
  90928. private _resetCopy;
  90929. private _meshBuilder;
  90930. private _posToShape;
  90931. private _uvsToShapeUV;
  90932. private _addParticle;
  90933. /**
  90934. * Adds some particles to the SPS from the model shape. Returns the shape id.
  90935. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  90936. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  90937. * @param nb (positive integer) the number of particles to be created from this model
  90938. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  90939. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  90940. * @returns the number of shapes in the system
  90941. */
  90942. addShape(mesh: Mesh, nb: number, options?: {
  90943. positionFunction?: any;
  90944. vertexFunction?: any;
  90945. }): number;
  90946. private _rebuildParticle;
  90947. /**
  90948. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  90949. * @returns the SPS.
  90950. */
  90951. rebuildMesh(): SolidParticleSystem;
  90952. /**
  90953. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  90954. * This method calls `updateParticle()` for each particle of the SPS.
  90955. * For an animated SPS, it is usually called within the render loop.
  90956. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  90957. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  90958. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  90959. * @returns the SPS.
  90960. */
  90961. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  90962. /**
  90963. * Disposes the SPS.
  90964. */
  90965. dispose(): void;
  90966. /**
  90967. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  90968. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90969. * @returns the SPS.
  90970. */
  90971. refreshVisibleSize(): SolidParticleSystem;
  90972. /**
  90973. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  90974. * @param size the size (float) of the visibility box
  90975. * note : this doesn't lock the SPS mesh bounding box.
  90976. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90977. */
  90978. setVisibilityBox(size: number): void;
  90979. /**
  90980. * Gets whether the SPS as always visible or not
  90981. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90982. */
  90983. /**
  90984. * Sets the SPS as always visible or not
  90985. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90986. */
  90987. isAlwaysVisible: boolean;
  90988. /**
  90989. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  90990. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90991. */
  90992. /**
  90993. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  90994. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  90995. */
  90996. isVisibilityBoxLocked: boolean;
  90997. /**
  90998. * Tells to `setParticles()` to compute the particle rotations or not.
  90999. * Default value : true. The SPS is faster when it's set to false.
  91000. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91001. */
  91002. /**
  91003. * Gets if `setParticles()` computes the particle rotations or not.
  91004. * Default value : true. The SPS is faster when it's set to false.
  91005. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91006. */
  91007. computeParticleRotation: boolean;
  91008. /**
  91009. * Tells to `setParticles()` to compute the particle colors or not.
  91010. * Default value : true. The SPS is faster when it's set to false.
  91011. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91012. */
  91013. /**
  91014. * Gets if `setParticles()` computes the particle colors or not.
  91015. * Default value : true. The SPS is faster when it's set to false.
  91016. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91017. */
  91018. computeParticleColor: boolean;
  91019. /**
  91020. * Gets if `setParticles()` computes the particle textures or not.
  91021. * Default value : true. The SPS is faster when it's set to false.
  91022. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  91023. */
  91024. computeParticleTexture: boolean;
  91025. /**
  91026. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  91027. * Default value : false. The SPS is faster when it's set to false.
  91028. * Note : the particle custom vertex positions aren't stored values.
  91029. */
  91030. /**
  91031. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  91032. * Default value : false. The SPS is faster when it's set to false.
  91033. * Note : the particle custom vertex positions aren't stored values.
  91034. */
  91035. computeParticleVertex: boolean;
  91036. /**
  91037. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  91038. */
  91039. /**
  91040. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  91041. */
  91042. computeBoundingBox: boolean;
  91043. /**
  91044. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  91045. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91046. * Default : `true`
  91047. */
  91048. /**
  91049. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  91050. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91051. * Default : `true`
  91052. */
  91053. depthSortParticles: boolean;
  91054. /**
  91055. * This function does nothing. It may be overwritten to set all the particle first values.
  91056. * The SPS doesn't call this function, you may have to call it by your own.
  91057. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91058. */
  91059. initParticles(): void;
  91060. /**
  91061. * This function does nothing. It may be overwritten to recycle a particle.
  91062. * The SPS doesn't call this function, you may have to call it by your own.
  91063. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91064. * @param particle The particle to recycle
  91065. * @returns the recycled particle
  91066. */
  91067. recycleParticle(particle: SolidParticle): SolidParticle;
  91068. /**
  91069. * Updates a particle : this function should be overwritten by the user.
  91070. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  91071. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91072. * @example : just set a particle position or velocity and recycle conditions
  91073. * @param particle The particle to update
  91074. * @returns the updated particle
  91075. */
  91076. updateParticle(particle: SolidParticle): SolidParticle;
  91077. /**
  91078. * Updates a vertex of a particle : it can be overwritten by the user.
  91079. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  91080. * @param particle the current particle
  91081. * @param vertex the current index of the current particle
  91082. * @param pt the index of the current vertex in the particle shape
  91083. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  91084. * @example : just set a vertex particle position
  91085. * @returns the updated vertex
  91086. */
  91087. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  91088. /**
  91089. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  91090. * This does nothing and may be overwritten by the user.
  91091. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91092. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91093. * @param update the boolean update value actually passed to setParticles()
  91094. */
  91095. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91096. /**
  91097. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  91098. * This will be passed three parameters.
  91099. * This does nothing and may be overwritten by the user.
  91100. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91101. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91102. * @param update the boolean update value actually passed to setParticles()
  91103. */
  91104. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91105. }
  91106. }
  91107. declare module BABYLON {
  91108. /**
  91109. * Represents one particle of a solid particle system.
  91110. */
  91111. export class SolidParticle {
  91112. /**
  91113. * particle global index
  91114. */
  91115. idx: number;
  91116. /**
  91117. * The color of the particle
  91118. */
  91119. color: Nullable<Color4>;
  91120. /**
  91121. * The world space position of the particle.
  91122. */
  91123. position: Vector3;
  91124. /**
  91125. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  91126. */
  91127. rotation: Vector3;
  91128. /**
  91129. * The world space rotation quaternion of the particle.
  91130. */
  91131. rotationQuaternion: Nullable<Quaternion>;
  91132. /**
  91133. * The scaling of the particle.
  91134. */
  91135. scaling: Vector3;
  91136. /**
  91137. * The uvs of the particle.
  91138. */
  91139. uvs: Vector4;
  91140. /**
  91141. * The current speed of the particle.
  91142. */
  91143. velocity: Vector3;
  91144. /**
  91145. * The pivot point in the particle local space.
  91146. */
  91147. pivot: Vector3;
  91148. /**
  91149. * Must the particle be translated from its pivot point in its local space ?
  91150. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  91151. * Default : false
  91152. */
  91153. translateFromPivot: boolean;
  91154. /**
  91155. * Is the particle active or not ?
  91156. */
  91157. alive: boolean;
  91158. /**
  91159. * Is the particle visible or not ?
  91160. */
  91161. isVisible: boolean;
  91162. /**
  91163. * Index of this particle in the global "positions" array (Internal use)
  91164. * @hidden
  91165. */
  91166. _pos: number;
  91167. /**
  91168. * @hidden Index of this particle in the global "indices" array (Internal use)
  91169. */
  91170. _ind: number;
  91171. /**
  91172. * @hidden ModelShape of this particle (Internal use)
  91173. */
  91174. _model: ModelShape;
  91175. /**
  91176. * ModelShape id of this particle
  91177. */
  91178. shapeId: number;
  91179. /**
  91180. * Index of the particle in its shape id
  91181. */
  91182. idxInShape: number;
  91183. /**
  91184. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  91185. */
  91186. _modelBoundingInfo: BoundingInfo;
  91187. /**
  91188. * @hidden Particle BoundingInfo object (Internal use)
  91189. */
  91190. _boundingInfo: BoundingInfo;
  91191. /**
  91192. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  91193. */
  91194. _sps: SolidParticleSystem;
  91195. /**
  91196. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  91197. */
  91198. _stillInvisible: boolean;
  91199. /**
  91200. * @hidden Last computed particle rotation matrix
  91201. */
  91202. _rotationMatrix: number[];
  91203. /**
  91204. * Parent particle Id, if any.
  91205. * Default null.
  91206. */
  91207. parentId: Nullable<number>;
  91208. /**
  91209. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  91210. * The possible values are :
  91211. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91212. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91213. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91214. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91215. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91216. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  91217. * */
  91218. cullingStrategy: number;
  91219. /**
  91220. * @hidden Internal global position in the SPS.
  91221. */
  91222. _globalPosition: Vector3;
  91223. /**
  91224. * Creates a Solid Particle object.
  91225. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  91226. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  91227. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  91228. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  91229. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  91230. * @param shapeId (integer) is the model shape identifier in the SPS.
  91231. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  91232. * @param sps defines the sps it is associated to
  91233. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  91234. */
  91235. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  91236. /**
  91237. * Legacy support, changed scale to scaling
  91238. */
  91239. /**
  91240. * Legacy support, changed scale to scaling
  91241. */
  91242. scale: Vector3;
  91243. /**
  91244. * Legacy support, changed quaternion to rotationQuaternion
  91245. */
  91246. /**
  91247. * Legacy support, changed quaternion to rotationQuaternion
  91248. */
  91249. quaternion: Nullable<Quaternion>;
  91250. /**
  91251. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  91252. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  91253. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  91254. * @returns true if it intersects
  91255. */
  91256. intersectsMesh(target: Mesh | SolidParticle): boolean;
  91257. /**
  91258. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  91259. * A particle is in the frustum if its bounding box intersects the frustum
  91260. * @param frustumPlanes defines the frustum to test
  91261. * @returns true if the particle is in the frustum planes
  91262. */
  91263. isInFrustum(frustumPlanes: Plane[]): boolean;
  91264. /**
  91265. * get the rotation matrix of the particle
  91266. * @hidden
  91267. */
  91268. getRotationMatrix(m: Matrix): void;
  91269. }
  91270. /**
  91271. * Represents the shape of the model used by one particle of a solid particle system.
  91272. * SPS internal tool, don't use it manually.
  91273. */
  91274. export class ModelShape {
  91275. /**
  91276. * The shape id
  91277. * @hidden
  91278. */
  91279. shapeID: number;
  91280. /**
  91281. * flat array of model positions (internal use)
  91282. * @hidden
  91283. */
  91284. _shape: Vector3[];
  91285. /**
  91286. * flat array of model UVs (internal use)
  91287. * @hidden
  91288. */
  91289. _shapeUV: number[];
  91290. /**
  91291. * length of the shape in the model indices array (internal use)
  91292. * @hidden
  91293. */
  91294. _indicesLength: number;
  91295. /**
  91296. * Custom position function (internal use)
  91297. * @hidden
  91298. */
  91299. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  91300. /**
  91301. * Custom vertex function (internal use)
  91302. * @hidden
  91303. */
  91304. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  91305. /**
  91306. * 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.
  91307. * SPS internal tool, don't use it manually.
  91308. * @hidden
  91309. */
  91310. 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>);
  91311. }
  91312. /**
  91313. * Represents a Depth Sorted Particle in the solid particle system.
  91314. */
  91315. export class DepthSortedParticle {
  91316. /**
  91317. * Index of the particle in the "indices" array
  91318. */
  91319. ind: number;
  91320. /**
  91321. * Length of the particle shape in the "indices" array
  91322. */
  91323. indicesLength: number;
  91324. /**
  91325. * Squared distance from the particle to the camera
  91326. */
  91327. sqDistance: number;
  91328. }
  91329. }
  91330. declare module BABYLON {
  91331. /**
  91332. * @hidden
  91333. */
  91334. export class _MeshCollisionData {
  91335. _checkCollisions: boolean;
  91336. _collisionMask: number;
  91337. _collisionGroup: number;
  91338. _collider: Nullable<Collider>;
  91339. _oldPositionForCollisions: Vector3;
  91340. _diffPositionForCollisions: Vector3;
  91341. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  91342. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  91343. }
  91344. }
  91345. declare module BABYLON {
  91346. /** @hidden */
  91347. class _FacetDataStorage {
  91348. facetPositions: Vector3[];
  91349. facetNormals: Vector3[];
  91350. facetPartitioning: number[][];
  91351. facetNb: number;
  91352. partitioningSubdivisions: number;
  91353. partitioningBBoxRatio: number;
  91354. facetDataEnabled: boolean;
  91355. facetParameters: any;
  91356. bbSize: Vector3;
  91357. subDiv: {
  91358. max: number;
  91359. X: number;
  91360. Y: number;
  91361. Z: number;
  91362. };
  91363. facetDepthSort: boolean;
  91364. facetDepthSortEnabled: boolean;
  91365. depthSortedIndices: IndicesArray;
  91366. depthSortedFacets: {
  91367. ind: number;
  91368. sqDistance: number;
  91369. }[];
  91370. facetDepthSortFunction: (f1: {
  91371. ind: number;
  91372. sqDistance: number;
  91373. }, f2: {
  91374. ind: number;
  91375. sqDistance: number;
  91376. }) => number;
  91377. facetDepthSortFrom: Vector3;
  91378. facetDepthSortOrigin: Vector3;
  91379. invertedMatrix: Matrix;
  91380. }
  91381. /**
  91382. * @hidden
  91383. **/
  91384. class _InternalAbstractMeshDataInfo {
  91385. _hasVertexAlpha: boolean;
  91386. _useVertexColors: boolean;
  91387. _numBoneInfluencers: number;
  91388. _applyFog: boolean;
  91389. _receiveShadows: boolean;
  91390. _facetData: _FacetDataStorage;
  91391. _visibility: number;
  91392. _skeleton: Nullable<Skeleton>;
  91393. _layerMask: number;
  91394. _computeBonesUsingShaders: boolean;
  91395. _isActive: boolean;
  91396. _onlyForInstances: boolean;
  91397. _isActiveIntermediate: boolean;
  91398. _onlyForInstancesIntermediate: boolean;
  91399. }
  91400. /**
  91401. * Class used to store all common mesh properties
  91402. */
  91403. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  91404. /** No occlusion */
  91405. static OCCLUSION_TYPE_NONE: number;
  91406. /** Occlusion set to optimisitic */
  91407. static OCCLUSION_TYPE_OPTIMISTIC: number;
  91408. /** Occlusion set to strict */
  91409. static OCCLUSION_TYPE_STRICT: number;
  91410. /** Use an accurante occlusion algorithm */
  91411. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  91412. /** Use a conservative occlusion algorithm */
  91413. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  91414. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  91415. * Test order :
  91416. * Is the bounding sphere outside the frustum ?
  91417. * If not, are the bounding box vertices outside the frustum ?
  91418. * It not, then the cullable object is in the frustum.
  91419. */
  91420. static readonly CULLINGSTRATEGY_STANDARD: number;
  91421. /** Culling strategy : Bounding Sphere Only.
  91422. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  91423. * It's also less accurate than the standard because some not visible objects can still be selected.
  91424. * Test : is the bounding sphere outside the frustum ?
  91425. * If not, then the cullable object is in the frustum.
  91426. */
  91427. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  91428. /** Culling strategy : Optimistic Inclusion.
  91429. * This in an inclusion test first, then the standard exclusion test.
  91430. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  91431. * 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.
  91432. * Anyway, it's as accurate as the standard strategy.
  91433. * Test :
  91434. * Is the cullable object bounding sphere center in the frustum ?
  91435. * If not, apply the default culling strategy.
  91436. */
  91437. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  91438. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  91439. * This in an inclusion test first, then the bounding sphere only exclusion test.
  91440. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  91441. * 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.
  91442. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  91443. * Test :
  91444. * Is the cullable object bounding sphere center in the frustum ?
  91445. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  91446. */
  91447. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  91448. /**
  91449. * No billboard
  91450. */
  91451. static readonly BILLBOARDMODE_NONE: number;
  91452. /** Billboard on X axis */
  91453. static readonly BILLBOARDMODE_X: number;
  91454. /** Billboard on Y axis */
  91455. static readonly BILLBOARDMODE_Y: number;
  91456. /** Billboard on Z axis */
  91457. static readonly BILLBOARDMODE_Z: number;
  91458. /** Billboard on all axes */
  91459. static readonly BILLBOARDMODE_ALL: number;
  91460. /** Billboard on using position instead of orientation */
  91461. static readonly BILLBOARDMODE_USE_POSITION: number;
  91462. /** @hidden */
  91463. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  91464. /**
  91465. * The culling strategy to use to check whether the mesh must be rendered or not.
  91466. * This value can be changed at any time and will be used on the next render mesh selection.
  91467. * The possible values are :
  91468. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91469. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91470. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91471. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91472. * Please read each static variable documentation to get details about the culling process.
  91473. * */
  91474. cullingStrategy: number;
  91475. /**
  91476. * Gets the number of facets in the mesh
  91477. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91478. */
  91479. readonly facetNb: number;
  91480. /**
  91481. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  91482. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91483. */
  91484. partitioningSubdivisions: number;
  91485. /**
  91486. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  91487. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  91488. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91489. */
  91490. partitioningBBoxRatio: number;
  91491. /**
  91492. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  91493. * Works only for updatable meshes.
  91494. * Doesn't work with multi-materials
  91495. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91496. */
  91497. mustDepthSortFacets: boolean;
  91498. /**
  91499. * The location (Vector3) where the facet depth sort must be computed from.
  91500. * By default, the active camera position.
  91501. * Used only when facet depth sort is enabled
  91502. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91503. */
  91504. facetDepthSortFrom: Vector3;
  91505. /**
  91506. * gets a boolean indicating if facetData is enabled
  91507. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91508. */
  91509. readonly isFacetDataEnabled: boolean;
  91510. /** @hidden */
  91511. _updateNonUniformScalingState(value: boolean): boolean;
  91512. /**
  91513. * An event triggered when this mesh collides with another one
  91514. */
  91515. onCollideObservable: Observable<AbstractMesh>;
  91516. /** Set a function to call when this mesh collides with another one */
  91517. onCollide: () => void;
  91518. /**
  91519. * An event triggered when the collision's position changes
  91520. */
  91521. onCollisionPositionChangeObservable: Observable<Vector3>;
  91522. /** Set a function to call when the collision's position changes */
  91523. onCollisionPositionChange: () => void;
  91524. /**
  91525. * An event triggered when material is changed
  91526. */
  91527. onMaterialChangedObservable: Observable<AbstractMesh>;
  91528. /**
  91529. * Gets or sets the orientation for POV movement & rotation
  91530. */
  91531. definedFacingForward: boolean;
  91532. /** @hidden */
  91533. _occlusionQuery: Nullable<WebGLQuery>;
  91534. /** @hidden */
  91535. _renderingGroup: Nullable<RenderingGroup>;
  91536. /**
  91537. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91538. */
  91539. /**
  91540. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91541. */
  91542. visibility: number;
  91543. /** Gets or sets the alpha index used to sort transparent meshes
  91544. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  91545. */
  91546. alphaIndex: number;
  91547. /**
  91548. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  91549. */
  91550. isVisible: boolean;
  91551. /**
  91552. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91553. */
  91554. isPickable: boolean;
  91555. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  91556. showSubMeshesBoundingBox: boolean;
  91557. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  91558. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  91559. */
  91560. isBlocker: boolean;
  91561. /**
  91562. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  91563. */
  91564. enablePointerMoveEvents: boolean;
  91565. /**
  91566. * Specifies the rendering group id for this mesh (0 by default)
  91567. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91568. */
  91569. renderingGroupId: number;
  91570. private _material;
  91571. /** Gets or sets current material */
  91572. material: Nullable<Material>;
  91573. /**
  91574. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  91575. * @see http://doc.babylonjs.com/babylon101/shadows
  91576. */
  91577. receiveShadows: boolean;
  91578. /** Defines color to use when rendering outline */
  91579. outlineColor: Color3;
  91580. /** Define width to use when rendering outline */
  91581. outlineWidth: number;
  91582. /** Defines color to use when rendering overlay */
  91583. overlayColor: Color3;
  91584. /** Defines alpha to use when rendering overlay */
  91585. overlayAlpha: number;
  91586. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  91587. hasVertexAlpha: boolean;
  91588. /** 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) */
  91589. useVertexColors: boolean;
  91590. /**
  91591. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  91592. */
  91593. computeBonesUsingShaders: boolean;
  91594. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  91595. numBoneInfluencers: number;
  91596. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  91597. applyFog: boolean;
  91598. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  91599. useOctreeForRenderingSelection: boolean;
  91600. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  91601. useOctreeForPicking: boolean;
  91602. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  91603. useOctreeForCollisions: boolean;
  91604. /**
  91605. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  91606. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  91607. */
  91608. layerMask: number;
  91609. /**
  91610. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  91611. */
  91612. alwaysSelectAsActiveMesh: boolean;
  91613. /**
  91614. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  91615. */
  91616. doNotSyncBoundingInfo: boolean;
  91617. /**
  91618. * Gets or sets the current action manager
  91619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91620. */
  91621. actionManager: Nullable<AbstractActionManager>;
  91622. private _meshCollisionData;
  91623. /**
  91624. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  91625. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91626. */
  91627. ellipsoid: Vector3;
  91628. /**
  91629. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  91630. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91631. */
  91632. ellipsoidOffset: Vector3;
  91633. /**
  91634. * Gets or sets a collision mask used to mask collisions (default is -1).
  91635. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91636. */
  91637. collisionMask: number;
  91638. /**
  91639. * Gets or sets the current collision group mask (-1 by default).
  91640. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91641. */
  91642. collisionGroup: number;
  91643. /**
  91644. * Defines edge width used when edgesRenderer is enabled
  91645. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91646. */
  91647. edgesWidth: number;
  91648. /**
  91649. * Defines edge color used when edgesRenderer is enabled
  91650. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91651. */
  91652. edgesColor: Color4;
  91653. /** @hidden */
  91654. _edgesRenderer: Nullable<IEdgesRenderer>;
  91655. /** @hidden */
  91656. _masterMesh: Nullable<AbstractMesh>;
  91657. /** @hidden */
  91658. _boundingInfo: Nullable<BoundingInfo>;
  91659. /** @hidden */
  91660. _renderId: number;
  91661. /**
  91662. * Gets or sets the list of subMeshes
  91663. * @see http://doc.babylonjs.com/how_to/multi_materials
  91664. */
  91665. subMeshes: SubMesh[];
  91666. /** @hidden */
  91667. _intersectionsInProgress: AbstractMesh[];
  91668. /** @hidden */
  91669. _unIndexed: boolean;
  91670. /** @hidden */
  91671. _lightSources: Light[];
  91672. /** Gets the list of lights affecting that mesh */
  91673. readonly lightSources: Light[];
  91674. /** @hidden */
  91675. readonly _positions: Nullable<Vector3[]>;
  91676. /** @hidden */
  91677. _waitingData: {
  91678. lods: Nullable<any>;
  91679. actions: Nullable<any>;
  91680. freezeWorldMatrix: Nullable<boolean>;
  91681. };
  91682. /** @hidden */
  91683. _bonesTransformMatrices: Nullable<Float32Array>;
  91684. /** @hidden */
  91685. _transformMatrixTexture: Nullable<RawTexture>;
  91686. /**
  91687. * Gets or sets a skeleton to apply skining transformations
  91688. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91689. */
  91690. skeleton: Nullable<Skeleton>;
  91691. /**
  91692. * An event triggered when the mesh is rebuilt.
  91693. */
  91694. onRebuildObservable: Observable<AbstractMesh>;
  91695. /**
  91696. * Creates a new AbstractMesh
  91697. * @param name defines the name of the mesh
  91698. * @param scene defines the hosting scene
  91699. */
  91700. constructor(name: string, scene?: Nullable<Scene>);
  91701. /**
  91702. * Returns the string "AbstractMesh"
  91703. * @returns "AbstractMesh"
  91704. */
  91705. getClassName(): string;
  91706. /**
  91707. * Gets a string representation of the current mesh
  91708. * @param fullDetails defines a boolean indicating if full details must be included
  91709. * @returns a string representation of the current mesh
  91710. */
  91711. toString(fullDetails?: boolean): string;
  91712. /**
  91713. * @hidden
  91714. */
  91715. protected _getEffectiveParent(): Nullable<Node>;
  91716. /** @hidden */
  91717. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  91718. /** @hidden */
  91719. _rebuild(): void;
  91720. /** @hidden */
  91721. _resyncLightSources(): void;
  91722. /** @hidden */
  91723. _resyncLighSource(light: Light): void;
  91724. /** @hidden */
  91725. _unBindEffect(): void;
  91726. /** @hidden */
  91727. _removeLightSource(light: Light, dispose: boolean): void;
  91728. private _markSubMeshesAsDirty;
  91729. /** @hidden */
  91730. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  91731. /** @hidden */
  91732. _markSubMeshesAsAttributesDirty(): void;
  91733. /** @hidden */
  91734. _markSubMeshesAsMiscDirty(): void;
  91735. /**
  91736. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  91737. */
  91738. scaling: Vector3;
  91739. /**
  91740. * Returns true if the mesh is blocked. Implemented by child classes
  91741. */
  91742. readonly isBlocked: boolean;
  91743. /**
  91744. * Returns the mesh itself by default. Implemented by child classes
  91745. * @param camera defines the camera to use to pick the right LOD level
  91746. * @returns the currentAbstractMesh
  91747. */
  91748. getLOD(camera: Camera): Nullable<AbstractMesh>;
  91749. /**
  91750. * Returns 0 by default. Implemented by child classes
  91751. * @returns an integer
  91752. */
  91753. getTotalVertices(): number;
  91754. /**
  91755. * Returns a positive integer : the total number of indices in this mesh geometry.
  91756. * @returns the numner of indices or zero if the mesh has no geometry.
  91757. */
  91758. getTotalIndices(): number;
  91759. /**
  91760. * Returns null by default. Implemented by child classes
  91761. * @returns null
  91762. */
  91763. getIndices(): Nullable<IndicesArray>;
  91764. /**
  91765. * Returns the array of the requested vertex data kind. Implemented by child classes
  91766. * @param kind defines the vertex data kind to use
  91767. * @returns null
  91768. */
  91769. getVerticesData(kind: string): Nullable<FloatArray>;
  91770. /**
  91771. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91772. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  91773. * Note that a new underlying VertexBuffer object is created each call.
  91774. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  91775. * @param kind defines vertex data kind:
  91776. * * VertexBuffer.PositionKind
  91777. * * VertexBuffer.UVKind
  91778. * * VertexBuffer.UV2Kind
  91779. * * VertexBuffer.UV3Kind
  91780. * * VertexBuffer.UV4Kind
  91781. * * VertexBuffer.UV5Kind
  91782. * * VertexBuffer.UV6Kind
  91783. * * VertexBuffer.ColorKind
  91784. * * VertexBuffer.MatricesIndicesKind
  91785. * * VertexBuffer.MatricesIndicesExtraKind
  91786. * * VertexBuffer.MatricesWeightsKind
  91787. * * VertexBuffer.MatricesWeightsExtraKind
  91788. * @param data defines the data source
  91789. * @param updatable defines if the data must be flagged as updatable (or static)
  91790. * @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
  91791. * @returns the current mesh
  91792. */
  91793. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91794. /**
  91795. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  91796. * If the mesh has no geometry, it is simply returned as it is.
  91797. * @param kind defines vertex data kind:
  91798. * * VertexBuffer.PositionKind
  91799. * * VertexBuffer.UVKind
  91800. * * VertexBuffer.UV2Kind
  91801. * * VertexBuffer.UV3Kind
  91802. * * VertexBuffer.UV4Kind
  91803. * * VertexBuffer.UV5Kind
  91804. * * VertexBuffer.UV6Kind
  91805. * * VertexBuffer.ColorKind
  91806. * * VertexBuffer.MatricesIndicesKind
  91807. * * VertexBuffer.MatricesIndicesExtraKind
  91808. * * VertexBuffer.MatricesWeightsKind
  91809. * * VertexBuffer.MatricesWeightsExtraKind
  91810. * @param data defines the data source
  91811. * @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
  91812. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  91813. * @returns the current mesh
  91814. */
  91815. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  91816. /**
  91817. * Sets the mesh indices,
  91818. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  91819. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  91820. * @param totalVertices Defines the total number of vertices
  91821. * @returns the current mesh
  91822. */
  91823. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  91824. /**
  91825. * Gets a boolean indicating if specific vertex data is present
  91826. * @param kind defines the vertex data kind to use
  91827. * @returns true is data kind is present
  91828. */
  91829. isVerticesDataPresent(kind: string): boolean;
  91830. /**
  91831. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  91832. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  91833. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  91834. * @returns a BoundingInfo
  91835. */
  91836. getBoundingInfo(): BoundingInfo;
  91837. /**
  91838. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  91839. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  91840. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  91841. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  91842. * @returns the current mesh
  91843. */
  91844. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  91845. /**
  91846. * Overwrite the current bounding info
  91847. * @param boundingInfo defines the new bounding info
  91848. * @returns the current mesh
  91849. */
  91850. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  91851. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  91852. readonly useBones: boolean;
  91853. /** @hidden */
  91854. _preActivate(): void;
  91855. /** @hidden */
  91856. _preActivateForIntermediateRendering(renderId: number): void;
  91857. /** @hidden */
  91858. _activate(renderId: number, intermediateRendering: boolean): boolean;
  91859. /** @hidden */
  91860. _postActivate(): void;
  91861. /** @hidden */
  91862. _freeze(): void;
  91863. /** @hidden */
  91864. _unFreeze(): void;
  91865. /**
  91866. * Gets the current world matrix
  91867. * @returns a Matrix
  91868. */
  91869. getWorldMatrix(): Matrix;
  91870. /** @hidden */
  91871. _getWorldMatrixDeterminant(): number;
  91872. /**
  91873. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  91874. */
  91875. readonly isAnInstance: boolean;
  91876. /**
  91877. * Gets a boolean indicating if this mesh has instances
  91878. */
  91879. readonly hasInstances: boolean;
  91880. /**
  91881. * Perform relative position change from the point of view of behind the front of the mesh.
  91882. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91883. * Supports definition of mesh facing forward or backward
  91884. * @param amountRight defines the distance on the right axis
  91885. * @param amountUp defines the distance on the up axis
  91886. * @param amountForward defines the distance on the forward axis
  91887. * @returns the current mesh
  91888. */
  91889. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  91890. /**
  91891. * Calculate relative position change from the point of view of behind the front of the mesh.
  91892. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91893. * Supports definition of mesh facing forward or backward
  91894. * @param amountRight defines the distance on the right axis
  91895. * @param amountUp defines the distance on the up axis
  91896. * @param amountForward defines the distance on the forward axis
  91897. * @returns the new displacement vector
  91898. */
  91899. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  91900. /**
  91901. * Perform relative rotation change from the point of view of behind the front of the mesh.
  91902. * Supports definition of mesh facing forward or backward
  91903. * @param flipBack defines the flip
  91904. * @param twirlClockwise defines the twirl
  91905. * @param tiltRight defines the tilt
  91906. * @returns the current mesh
  91907. */
  91908. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  91909. /**
  91910. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  91911. * Supports definition of mesh facing forward or backward.
  91912. * @param flipBack defines the flip
  91913. * @param twirlClockwise defines the twirl
  91914. * @param tiltRight defines the tilt
  91915. * @returns the new rotation vector
  91916. */
  91917. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  91918. /**
  91919. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  91920. * This means the mesh underlying bounding box and sphere are recomputed.
  91921. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  91922. * @returns the current mesh
  91923. */
  91924. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  91925. /** @hidden */
  91926. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  91927. /** @hidden */
  91928. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  91929. /** @hidden */
  91930. _updateBoundingInfo(): AbstractMesh;
  91931. /** @hidden */
  91932. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  91933. /** @hidden */
  91934. protected _afterComputeWorldMatrix(): void;
  91935. /** @hidden */
  91936. readonly _effectiveMesh: AbstractMesh;
  91937. /**
  91938. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  91939. * A mesh is in the frustum if its bounding box intersects the frustum
  91940. * @param frustumPlanes defines the frustum to test
  91941. * @returns true if the mesh is in the frustum planes
  91942. */
  91943. isInFrustum(frustumPlanes: Plane[]): boolean;
  91944. /**
  91945. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  91946. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  91947. * @param frustumPlanes defines the frustum to test
  91948. * @returns true if the mesh is completely in the frustum planes
  91949. */
  91950. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  91951. /**
  91952. * True if the mesh intersects another mesh or a SolidParticle object
  91953. * @param mesh defines a target mesh or SolidParticle to test
  91954. * @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)
  91955. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  91956. * @returns true if there is an intersection
  91957. */
  91958. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  91959. /**
  91960. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  91961. * @param point defines the point to test
  91962. * @returns true if there is an intersection
  91963. */
  91964. intersectsPoint(point: Vector3): boolean;
  91965. /**
  91966. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  91967. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91968. */
  91969. checkCollisions: boolean;
  91970. /**
  91971. * Gets Collider object used to compute collisions (not physics)
  91972. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91973. */
  91974. readonly collider: Nullable<Collider>;
  91975. /**
  91976. * Move the mesh using collision engine
  91977. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91978. * @param displacement defines the requested displacement vector
  91979. * @returns the current mesh
  91980. */
  91981. moveWithCollisions(displacement: Vector3): AbstractMesh;
  91982. private _onCollisionPositionChange;
  91983. /** @hidden */
  91984. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  91985. /** @hidden */
  91986. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  91987. /** @hidden */
  91988. _checkCollision(collider: Collider): AbstractMesh;
  91989. /** @hidden */
  91990. _generatePointsArray(): boolean;
  91991. /**
  91992. * Checks if the passed Ray intersects with the mesh
  91993. * @param ray defines the ray to use
  91994. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  91995. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91996. * @returns the picking info
  91997. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  91998. */
  91999. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  92000. /**
  92001. * Clones the current mesh
  92002. * @param name defines the mesh name
  92003. * @param newParent defines the new mesh parent
  92004. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  92005. * @returns the new mesh
  92006. */
  92007. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  92008. /**
  92009. * Disposes all the submeshes of the current meshnp
  92010. * @returns the current mesh
  92011. */
  92012. releaseSubMeshes(): AbstractMesh;
  92013. /**
  92014. * Releases resources associated with this abstract mesh.
  92015. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92016. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92017. */
  92018. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92019. /**
  92020. * Adds the passed mesh as a child to the current mesh
  92021. * @param mesh defines the child mesh
  92022. * @returns the current mesh
  92023. */
  92024. addChild(mesh: AbstractMesh): AbstractMesh;
  92025. /**
  92026. * Removes the passed mesh from the current mesh children list
  92027. * @param mesh defines the child mesh
  92028. * @returns the current mesh
  92029. */
  92030. removeChild(mesh: AbstractMesh): AbstractMesh;
  92031. /** @hidden */
  92032. private _initFacetData;
  92033. /**
  92034. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  92035. * This method can be called within the render loop.
  92036. * 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
  92037. * @returns the current mesh
  92038. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92039. */
  92040. updateFacetData(): AbstractMesh;
  92041. /**
  92042. * Returns the facetLocalNormals array.
  92043. * The normals are expressed in the mesh local spac
  92044. * @returns an array of Vector3
  92045. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92046. */
  92047. getFacetLocalNormals(): Vector3[];
  92048. /**
  92049. * Returns the facetLocalPositions array.
  92050. * The facet positions are expressed in the mesh local space
  92051. * @returns an array of Vector3
  92052. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92053. */
  92054. getFacetLocalPositions(): Vector3[];
  92055. /**
  92056. * Returns the facetLocalPartioning array
  92057. * @returns an array of array of numbers
  92058. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92059. */
  92060. getFacetLocalPartitioning(): number[][];
  92061. /**
  92062. * Returns the i-th facet position in the world system.
  92063. * This method allocates a new Vector3 per call
  92064. * @param i defines the facet index
  92065. * @returns a new Vector3
  92066. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92067. */
  92068. getFacetPosition(i: number): Vector3;
  92069. /**
  92070. * Sets the reference Vector3 with the i-th facet position in the world system
  92071. * @param i defines the facet index
  92072. * @param ref defines the target vector
  92073. * @returns the current mesh
  92074. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92075. */
  92076. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  92077. /**
  92078. * Returns the i-th facet normal in the world system.
  92079. * This method allocates a new Vector3 per call
  92080. * @param i defines the facet index
  92081. * @returns a new Vector3
  92082. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92083. */
  92084. getFacetNormal(i: number): Vector3;
  92085. /**
  92086. * Sets the reference Vector3 with the i-th facet normal in the world system
  92087. * @param i defines the facet index
  92088. * @param ref defines the target vector
  92089. * @returns the current mesh
  92090. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92091. */
  92092. getFacetNormalToRef(i: number, ref: Vector3): this;
  92093. /**
  92094. * 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)
  92095. * @param x defines x coordinate
  92096. * @param y defines y coordinate
  92097. * @param z defines z coordinate
  92098. * @returns the array of facet indexes
  92099. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92100. */
  92101. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  92102. /**
  92103. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  92104. * @param projected sets as the (x,y,z) world projection on the facet
  92105. * @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
  92106. * @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
  92107. * @param x defines x coordinate
  92108. * @param y defines y coordinate
  92109. * @param z defines z coordinate
  92110. * @returns the face index if found (or null instead)
  92111. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92112. */
  92113. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92114. /**
  92115. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  92116. * @param projected sets as the (x,y,z) local projection on the facet
  92117. * @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
  92118. * @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
  92119. * @param x defines x coordinate
  92120. * @param y defines y coordinate
  92121. * @param z defines z coordinate
  92122. * @returns the face index if found (or null instead)
  92123. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92124. */
  92125. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92126. /**
  92127. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  92128. * @returns the parameters
  92129. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92130. */
  92131. getFacetDataParameters(): any;
  92132. /**
  92133. * Disables the feature FacetData and frees the related memory
  92134. * @returns the current mesh
  92135. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92136. */
  92137. disableFacetData(): AbstractMesh;
  92138. /**
  92139. * Updates the AbstractMesh indices array
  92140. * @param indices defines the data source
  92141. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92142. * @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)
  92143. * @returns the current mesh
  92144. */
  92145. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92146. /**
  92147. * Creates new normals data for the mesh
  92148. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  92149. * @returns the current mesh
  92150. */
  92151. createNormals(updatable: boolean): AbstractMesh;
  92152. /**
  92153. * Align the mesh with a normal
  92154. * @param normal defines the normal to use
  92155. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  92156. * @returns the current mesh
  92157. */
  92158. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  92159. /** @hidden */
  92160. _checkOcclusionQuery(): boolean;
  92161. /**
  92162. * Disables the mesh edge rendering mode
  92163. * @returns the currentAbstractMesh
  92164. */
  92165. disableEdgesRendering(): AbstractMesh;
  92166. /**
  92167. * Enables the edge rendering mode on the mesh.
  92168. * This mode makes the mesh edges visible
  92169. * @param epsilon defines the maximal distance between two angles to detect a face
  92170. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92171. * @returns the currentAbstractMesh
  92172. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92173. */
  92174. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  92175. }
  92176. }
  92177. declare module BABYLON {
  92178. /**
  92179. * Interface used to define ActionEvent
  92180. */
  92181. export interface IActionEvent {
  92182. /** The mesh or sprite that triggered the action */
  92183. source: any;
  92184. /** The X mouse cursor position at the time of the event */
  92185. pointerX: number;
  92186. /** The Y mouse cursor position at the time of the event */
  92187. pointerY: number;
  92188. /** The mesh that is currently pointed at (can be null) */
  92189. meshUnderPointer: Nullable<AbstractMesh>;
  92190. /** the original (browser) event that triggered the ActionEvent */
  92191. sourceEvent?: any;
  92192. /** additional data for the event */
  92193. additionalData?: any;
  92194. }
  92195. /**
  92196. * ActionEvent is the event being sent when an action is triggered.
  92197. */
  92198. export class ActionEvent implements IActionEvent {
  92199. /** The mesh or sprite that triggered the action */
  92200. source: any;
  92201. /** The X mouse cursor position at the time of the event */
  92202. pointerX: number;
  92203. /** The Y mouse cursor position at the time of the event */
  92204. pointerY: number;
  92205. /** The mesh that is currently pointed at (can be null) */
  92206. meshUnderPointer: Nullable<AbstractMesh>;
  92207. /** the original (browser) event that triggered the ActionEvent */
  92208. sourceEvent?: any;
  92209. /** additional data for the event */
  92210. additionalData?: any;
  92211. /**
  92212. * Creates a new ActionEvent
  92213. * @param source The mesh or sprite that triggered the action
  92214. * @param pointerX The X mouse cursor position at the time of the event
  92215. * @param pointerY The Y mouse cursor position at the time of the event
  92216. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  92217. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  92218. * @param additionalData additional data for the event
  92219. */
  92220. constructor(
  92221. /** The mesh or sprite that triggered the action */
  92222. source: any,
  92223. /** The X mouse cursor position at the time of the event */
  92224. pointerX: number,
  92225. /** The Y mouse cursor position at the time of the event */
  92226. pointerY: number,
  92227. /** The mesh that is currently pointed at (can be null) */
  92228. meshUnderPointer: Nullable<AbstractMesh>,
  92229. /** the original (browser) event that triggered the ActionEvent */
  92230. sourceEvent?: any,
  92231. /** additional data for the event */
  92232. additionalData?: any);
  92233. /**
  92234. * Helper function to auto-create an ActionEvent from a source mesh.
  92235. * @param source The source mesh that triggered the event
  92236. * @param evt The original (browser) event
  92237. * @param additionalData additional data for the event
  92238. * @returns the new ActionEvent
  92239. */
  92240. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  92241. /**
  92242. * Helper function to auto-create an ActionEvent from a source sprite
  92243. * @param source The source sprite that triggered the event
  92244. * @param scene Scene associated with the sprite
  92245. * @param evt The original (browser) event
  92246. * @param additionalData additional data for the event
  92247. * @returns the new ActionEvent
  92248. */
  92249. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  92250. /**
  92251. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  92252. * @param scene the scene where the event occurred
  92253. * @param evt The original (browser) event
  92254. * @returns the new ActionEvent
  92255. */
  92256. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  92257. /**
  92258. * Helper function to auto-create an ActionEvent from a primitive
  92259. * @param prim defines the target primitive
  92260. * @param pointerPos defines the pointer position
  92261. * @param evt The original (browser) event
  92262. * @param additionalData additional data for the event
  92263. * @returns the new ActionEvent
  92264. */
  92265. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  92266. }
  92267. }
  92268. declare module BABYLON {
  92269. /**
  92270. * Abstract class used to decouple action Manager from scene and meshes.
  92271. * Do not instantiate.
  92272. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92273. */
  92274. export abstract class AbstractActionManager implements IDisposable {
  92275. /** Gets the list of active triggers */
  92276. static Triggers: {
  92277. [key: string]: number;
  92278. };
  92279. /** Gets the cursor to use when hovering items */
  92280. hoverCursor: string;
  92281. /** Gets the list of actions */
  92282. actions: IAction[];
  92283. /**
  92284. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  92285. */
  92286. isRecursive: boolean;
  92287. /**
  92288. * Releases all associated resources
  92289. */
  92290. abstract dispose(): void;
  92291. /**
  92292. * Does this action manager has pointer triggers
  92293. */
  92294. abstract readonly hasPointerTriggers: boolean;
  92295. /**
  92296. * Does this action manager has pick triggers
  92297. */
  92298. abstract readonly hasPickTriggers: boolean;
  92299. /**
  92300. * Process a specific trigger
  92301. * @param trigger defines the trigger to process
  92302. * @param evt defines the event details to be processed
  92303. */
  92304. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  92305. /**
  92306. * Does this action manager handles actions of any of the given triggers
  92307. * @param triggers defines the triggers to be tested
  92308. * @return a boolean indicating whether one (or more) of the triggers is handled
  92309. */
  92310. abstract hasSpecificTriggers(triggers: number[]): boolean;
  92311. /**
  92312. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  92313. * speed.
  92314. * @param triggerA defines the trigger to be tested
  92315. * @param triggerB defines the trigger to be tested
  92316. * @return a boolean indicating whether one (or more) of the triggers is handled
  92317. */
  92318. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  92319. /**
  92320. * Does this action manager handles actions of a given trigger
  92321. * @param trigger defines the trigger to be tested
  92322. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  92323. * @return whether the trigger is handled
  92324. */
  92325. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  92326. /**
  92327. * Serialize this manager to a JSON object
  92328. * @param name defines the property name to store this manager
  92329. * @returns a JSON representation of this manager
  92330. */
  92331. abstract serialize(name: string): any;
  92332. /**
  92333. * Registers an action to this action manager
  92334. * @param action defines the action to be registered
  92335. * @return the action amended (prepared) after registration
  92336. */
  92337. abstract registerAction(action: IAction): Nullable<IAction>;
  92338. /**
  92339. * Unregisters an action to this action manager
  92340. * @param action defines the action to be unregistered
  92341. * @return a boolean indicating whether the action has been unregistered
  92342. */
  92343. abstract unregisterAction(action: IAction): Boolean;
  92344. /**
  92345. * Does exist one action manager with at least one trigger
  92346. **/
  92347. static readonly HasTriggers: boolean;
  92348. /**
  92349. * Does exist one action manager with at least one pick trigger
  92350. **/
  92351. static readonly HasPickTriggers: boolean;
  92352. /**
  92353. * Does exist one action manager that handles actions of a given trigger
  92354. * @param trigger defines the trigger to be tested
  92355. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  92356. **/
  92357. static HasSpecificTrigger(trigger: number): boolean;
  92358. }
  92359. }
  92360. declare module BABYLON {
  92361. /**
  92362. * Defines how a node can be built from a string name.
  92363. */
  92364. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  92365. /**
  92366. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  92367. */
  92368. export class Node implements IBehaviorAware<Node> {
  92369. /** @hidden */
  92370. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  92371. private static _NodeConstructors;
  92372. /**
  92373. * Add a new node constructor
  92374. * @param type defines the type name of the node to construct
  92375. * @param constructorFunc defines the constructor function
  92376. */
  92377. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  92378. /**
  92379. * Returns a node constructor based on type name
  92380. * @param type defines the type name
  92381. * @param name defines the new node name
  92382. * @param scene defines the hosting scene
  92383. * @param options defines optional options to transmit to constructors
  92384. * @returns the new constructor or null
  92385. */
  92386. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  92387. /**
  92388. * Gets or sets the name of the node
  92389. */
  92390. name: string;
  92391. /**
  92392. * Gets or sets the id of the node
  92393. */
  92394. id: string;
  92395. /**
  92396. * Gets or sets the unique id of the node
  92397. */
  92398. uniqueId: number;
  92399. /**
  92400. * Gets or sets a string used to store user defined state for the node
  92401. */
  92402. state: string;
  92403. /**
  92404. * Gets or sets an object used to store user defined information for the node
  92405. */
  92406. metadata: any;
  92407. /**
  92408. * For internal use only. Please do not use.
  92409. */
  92410. reservedDataStore: any;
  92411. /**
  92412. * List of inspectable custom properties (used by the Inspector)
  92413. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92414. */
  92415. inspectableCustomProperties: IInspectable[];
  92416. /**
  92417. * Gets or sets a boolean used to define if the node must be serialized
  92418. */
  92419. doNotSerialize: boolean;
  92420. /** @hidden */
  92421. _isDisposed: boolean;
  92422. /**
  92423. * Gets a list of Animations associated with the node
  92424. */
  92425. animations: Animation[];
  92426. protected _ranges: {
  92427. [name: string]: Nullable<AnimationRange>;
  92428. };
  92429. /**
  92430. * Callback raised when the node is ready to be used
  92431. */
  92432. onReady: Nullable<(node: Node) => void>;
  92433. private _isEnabled;
  92434. private _isParentEnabled;
  92435. private _isReady;
  92436. /** @hidden */
  92437. _currentRenderId: number;
  92438. private _parentUpdateId;
  92439. /** @hidden */
  92440. _childUpdateId: number;
  92441. /** @hidden */
  92442. _waitingParentId: Nullable<string>;
  92443. /** @hidden */
  92444. _scene: Scene;
  92445. /** @hidden */
  92446. _cache: any;
  92447. private _parentNode;
  92448. private _children;
  92449. /** @hidden */
  92450. _worldMatrix: Matrix;
  92451. /** @hidden */
  92452. _worldMatrixDeterminant: number;
  92453. /** @hidden */
  92454. _worldMatrixDeterminantIsDirty: boolean;
  92455. /** @hidden */
  92456. private _sceneRootNodesIndex;
  92457. /**
  92458. * Gets a boolean indicating if the node has been disposed
  92459. * @returns true if the node was disposed
  92460. */
  92461. isDisposed(): boolean;
  92462. /**
  92463. * Gets or sets the parent of the node (without keeping the current position in the scene)
  92464. * @see https://doc.babylonjs.com/how_to/parenting
  92465. */
  92466. parent: Nullable<Node>;
  92467. private addToSceneRootNodes;
  92468. private removeFromSceneRootNodes;
  92469. private _animationPropertiesOverride;
  92470. /**
  92471. * Gets or sets the animation properties override
  92472. */
  92473. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  92474. /**
  92475. * Gets a string idenfifying the name of the class
  92476. * @returns "Node" string
  92477. */
  92478. getClassName(): string;
  92479. /** @hidden */
  92480. readonly _isNode: boolean;
  92481. /**
  92482. * An event triggered when the mesh is disposed
  92483. */
  92484. onDisposeObservable: Observable<Node>;
  92485. private _onDisposeObserver;
  92486. /**
  92487. * Sets a callback that will be raised when the node will be disposed
  92488. */
  92489. onDispose: () => void;
  92490. /**
  92491. * Creates a new Node
  92492. * @param name the name and id to be given to this node
  92493. * @param scene the scene this node will be added to
  92494. * @param addToRootNodes the node will be added to scene.rootNodes
  92495. */
  92496. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  92497. /**
  92498. * Gets the scene of the node
  92499. * @returns a scene
  92500. */
  92501. getScene(): Scene;
  92502. /**
  92503. * Gets the engine of the node
  92504. * @returns a Engine
  92505. */
  92506. getEngine(): Engine;
  92507. private _behaviors;
  92508. /**
  92509. * Attach a behavior to the node
  92510. * @see http://doc.babylonjs.com/features/behaviour
  92511. * @param behavior defines the behavior to attach
  92512. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  92513. * @returns the current Node
  92514. */
  92515. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  92516. /**
  92517. * Remove an attached behavior
  92518. * @see http://doc.babylonjs.com/features/behaviour
  92519. * @param behavior defines the behavior to attach
  92520. * @returns the current Node
  92521. */
  92522. removeBehavior(behavior: Behavior<Node>): Node;
  92523. /**
  92524. * Gets the list of attached behaviors
  92525. * @see http://doc.babylonjs.com/features/behaviour
  92526. */
  92527. readonly behaviors: Behavior<Node>[];
  92528. /**
  92529. * Gets an attached behavior by name
  92530. * @param name defines the name of the behavior to look for
  92531. * @see http://doc.babylonjs.com/features/behaviour
  92532. * @returns null if behavior was not found else the requested behavior
  92533. */
  92534. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  92535. /**
  92536. * Returns the latest update of the World matrix
  92537. * @returns a Matrix
  92538. */
  92539. getWorldMatrix(): Matrix;
  92540. /** @hidden */
  92541. _getWorldMatrixDeterminant(): number;
  92542. /**
  92543. * Returns directly the latest state of the mesh World matrix.
  92544. * A Matrix is returned.
  92545. */
  92546. readonly worldMatrixFromCache: Matrix;
  92547. /** @hidden */
  92548. _initCache(): void;
  92549. /** @hidden */
  92550. updateCache(force?: boolean): void;
  92551. /** @hidden */
  92552. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92553. /** @hidden */
  92554. _updateCache(ignoreParentClass?: boolean): void;
  92555. /** @hidden */
  92556. _isSynchronized(): boolean;
  92557. /** @hidden */
  92558. _markSyncedWithParent(): void;
  92559. /** @hidden */
  92560. isSynchronizedWithParent(): boolean;
  92561. /** @hidden */
  92562. isSynchronized(): boolean;
  92563. /**
  92564. * Is this node ready to be used/rendered
  92565. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92566. * @return true if the node is ready
  92567. */
  92568. isReady(completeCheck?: boolean): boolean;
  92569. /**
  92570. * Is this node enabled?
  92571. * 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
  92572. * @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
  92573. * @return whether this node (and its parent) is enabled
  92574. */
  92575. isEnabled(checkAncestors?: boolean): boolean;
  92576. /** @hidden */
  92577. protected _syncParentEnabledState(): void;
  92578. /**
  92579. * Set the enabled state of this node
  92580. * @param value defines the new enabled state
  92581. */
  92582. setEnabled(value: boolean): void;
  92583. /**
  92584. * Is this node a descendant of the given node?
  92585. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  92586. * @param ancestor defines the parent node to inspect
  92587. * @returns a boolean indicating if this node is a descendant of the given node
  92588. */
  92589. isDescendantOf(ancestor: Node): boolean;
  92590. /** @hidden */
  92591. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  92592. /**
  92593. * Will return all nodes that have this node as ascendant
  92594. * @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
  92595. * @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
  92596. * @return all children nodes of all types
  92597. */
  92598. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  92599. /**
  92600. * Get all child-meshes of this node
  92601. * @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)
  92602. * @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
  92603. * @returns an array of AbstractMesh
  92604. */
  92605. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  92606. /**
  92607. * Get all direct children of this node
  92608. * @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
  92609. * @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)
  92610. * @returns an array of Node
  92611. */
  92612. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  92613. /** @hidden */
  92614. _setReady(state: boolean): void;
  92615. /**
  92616. * Get an animation by name
  92617. * @param name defines the name of the animation to look for
  92618. * @returns null if not found else the requested animation
  92619. */
  92620. getAnimationByName(name: string): Nullable<Animation>;
  92621. /**
  92622. * Creates an animation range for this node
  92623. * @param name defines the name of the range
  92624. * @param from defines the starting key
  92625. * @param to defines the end key
  92626. */
  92627. createAnimationRange(name: string, from: number, to: number): void;
  92628. /**
  92629. * Delete a specific animation range
  92630. * @param name defines the name of the range to delete
  92631. * @param deleteFrames defines if animation frames from the range must be deleted as well
  92632. */
  92633. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  92634. /**
  92635. * Get an animation range by name
  92636. * @param name defines the name of the animation range to look for
  92637. * @returns null if not found else the requested animation range
  92638. */
  92639. getAnimationRange(name: string): Nullable<AnimationRange>;
  92640. /**
  92641. * Gets the list of all animation ranges defined on this node
  92642. * @returns an array
  92643. */
  92644. getAnimationRanges(): Nullable<AnimationRange>[];
  92645. /**
  92646. * Will start the animation sequence
  92647. * @param name defines the range frames for animation sequence
  92648. * @param loop defines if the animation should loop (false by default)
  92649. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  92650. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  92651. * @returns the object created for this animation. If range does not exist, it will return null
  92652. */
  92653. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  92654. /**
  92655. * Serialize animation ranges into a JSON compatible object
  92656. * @returns serialization object
  92657. */
  92658. serializeAnimationRanges(): any;
  92659. /**
  92660. * Computes the world matrix of the node
  92661. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92662. * @returns the world matrix
  92663. */
  92664. computeWorldMatrix(force?: boolean): Matrix;
  92665. /**
  92666. * Releases resources associated with this node.
  92667. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92668. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92669. */
  92670. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92671. /**
  92672. * Parse animation range data from a serialization object and store them into a given node
  92673. * @param node defines where to store the animation ranges
  92674. * @param parsedNode defines the serialization object to read data from
  92675. * @param scene defines the hosting scene
  92676. */
  92677. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  92678. /**
  92679. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  92680. * @param includeDescendants Include bounding info from descendants as well (true by default)
  92681. * @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
  92682. * @returns the new bounding vectors
  92683. */
  92684. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  92685. min: Vector3;
  92686. max: Vector3;
  92687. };
  92688. }
  92689. }
  92690. declare module BABYLON {
  92691. /**
  92692. * @hidden
  92693. */
  92694. export class _IAnimationState {
  92695. key: number;
  92696. repeatCount: number;
  92697. workValue?: any;
  92698. loopMode?: number;
  92699. offsetValue?: any;
  92700. highLimitValue?: any;
  92701. }
  92702. /**
  92703. * Class used to store any kind of animation
  92704. */
  92705. export class Animation {
  92706. /**Name of the animation */
  92707. name: string;
  92708. /**Property to animate */
  92709. targetProperty: string;
  92710. /**The frames per second of the animation */
  92711. framePerSecond: number;
  92712. /**The data type of the animation */
  92713. dataType: number;
  92714. /**The loop mode of the animation */
  92715. loopMode?: number | undefined;
  92716. /**Specifies if blending should be enabled */
  92717. enableBlending?: boolean | undefined;
  92718. /**
  92719. * Use matrix interpolation instead of using direct key value when animating matrices
  92720. */
  92721. static AllowMatricesInterpolation: boolean;
  92722. /**
  92723. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  92724. */
  92725. static AllowMatrixDecomposeForInterpolation: boolean;
  92726. /**
  92727. * Stores the key frames of the animation
  92728. */
  92729. private _keys;
  92730. /**
  92731. * Stores the easing function of the animation
  92732. */
  92733. private _easingFunction;
  92734. /**
  92735. * @hidden Internal use only
  92736. */
  92737. _runtimeAnimations: RuntimeAnimation[];
  92738. /**
  92739. * The set of event that will be linked to this animation
  92740. */
  92741. private _events;
  92742. /**
  92743. * Stores an array of target property paths
  92744. */
  92745. targetPropertyPath: string[];
  92746. /**
  92747. * Stores the blending speed of the animation
  92748. */
  92749. blendingSpeed: number;
  92750. /**
  92751. * Stores the animation ranges for the animation
  92752. */
  92753. private _ranges;
  92754. /**
  92755. * @hidden Internal use
  92756. */
  92757. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  92758. /**
  92759. * Sets up an animation
  92760. * @param property The property to animate
  92761. * @param animationType The animation type to apply
  92762. * @param framePerSecond The frames per second of the animation
  92763. * @param easingFunction The easing function used in the animation
  92764. * @returns The created animation
  92765. */
  92766. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  92767. /**
  92768. * Create and start an animation on a node
  92769. * @param name defines the name of the global animation that will be run on all nodes
  92770. * @param node defines the root node where the animation will take place
  92771. * @param targetProperty defines property to animate
  92772. * @param framePerSecond defines the number of frame per second yo use
  92773. * @param totalFrame defines the number of frames in total
  92774. * @param from defines the initial value
  92775. * @param to defines the final value
  92776. * @param loopMode defines which loop mode you want to use (off by default)
  92777. * @param easingFunction defines the easing function to use (linear by default)
  92778. * @param onAnimationEnd defines the callback to call when animation end
  92779. * @returns the animatable created for this animation
  92780. */
  92781. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92782. /**
  92783. * Create and start an animation on a node and its descendants
  92784. * @param name defines the name of the global animation that will be run on all nodes
  92785. * @param node defines the root node where the animation will take place
  92786. * @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
  92787. * @param targetProperty defines property to animate
  92788. * @param framePerSecond defines the number of frame per second to use
  92789. * @param totalFrame defines the number of frames in total
  92790. * @param from defines the initial value
  92791. * @param to defines the final value
  92792. * @param loopMode defines which loop mode you want to use (off by default)
  92793. * @param easingFunction defines the easing function to use (linear by default)
  92794. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  92795. * @returns the list of animatables created for all nodes
  92796. * @example https://www.babylonjs-playground.com/#MH0VLI
  92797. */
  92798. 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[]>;
  92799. /**
  92800. * Creates a new animation, merges it with the existing animations and starts it
  92801. * @param name Name of the animation
  92802. * @param node Node which contains the scene that begins the animations
  92803. * @param targetProperty Specifies which property to animate
  92804. * @param framePerSecond The frames per second of the animation
  92805. * @param totalFrame The total number of frames
  92806. * @param from The frame at the beginning of the animation
  92807. * @param to The frame at the end of the animation
  92808. * @param loopMode Specifies the loop mode of the animation
  92809. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  92810. * @param onAnimationEnd Callback to run once the animation is complete
  92811. * @returns Nullable animation
  92812. */
  92813. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92814. /**
  92815. * Transition property of an host to the target Value
  92816. * @param property The property to transition
  92817. * @param targetValue The target Value of the property
  92818. * @param host The object where the property to animate belongs
  92819. * @param scene Scene used to run the animation
  92820. * @param frameRate Framerate (in frame/s) to use
  92821. * @param transition The transition type we want to use
  92822. * @param duration The duration of the animation, in milliseconds
  92823. * @param onAnimationEnd Callback trigger at the end of the animation
  92824. * @returns Nullable animation
  92825. */
  92826. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  92827. /**
  92828. * Return the array of runtime animations currently using this animation
  92829. */
  92830. readonly runtimeAnimations: RuntimeAnimation[];
  92831. /**
  92832. * Specifies if any of the runtime animations are currently running
  92833. */
  92834. readonly hasRunningRuntimeAnimations: boolean;
  92835. /**
  92836. * Initializes the animation
  92837. * @param name Name of the animation
  92838. * @param targetProperty Property to animate
  92839. * @param framePerSecond The frames per second of the animation
  92840. * @param dataType The data type of the animation
  92841. * @param loopMode The loop mode of the animation
  92842. * @param enableBlending Specifies if blending should be enabled
  92843. */
  92844. constructor(
  92845. /**Name of the animation */
  92846. name: string,
  92847. /**Property to animate */
  92848. targetProperty: string,
  92849. /**The frames per second of the animation */
  92850. framePerSecond: number,
  92851. /**The data type of the animation */
  92852. dataType: number,
  92853. /**The loop mode of the animation */
  92854. loopMode?: number | undefined,
  92855. /**Specifies if blending should be enabled */
  92856. enableBlending?: boolean | undefined);
  92857. /**
  92858. * Converts the animation to a string
  92859. * @param fullDetails support for multiple levels of logging within scene loading
  92860. * @returns String form of the animation
  92861. */
  92862. toString(fullDetails?: boolean): string;
  92863. /**
  92864. * Add an event to this animation
  92865. * @param event Event to add
  92866. */
  92867. addEvent(event: AnimationEvent): void;
  92868. /**
  92869. * Remove all events found at the given frame
  92870. * @param frame The frame to remove events from
  92871. */
  92872. removeEvents(frame: number): void;
  92873. /**
  92874. * Retrieves all the events from the animation
  92875. * @returns Events from the animation
  92876. */
  92877. getEvents(): AnimationEvent[];
  92878. /**
  92879. * Creates an animation range
  92880. * @param name Name of the animation range
  92881. * @param from Starting frame of the animation range
  92882. * @param to Ending frame of the animation
  92883. */
  92884. createRange(name: string, from: number, to: number): void;
  92885. /**
  92886. * Deletes an animation range by name
  92887. * @param name Name of the animation range to delete
  92888. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  92889. */
  92890. deleteRange(name: string, deleteFrames?: boolean): void;
  92891. /**
  92892. * Gets the animation range by name, or null if not defined
  92893. * @param name Name of the animation range
  92894. * @returns Nullable animation range
  92895. */
  92896. getRange(name: string): Nullable<AnimationRange>;
  92897. /**
  92898. * Gets the key frames from the animation
  92899. * @returns The key frames of the animation
  92900. */
  92901. getKeys(): Array<IAnimationKey>;
  92902. /**
  92903. * Gets the highest frame rate of the animation
  92904. * @returns Highest frame rate of the animation
  92905. */
  92906. getHighestFrame(): number;
  92907. /**
  92908. * Gets the easing function of the animation
  92909. * @returns Easing function of the animation
  92910. */
  92911. getEasingFunction(): IEasingFunction;
  92912. /**
  92913. * Sets the easing function of the animation
  92914. * @param easingFunction A custom mathematical formula for animation
  92915. */
  92916. setEasingFunction(easingFunction: EasingFunction): void;
  92917. /**
  92918. * Interpolates a scalar linearly
  92919. * @param startValue Start value of the animation curve
  92920. * @param endValue End value of the animation curve
  92921. * @param gradient Scalar amount to interpolate
  92922. * @returns Interpolated scalar value
  92923. */
  92924. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  92925. /**
  92926. * Interpolates a scalar cubically
  92927. * @param startValue Start value of the animation curve
  92928. * @param outTangent End tangent of the animation
  92929. * @param endValue End value of the animation curve
  92930. * @param inTangent Start tangent of the animation curve
  92931. * @param gradient Scalar amount to interpolate
  92932. * @returns Interpolated scalar value
  92933. */
  92934. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  92935. /**
  92936. * Interpolates a quaternion using a spherical linear interpolation
  92937. * @param startValue Start value of the animation curve
  92938. * @param endValue End value of the animation curve
  92939. * @param gradient Scalar amount to interpolate
  92940. * @returns Interpolated quaternion value
  92941. */
  92942. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  92943. /**
  92944. * Interpolates a quaternion cubically
  92945. * @param startValue Start value of the animation curve
  92946. * @param outTangent End tangent of the animation curve
  92947. * @param endValue End value of the animation curve
  92948. * @param inTangent Start tangent of the animation curve
  92949. * @param gradient Scalar amount to interpolate
  92950. * @returns Interpolated quaternion value
  92951. */
  92952. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  92953. /**
  92954. * Interpolates a Vector3 linearl
  92955. * @param startValue Start value of the animation curve
  92956. * @param endValue End value of the animation curve
  92957. * @param gradient Scalar amount to interpolate
  92958. * @returns Interpolated scalar value
  92959. */
  92960. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  92961. /**
  92962. * Interpolates a Vector3 cubically
  92963. * @param startValue Start value of the animation curve
  92964. * @param outTangent End tangent of the animation
  92965. * @param endValue End value of the animation curve
  92966. * @param inTangent Start tangent of the animation curve
  92967. * @param gradient Scalar amount to interpolate
  92968. * @returns InterpolatedVector3 value
  92969. */
  92970. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  92971. /**
  92972. * Interpolates a Vector2 linearly
  92973. * @param startValue Start value of the animation curve
  92974. * @param endValue End value of the animation curve
  92975. * @param gradient Scalar amount to interpolate
  92976. * @returns Interpolated Vector2 value
  92977. */
  92978. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  92979. /**
  92980. * Interpolates a Vector2 cubically
  92981. * @param startValue Start value of the animation curve
  92982. * @param outTangent End tangent of the animation
  92983. * @param endValue End value of the animation curve
  92984. * @param inTangent Start tangent of the animation curve
  92985. * @param gradient Scalar amount to interpolate
  92986. * @returns Interpolated Vector2 value
  92987. */
  92988. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  92989. /**
  92990. * Interpolates a size linearly
  92991. * @param startValue Start value of the animation curve
  92992. * @param endValue End value of the animation curve
  92993. * @param gradient Scalar amount to interpolate
  92994. * @returns Interpolated Size value
  92995. */
  92996. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  92997. /**
  92998. * Interpolates a Color3 linearly
  92999. * @param startValue Start value of the animation curve
  93000. * @param endValue End value of the animation curve
  93001. * @param gradient Scalar amount to interpolate
  93002. * @returns Interpolated Color3 value
  93003. */
  93004. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  93005. /**
  93006. * @hidden Internal use only
  93007. */
  93008. _getKeyValue(value: any): any;
  93009. /**
  93010. * @hidden Internal use only
  93011. */
  93012. _interpolate(currentFrame: number, state: _IAnimationState): any;
  93013. /**
  93014. * Defines the function to use to interpolate matrices
  93015. * @param startValue defines the start matrix
  93016. * @param endValue defines the end matrix
  93017. * @param gradient defines the gradient between both matrices
  93018. * @param result defines an optional target matrix where to store the interpolation
  93019. * @returns the interpolated matrix
  93020. */
  93021. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  93022. /**
  93023. * Makes a copy of the animation
  93024. * @returns Cloned animation
  93025. */
  93026. clone(): Animation;
  93027. /**
  93028. * Sets the key frames of the animation
  93029. * @param values The animation key frames to set
  93030. */
  93031. setKeys(values: Array<IAnimationKey>): void;
  93032. /**
  93033. * Serializes the animation to an object
  93034. * @returns Serialized object
  93035. */
  93036. serialize(): any;
  93037. /**
  93038. * Float animation type
  93039. */
  93040. private static _ANIMATIONTYPE_FLOAT;
  93041. /**
  93042. * Vector3 animation type
  93043. */
  93044. private static _ANIMATIONTYPE_VECTOR3;
  93045. /**
  93046. * Quaternion animation type
  93047. */
  93048. private static _ANIMATIONTYPE_QUATERNION;
  93049. /**
  93050. * Matrix animation type
  93051. */
  93052. private static _ANIMATIONTYPE_MATRIX;
  93053. /**
  93054. * Color3 animation type
  93055. */
  93056. private static _ANIMATIONTYPE_COLOR3;
  93057. /**
  93058. * Vector2 animation type
  93059. */
  93060. private static _ANIMATIONTYPE_VECTOR2;
  93061. /**
  93062. * Size animation type
  93063. */
  93064. private static _ANIMATIONTYPE_SIZE;
  93065. /**
  93066. * Relative Loop Mode
  93067. */
  93068. private static _ANIMATIONLOOPMODE_RELATIVE;
  93069. /**
  93070. * Cycle Loop Mode
  93071. */
  93072. private static _ANIMATIONLOOPMODE_CYCLE;
  93073. /**
  93074. * Constant Loop Mode
  93075. */
  93076. private static _ANIMATIONLOOPMODE_CONSTANT;
  93077. /**
  93078. * Get the float animation type
  93079. */
  93080. static readonly ANIMATIONTYPE_FLOAT: number;
  93081. /**
  93082. * Get the Vector3 animation type
  93083. */
  93084. static readonly ANIMATIONTYPE_VECTOR3: number;
  93085. /**
  93086. * Get the Vector2 animation type
  93087. */
  93088. static readonly ANIMATIONTYPE_VECTOR2: number;
  93089. /**
  93090. * Get the Size animation type
  93091. */
  93092. static readonly ANIMATIONTYPE_SIZE: number;
  93093. /**
  93094. * Get the Quaternion animation type
  93095. */
  93096. static readonly ANIMATIONTYPE_QUATERNION: number;
  93097. /**
  93098. * Get the Matrix animation type
  93099. */
  93100. static readonly ANIMATIONTYPE_MATRIX: number;
  93101. /**
  93102. * Get the Color3 animation type
  93103. */
  93104. static readonly ANIMATIONTYPE_COLOR3: number;
  93105. /**
  93106. * Get the Relative Loop Mode
  93107. */
  93108. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  93109. /**
  93110. * Get the Cycle Loop Mode
  93111. */
  93112. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  93113. /**
  93114. * Get the Constant Loop Mode
  93115. */
  93116. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  93117. /** @hidden */
  93118. static _UniversalLerp(left: any, right: any, amount: number): any;
  93119. /**
  93120. * Parses an animation object and creates an animation
  93121. * @param parsedAnimation Parsed animation object
  93122. * @returns Animation object
  93123. */
  93124. static Parse(parsedAnimation: any): Animation;
  93125. /**
  93126. * Appends the serialized animations from the source animations
  93127. * @param source Source containing the animations
  93128. * @param destination Target to store the animations
  93129. */
  93130. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93131. }
  93132. }
  93133. declare module BABYLON {
  93134. /**
  93135. * Interface containing an array of animations
  93136. */
  93137. export interface IAnimatable {
  93138. /**
  93139. * Array of animations
  93140. */
  93141. animations: Nullable<Array<Animation>>;
  93142. }
  93143. }
  93144. declare module BABYLON {
  93145. /**
  93146. * This represents all the required information to add a fresnel effect on a material:
  93147. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93148. */
  93149. export class FresnelParameters {
  93150. private _isEnabled;
  93151. /**
  93152. * Define if the fresnel effect is enable or not.
  93153. */
  93154. isEnabled: boolean;
  93155. /**
  93156. * Define the color used on edges (grazing angle)
  93157. */
  93158. leftColor: Color3;
  93159. /**
  93160. * Define the color used on center
  93161. */
  93162. rightColor: Color3;
  93163. /**
  93164. * Define bias applied to computed fresnel term
  93165. */
  93166. bias: number;
  93167. /**
  93168. * Defined the power exponent applied to fresnel term
  93169. */
  93170. power: number;
  93171. /**
  93172. * Clones the current fresnel and its valuues
  93173. * @returns a clone fresnel configuration
  93174. */
  93175. clone(): FresnelParameters;
  93176. /**
  93177. * Serializes the current fresnel parameters to a JSON representation.
  93178. * @return the JSON serialization
  93179. */
  93180. serialize(): any;
  93181. /**
  93182. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  93183. * @param parsedFresnelParameters Define the JSON representation
  93184. * @returns the parsed parameters
  93185. */
  93186. static Parse(parsedFresnelParameters: any): FresnelParameters;
  93187. }
  93188. }
  93189. declare module BABYLON {
  93190. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  93191. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93192. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93193. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93194. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93195. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93196. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93197. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93198. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93199. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93200. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93201. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93202. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93203. /**
  93204. * Decorator used to define property that can be serialized as reference to a camera
  93205. * @param sourceName defines the name of the property to decorate
  93206. */
  93207. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93208. /**
  93209. * Class used to help serialization objects
  93210. */
  93211. export class SerializationHelper {
  93212. /** @hidden */
  93213. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  93214. /** @hidden */
  93215. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  93216. /** @hidden */
  93217. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  93218. /** @hidden */
  93219. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  93220. /**
  93221. * Appends the serialized animations from the source animations
  93222. * @param source Source containing the animations
  93223. * @param destination Target to store the animations
  93224. */
  93225. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93226. /**
  93227. * Static function used to serialized a specific entity
  93228. * @param entity defines the entity to serialize
  93229. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93230. * @returns a JSON compatible object representing the serialization of the entity
  93231. */
  93232. static Serialize<T>(entity: T, serializationObject?: any): any;
  93233. /**
  93234. * Creates a new entity from a serialization data object
  93235. * @param creationFunction defines a function used to instanciated the new entity
  93236. * @param source defines the source serialization data
  93237. * @param scene defines the hosting scene
  93238. * @param rootUrl defines the root url for resources
  93239. * @returns a new entity
  93240. */
  93241. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93242. /**
  93243. * Clones an object
  93244. * @param creationFunction defines the function used to instanciate the new object
  93245. * @param source defines the source object
  93246. * @returns the cloned object
  93247. */
  93248. static Clone<T>(creationFunction: () => T, source: T): T;
  93249. /**
  93250. * Instanciates a new object based on a source one (some data will be shared between both object)
  93251. * @param creationFunction defines the function used to instanciate the new object
  93252. * @param source defines the source object
  93253. * @returns the new object
  93254. */
  93255. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93256. }
  93257. }
  93258. declare module BABYLON {
  93259. /**
  93260. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  93261. */
  93262. export interface CubeMapInfo {
  93263. /**
  93264. * The pixel array for the front face.
  93265. * This is stored in format, left to right, up to down format.
  93266. */
  93267. front: Nullable<ArrayBufferView>;
  93268. /**
  93269. * The pixel array for the back face.
  93270. * This is stored in format, left to right, up to down format.
  93271. */
  93272. back: Nullable<ArrayBufferView>;
  93273. /**
  93274. * The pixel array for the left face.
  93275. * This is stored in format, left to right, up to down format.
  93276. */
  93277. left: Nullable<ArrayBufferView>;
  93278. /**
  93279. * The pixel array for the right face.
  93280. * This is stored in format, left to right, up to down format.
  93281. */
  93282. right: Nullable<ArrayBufferView>;
  93283. /**
  93284. * The pixel array for the up face.
  93285. * This is stored in format, left to right, up to down format.
  93286. */
  93287. up: Nullable<ArrayBufferView>;
  93288. /**
  93289. * The pixel array for the down face.
  93290. * This is stored in format, left to right, up to down format.
  93291. */
  93292. down: Nullable<ArrayBufferView>;
  93293. /**
  93294. * The size of the cubemap stored.
  93295. *
  93296. * Each faces will be size * size pixels.
  93297. */
  93298. size: number;
  93299. /**
  93300. * The format of the texture.
  93301. *
  93302. * RGBA, RGB.
  93303. */
  93304. format: number;
  93305. /**
  93306. * The type of the texture data.
  93307. *
  93308. * UNSIGNED_INT, FLOAT.
  93309. */
  93310. type: number;
  93311. /**
  93312. * Specifies whether the texture is in gamma space.
  93313. */
  93314. gammaSpace: boolean;
  93315. }
  93316. /**
  93317. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  93318. */
  93319. export class PanoramaToCubeMapTools {
  93320. private static FACE_FRONT;
  93321. private static FACE_BACK;
  93322. private static FACE_RIGHT;
  93323. private static FACE_LEFT;
  93324. private static FACE_DOWN;
  93325. private static FACE_UP;
  93326. /**
  93327. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  93328. *
  93329. * @param float32Array The source data.
  93330. * @param inputWidth The width of the input panorama.
  93331. * @param inputHeight The height of the input panorama.
  93332. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  93333. * @return The cubemap data
  93334. */
  93335. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  93336. private static CreateCubemapTexture;
  93337. private static CalcProjectionSpherical;
  93338. }
  93339. }
  93340. declare module BABYLON {
  93341. /**
  93342. * Helper class dealing with the extraction of spherical polynomial dataArray
  93343. * from a cube map.
  93344. */
  93345. export class CubeMapToSphericalPolynomialTools {
  93346. private static FileFaces;
  93347. /**
  93348. * Converts a texture to the according Spherical Polynomial data.
  93349. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93350. *
  93351. * @param texture The texture to extract the information from.
  93352. * @return The Spherical Polynomial data.
  93353. */
  93354. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  93355. /**
  93356. * Converts a cubemap to the according Spherical Polynomial data.
  93357. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93358. *
  93359. * @param cubeInfo The Cube map to extract the information from.
  93360. * @return The Spherical Polynomial data.
  93361. */
  93362. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  93363. }
  93364. }
  93365. declare module BABYLON {
  93366. /**
  93367. * Class used to manipulate GUIDs
  93368. */
  93369. export class GUID {
  93370. /**
  93371. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93372. * Be aware Math.random() could cause collisions, but:
  93373. * "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"
  93374. * @returns a pseudo random id
  93375. */
  93376. static RandomId(): string;
  93377. }
  93378. }
  93379. declare module BABYLON {
  93380. /**
  93381. * Base class of all the textures in babylon.
  93382. * It groups all the common properties the materials, post process, lights... might need
  93383. * in order to make a correct use of the texture.
  93384. */
  93385. export class BaseTexture implements IAnimatable {
  93386. /**
  93387. * Default anisotropic filtering level for the application.
  93388. * It is set to 4 as a good tradeoff between perf and quality.
  93389. */
  93390. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  93391. /**
  93392. * Gets or sets the unique id of the texture
  93393. */
  93394. uniqueId: number;
  93395. /**
  93396. * Define the name of the texture.
  93397. */
  93398. name: string;
  93399. /**
  93400. * Gets or sets an object used to store user defined information.
  93401. */
  93402. metadata: any;
  93403. /**
  93404. * For internal use only. Please do not use.
  93405. */
  93406. reservedDataStore: any;
  93407. private _hasAlpha;
  93408. /**
  93409. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  93410. */
  93411. hasAlpha: boolean;
  93412. /**
  93413. * Defines if the alpha value should be determined via the rgb values.
  93414. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  93415. */
  93416. getAlphaFromRGB: boolean;
  93417. /**
  93418. * Intensity or strength of the texture.
  93419. * It is commonly used by materials to fine tune the intensity of the texture
  93420. */
  93421. level: number;
  93422. /**
  93423. * Define the UV chanel to use starting from 0 and defaulting to 0.
  93424. * This is part of the texture as textures usually maps to one uv set.
  93425. */
  93426. coordinatesIndex: number;
  93427. private _coordinatesMode;
  93428. /**
  93429. * How a texture is mapped.
  93430. *
  93431. * | Value | Type | Description |
  93432. * | ----- | ----------------------------------- | ----------- |
  93433. * | 0 | EXPLICIT_MODE | |
  93434. * | 1 | SPHERICAL_MODE | |
  93435. * | 2 | PLANAR_MODE | |
  93436. * | 3 | CUBIC_MODE | |
  93437. * | 4 | PROJECTION_MODE | |
  93438. * | 5 | SKYBOX_MODE | |
  93439. * | 6 | INVCUBIC_MODE | |
  93440. * | 7 | EQUIRECTANGULAR_MODE | |
  93441. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  93442. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  93443. */
  93444. coordinatesMode: number;
  93445. /**
  93446. * | Value | Type | Description |
  93447. * | ----- | ------------------ | ----------- |
  93448. * | 0 | CLAMP_ADDRESSMODE | |
  93449. * | 1 | WRAP_ADDRESSMODE | |
  93450. * | 2 | MIRROR_ADDRESSMODE | |
  93451. */
  93452. wrapU: number;
  93453. /**
  93454. * | Value | Type | Description |
  93455. * | ----- | ------------------ | ----------- |
  93456. * | 0 | CLAMP_ADDRESSMODE | |
  93457. * | 1 | WRAP_ADDRESSMODE | |
  93458. * | 2 | MIRROR_ADDRESSMODE | |
  93459. */
  93460. wrapV: number;
  93461. /**
  93462. * | Value | Type | Description |
  93463. * | ----- | ------------------ | ----------- |
  93464. * | 0 | CLAMP_ADDRESSMODE | |
  93465. * | 1 | WRAP_ADDRESSMODE | |
  93466. * | 2 | MIRROR_ADDRESSMODE | |
  93467. */
  93468. wrapR: number;
  93469. /**
  93470. * With compliant hardware and browser (supporting anisotropic filtering)
  93471. * this defines the level of anisotropic filtering in the texture.
  93472. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  93473. */
  93474. anisotropicFilteringLevel: number;
  93475. /**
  93476. * Define if the texture is a cube texture or if false a 2d texture.
  93477. */
  93478. isCube: boolean;
  93479. /**
  93480. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  93481. */
  93482. is3D: boolean;
  93483. /**
  93484. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  93485. * HDR texture are usually stored in linear space.
  93486. * This only impacts the PBR and Background materials
  93487. */
  93488. gammaSpace: boolean;
  93489. /**
  93490. * Gets or sets whether or not the texture contains RGBD data.
  93491. */
  93492. isRGBD: boolean;
  93493. /**
  93494. * Is Z inverted in the texture (useful in a cube texture).
  93495. */
  93496. invertZ: boolean;
  93497. /**
  93498. * Are mip maps generated for this texture or not.
  93499. */
  93500. readonly noMipmap: boolean;
  93501. /**
  93502. * @hidden
  93503. */
  93504. lodLevelInAlpha: boolean;
  93505. /**
  93506. * With prefiltered texture, defined the offset used during the prefiltering steps.
  93507. */
  93508. lodGenerationOffset: number;
  93509. /**
  93510. * With prefiltered texture, defined the scale used during the prefiltering steps.
  93511. */
  93512. lodGenerationScale: number;
  93513. /**
  93514. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  93515. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  93516. * average roughness values.
  93517. */
  93518. linearSpecularLOD: boolean;
  93519. /**
  93520. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  93521. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  93522. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  93523. */
  93524. irradianceTexture: Nullable<BaseTexture>;
  93525. /**
  93526. * Define if the texture is a render target.
  93527. */
  93528. isRenderTarget: boolean;
  93529. /**
  93530. * Define the unique id of the texture in the scene.
  93531. */
  93532. readonly uid: string;
  93533. /**
  93534. * Return a string representation of the texture.
  93535. * @returns the texture as a string
  93536. */
  93537. toString(): string;
  93538. /**
  93539. * Get the class name of the texture.
  93540. * @returns "BaseTexture"
  93541. */
  93542. getClassName(): string;
  93543. /**
  93544. * Define the list of animation attached to the texture.
  93545. */
  93546. animations: Animation[];
  93547. /**
  93548. * An event triggered when the texture is disposed.
  93549. */
  93550. onDisposeObservable: Observable<BaseTexture>;
  93551. private _onDisposeObserver;
  93552. /**
  93553. * Callback triggered when the texture has been disposed.
  93554. * Kept for back compatibility, you can use the onDisposeObservable instead.
  93555. */
  93556. onDispose: () => void;
  93557. /**
  93558. * Define the current state of the loading sequence when in delayed load mode.
  93559. */
  93560. delayLoadState: number;
  93561. private _scene;
  93562. /** @hidden */
  93563. _texture: Nullable<InternalTexture>;
  93564. private _uid;
  93565. /**
  93566. * Define if the texture is preventinga material to render or not.
  93567. * If not and the texture is not ready, the engine will use a default black texture instead.
  93568. */
  93569. readonly isBlocking: boolean;
  93570. /**
  93571. * Instantiates a new BaseTexture.
  93572. * Base class of all the textures in babylon.
  93573. * It groups all the common properties the materials, post process, lights... might need
  93574. * in order to make a correct use of the texture.
  93575. * @param scene Define the scene the texture blongs to
  93576. */
  93577. constructor(scene: Nullable<Scene>);
  93578. /**
  93579. * Get the scene the texture belongs to.
  93580. * @returns the scene or null if undefined
  93581. */
  93582. getScene(): Nullable<Scene>;
  93583. /**
  93584. * Get the texture transform matrix used to offset tile the texture for istance.
  93585. * @returns the transformation matrix
  93586. */
  93587. getTextureMatrix(): Matrix;
  93588. /**
  93589. * Get the texture reflection matrix used to rotate/transform the reflection.
  93590. * @returns the reflection matrix
  93591. */
  93592. getReflectionTextureMatrix(): Matrix;
  93593. /**
  93594. * Get the underlying lower level texture from Babylon.
  93595. * @returns the insternal texture
  93596. */
  93597. getInternalTexture(): Nullable<InternalTexture>;
  93598. /**
  93599. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  93600. * @returns true if ready or not blocking
  93601. */
  93602. isReadyOrNotBlocking(): boolean;
  93603. /**
  93604. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  93605. * @returns true if fully ready
  93606. */
  93607. isReady(): boolean;
  93608. private _cachedSize;
  93609. /**
  93610. * Get the size of the texture.
  93611. * @returns the texture size.
  93612. */
  93613. getSize(): ISize;
  93614. /**
  93615. * Get the base size of the texture.
  93616. * It can be different from the size if the texture has been resized for POT for instance
  93617. * @returns the base size
  93618. */
  93619. getBaseSize(): ISize;
  93620. /**
  93621. * Update the sampling mode of the texture.
  93622. * Default is Trilinear mode.
  93623. *
  93624. * | Value | Type | Description |
  93625. * | ----- | ------------------ | ----------- |
  93626. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  93627. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  93628. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  93629. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  93630. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  93631. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  93632. * | 7 | NEAREST_LINEAR | |
  93633. * | 8 | NEAREST_NEAREST | |
  93634. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  93635. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  93636. * | 11 | LINEAR_LINEAR | |
  93637. * | 12 | LINEAR_NEAREST | |
  93638. *
  93639. * > _mag_: magnification filter (close to the viewer)
  93640. * > _min_: minification filter (far from the viewer)
  93641. * > _mip_: filter used between mip map levels
  93642. *@param samplingMode Define the new sampling mode of the texture
  93643. */
  93644. updateSamplingMode(samplingMode: number): void;
  93645. /**
  93646. * Scales the texture if is `canRescale()`
  93647. * @param ratio the resize factor we want to use to rescale
  93648. */
  93649. scale(ratio: number): void;
  93650. /**
  93651. * Get if the texture can rescale.
  93652. */
  93653. readonly canRescale: boolean;
  93654. /** @hidden */
  93655. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  93656. /** @hidden */
  93657. _rebuild(): void;
  93658. /**
  93659. * Triggers the load sequence in delayed load mode.
  93660. */
  93661. delayLoad(): void;
  93662. /**
  93663. * Clones the texture.
  93664. * @returns the cloned texture
  93665. */
  93666. clone(): Nullable<BaseTexture>;
  93667. /**
  93668. * Get the texture underlying type (INT, FLOAT...)
  93669. */
  93670. readonly textureType: number;
  93671. /**
  93672. * Get the texture underlying format (RGB, RGBA...)
  93673. */
  93674. readonly textureFormat: number;
  93675. /**
  93676. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  93677. * This will returns an RGBA array buffer containing either in values (0-255) or
  93678. * float values (0-1) depending of the underlying buffer type.
  93679. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  93680. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  93681. * @param buffer defines a user defined buffer to fill with data (can be null)
  93682. * @returns The Array buffer containing the pixels data.
  93683. */
  93684. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  93685. /**
  93686. * Release and destroy the underlying lower level texture aka internalTexture.
  93687. */
  93688. releaseInternalTexture(): void;
  93689. /**
  93690. * Get the polynomial representation of the texture data.
  93691. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  93692. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  93693. */
  93694. sphericalPolynomial: Nullable<SphericalPolynomial>;
  93695. /** @hidden */
  93696. readonly _lodTextureHigh: Nullable<BaseTexture>;
  93697. /** @hidden */
  93698. readonly _lodTextureMid: Nullable<BaseTexture>;
  93699. /** @hidden */
  93700. readonly _lodTextureLow: Nullable<BaseTexture>;
  93701. /**
  93702. * Dispose the texture and release its associated resources.
  93703. */
  93704. dispose(): void;
  93705. /**
  93706. * Serialize the texture into a JSON representation that can be parsed later on.
  93707. * @returns the JSON representation of the texture
  93708. */
  93709. serialize(): any;
  93710. /**
  93711. * Helper function to be called back once a list of texture contains only ready textures.
  93712. * @param textures Define the list of textures to wait for
  93713. * @param callback Define the callback triggered once the entire list will be ready
  93714. */
  93715. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  93716. }
  93717. }
  93718. declare module BABYLON {
  93719. /**
  93720. * Class used to store data associated with WebGL texture data for the engine
  93721. * This class should not be used directly
  93722. */
  93723. export class InternalTexture {
  93724. /** @hidden */
  93725. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  93726. /**
  93727. * The source of the texture data is unknown
  93728. */
  93729. static DATASOURCE_UNKNOWN: number;
  93730. /**
  93731. * Texture data comes from an URL
  93732. */
  93733. static DATASOURCE_URL: number;
  93734. /**
  93735. * Texture data is only used for temporary storage
  93736. */
  93737. static DATASOURCE_TEMP: number;
  93738. /**
  93739. * Texture data comes from raw data (ArrayBuffer)
  93740. */
  93741. static DATASOURCE_RAW: number;
  93742. /**
  93743. * Texture content is dynamic (video or dynamic texture)
  93744. */
  93745. static DATASOURCE_DYNAMIC: number;
  93746. /**
  93747. * Texture content is generated by rendering to it
  93748. */
  93749. static DATASOURCE_RENDERTARGET: number;
  93750. /**
  93751. * Texture content is part of a multi render target process
  93752. */
  93753. static DATASOURCE_MULTIRENDERTARGET: number;
  93754. /**
  93755. * Texture data comes from a cube data file
  93756. */
  93757. static DATASOURCE_CUBE: number;
  93758. /**
  93759. * Texture data comes from a raw cube data
  93760. */
  93761. static DATASOURCE_CUBERAW: number;
  93762. /**
  93763. * Texture data come from a prefiltered cube data file
  93764. */
  93765. static DATASOURCE_CUBEPREFILTERED: number;
  93766. /**
  93767. * Texture content is raw 3D data
  93768. */
  93769. static DATASOURCE_RAW3D: number;
  93770. /**
  93771. * Texture content is a depth texture
  93772. */
  93773. static DATASOURCE_DEPTHTEXTURE: number;
  93774. /**
  93775. * Texture data comes from a raw cube data encoded with RGBD
  93776. */
  93777. static DATASOURCE_CUBERAW_RGBD: number;
  93778. /**
  93779. * Defines if the texture is ready
  93780. */
  93781. isReady: boolean;
  93782. /**
  93783. * Defines if the texture is a cube texture
  93784. */
  93785. isCube: boolean;
  93786. /**
  93787. * Defines if the texture contains 3D data
  93788. */
  93789. is3D: boolean;
  93790. /**
  93791. * Defines if the texture contains multiview data
  93792. */
  93793. isMultiview: boolean;
  93794. /**
  93795. * Gets the URL used to load this texture
  93796. */
  93797. url: string;
  93798. /**
  93799. * Gets the sampling mode of the texture
  93800. */
  93801. samplingMode: number;
  93802. /**
  93803. * Gets a boolean indicating if the texture needs mipmaps generation
  93804. */
  93805. generateMipMaps: boolean;
  93806. /**
  93807. * Gets the number of samples used by the texture (WebGL2+ only)
  93808. */
  93809. samples: number;
  93810. /**
  93811. * Gets the type of the texture (int, float...)
  93812. */
  93813. type: number;
  93814. /**
  93815. * Gets the format of the texture (RGB, RGBA...)
  93816. */
  93817. format: number;
  93818. /**
  93819. * Observable called when the texture is loaded
  93820. */
  93821. onLoadedObservable: Observable<InternalTexture>;
  93822. /**
  93823. * Gets the width of the texture
  93824. */
  93825. width: number;
  93826. /**
  93827. * Gets the height of the texture
  93828. */
  93829. height: number;
  93830. /**
  93831. * Gets the depth of the texture
  93832. */
  93833. depth: number;
  93834. /**
  93835. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  93836. */
  93837. baseWidth: number;
  93838. /**
  93839. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  93840. */
  93841. baseHeight: number;
  93842. /**
  93843. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  93844. */
  93845. baseDepth: number;
  93846. /**
  93847. * Gets a boolean indicating if the texture is inverted on Y axis
  93848. */
  93849. invertY: boolean;
  93850. /** @hidden */
  93851. _invertVScale: boolean;
  93852. /** @hidden */
  93853. _associatedChannel: number;
  93854. /** @hidden */
  93855. _dataSource: number;
  93856. /** @hidden */
  93857. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  93858. /** @hidden */
  93859. _bufferView: Nullable<ArrayBufferView>;
  93860. /** @hidden */
  93861. _bufferViewArray: Nullable<ArrayBufferView[]>;
  93862. /** @hidden */
  93863. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  93864. /** @hidden */
  93865. _size: number;
  93866. /** @hidden */
  93867. _extension: string;
  93868. /** @hidden */
  93869. _files: Nullable<string[]>;
  93870. /** @hidden */
  93871. _workingCanvas: Nullable<HTMLCanvasElement>;
  93872. /** @hidden */
  93873. _workingContext: Nullable<CanvasRenderingContext2D>;
  93874. /** @hidden */
  93875. _framebuffer: Nullable<WebGLFramebuffer>;
  93876. /** @hidden */
  93877. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  93878. /** @hidden */
  93879. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  93880. /** @hidden */
  93881. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  93882. /** @hidden */
  93883. _attachments: Nullable<number[]>;
  93884. /** @hidden */
  93885. _cachedCoordinatesMode: Nullable<number>;
  93886. /** @hidden */
  93887. _cachedWrapU: Nullable<number>;
  93888. /** @hidden */
  93889. _cachedWrapV: Nullable<number>;
  93890. /** @hidden */
  93891. _cachedWrapR: Nullable<number>;
  93892. /** @hidden */
  93893. _cachedAnisotropicFilteringLevel: Nullable<number>;
  93894. /** @hidden */
  93895. _isDisabled: boolean;
  93896. /** @hidden */
  93897. _compression: Nullable<string>;
  93898. /** @hidden */
  93899. _generateStencilBuffer: boolean;
  93900. /** @hidden */
  93901. _generateDepthBuffer: boolean;
  93902. /** @hidden */
  93903. _comparisonFunction: number;
  93904. /** @hidden */
  93905. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  93906. /** @hidden */
  93907. _lodGenerationScale: number;
  93908. /** @hidden */
  93909. _lodGenerationOffset: number;
  93910. /** @hidden */
  93911. _colorTextureArray: Nullable<WebGLTexture>;
  93912. /** @hidden */
  93913. _depthStencilTextureArray: Nullable<WebGLTexture>;
  93914. /** @hidden */
  93915. _lodTextureHigh: Nullable<BaseTexture>;
  93916. /** @hidden */
  93917. _lodTextureMid: Nullable<BaseTexture>;
  93918. /** @hidden */
  93919. _lodTextureLow: Nullable<BaseTexture>;
  93920. /** @hidden */
  93921. _isRGBD: boolean;
  93922. /** @hidden */
  93923. _linearSpecularLOD: boolean;
  93924. /** @hidden */
  93925. _irradianceTexture: Nullable<BaseTexture>;
  93926. /** @hidden */
  93927. _webGLTexture: Nullable<WebGLTexture>;
  93928. /** @hidden */
  93929. _references: number;
  93930. private _engine;
  93931. /**
  93932. * Gets the Engine the texture belongs to.
  93933. * @returns The babylon engine
  93934. */
  93935. getEngine(): Engine;
  93936. /**
  93937. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  93938. */
  93939. readonly dataSource: number;
  93940. /**
  93941. * Creates a new InternalTexture
  93942. * @param engine defines the engine to use
  93943. * @param dataSource defines the type of data that will be used
  93944. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93945. */
  93946. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  93947. /**
  93948. * Increments the number of references (ie. the number of Texture that point to it)
  93949. */
  93950. incrementReferences(): void;
  93951. /**
  93952. * Change the size of the texture (not the size of the content)
  93953. * @param width defines the new width
  93954. * @param height defines the new height
  93955. * @param depth defines the new depth (1 by default)
  93956. */
  93957. updateSize(width: int, height: int, depth?: int): void;
  93958. /** @hidden */
  93959. _rebuild(): void;
  93960. /** @hidden */
  93961. _swapAndDie(target: InternalTexture): void;
  93962. /**
  93963. * Dispose the current allocated resources
  93964. */
  93965. dispose(): void;
  93966. }
  93967. }
  93968. declare module BABYLON {
  93969. /**
  93970. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  93971. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  93972. */
  93973. export class EffectFallbacks {
  93974. private _defines;
  93975. private _currentRank;
  93976. private _maxRank;
  93977. private _mesh;
  93978. /**
  93979. * Removes the fallback from the bound mesh.
  93980. */
  93981. unBindMesh(): void;
  93982. /**
  93983. * Adds a fallback on the specified property.
  93984. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  93985. * @param define The name of the define in the shader
  93986. */
  93987. addFallback(rank: number, define: string): void;
  93988. /**
  93989. * Sets the mesh to use CPU skinning when needing to fallback.
  93990. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  93991. * @param mesh The mesh to use the fallbacks.
  93992. */
  93993. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  93994. /**
  93995. * Checks to see if more fallbacks are still availible.
  93996. */
  93997. readonly hasMoreFallbacks: boolean;
  93998. /**
  93999. * Removes the defines that should be removed when falling back.
  94000. * @param currentDefines defines the current define statements for the shader.
  94001. * @param effect defines the current effect we try to compile
  94002. * @returns The resulting defines with defines of the current rank removed.
  94003. */
  94004. reduce(currentDefines: string, effect: Effect): string;
  94005. }
  94006. /**
  94007. * Options to be used when creating an effect.
  94008. */
  94009. export class EffectCreationOptions {
  94010. /**
  94011. * Atrributes that will be used in the shader.
  94012. */
  94013. attributes: string[];
  94014. /**
  94015. * Uniform varible names that will be set in the shader.
  94016. */
  94017. uniformsNames: string[];
  94018. /**
  94019. * Uniform buffer varible names that will be set in the shader.
  94020. */
  94021. uniformBuffersNames: string[];
  94022. /**
  94023. * Sampler texture variable names that will be set in the shader.
  94024. */
  94025. samplers: string[];
  94026. /**
  94027. * Define statements that will be set in the shader.
  94028. */
  94029. defines: any;
  94030. /**
  94031. * Possible fallbacks for this effect to improve performance when needed.
  94032. */
  94033. fallbacks: Nullable<EffectFallbacks>;
  94034. /**
  94035. * Callback that will be called when the shader is compiled.
  94036. */
  94037. onCompiled: Nullable<(effect: Effect) => void>;
  94038. /**
  94039. * Callback that will be called if an error occurs during shader compilation.
  94040. */
  94041. onError: Nullable<(effect: Effect, errors: string) => void>;
  94042. /**
  94043. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94044. */
  94045. indexParameters: any;
  94046. /**
  94047. * Max number of lights that can be used in the shader.
  94048. */
  94049. maxSimultaneousLights: number;
  94050. /**
  94051. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94052. */
  94053. transformFeedbackVaryings: Nullable<string[]>;
  94054. }
  94055. /**
  94056. * Effect containing vertex and fragment shader that can be executed on an object.
  94057. */
  94058. export class Effect implements IDisposable {
  94059. /**
  94060. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94061. */
  94062. static ShadersRepository: string;
  94063. /**
  94064. * Name of the effect.
  94065. */
  94066. name: any;
  94067. /**
  94068. * String container all the define statements that should be set on the shader.
  94069. */
  94070. defines: string;
  94071. /**
  94072. * Callback that will be called when the shader is compiled.
  94073. */
  94074. onCompiled: Nullable<(effect: Effect) => void>;
  94075. /**
  94076. * Callback that will be called if an error occurs during shader compilation.
  94077. */
  94078. onError: Nullable<(effect: Effect, errors: string) => void>;
  94079. /**
  94080. * Callback that will be called when effect is bound.
  94081. */
  94082. onBind: Nullable<(effect: Effect) => void>;
  94083. /**
  94084. * Unique ID of the effect.
  94085. */
  94086. uniqueId: number;
  94087. /**
  94088. * Observable that will be called when the shader is compiled.
  94089. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94090. */
  94091. onCompileObservable: Observable<Effect>;
  94092. /**
  94093. * Observable that will be called if an error occurs during shader compilation.
  94094. */
  94095. onErrorObservable: Observable<Effect>;
  94096. /** @hidden */
  94097. _onBindObservable: Nullable<Observable<Effect>>;
  94098. /**
  94099. * Observable that will be called when effect is bound.
  94100. */
  94101. readonly onBindObservable: Observable<Effect>;
  94102. /** @hidden */
  94103. _bonesComputationForcedToCPU: boolean;
  94104. private static _uniqueIdSeed;
  94105. private _engine;
  94106. private _uniformBuffersNames;
  94107. private _uniformsNames;
  94108. private _samplerList;
  94109. private _samplers;
  94110. private _isReady;
  94111. private _compilationError;
  94112. private _attributesNames;
  94113. private _attributes;
  94114. private _uniforms;
  94115. /**
  94116. * Key for the effect.
  94117. * @hidden
  94118. */
  94119. _key: string;
  94120. private _indexParameters;
  94121. private _fallbacks;
  94122. private _vertexSourceCode;
  94123. private _fragmentSourceCode;
  94124. private _vertexSourceCodeOverride;
  94125. private _fragmentSourceCodeOverride;
  94126. private _transformFeedbackVaryings;
  94127. /**
  94128. * Compiled shader to webGL program.
  94129. * @hidden
  94130. */
  94131. _pipelineContext: Nullable<IPipelineContext>;
  94132. private _valueCache;
  94133. private static _baseCache;
  94134. /**
  94135. * Instantiates an effect.
  94136. * An effect can be used to create/manage/execute vertex and fragment shaders.
  94137. * @param baseName Name of the effect.
  94138. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  94139. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  94140. * @param samplers List of sampler variables that will be passed to the shader.
  94141. * @param engine Engine to be used to render the effect
  94142. * @param defines Define statements to be added to the shader.
  94143. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  94144. * @param onCompiled Callback that will be called when the shader is compiled.
  94145. * @param onError Callback that will be called if an error occurs during shader compilation.
  94146. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94147. */
  94148. 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);
  94149. private _useFinalCode;
  94150. /**
  94151. * Unique key for this effect
  94152. */
  94153. readonly key: string;
  94154. /**
  94155. * If the effect has been compiled and prepared.
  94156. * @returns if the effect is compiled and prepared.
  94157. */
  94158. isReady(): boolean;
  94159. private _isReadyInternal;
  94160. /**
  94161. * The engine the effect was initialized with.
  94162. * @returns the engine.
  94163. */
  94164. getEngine(): Engine;
  94165. /**
  94166. * The pipeline context for this effect
  94167. * @returns the associated pipeline context
  94168. */
  94169. getPipelineContext(): Nullable<IPipelineContext>;
  94170. /**
  94171. * The set of names of attribute variables for the shader.
  94172. * @returns An array of attribute names.
  94173. */
  94174. getAttributesNames(): string[];
  94175. /**
  94176. * Returns the attribute at the given index.
  94177. * @param index The index of the attribute.
  94178. * @returns The location of the attribute.
  94179. */
  94180. getAttributeLocation(index: number): number;
  94181. /**
  94182. * Returns the attribute based on the name of the variable.
  94183. * @param name of the attribute to look up.
  94184. * @returns the attribute location.
  94185. */
  94186. getAttributeLocationByName(name: string): number;
  94187. /**
  94188. * The number of attributes.
  94189. * @returns the numnber of attributes.
  94190. */
  94191. getAttributesCount(): number;
  94192. /**
  94193. * Gets the index of a uniform variable.
  94194. * @param uniformName of the uniform to look up.
  94195. * @returns the index.
  94196. */
  94197. getUniformIndex(uniformName: string): number;
  94198. /**
  94199. * Returns the attribute based on the name of the variable.
  94200. * @param uniformName of the uniform to look up.
  94201. * @returns the location of the uniform.
  94202. */
  94203. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  94204. /**
  94205. * Returns an array of sampler variable names
  94206. * @returns The array of sampler variable neames.
  94207. */
  94208. getSamplers(): string[];
  94209. /**
  94210. * The error from the last compilation.
  94211. * @returns the error string.
  94212. */
  94213. getCompilationError(): string;
  94214. /**
  94215. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  94216. * @param func The callback to be used.
  94217. */
  94218. executeWhenCompiled(func: (effect: Effect) => void): void;
  94219. private _checkIsReady;
  94220. /** @hidden */
  94221. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  94222. /** @hidden */
  94223. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  94224. /** @hidden */
  94225. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  94226. /**
  94227. * Recompiles the webGL program
  94228. * @param vertexSourceCode The source code for the vertex shader.
  94229. * @param fragmentSourceCode The source code for the fragment shader.
  94230. * @param onCompiled Callback called when completed.
  94231. * @param onError Callback called on error.
  94232. * @hidden
  94233. */
  94234. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  94235. /**
  94236. * Prepares the effect
  94237. * @hidden
  94238. */
  94239. _prepareEffect(): void;
  94240. private _processCompilationErrors;
  94241. /**
  94242. * Checks if the effect is supported. (Must be called after compilation)
  94243. */
  94244. readonly isSupported: boolean;
  94245. /**
  94246. * Binds a texture to the engine to be used as output of the shader.
  94247. * @param channel Name of the output variable.
  94248. * @param texture Texture to bind.
  94249. * @hidden
  94250. */
  94251. _bindTexture(channel: string, texture: InternalTexture): void;
  94252. /**
  94253. * Sets a texture on the engine to be used in the shader.
  94254. * @param channel Name of the sampler variable.
  94255. * @param texture Texture to set.
  94256. */
  94257. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  94258. /**
  94259. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  94260. * @param channel Name of the sampler variable.
  94261. * @param texture Texture to set.
  94262. */
  94263. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  94264. /**
  94265. * Sets an array of textures on the engine to be used in the shader.
  94266. * @param channel Name of the variable.
  94267. * @param textures Textures to set.
  94268. */
  94269. setTextureArray(channel: string, textures: BaseTexture[]): void;
  94270. /**
  94271. * 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)
  94272. * @param channel Name of the sampler variable.
  94273. * @param postProcess Post process to get the input texture from.
  94274. */
  94275. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  94276. /**
  94277. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  94278. * 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)
  94279. * @param channel Name of the sampler variable.
  94280. * @param postProcess Post process to get the output texture from.
  94281. */
  94282. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  94283. /** @hidden */
  94284. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  94285. /** @hidden */
  94286. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  94287. /** @hidden */
  94288. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  94289. /** @hidden */
  94290. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  94291. /**
  94292. * Binds a buffer to a uniform.
  94293. * @param buffer Buffer to bind.
  94294. * @param name Name of the uniform variable to bind to.
  94295. */
  94296. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  94297. /**
  94298. * Binds block to a uniform.
  94299. * @param blockName Name of the block to bind.
  94300. * @param index Index to bind.
  94301. */
  94302. bindUniformBlock(blockName: string, index: number): void;
  94303. /**
  94304. * Sets an interger value on a uniform variable.
  94305. * @param uniformName Name of the variable.
  94306. * @param value Value to be set.
  94307. * @returns this effect.
  94308. */
  94309. setInt(uniformName: string, value: number): Effect;
  94310. /**
  94311. * Sets an int array on a uniform variable.
  94312. * @param uniformName Name of the variable.
  94313. * @param array array to be set.
  94314. * @returns this effect.
  94315. */
  94316. setIntArray(uniformName: string, array: Int32Array): Effect;
  94317. /**
  94318. * 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)
  94319. * @param uniformName Name of the variable.
  94320. * @param array array to be set.
  94321. * @returns this effect.
  94322. */
  94323. setIntArray2(uniformName: string, array: Int32Array): Effect;
  94324. /**
  94325. * 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)
  94326. * @param uniformName Name of the variable.
  94327. * @param array array to be set.
  94328. * @returns this effect.
  94329. */
  94330. setIntArray3(uniformName: string, array: Int32Array): Effect;
  94331. /**
  94332. * 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)
  94333. * @param uniformName Name of the variable.
  94334. * @param array array to be set.
  94335. * @returns this effect.
  94336. */
  94337. setIntArray4(uniformName: string, array: Int32Array): Effect;
  94338. /**
  94339. * Sets an float array on a uniform variable.
  94340. * @param uniformName Name of the variable.
  94341. * @param array array to be set.
  94342. * @returns this effect.
  94343. */
  94344. setFloatArray(uniformName: string, array: Float32Array): Effect;
  94345. /**
  94346. * 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)
  94347. * @param uniformName Name of the variable.
  94348. * @param array array to be set.
  94349. * @returns this effect.
  94350. */
  94351. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  94352. /**
  94353. * 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)
  94354. * @param uniformName Name of the variable.
  94355. * @param array array to be set.
  94356. * @returns this effect.
  94357. */
  94358. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  94359. /**
  94360. * 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)
  94361. * @param uniformName Name of the variable.
  94362. * @param array array to be set.
  94363. * @returns this effect.
  94364. */
  94365. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  94366. /**
  94367. * Sets an array on a uniform variable.
  94368. * @param uniformName Name of the variable.
  94369. * @param array array to be set.
  94370. * @returns this effect.
  94371. */
  94372. setArray(uniformName: string, array: number[]): Effect;
  94373. /**
  94374. * 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)
  94375. * @param uniformName Name of the variable.
  94376. * @param array array to be set.
  94377. * @returns this effect.
  94378. */
  94379. setArray2(uniformName: string, array: number[]): Effect;
  94380. /**
  94381. * 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)
  94382. * @param uniformName Name of the variable.
  94383. * @param array array to be set.
  94384. * @returns this effect.
  94385. */
  94386. setArray3(uniformName: string, array: number[]): Effect;
  94387. /**
  94388. * 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)
  94389. * @param uniformName Name of the variable.
  94390. * @param array array to be set.
  94391. * @returns this effect.
  94392. */
  94393. setArray4(uniformName: string, array: number[]): Effect;
  94394. /**
  94395. * Sets matrices on a uniform variable.
  94396. * @param uniformName Name of the variable.
  94397. * @param matrices matrices to be set.
  94398. * @returns this effect.
  94399. */
  94400. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  94401. /**
  94402. * Sets matrix on a uniform variable.
  94403. * @param uniformName Name of the variable.
  94404. * @param matrix matrix to be set.
  94405. * @returns this effect.
  94406. */
  94407. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  94408. /**
  94409. * 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)
  94410. * @param uniformName Name of the variable.
  94411. * @param matrix matrix to be set.
  94412. * @returns this effect.
  94413. */
  94414. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  94415. /**
  94416. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  94417. * @param uniformName Name of the variable.
  94418. * @param matrix matrix to be set.
  94419. * @returns this effect.
  94420. */
  94421. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  94422. /**
  94423. * Sets a float on a uniform variable.
  94424. * @param uniformName Name of the variable.
  94425. * @param value value to be set.
  94426. * @returns this effect.
  94427. */
  94428. setFloat(uniformName: string, value: number): Effect;
  94429. /**
  94430. * Sets a boolean on a uniform variable.
  94431. * @param uniformName Name of the variable.
  94432. * @param bool value to be set.
  94433. * @returns this effect.
  94434. */
  94435. setBool(uniformName: string, bool: boolean): Effect;
  94436. /**
  94437. * Sets a Vector2 on a uniform variable.
  94438. * @param uniformName Name of the variable.
  94439. * @param vector2 vector2 to be set.
  94440. * @returns this effect.
  94441. */
  94442. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  94443. /**
  94444. * Sets a float2 on a uniform variable.
  94445. * @param uniformName Name of the variable.
  94446. * @param x First float in float2.
  94447. * @param y Second float in float2.
  94448. * @returns this effect.
  94449. */
  94450. setFloat2(uniformName: string, x: number, y: number): Effect;
  94451. /**
  94452. * Sets a Vector3 on a uniform variable.
  94453. * @param uniformName Name of the variable.
  94454. * @param vector3 Value to be set.
  94455. * @returns this effect.
  94456. */
  94457. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  94458. /**
  94459. * Sets a float3 on a uniform variable.
  94460. * @param uniformName Name of the variable.
  94461. * @param x First float in float3.
  94462. * @param y Second float in float3.
  94463. * @param z Third float in float3.
  94464. * @returns this effect.
  94465. */
  94466. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  94467. /**
  94468. * Sets a Vector4 on a uniform variable.
  94469. * @param uniformName Name of the variable.
  94470. * @param vector4 Value to be set.
  94471. * @returns this effect.
  94472. */
  94473. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  94474. /**
  94475. * Sets a float4 on a uniform variable.
  94476. * @param uniformName Name of the variable.
  94477. * @param x First float in float4.
  94478. * @param y Second float in float4.
  94479. * @param z Third float in float4.
  94480. * @param w Fourth float in float4.
  94481. * @returns this effect.
  94482. */
  94483. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  94484. /**
  94485. * Sets a Color3 on a uniform variable.
  94486. * @param uniformName Name of the variable.
  94487. * @param color3 Value to be set.
  94488. * @returns this effect.
  94489. */
  94490. setColor3(uniformName: string, color3: IColor3Like): Effect;
  94491. /**
  94492. * Sets a Color4 on a uniform variable.
  94493. * @param uniformName Name of the variable.
  94494. * @param color3 Value to be set.
  94495. * @param alpha Alpha value to be set.
  94496. * @returns this effect.
  94497. */
  94498. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  94499. /**
  94500. * Sets a Color4 on a uniform variable
  94501. * @param uniformName defines the name of the variable
  94502. * @param color4 defines the value to be set
  94503. * @returns this effect.
  94504. */
  94505. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  94506. /** Release all associated resources */
  94507. dispose(): void;
  94508. /**
  94509. * This function will add a new shader to the shader store
  94510. * @param name the name of the shader
  94511. * @param pixelShader optional pixel shader content
  94512. * @param vertexShader optional vertex shader content
  94513. */
  94514. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  94515. /**
  94516. * Store of each shader (The can be looked up using effect.key)
  94517. */
  94518. static ShadersStore: {
  94519. [key: string]: string;
  94520. };
  94521. /**
  94522. * Store of each included file for a shader (The can be looked up using effect.key)
  94523. */
  94524. static IncludesShadersStore: {
  94525. [key: string]: string;
  94526. };
  94527. /**
  94528. * Resets the cache of effects.
  94529. */
  94530. static ResetCache(): void;
  94531. }
  94532. }
  94533. declare module BABYLON {
  94534. /**
  94535. * Uniform buffer objects.
  94536. *
  94537. * Handles blocks of uniform on the GPU.
  94538. *
  94539. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94540. *
  94541. * For more information, please refer to :
  94542. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94543. */
  94544. export class UniformBuffer {
  94545. private _engine;
  94546. private _buffer;
  94547. private _data;
  94548. private _bufferData;
  94549. private _dynamic?;
  94550. private _uniformLocations;
  94551. private _uniformSizes;
  94552. private _uniformLocationPointer;
  94553. private _needSync;
  94554. private _noUBO;
  94555. private _currentEffect;
  94556. private static _MAX_UNIFORM_SIZE;
  94557. private static _tempBuffer;
  94558. /**
  94559. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  94560. * This is dynamic to allow compat with webgl 1 and 2.
  94561. * You will need to pass the name of the uniform as well as the value.
  94562. */
  94563. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  94564. /**
  94565. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  94566. * This is dynamic to allow compat with webgl 1 and 2.
  94567. * You will need to pass the name of the uniform as well as the value.
  94568. */
  94569. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  94570. /**
  94571. * Lambda to Update a single float in a uniform buffer.
  94572. * This is dynamic to allow compat with webgl 1 and 2.
  94573. * You will need to pass the name of the uniform as well as the value.
  94574. */
  94575. updateFloat: (name: string, x: number) => void;
  94576. /**
  94577. * Lambda to Update a vec2 of float in a uniform buffer.
  94578. * This is dynamic to allow compat with webgl 1 and 2.
  94579. * You will need to pass the name of the uniform as well as the value.
  94580. */
  94581. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  94582. /**
  94583. * Lambda to Update a vec3 of float in a uniform buffer.
  94584. * This is dynamic to allow compat with webgl 1 and 2.
  94585. * You will need to pass the name of the uniform as well as the value.
  94586. */
  94587. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  94588. /**
  94589. * Lambda to Update a vec4 of float in a uniform buffer.
  94590. * This is dynamic to allow compat with webgl 1 and 2.
  94591. * You will need to pass the name of the uniform as well as the value.
  94592. */
  94593. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  94594. /**
  94595. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  94596. * This is dynamic to allow compat with webgl 1 and 2.
  94597. * You will need to pass the name of the uniform as well as the value.
  94598. */
  94599. updateMatrix: (name: string, mat: Matrix) => void;
  94600. /**
  94601. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  94602. * This is dynamic to allow compat with webgl 1 and 2.
  94603. * You will need to pass the name of the uniform as well as the value.
  94604. */
  94605. updateVector3: (name: string, vector: Vector3) => void;
  94606. /**
  94607. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  94608. * This is dynamic to allow compat with webgl 1 and 2.
  94609. * You will need to pass the name of the uniform as well as the value.
  94610. */
  94611. updateVector4: (name: string, vector: Vector4) => void;
  94612. /**
  94613. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  94614. * This is dynamic to allow compat with webgl 1 and 2.
  94615. * You will need to pass the name of the uniform as well as the value.
  94616. */
  94617. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  94618. /**
  94619. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  94620. * This is dynamic to allow compat with webgl 1 and 2.
  94621. * You will need to pass the name of the uniform as well as the value.
  94622. */
  94623. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  94624. /**
  94625. * Instantiates a new Uniform buffer objects.
  94626. *
  94627. * Handles blocks of uniform on the GPU.
  94628. *
  94629. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94630. *
  94631. * For more information, please refer to :
  94632. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94633. * @param engine Define the engine the buffer is associated with
  94634. * @param data Define the data contained in the buffer
  94635. * @param dynamic Define if the buffer is updatable
  94636. */
  94637. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  94638. /**
  94639. * Indicates if the buffer is using the WebGL2 UBO implementation,
  94640. * or just falling back on setUniformXXX calls.
  94641. */
  94642. readonly useUbo: boolean;
  94643. /**
  94644. * Indicates if the WebGL underlying uniform buffer is in sync
  94645. * with the javascript cache data.
  94646. */
  94647. readonly isSync: boolean;
  94648. /**
  94649. * Indicates if the WebGL underlying uniform buffer is dynamic.
  94650. * Also, a dynamic UniformBuffer will disable cache verification and always
  94651. * update the underlying WebGL uniform buffer to the GPU.
  94652. * @returns if Dynamic, otherwise false
  94653. */
  94654. isDynamic(): boolean;
  94655. /**
  94656. * The data cache on JS side.
  94657. * @returns the underlying data as a float array
  94658. */
  94659. getData(): Float32Array;
  94660. /**
  94661. * The underlying WebGL Uniform buffer.
  94662. * @returns the webgl buffer
  94663. */
  94664. getBuffer(): Nullable<DataBuffer>;
  94665. /**
  94666. * std140 layout specifies how to align data within an UBO structure.
  94667. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  94668. * for specs.
  94669. */
  94670. private _fillAlignment;
  94671. /**
  94672. * Adds an uniform in the buffer.
  94673. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  94674. * for the layout to be correct !
  94675. * @param name Name of the uniform, as used in the uniform block in the shader.
  94676. * @param size Data size, or data directly.
  94677. */
  94678. addUniform(name: string, size: number | number[]): void;
  94679. /**
  94680. * Adds a Matrix 4x4 to the uniform buffer.
  94681. * @param name Name of the uniform, as used in the uniform block in the shader.
  94682. * @param mat A 4x4 matrix.
  94683. */
  94684. addMatrix(name: string, mat: Matrix): void;
  94685. /**
  94686. * Adds a vec2 to the uniform buffer.
  94687. * @param name Name of the uniform, as used in the uniform block in the shader.
  94688. * @param x Define the x component value of the vec2
  94689. * @param y Define the y component value of the vec2
  94690. */
  94691. addFloat2(name: string, x: number, y: number): void;
  94692. /**
  94693. * Adds a vec3 to the uniform buffer.
  94694. * @param name Name of the uniform, as used in the uniform block in the shader.
  94695. * @param x Define the x component value of the vec3
  94696. * @param y Define the y component value of the vec3
  94697. * @param z Define the z component value of the vec3
  94698. */
  94699. addFloat3(name: string, x: number, y: number, z: number): void;
  94700. /**
  94701. * Adds a vec3 to the uniform buffer.
  94702. * @param name Name of the uniform, as used in the uniform block in the shader.
  94703. * @param color Define the vec3 from a Color
  94704. */
  94705. addColor3(name: string, color: Color3): void;
  94706. /**
  94707. * Adds a vec4 to the uniform buffer.
  94708. * @param name Name of the uniform, as used in the uniform block in the shader.
  94709. * @param color Define the rgb components from a Color
  94710. * @param alpha Define the a component of the vec4
  94711. */
  94712. addColor4(name: string, color: Color3, alpha: number): void;
  94713. /**
  94714. * Adds a vec3 to the uniform buffer.
  94715. * @param name Name of the uniform, as used in the uniform block in the shader.
  94716. * @param vector Define the vec3 components from a Vector
  94717. */
  94718. addVector3(name: string, vector: Vector3): void;
  94719. /**
  94720. * Adds a Matrix 3x3 to the uniform buffer.
  94721. * @param name Name of the uniform, as used in the uniform block in the shader.
  94722. */
  94723. addMatrix3x3(name: string): void;
  94724. /**
  94725. * Adds a Matrix 2x2 to the uniform buffer.
  94726. * @param name Name of the uniform, as used in the uniform block in the shader.
  94727. */
  94728. addMatrix2x2(name: string): void;
  94729. /**
  94730. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  94731. */
  94732. create(): void;
  94733. /** @hidden */
  94734. _rebuild(): void;
  94735. /**
  94736. * Updates the WebGL Uniform Buffer on the GPU.
  94737. * If the `dynamic` flag is set to true, no cache comparison is done.
  94738. * Otherwise, the buffer will be updated only if the cache differs.
  94739. */
  94740. update(): void;
  94741. /**
  94742. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  94743. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94744. * @param data Define the flattened data
  94745. * @param size Define the size of the data.
  94746. */
  94747. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  94748. private _valueCache;
  94749. private _cacheMatrix;
  94750. private _updateMatrix3x3ForUniform;
  94751. private _updateMatrix3x3ForEffect;
  94752. private _updateMatrix2x2ForEffect;
  94753. private _updateMatrix2x2ForUniform;
  94754. private _updateFloatForEffect;
  94755. private _updateFloatForUniform;
  94756. private _updateFloat2ForEffect;
  94757. private _updateFloat2ForUniform;
  94758. private _updateFloat3ForEffect;
  94759. private _updateFloat3ForUniform;
  94760. private _updateFloat4ForEffect;
  94761. private _updateFloat4ForUniform;
  94762. private _updateMatrixForEffect;
  94763. private _updateMatrixForUniform;
  94764. private _updateVector3ForEffect;
  94765. private _updateVector3ForUniform;
  94766. private _updateVector4ForEffect;
  94767. private _updateVector4ForUniform;
  94768. private _updateColor3ForEffect;
  94769. private _updateColor3ForUniform;
  94770. private _updateColor4ForEffect;
  94771. private _updateColor4ForUniform;
  94772. /**
  94773. * Sets a sampler uniform on the effect.
  94774. * @param name Define the name of the sampler.
  94775. * @param texture Define the texture to set in the sampler
  94776. */
  94777. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  94778. /**
  94779. * Directly updates the value of the uniform in the cache AND on the GPU.
  94780. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94781. * @param data Define the flattened data
  94782. */
  94783. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  94784. /**
  94785. * Binds this uniform buffer to an effect.
  94786. * @param effect Define the effect to bind the buffer to
  94787. * @param name Name of the uniform block in the shader.
  94788. */
  94789. bindToEffect(effect: Effect, name: string): void;
  94790. /**
  94791. * Disposes the uniform buffer.
  94792. */
  94793. dispose(): void;
  94794. }
  94795. }
  94796. declare module BABYLON {
  94797. /**
  94798. * Class used to work with sound analyzer using fast fourier transform (FFT)
  94799. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94800. */
  94801. export class Analyser {
  94802. /**
  94803. * Gets or sets the smoothing
  94804. * @ignorenaming
  94805. */
  94806. SMOOTHING: number;
  94807. /**
  94808. * Gets or sets the FFT table size
  94809. * @ignorenaming
  94810. */
  94811. FFT_SIZE: number;
  94812. /**
  94813. * Gets or sets the bar graph amplitude
  94814. * @ignorenaming
  94815. */
  94816. BARGRAPHAMPLITUDE: number;
  94817. /**
  94818. * Gets or sets the position of the debug canvas
  94819. * @ignorenaming
  94820. */
  94821. DEBUGCANVASPOS: {
  94822. x: number;
  94823. y: number;
  94824. };
  94825. /**
  94826. * Gets or sets the debug canvas size
  94827. * @ignorenaming
  94828. */
  94829. DEBUGCANVASSIZE: {
  94830. width: number;
  94831. height: number;
  94832. };
  94833. private _byteFreqs;
  94834. private _byteTime;
  94835. private _floatFreqs;
  94836. private _webAudioAnalyser;
  94837. private _debugCanvas;
  94838. private _debugCanvasContext;
  94839. private _scene;
  94840. private _registerFunc;
  94841. private _audioEngine;
  94842. /**
  94843. * Creates a new analyser
  94844. * @param scene defines hosting scene
  94845. */
  94846. constructor(scene: Scene);
  94847. /**
  94848. * Get the number of data values you will have to play with for the visualization
  94849. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  94850. * @returns a number
  94851. */
  94852. getFrequencyBinCount(): number;
  94853. /**
  94854. * Gets the current frequency data as a byte array
  94855. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94856. * @returns a Uint8Array
  94857. */
  94858. getByteFrequencyData(): Uint8Array;
  94859. /**
  94860. * Gets the current waveform as a byte array
  94861. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  94862. * @returns a Uint8Array
  94863. */
  94864. getByteTimeDomainData(): Uint8Array;
  94865. /**
  94866. * Gets the current frequency data as a float array
  94867. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94868. * @returns a Float32Array
  94869. */
  94870. getFloatFrequencyData(): Float32Array;
  94871. /**
  94872. * Renders the debug canvas
  94873. */
  94874. drawDebugCanvas(): void;
  94875. /**
  94876. * Stops rendering the debug canvas and removes it
  94877. */
  94878. stopDebugCanvas(): void;
  94879. /**
  94880. * Connects two audio nodes
  94881. * @param inputAudioNode defines first node to connect
  94882. * @param outputAudioNode defines second node to connect
  94883. */
  94884. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  94885. /**
  94886. * Releases all associated resources
  94887. */
  94888. dispose(): void;
  94889. }
  94890. }
  94891. declare module BABYLON {
  94892. /**
  94893. * This represents an audio engine and it is responsible
  94894. * to play, synchronize and analyse sounds throughout the application.
  94895. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94896. */
  94897. export interface IAudioEngine extends IDisposable {
  94898. /**
  94899. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  94900. */
  94901. readonly canUseWebAudio: boolean;
  94902. /**
  94903. * Gets the current AudioContext if available.
  94904. */
  94905. readonly audioContext: Nullable<AudioContext>;
  94906. /**
  94907. * The master gain node defines the global audio volume of your audio engine.
  94908. */
  94909. readonly masterGain: GainNode;
  94910. /**
  94911. * Gets whether or not mp3 are supported by your browser.
  94912. */
  94913. readonly isMP3supported: boolean;
  94914. /**
  94915. * Gets whether or not ogg are supported by your browser.
  94916. */
  94917. readonly isOGGsupported: boolean;
  94918. /**
  94919. * Defines if Babylon should emit a warning if WebAudio is not supported.
  94920. * @ignoreNaming
  94921. */
  94922. WarnedWebAudioUnsupported: boolean;
  94923. /**
  94924. * Defines if the audio engine relies on a custom unlocked button.
  94925. * In this case, the embedded button will not be displayed.
  94926. */
  94927. useCustomUnlockedButton: boolean;
  94928. /**
  94929. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  94930. */
  94931. readonly unlocked: boolean;
  94932. /**
  94933. * Event raised when audio has been unlocked on the browser.
  94934. */
  94935. onAudioUnlockedObservable: Observable<AudioEngine>;
  94936. /**
  94937. * Event raised when audio has been locked on the browser.
  94938. */
  94939. onAudioLockedObservable: Observable<AudioEngine>;
  94940. /**
  94941. * Flags the audio engine in Locked state.
  94942. * This happens due to new browser policies preventing audio to autoplay.
  94943. */
  94944. lock(): void;
  94945. /**
  94946. * Unlocks the audio engine once a user action has been done on the dom.
  94947. * This is helpful to resume play once browser policies have been satisfied.
  94948. */
  94949. unlock(): void;
  94950. }
  94951. /**
  94952. * This represents the default audio engine used in babylon.
  94953. * It is responsible to play, synchronize and analyse sounds throughout the application.
  94954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94955. */
  94956. export class AudioEngine implements IAudioEngine {
  94957. private _audioContext;
  94958. private _audioContextInitialized;
  94959. private _muteButton;
  94960. private _hostElement;
  94961. /**
  94962. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  94963. */
  94964. canUseWebAudio: boolean;
  94965. /**
  94966. * The master gain node defines the global audio volume of your audio engine.
  94967. */
  94968. masterGain: GainNode;
  94969. /**
  94970. * Defines if Babylon should emit a warning if WebAudio is not supported.
  94971. * @ignoreNaming
  94972. */
  94973. WarnedWebAudioUnsupported: boolean;
  94974. /**
  94975. * Gets whether or not mp3 are supported by your browser.
  94976. */
  94977. isMP3supported: boolean;
  94978. /**
  94979. * Gets whether or not ogg are supported by your browser.
  94980. */
  94981. isOGGsupported: boolean;
  94982. /**
  94983. * Gets whether audio has been unlocked on the device.
  94984. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  94985. * a user interaction has happened.
  94986. */
  94987. unlocked: boolean;
  94988. /**
  94989. * Defines if the audio engine relies on a custom unlocked button.
  94990. * In this case, the embedded button will not be displayed.
  94991. */
  94992. useCustomUnlockedButton: boolean;
  94993. /**
  94994. * Event raised when audio has been unlocked on the browser.
  94995. */
  94996. onAudioUnlockedObservable: Observable<AudioEngine>;
  94997. /**
  94998. * Event raised when audio has been locked on the browser.
  94999. */
  95000. onAudioLockedObservable: Observable<AudioEngine>;
  95001. /**
  95002. * Gets the current AudioContext if available.
  95003. */
  95004. readonly audioContext: Nullable<AudioContext>;
  95005. private _connectedAnalyser;
  95006. /**
  95007. * Instantiates a new audio engine.
  95008. *
  95009. * There should be only one per page as some browsers restrict the number
  95010. * of audio contexts you can create.
  95011. * @param hostElement defines the host element where to display the mute icon if necessary
  95012. */
  95013. constructor(hostElement?: Nullable<HTMLElement>);
  95014. /**
  95015. * Flags the audio engine in Locked state.
  95016. * This happens due to new browser policies preventing audio to autoplay.
  95017. */
  95018. lock(): void;
  95019. /**
  95020. * Unlocks the audio engine once a user action has been done on the dom.
  95021. * This is helpful to resume play once browser policies have been satisfied.
  95022. */
  95023. unlock(): void;
  95024. private _resumeAudioContext;
  95025. private _initializeAudioContext;
  95026. private _tryToRun;
  95027. private _triggerRunningState;
  95028. private _triggerSuspendedState;
  95029. private _displayMuteButton;
  95030. private _moveButtonToTopLeft;
  95031. private _onResize;
  95032. private _hideMuteButton;
  95033. /**
  95034. * Destroy and release the resources associated with the audio ccontext.
  95035. */
  95036. dispose(): void;
  95037. /**
  95038. * Gets the global volume sets on the master gain.
  95039. * @returns the global volume if set or -1 otherwise
  95040. */
  95041. getGlobalVolume(): number;
  95042. /**
  95043. * Sets the global volume of your experience (sets on the master gain).
  95044. * @param newVolume Defines the new global volume of the application
  95045. */
  95046. setGlobalVolume(newVolume: number): void;
  95047. /**
  95048. * Connect the audio engine to an audio analyser allowing some amazing
  95049. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  95050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  95051. * @param analyser The analyser to connect to the engine
  95052. */
  95053. connectToAnalyser(analyser: Analyser): void;
  95054. }
  95055. }
  95056. declare module BABYLON {
  95057. /**
  95058. * Interface used to present a loading screen while loading a scene
  95059. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95060. */
  95061. export interface ILoadingScreen {
  95062. /**
  95063. * Function called to display the loading screen
  95064. */
  95065. displayLoadingUI: () => void;
  95066. /**
  95067. * Function called to hide the loading screen
  95068. */
  95069. hideLoadingUI: () => void;
  95070. /**
  95071. * Gets or sets the color to use for the background
  95072. */
  95073. loadingUIBackgroundColor: string;
  95074. /**
  95075. * Gets or sets the text to display while loading
  95076. */
  95077. loadingUIText: string;
  95078. }
  95079. /**
  95080. * Class used for the default loading screen
  95081. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95082. */
  95083. export class DefaultLoadingScreen implements ILoadingScreen {
  95084. private _renderingCanvas;
  95085. private _loadingText;
  95086. private _loadingDivBackgroundColor;
  95087. private _loadingDiv;
  95088. private _loadingTextDiv;
  95089. /** Gets or sets the logo url to use for the default loading screen */
  95090. static DefaultLogoUrl: string;
  95091. /** Gets or sets the spinner url to use for the default loading screen */
  95092. static DefaultSpinnerUrl: string;
  95093. /**
  95094. * Creates a new default loading screen
  95095. * @param _renderingCanvas defines the canvas used to render the scene
  95096. * @param _loadingText defines the default text to display
  95097. * @param _loadingDivBackgroundColor defines the default background color
  95098. */
  95099. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  95100. /**
  95101. * Function called to display the loading screen
  95102. */
  95103. displayLoadingUI(): void;
  95104. /**
  95105. * Function called to hide the loading screen
  95106. */
  95107. hideLoadingUI(): void;
  95108. /**
  95109. * Gets or sets the text to display while loading
  95110. */
  95111. loadingUIText: string;
  95112. /**
  95113. * Gets or sets the color to use for the background
  95114. */
  95115. loadingUIBackgroundColor: string;
  95116. private _resizeLoadingUI;
  95117. }
  95118. }
  95119. declare module BABYLON {
  95120. /** @hidden */
  95121. export class WebGLPipelineContext implements IPipelineContext {
  95122. engine: Engine;
  95123. program: Nullable<WebGLProgram>;
  95124. context?: WebGLRenderingContext;
  95125. vertexShader?: WebGLShader;
  95126. fragmentShader?: WebGLShader;
  95127. isParallelCompiled: boolean;
  95128. onCompiled?: () => void;
  95129. transformFeedback?: WebGLTransformFeedback | null;
  95130. readonly isAsync: boolean;
  95131. readonly isReady: boolean;
  95132. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  95133. }
  95134. }
  95135. declare module BABYLON {
  95136. /** @hidden */
  95137. export class WebGLDataBuffer extends DataBuffer {
  95138. private _buffer;
  95139. constructor(resource: WebGLBuffer);
  95140. readonly underlyingResource: any;
  95141. }
  95142. }
  95143. declare module BABYLON {
  95144. /** @hidden */
  95145. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95146. attributeProcessor(attribute: string): string;
  95147. varyingProcessor(varying: string, isFragment: boolean): string;
  95148. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95149. }
  95150. }
  95151. declare module BABYLON {
  95152. /**
  95153. * This class is used to track a performance counter which is number based.
  95154. * The user has access to many properties which give statistics of different nature.
  95155. *
  95156. * The implementer can track two kinds of Performance Counter: time and count.
  95157. * 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.
  95158. * 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.
  95159. */
  95160. export class PerfCounter {
  95161. /**
  95162. * Gets or sets a global boolean to turn on and off all the counters
  95163. */
  95164. static Enabled: boolean;
  95165. /**
  95166. * Returns the smallest value ever
  95167. */
  95168. readonly min: number;
  95169. /**
  95170. * Returns the biggest value ever
  95171. */
  95172. readonly max: number;
  95173. /**
  95174. * Returns the average value since the performance counter is running
  95175. */
  95176. readonly average: number;
  95177. /**
  95178. * Returns the average value of the last second the counter was monitored
  95179. */
  95180. readonly lastSecAverage: number;
  95181. /**
  95182. * Returns the current value
  95183. */
  95184. readonly current: number;
  95185. /**
  95186. * Gets the accumulated total
  95187. */
  95188. readonly total: number;
  95189. /**
  95190. * Gets the total value count
  95191. */
  95192. readonly count: number;
  95193. /**
  95194. * Creates a new counter
  95195. */
  95196. constructor();
  95197. /**
  95198. * Call this method to start monitoring a new frame.
  95199. * 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.
  95200. */
  95201. fetchNewFrame(): void;
  95202. /**
  95203. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  95204. * @param newCount the count value to add to the monitored count
  95205. * @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.
  95206. */
  95207. addCount(newCount: number, fetchResult: boolean): void;
  95208. /**
  95209. * Start monitoring this performance counter
  95210. */
  95211. beginMonitoring(): void;
  95212. /**
  95213. * Compute the time lapsed since the previous beginMonitoring() call.
  95214. * @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
  95215. */
  95216. endMonitoring(newFrame?: boolean): void;
  95217. private _fetchResult;
  95218. private _startMonitoringTime;
  95219. private _min;
  95220. private _max;
  95221. private _average;
  95222. private _current;
  95223. private _totalValueCount;
  95224. private _totalAccumulated;
  95225. private _lastSecAverage;
  95226. private _lastSecAccumulated;
  95227. private _lastSecTime;
  95228. private _lastSecValueCount;
  95229. }
  95230. }
  95231. declare module BABYLON {
  95232. /**
  95233. * Interface for any object that can request an animation frame
  95234. */
  95235. export interface ICustomAnimationFrameRequester {
  95236. /**
  95237. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  95238. */
  95239. renderFunction?: Function;
  95240. /**
  95241. * Called to request the next frame to render to
  95242. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  95243. */
  95244. requestAnimationFrame: Function;
  95245. /**
  95246. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  95247. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  95248. */
  95249. requestID?: number;
  95250. }
  95251. }
  95252. declare module BABYLON {
  95253. /**
  95254. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  95255. */
  95256. export class PerformanceMonitor {
  95257. private _enabled;
  95258. private _rollingFrameTime;
  95259. private _lastFrameTimeMs;
  95260. /**
  95261. * constructor
  95262. * @param frameSampleSize The number of samples required to saturate the sliding window
  95263. */
  95264. constructor(frameSampleSize?: number);
  95265. /**
  95266. * Samples current frame
  95267. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  95268. */
  95269. sampleFrame(timeMs?: number): void;
  95270. /**
  95271. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  95272. */
  95273. readonly averageFrameTime: number;
  95274. /**
  95275. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  95276. */
  95277. readonly averageFrameTimeVariance: number;
  95278. /**
  95279. * Returns the frame time of the most recent frame
  95280. */
  95281. readonly instantaneousFrameTime: number;
  95282. /**
  95283. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  95284. */
  95285. readonly averageFPS: number;
  95286. /**
  95287. * Returns the average framerate in frames per second using the most recent frame time
  95288. */
  95289. readonly instantaneousFPS: number;
  95290. /**
  95291. * Returns true if enough samples have been taken to completely fill the sliding window
  95292. */
  95293. readonly isSaturated: boolean;
  95294. /**
  95295. * Enables contributions to the sliding window sample set
  95296. */
  95297. enable(): void;
  95298. /**
  95299. * Disables contributions to the sliding window sample set
  95300. * Samples will not be interpolated over the disabled period
  95301. */
  95302. disable(): void;
  95303. /**
  95304. * Returns true if sampling is enabled
  95305. */
  95306. readonly isEnabled: boolean;
  95307. /**
  95308. * Resets performance monitor
  95309. */
  95310. reset(): void;
  95311. }
  95312. /**
  95313. * RollingAverage
  95314. *
  95315. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  95316. */
  95317. export class RollingAverage {
  95318. /**
  95319. * Current average
  95320. */
  95321. average: number;
  95322. /**
  95323. * Current variance
  95324. */
  95325. variance: number;
  95326. protected _samples: Array<number>;
  95327. protected _sampleCount: number;
  95328. protected _pos: number;
  95329. protected _m2: number;
  95330. /**
  95331. * constructor
  95332. * @param length The number of samples required to saturate the sliding window
  95333. */
  95334. constructor(length: number);
  95335. /**
  95336. * Adds a sample to the sample set
  95337. * @param v The sample value
  95338. */
  95339. add(v: number): void;
  95340. /**
  95341. * Returns previously added values or null if outside of history or outside the sliding window domain
  95342. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  95343. * @return Value previously recorded with add() or null if outside of range
  95344. */
  95345. history(i: number): number;
  95346. /**
  95347. * Returns true if enough samples have been taken to completely fill the sliding window
  95348. * @return true if sample-set saturated
  95349. */
  95350. isSaturated(): boolean;
  95351. /**
  95352. * Resets the rolling average (equivalent to 0 samples taken so far)
  95353. */
  95354. reset(): void;
  95355. /**
  95356. * Wraps a value around the sample range boundaries
  95357. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  95358. * @return Wrapped position in sample range
  95359. */
  95360. protected _wrapPosition(i: number): number;
  95361. }
  95362. }
  95363. declare module BABYLON {
  95364. /**
  95365. * Settings for finer control over video usage
  95366. */
  95367. export interface VideoTextureSettings {
  95368. /**
  95369. * Applies `autoplay` to video, if specified
  95370. */
  95371. autoPlay?: boolean;
  95372. /**
  95373. * Applies `loop` to video, if specified
  95374. */
  95375. loop?: boolean;
  95376. /**
  95377. * Automatically updates internal texture from video at every frame in the render loop
  95378. */
  95379. autoUpdateTexture: boolean;
  95380. /**
  95381. * Image src displayed during the video loading or until the user interacts with the video.
  95382. */
  95383. poster?: string;
  95384. }
  95385. /**
  95386. * If you want to display a video in your scene, this is the special texture for that.
  95387. * This special texture works similar to other textures, with the exception of a few parameters.
  95388. * @see https://doc.babylonjs.com/how_to/video_texture
  95389. */
  95390. export class VideoTexture extends Texture {
  95391. /**
  95392. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95393. */
  95394. readonly autoUpdateTexture: boolean;
  95395. /**
  95396. * The video instance used by the texture internally
  95397. */
  95398. readonly video: HTMLVideoElement;
  95399. private _onUserActionRequestedObservable;
  95400. /**
  95401. * Event triggerd when a dom action is required by the user to play the video.
  95402. * This happens due to recent changes in browser policies preventing video to auto start.
  95403. */
  95404. readonly onUserActionRequestedObservable: Observable<Texture>;
  95405. private _generateMipMaps;
  95406. private _engine;
  95407. private _stillImageCaptured;
  95408. private _displayingPosterTexture;
  95409. private _settings;
  95410. private _createInternalTextureOnEvent;
  95411. private _frameId;
  95412. /**
  95413. * Creates a video texture.
  95414. * If you want to display a video in your scene, this is the special texture for that.
  95415. * This special texture works similar to other textures, with the exception of a few parameters.
  95416. * @see https://doc.babylonjs.com/how_to/video_texture
  95417. * @param name optional name, will detect from video source, if not defined
  95418. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95419. * @param scene is obviously the current scene.
  95420. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95421. * @param invertY is false by default but can be used to invert video on Y axis
  95422. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95423. * @param settings allows finer control over video usage
  95424. */
  95425. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95426. private _getName;
  95427. private _getVideo;
  95428. private _createInternalTexture;
  95429. private reset;
  95430. /**
  95431. * @hidden Internal method to initiate `update`.
  95432. */
  95433. _rebuild(): void;
  95434. /**
  95435. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95436. */
  95437. update(): void;
  95438. /**
  95439. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95440. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95441. */
  95442. updateTexture(isVisible: boolean): void;
  95443. protected _updateInternalTexture: () => void;
  95444. /**
  95445. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95446. * @param url New url.
  95447. */
  95448. updateURL(url: string): void;
  95449. /**
  95450. * Dispose the texture and release its associated resources.
  95451. */
  95452. dispose(): void;
  95453. /**
  95454. * Creates a video texture straight from a stream.
  95455. * @param scene Define the scene the texture should be created in
  95456. * @param stream Define the stream the texture should be created from
  95457. * @returns The created video texture as a promise
  95458. */
  95459. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95460. /**
  95461. * Creates a video texture straight from your WebCam video feed.
  95462. * @param scene Define the scene the texture should be created in
  95463. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95464. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95465. * @returns The created video texture as a promise
  95466. */
  95467. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95468. minWidth: number;
  95469. maxWidth: number;
  95470. minHeight: number;
  95471. maxHeight: number;
  95472. deviceId: string;
  95473. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95474. /**
  95475. * Creates a video texture straight from your WebCam video feed.
  95476. * @param scene Define the scene the texture should be created in
  95477. * @param onReady Define a callback to triggered once the texture will be ready
  95478. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95479. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95480. */
  95481. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95482. minWidth: number;
  95483. maxWidth: number;
  95484. minHeight: number;
  95485. maxHeight: number;
  95486. deviceId: string;
  95487. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95488. }
  95489. }
  95490. declare module BABYLON {
  95491. /**
  95492. * Defines the interface used by objects containing a viewport (like a camera)
  95493. */
  95494. interface IViewportOwnerLike {
  95495. /**
  95496. * Gets or sets the viewport
  95497. */
  95498. viewport: IViewportLike;
  95499. }
  95500. /**
  95501. * Interface for attribute information associated with buffer instanciation
  95502. */
  95503. export class InstancingAttributeInfo {
  95504. /**
  95505. * Index/offset of the attribute in the vertex shader
  95506. */
  95507. index: number;
  95508. /**
  95509. * size of the attribute, 1, 2, 3 or 4
  95510. */
  95511. attributeSize: number;
  95512. /**
  95513. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95514. * default is FLOAT
  95515. */
  95516. attribyteType: number;
  95517. /**
  95518. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95519. */
  95520. normalized: boolean;
  95521. /**
  95522. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95523. */
  95524. offset: number;
  95525. /**
  95526. * Name of the GLSL attribute, for debugging purpose only
  95527. */
  95528. attributeName: string;
  95529. }
  95530. /**
  95531. * Define options used to create a depth texture
  95532. */
  95533. export class DepthTextureCreationOptions {
  95534. /** Specifies whether or not a stencil should be allocated in the texture */
  95535. generateStencil?: boolean;
  95536. /** Specifies whether or not bilinear filtering is enable on the texture */
  95537. bilinearFiltering?: boolean;
  95538. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  95539. comparisonFunction?: number;
  95540. /** Specifies if the created texture is a cube texture */
  95541. isCube?: boolean;
  95542. }
  95543. /**
  95544. * Class used to describe the capabilities of the engine relatively to the current browser
  95545. */
  95546. export class EngineCapabilities {
  95547. /** Maximum textures units per fragment shader */
  95548. maxTexturesImageUnits: number;
  95549. /** Maximum texture units per vertex shader */
  95550. maxVertexTextureImageUnits: number;
  95551. /** Maximum textures units in the entire pipeline */
  95552. maxCombinedTexturesImageUnits: number;
  95553. /** Maximum texture size */
  95554. maxTextureSize: number;
  95555. /** Maximum cube texture size */
  95556. maxCubemapTextureSize: number;
  95557. /** Maximum render texture size */
  95558. maxRenderTextureSize: number;
  95559. /** Maximum number of vertex attributes */
  95560. maxVertexAttribs: number;
  95561. /** Maximum number of varyings */
  95562. maxVaryingVectors: number;
  95563. /** Maximum number of uniforms per vertex shader */
  95564. maxVertexUniformVectors: number;
  95565. /** Maximum number of uniforms per fragment shader */
  95566. maxFragmentUniformVectors: number;
  95567. /** Defines if standard derivates (dx/dy) are supported */
  95568. standardDerivatives: boolean;
  95569. /** Defines if s3tc texture compression is supported */
  95570. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95571. /** Defines if pvrtc texture compression is supported */
  95572. pvrtc: any;
  95573. /** Defines if etc1 texture compression is supported */
  95574. etc1: any;
  95575. /** Defines if etc2 texture compression is supported */
  95576. etc2: any;
  95577. /** Defines if astc texture compression is supported */
  95578. astc: any;
  95579. /** Defines if float textures are supported */
  95580. textureFloat: boolean;
  95581. /** Defines if vertex array objects are supported */
  95582. vertexArrayObject: boolean;
  95583. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95584. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95585. /** Gets the maximum level of anisotropy supported */
  95586. maxAnisotropy: number;
  95587. /** Defines if instancing is supported */
  95588. instancedArrays: boolean;
  95589. /** Defines if 32 bits indices are supported */
  95590. uintIndices: boolean;
  95591. /** Defines if high precision shaders are supported */
  95592. highPrecisionShaderSupported: boolean;
  95593. /** Defines if depth reading in the fragment shader is supported */
  95594. fragmentDepthSupported: boolean;
  95595. /** Defines if float texture linear filtering is supported*/
  95596. textureFloatLinearFiltering: boolean;
  95597. /** Defines if rendering to float textures is supported */
  95598. textureFloatRender: boolean;
  95599. /** Defines if half float textures are supported*/
  95600. textureHalfFloat: boolean;
  95601. /** Defines if half float texture linear filtering is supported*/
  95602. textureHalfFloatLinearFiltering: boolean;
  95603. /** Defines if rendering to half float textures is supported */
  95604. textureHalfFloatRender: boolean;
  95605. /** Defines if textureLOD shader command is supported */
  95606. textureLOD: boolean;
  95607. /** Defines if draw buffers extension is supported */
  95608. drawBuffersExtension: boolean;
  95609. /** Defines if depth textures are supported */
  95610. depthTextureExtension: boolean;
  95611. /** Defines if float color buffer are supported */
  95612. colorBufferFloat: boolean;
  95613. /** Gets disjoint timer query extension (null if not supported) */
  95614. timerQuery: EXT_disjoint_timer_query;
  95615. /** Defines if timestamp can be used with timer query */
  95616. canUseTimestampForTimerQuery: boolean;
  95617. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95618. multiview: any;
  95619. /** Function used to let the system compiles shaders in background */
  95620. parallelShaderCompile: {
  95621. COMPLETION_STATUS_KHR: number;
  95622. };
  95623. /** Max number of texture samples for MSAA */
  95624. maxMSAASamples: number;
  95625. /** Defines if the blend min max extension is supported */
  95626. blendMinMax: boolean;
  95627. }
  95628. /** Interface defining initialization parameters for Engine class */
  95629. export interface EngineOptions extends WebGLContextAttributes {
  95630. /**
  95631. * Defines if the engine should no exceed a specified device ratio
  95632. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95633. */
  95634. limitDeviceRatio?: number;
  95635. /**
  95636. * Defines if webvr should be enabled automatically
  95637. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95638. */
  95639. autoEnableWebVR?: boolean;
  95640. /**
  95641. * Defines if webgl2 should be turned off even if supported
  95642. * @see http://doc.babylonjs.com/features/webgl2
  95643. */
  95644. disableWebGL2Support?: boolean;
  95645. /**
  95646. * Defines if webaudio should be initialized as well
  95647. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95648. */
  95649. audioEngine?: boolean;
  95650. /**
  95651. * Defines if animations should run using a deterministic lock step
  95652. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95653. */
  95654. deterministicLockstep?: boolean;
  95655. /** Defines the maximum steps to use with deterministic lock step mode */
  95656. lockstepMaxSteps?: number;
  95657. /**
  95658. * Defines that engine should ignore context lost events
  95659. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95660. */
  95661. doNotHandleContextLost?: boolean;
  95662. /**
  95663. * Defines that engine should ignore modifying touch action attribute and style
  95664. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95665. */
  95666. doNotHandleTouchAction?: boolean;
  95667. /**
  95668. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95669. */
  95670. useHighPrecisionFloats?: boolean;
  95671. }
  95672. /**
  95673. * Defines the interface used by display changed events
  95674. */
  95675. export interface IDisplayChangedEventArgs {
  95676. /** Gets the vrDisplay object (if any) */
  95677. vrDisplay: Nullable<any>;
  95678. /** Gets a boolean indicating if webVR is supported */
  95679. vrSupported: boolean;
  95680. }
  95681. /**
  95682. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  95683. */
  95684. export class Engine {
  95685. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95686. static ExceptionList: ({
  95687. key: string;
  95688. capture: string;
  95689. captureConstraint: number;
  95690. targets: string[];
  95691. } | {
  95692. key: string;
  95693. capture: null;
  95694. captureConstraint: null;
  95695. targets: string[];
  95696. })[];
  95697. /** Gets the list of created engines */
  95698. static readonly Instances: Engine[];
  95699. /**
  95700. * Gets the latest created engine
  95701. */
  95702. static readonly LastCreatedEngine: Nullable<Engine>;
  95703. /**
  95704. * Gets the latest created scene
  95705. */
  95706. static readonly LastCreatedScene: Nullable<Scene>;
  95707. /**
  95708. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  95709. * @param flag defines which part of the materials must be marked as dirty
  95710. * @param predicate defines a predicate used to filter which materials should be affected
  95711. */
  95712. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  95713. /** Defines that alpha blending is disabled */
  95714. static readonly ALPHA_DISABLE: number;
  95715. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  95716. static readonly ALPHA_ADD: number;
  95717. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  95718. static readonly ALPHA_COMBINE: number;
  95719. /** Defines that alpha blending to DEST - SRC * DEST */
  95720. static readonly ALPHA_SUBTRACT: number;
  95721. /** Defines that alpha blending to SRC * DEST */
  95722. static readonly ALPHA_MULTIPLY: number;
  95723. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  95724. static readonly ALPHA_MAXIMIZED: number;
  95725. /** Defines that alpha blending to SRC + DEST */
  95726. static readonly ALPHA_ONEONE: number;
  95727. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  95728. static readonly ALPHA_PREMULTIPLIED: number;
  95729. /**
  95730. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  95731. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  95732. */
  95733. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  95734. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  95735. static readonly ALPHA_INTERPOLATE: number;
  95736. /**
  95737. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  95738. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  95739. */
  95740. static readonly ALPHA_SCREENMODE: number;
  95741. /** Defines that the ressource is not delayed*/
  95742. static readonly DELAYLOADSTATE_NONE: number;
  95743. /** Defines that the ressource was successfully delay loaded */
  95744. static readonly DELAYLOADSTATE_LOADED: number;
  95745. /** Defines that the ressource is currently delay loading */
  95746. static readonly DELAYLOADSTATE_LOADING: number;
  95747. /** Defines that the ressource is delayed and has not started loading */
  95748. static readonly DELAYLOADSTATE_NOTLOADED: number;
  95749. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  95750. static readonly NEVER: number;
  95751. /** 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 */
  95752. static readonly ALWAYS: number;
  95753. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  95754. static readonly LESS: number;
  95755. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  95756. static readonly EQUAL: number;
  95757. /** 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 */
  95758. static readonly LEQUAL: number;
  95759. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  95760. static readonly GREATER: number;
  95761. /** 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 */
  95762. static readonly GEQUAL: number;
  95763. /** 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 */
  95764. static readonly NOTEQUAL: number;
  95765. /** Passed to stencilOperation to specify that stencil value must be kept */
  95766. static readonly KEEP: number;
  95767. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95768. static readonly REPLACE: number;
  95769. /** Passed to stencilOperation to specify that stencil value must be incremented */
  95770. static readonly INCR: number;
  95771. /** Passed to stencilOperation to specify that stencil value must be decremented */
  95772. static readonly DECR: number;
  95773. /** Passed to stencilOperation to specify that stencil value must be inverted */
  95774. static readonly INVERT: number;
  95775. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  95776. static readonly INCR_WRAP: number;
  95777. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  95778. static readonly DECR_WRAP: number;
  95779. /** Texture is not repeating outside of 0..1 UVs */
  95780. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  95781. /** Texture is repeating outside of 0..1 UVs */
  95782. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  95783. /** Texture is repeating and mirrored */
  95784. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  95785. /** ALPHA */
  95786. static readonly TEXTUREFORMAT_ALPHA: number;
  95787. /** LUMINANCE */
  95788. static readonly TEXTUREFORMAT_LUMINANCE: number;
  95789. /** LUMINANCE_ALPHA */
  95790. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  95791. /** RGB */
  95792. static readonly TEXTUREFORMAT_RGB: number;
  95793. /** RGBA */
  95794. static readonly TEXTUREFORMAT_RGBA: number;
  95795. /** RED */
  95796. static readonly TEXTUREFORMAT_RED: number;
  95797. /** RED (2nd reference) */
  95798. static readonly TEXTUREFORMAT_R: number;
  95799. /** RG */
  95800. static readonly TEXTUREFORMAT_RG: number;
  95801. /** RED_INTEGER */
  95802. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  95803. /** RED_INTEGER (2nd reference) */
  95804. static readonly TEXTUREFORMAT_R_INTEGER: number;
  95805. /** RG_INTEGER */
  95806. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  95807. /** RGB_INTEGER */
  95808. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  95809. /** RGBA_INTEGER */
  95810. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  95811. /** UNSIGNED_BYTE */
  95812. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  95813. /** UNSIGNED_BYTE (2nd reference) */
  95814. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  95815. /** FLOAT */
  95816. static readonly TEXTURETYPE_FLOAT: number;
  95817. /** HALF_FLOAT */
  95818. static readonly TEXTURETYPE_HALF_FLOAT: number;
  95819. /** BYTE */
  95820. static readonly TEXTURETYPE_BYTE: number;
  95821. /** SHORT */
  95822. static readonly TEXTURETYPE_SHORT: number;
  95823. /** UNSIGNED_SHORT */
  95824. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  95825. /** INT */
  95826. static readonly TEXTURETYPE_INT: number;
  95827. /** UNSIGNED_INT */
  95828. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  95829. /** UNSIGNED_SHORT_4_4_4_4 */
  95830. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  95831. /** UNSIGNED_SHORT_5_5_5_1 */
  95832. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  95833. /** UNSIGNED_SHORT_5_6_5 */
  95834. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  95835. /** UNSIGNED_INT_2_10_10_10_REV */
  95836. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  95837. /** UNSIGNED_INT_24_8 */
  95838. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  95839. /** UNSIGNED_INT_10F_11F_11F_REV */
  95840. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  95841. /** UNSIGNED_INT_5_9_9_9_REV */
  95842. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  95843. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  95844. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  95845. /** nearest is mag = nearest and min = nearest and mip = linear */
  95846. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  95847. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95848. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  95849. /** Trilinear is mag = linear and min = linear and mip = linear */
  95850. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  95851. /** nearest is mag = nearest and min = nearest and mip = linear */
  95852. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  95853. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95854. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  95855. /** Trilinear is mag = linear and min = linear and mip = linear */
  95856. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  95857. /** mag = nearest and min = nearest and mip = nearest */
  95858. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  95859. /** mag = nearest and min = linear and mip = nearest */
  95860. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  95861. /** mag = nearest and min = linear and mip = linear */
  95862. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  95863. /** mag = nearest and min = linear and mip = none */
  95864. static readonly TEXTURE_NEAREST_LINEAR: number;
  95865. /** mag = nearest and min = nearest and mip = none */
  95866. static readonly TEXTURE_NEAREST_NEAREST: number;
  95867. /** mag = linear and min = nearest and mip = nearest */
  95868. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  95869. /** mag = linear and min = nearest and mip = linear */
  95870. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  95871. /** mag = linear and min = linear and mip = none */
  95872. static readonly TEXTURE_LINEAR_LINEAR: number;
  95873. /** mag = linear and min = nearest and mip = none */
  95874. static readonly TEXTURE_LINEAR_NEAREST: number;
  95875. /** Explicit coordinates mode */
  95876. static readonly TEXTURE_EXPLICIT_MODE: number;
  95877. /** Spherical coordinates mode */
  95878. static readonly TEXTURE_SPHERICAL_MODE: number;
  95879. /** Planar coordinates mode */
  95880. static readonly TEXTURE_PLANAR_MODE: number;
  95881. /** Cubic coordinates mode */
  95882. static readonly TEXTURE_CUBIC_MODE: number;
  95883. /** Projection coordinates mode */
  95884. static readonly TEXTURE_PROJECTION_MODE: number;
  95885. /** Skybox coordinates mode */
  95886. static readonly TEXTURE_SKYBOX_MODE: number;
  95887. /** Inverse Cubic coordinates mode */
  95888. static readonly TEXTURE_INVCUBIC_MODE: number;
  95889. /** Equirectangular coordinates mode */
  95890. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  95891. /** Equirectangular Fixed coordinates mode */
  95892. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  95893. /** Equirectangular Fixed Mirrored coordinates mode */
  95894. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  95895. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  95896. static readonly SCALEMODE_FLOOR: number;
  95897. /** Defines that texture rescaling will look for the nearest power of 2 size */
  95898. static readonly SCALEMODE_NEAREST: number;
  95899. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  95900. static readonly SCALEMODE_CEILING: number;
  95901. /** @hidden */
  95902. static _TextureLoaders: IInternalTextureLoader[];
  95903. /**
  95904. * Returns the current npm package of the sdk
  95905. */
  95906. static readonly NpmPackage: string;
  95907. /**
  95908. * Returns the current version of the framework
  95909. */
  95910. static readonly Version: string;
  95911. /**
  95912. * Returns a string describing the current engine
  95913. */
  95914. readonly description: string;
  95915. /**
  95916. * Gets or sets the epsilon value used by collision engine
  95917. */
  95918. static CollisionsEpsilon: number;
  95919. /**
  95920. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95921. */
  95922. static ShadersRepository: string;
  95923. /**
  95924. * Method called to create the default loading screen.
  95925. * This can be overriden in your own app.
  95926. * @param canvas The rendering canvas element
  95927. * @returns The loading screen
  95928. */
  95929. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  95930. /**
  95931. * Method called to create the default rescale post process on each engine.
  95932. */
  95933. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  95934. /** @hidden */
  95935. _shaderProcessor: IShaderProcessor;
  95936. /**
  95937. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95938. */
  95939. forcePOTTextures: boolean;
  95940. /**
  95941. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95942. */
  95943. isFullscreen: boolean;
  95944. /**
  95945. * Gets a boolean indicating if the pointer is currently locked
  95946. */
  95947. isPointerLock: boolean;
  95948. /**
  95949. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95950. */
  95951. cullBackFaces: boolean;
  95952. /**
  95953. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95954. */
  95955. renderEvenInBackground: boolean;
  95956. /**
  95957. * Gets or sets a boolean indicating that cache can be kept between frames
  95958. */
  95959. preventCacheWipeBetweenFrames: boolean;
  95960. /**
  95961. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  95962. **/
  95963. enableOfflineSupport: boolean;
  95964. /**
  95965. * 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)
  95966. **/
  95967. disableManifestCheck: boolean;
  95968. /**
  95969. * Gets the list of created scenes
  95970. */
  95971. scenes: Scene[];
  95972. /**
  95973. * Event raised when a new scene is created
  95974. */
  95975. onNewSceneAddedObservable: Observable<Scene>;
  95976. /**
  95977. * Gets the list of created postprocesses
  95978. */
  95979. postProcesses: PostProcess[];
  95980. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95981. validateShaderPrograms: boolean;
  95982. /**
  95983. * Observable event triggered each time the rendering canvas is resized
  95984. */
  95985. onResizeObservable: Observable<Engine>;
  95986. /**
  95987. * Observable event triggered each time the canvas loses focus
  95988. */
  95989. onCanvasBlurObservable: Observable<Engine>;
  95990. /**
  95991. * Observable event triggered each time the canvas gains focus
  95992. */
  95993. onCanvasFocusObservable: Observable<Engine>;
  95994. /**
  95995. * Observable event triggered each time the canvas receives pointerout event
  95996. */
  95997. onCanvasPointerOutObservable: Observable<PointerEvent>;
  95998. /**
  95999. * Observable event triggered before each texture is initialized
  96000. */
  96001. onBeforeTextureInitObservable: Observable<Texture>;
  96002. /**
  96003. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  96004. */
  96005. disableUniformBuffers: boolean;
  96006. /** @hidden */
  96007. _uniformBuffers: UniformBuffer[];
  96008. /**
  96009. * Gets a boolean indicating that the engine supports uniform buffers
  96010. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96011. */
  96012. readonly supportsUniformBuffers: boolean;
  96013. /**
  96014. * Observable raised when the engine begins a new frame
  96015. */
  96016. onBeginFrameObservable: Observable<Engine>;
  96017. /**
  96018. * If set, will be used to request the next animation frame for the render loop
  96019. */
  96020. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  96021. /**
  96022. * Observable raised when the engine ends the current frame
  96023. */
  96024. onEndFrameObservable: Observable<Engine>;
  96025. /**
  96026. * Observable raised when the engine is about to compile a shader
  96027. */
  96028. onBeforeShaderCompilationObservable: Observable<Engine>;
  96029. /**
  96030. * Observable raised when the engine has jsut compiled a shader
  96031. */
  96032. onAfterShaderCompilationObservable: Observable<Engine>;
  96033. /** @hidden */
  96034. _gl: WebGLRenderingContext;
  96035. private _renderingCanvas;
  96036. private _windowIsBackground;
  96037. protected _webGLVersion: number;
  96038. protected _highPrecisionShadersAllowed: boolean;
  96039. /** @hidden */
  96040. readonly _shouldUseHighPrecisionShader: boolean;
  96041. /**
  96042. * Gets a boolean indicating that only power of 2 textures are supported
  96043. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96044. */
  96045. readonly needPOTTextures: boolean;
  96046. /** @hidden */
  96047. _badOS: boolean;
  96048. /** @hidden */
  96049. _badDesktopOS: boolean;
  96050. /**
  96051. * Gets the audio engine
  96052. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96053. * @ignorenaming
  96054. */
  96055. static audioEngine: IAudioEngine;
  96056. /**
  96057. * Default AudioEngine factory responsible of creating the Audio Engine.
  96058. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  96059. */
  96060. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  96061. /**
  96062. * Default offline support factory responsible of creating a tool used to store data locally.
  96063. * By default, this will create a Database object if the workload has been embedded.
  96064. */
  96065. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  96066. private _onFocus;
  96067. private _onBlur;
  96068. private _onCanvasPointerOut;
  96069. private _onCanvasBlur;
  96070. private _onCanvasFocus;
  96071. private _onFullscreenChange;
  96072. private _onPointerLockChange;
  96073. private _hardwareScalingLevel;
  96074. /** @hidden */
  96075. _caps: EngineCapabilities;
  96076. private _pointerLockRequested;
  96077. private _isStencilEnable;
  96078. protected _colorWrite: boolean;
  96079. private _loadingScreen;
  96080. /** @hidden */
  96081. _drawCalls: PerfCounter;
  96082. private _glVersion;
  96083. private _glRenderer;
  96084. private _glVendor;
  96085. private _videoTextureSupported;
  96086. private _renderingQueueLaunched;
  96087. private _activeRenderLoops;
  96088. private _deterministicLockstep;
  96089. private _lockstepMaxSteps;
  96090. /**
  96091. * Observable signaled when a context lost event is raised
  96092. */
  96093. onContextLostObservable: Observable<Engine>;
  96094. /**
  96095. * Observable signaled when a context restored event is raised
  96096. */
  96097. onContextRestoredObservable: Observable<Engine>;
  96098. private _onContextLost;
  96099. private _onContextRestored;
  96100. private _contextWasLost;
  96101. /** @hidden */
  96102. _doNotHandleContextLost: boolean;
  96103. /**
  96104. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  96105. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  96106. */
  96107. doNotHandleContextLost: boolean;
  96108. private _fps;
  96109. private _deltaTime;
  96110. /**
  96111. * Turn this value on if you want to pause FPS computation when in background
  96112. */
  96113. disablePerformanceMonitorInBackground: boolean;
  96114. private _performanceMonitor;
  96115. /**
  96116. * Gets the performance monitor attached to this engine
  96117. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  96118. */
  96119. readonly performanceMonitor: PerformanceMonitor;
  96120. /**
  96121. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  96122. */
  96123. disableVertexArrayObjects: boolean;
  96124. /** @hidden */
  96125. protected _depthCullingState: _DepthCullingState;
  96126. /** @hidden */
  96127. protected _stencilState: _StencilState;
  96128. /** @hidden */
  96129. protected _alphaState: _AlphaState;
  96130. /** @hidden */
  96131. protected _alphaMode: number;
  96132. /** @hidden */
  96133. protected _alphaEquation: number;
  96134. /** @hidden */
  96135. _internalTexturesCache: InternalTexture[];
  96136. /** @hidden */
  96137. protected _activeChannel: number;
  96138. private _currentTextureChannel;
  96139. /** @hidden */
  96140. protected _boundTexturesCache: {
  96141. [key: string]: Nullable<InternalTexture>;
  96142. };
  96143. /** @hidden */
  96144. protected _currentEffect: Nullable<Effect>;
  96145. /** @hidden */
  96146. protected _currentProgram: Nullable<WebGLProgram>;
  96147. private _compiledEffects;
  96148. private _vertexAttribArraysEnabled;
  96149. /** @hidden */
  96150. protected _cachedViewport: Nullable<IViewportLike>;
  96151. private _cachedVertexArrayObject;
  96152. /** @hidden */
  96153. protected _cachedVertexBuffers: any;
  96154. /** @hidden */
  96155. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96156. /** @hidden */
  96157. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96158. /** @hidden */
  96159. _currentRenderTarget: Nullable<InternalTexture>;
  96160. private _uintIndicesCurrentlySet;
  96161. private _currentBoundBuffer;
  96162. /** @hidden */
  96163. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96164. private _currentBufferPointers;
  96165. private _currentInstanceLocations;
  96166. private _currentInstanceBuffers;
  96167. private _textureUnits;
  96168. /** @hidden */
  96169. _workingCanvas: Nullable<HTMLCanvasElement>;
  96170. /** @hidden */
  96171. _workingContext: Nullable<CanvasRenderingContext2D>;
  96172. private _rescalePostProcess;
  96173. private _dummyFramebuffer;
  96174. /** @hidden */
  96175. _bindedRenderFunction: any;
  96176. private _vaoRecordInProgress;
  96177. private _mustWipeVertexAttributes;
  96178. private _emptyTexture;
  96179. private _emptyCubeTexture;
  96180. private _emptyTexture3D;
  96181. /** @hidden */
  96182. _frameHandler: number;
  96183. private _nextFreeTextureSlots;
  96184. private _maxSimultaneousTextures;
  96185. private _activeRequests;
  96186. private _texturesSupported;
  96187. /** @hidden */
  96188. _textureFormatInUse: Nullable<string>;
  96189. /**
  96190. * Gets the list of texture formats supported
  96191. */
  96192. readonly texturesSupported: Array<string>;
  96193. /**
  96194. * Gets the list of texture formats in use
  96195. */
  96196. readonly textureFormatInUse: Nullable<string>;
  96197. /**
  96198. * Gets the current viewport
  96199. */
  96200. readonly currentViewport: Nullable<IViewportLike>;
  96201. /**
  96202. * Gets the default empty texture
  96203. */
  96204. readonly emptyTexture: InternalTexture;
  96205. /**
  96206. * Gets the default empty 3D texture
  96207. */
  96208. readonly emptyTexture3D: InternalTexture;
  96209. /**
  96210. * Gets the default empty cube texture
  96211. */
  96212. readonly emptyCubeTexture: InternalTexture;
  96213. /**
  96214. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96215. */
  96216. readonly premultipliedAlpha: boolean;
  96217. /**
  96218. * Creates a new engine
  96219. * @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
  96220. * @param antialias defines enable antialiasing (default: false)
  96221. * @param options defines further options to be sent to the getContext() function
  96222. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96223. */
  96224. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96225. /**
  96226. * Initializes a webVR display and starts listening to display change events
  96227. * The onVRDisplayChangedObservable will be notified upon these changes
  96228. * @returns The onVRDisplayChangedObservable
  96229. */
  96230. initWebVR(): Observable<IDisplayChangedEventArgs>;
  96231. /** @hidden */
  96232. _prepareVRComponent(): void;
  96233. /** @hidden */
  96234. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  96235. /** @hidden */
  96236. _submitVRFrame(): void;
  96237. /**
  96238. * Call this function to leave webVR mode
  96239. * Will do nothing if webVR is not supported or if there is no webVR device
  96240. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96241. */
  96242. disableVR(): void;
  96243. /**
  96244. * Gets a boolean indicating that the system is in VR mode and is presenting
  96245. * @returns true if VR mode is engaged
  96246. */
  96247. isVRPresenting(): boolean;
  96248. /** @hidden */
  96249. _requestVRFrame(): void;
  96250. private _disableTouchAction;
  96251. private _rebuildInternalTextures;
  96252. private _rebuildEffects;
  96253. /**
  96254. * Gets a boolean indicating if all created effects are ready
  96255. * @returns true if all effects are ready
  96256. */
  96257. areAllEffectsReady(): boolean;
  96258. private _rebuildBuffers;
  96259. private _initGLContext;
  96260. /**
  96261. * Gets version of the current webGL context
  96262. */
  96263. readonly webGLVersion: number;
  96264. /**
  96265. * Gets a string idenfifying the name of the class
  96266. * @returns "Engine" string
  96267. */
  96268. getClassName(): string;
  96269. /**
  96270. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96271. */
  96272. readonly isStencilEnable: boolean;
  96273. /** @hidden */
  96274. _prepareWorkingCanvas(): void;
  96275. /**
  96276. * Reset the texture cache to empty state
  96277. */
  96278. resetTextureCache(): void;
  96279. /**
  96280. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  96281. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96282. * @returns true if engine is in deterministic lock step mode
  96283. */
  96284. isDeterministicLockStep(): boolean;
  96285. /**
  96286. * Gets the max steps when engine is running in deterministic lock step
  96287. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96288. * @returns the max steps
  96289. */
  96290. getLockstepMaxSteps(): number;
  96291. /**
  96292. * Gets an object containing information about the current webGL context
  96293. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96294. */
  96295. getGlInfo(): {
  96296. vendor: string;
  96297. renderer: string;
  96298. version: string;
  96299. };
  96300. /**
  96301. * Gets current aspect ratio
  96302. * @param viewportOwner defines the camera to use to get the aspect ratio
  96303. * @param useScreen defines if screen size must be used (or the current render target if any)
  96304. * @returns a number defining the aspect ratio
  96305. */
  96306. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  96307. /**
  96308. * Gets current screen aspect ratio
  96309. * @returns a number defining the aspect ratio
  96310. */
  96311. getScreenAspectRatio(): number;
  96312. /**
  96313. * Gets the current render width
  96314. * @param useScreen defines if screen size must be used (or the current render target if any)
  96315. * @returns a number defining the current render width
  96316. */
  96317. getRenderWidth(useScreen?: boolean): number;
  96318. /**
  96319. * Gets the current render height
  96320. * @param useScreen defines if screen size must be used (or the current render target if any)
  96321. * @returns a number defining the current render height
  96322. */
  96323. getRenderHeight(useScreen?: boolean): number;
  96324. /**
  96325. * Gets the HTML canvas attached with the current webGL context
  96326. * @returns a HTML canvas
  96327. */
  96328. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96329. /**
  96330. * Gets host window
  96331. * @returns the host window object
  96332. */
  96333. getHostWindow(): Window;
  96334. /**
  96335. * Gets host document
  96336. * @returns the host document object
  96337. */
  96338. getHostDocument(): Document;
  96339. /**
  96340. * Gets the client rect of the HTML canvas attached with the current webGL context
  96341. * @returns a client rectanglee
  96342. */
  96343. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  96344. /**
  96345. * Defines the hardware scaling level.
  96346. * By default the hardware scaling level is computed from the window device ratio.
  96347. * 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.
  96348. * @param level defines the level to use
  96349. */
  96350. setHardwareScalingLevel(level: number): void;
  96351. /**
  96352. * Gets the current hardware scaling level.
  96353. * By default the hardware scaling level is computed from the window device ratio.
  96354. * 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.
  96355. * @returns a number indicating the current hardware scaling level
  96356. */
  96357. getHardwareScalingLevel(): number;
  96358. /**
  96359. * Gets the list of loaded textures
  96360. * @returns an array containing all loaded textures
  96361. */
  96362. getLoadedTexturesCache(): InternalTexture[];
  96363. /**
  96364. * Gets the object containing all engine capabilities
  96365. * @returns the EngineCapabilities object
  96366. */
  96367. getCaps(): EngineCapabilities;
  96368. /**
  96369. * Gets the current depth function
  96370. * @returns a number defining the depth function
  96371. */
  96372. getDepthFunction(): Nullable<number>;
  96373. /**
  96374. * Sets the current depth function
  96375. * @param depthFunc defines the function to use
  96376. */
  96377. setDepthFunction(depthFunc: number): void;
  96378. /**
  96379. * Sets the current depth function to GREATER
  96380. */
  96381. setDepthFunctionToGreater(): void;
  96382. /**
  96383. * Sets the current depth function to GEQUAL
  96384. */
  96385. setDepthFunctionToGreaterOrEqual(): void;
  96386. /**
  96387. * Sets the current depth function to LESS
  96388. */
  96389. setDepthFunctionToLess(): void;
  96390. private _cachedStencilBuffer;
  96391. private _cachedStencilFunction;
  96392. private _cachedStencilMask;
  96393. private _cachedStencilOperationPass;
  96394. private _cachedStencilOperationFail;
  96395. private _cachedStencilOperationDepthFail;
  96396. private _cachedStencilReference;
  96397. /**
  96398. * Caches the the state of the stencil buffer
  96399. */
  96400. cacheStencilState(): void;
  96401. /**
  96402. * Restores the state of the stencil buffer
  96403. */
  96404. restoreStencilState(): void;
  96405. /**
  96406. * Sets the current depth function to LEQUAL
  96407. */
  96408. setDepthFunctionToLessOrEqual(): void;
  96409. /**
  96410. * Gets a boolean indicating if stencil buffer is enabled
  96411. * @returns the current stencil buffer state
  96412. */
  96413. getStencilBuffer(): boolean;
  96414. /**
  96415. * Enable or disable the stencil buffer
  96416. * @param enable defines if the stencil buffer must be enabled or disabled
  96417. */
  96418. setStencilBuffer(enable: boolean): void;
  96419. /**
  96420. * Gets the current stencil mask
  96421. * @returns a number defining the new stencil mask to use
  96422. */
  96423. getStencilMask(): number;
  96424. /**
  96425. * Sets the current stencil mask
  96426. * @param mask defines the new stencil mask to use
  96427. */
  96428. setStencilMask(mask: number): void;
  96429. /**
  96430. * Gets the current stencil function
  96431. * @returns a number defining the stencil function to use
  96432. */
  96433. getStencilFunction(): number;
  96434. /**
  96435. * Gets the current stencil reference value
  96436. * @returns a number defining the stencil reference value to use
  96437. */
  96438. getStencilFunctionReference(): number;
  96439. /**
  96440. * Gets the current stencil mask
  96441. * @returns a number defining the stencil mask to use
  96442. */
  96443. getStencilFunctionMask(): number;
  96444. /**
  96445. * Sets the current stencil function
  96446. * @param stencilFunc defines the new stencil function to use
  96447. */
  96448. setStencilFunction(stencilFunc: number): void;
  96449. /**
  96450. * Sets the current stencil reference
  96451. * @param reference defines the new stencil reference to use
  96452. */
  96453. setStencilFunctionReference(reference: number): void;
  96454. /**
  96455. * Sets the current stencil mask
  96456. * @param mask defines the new stencil mask to use
  96457. */
  96458. setStencilFunctionMask(mask: number): void;
  96459. /**
  96460. * Gets the current stencil operation when stencil fails
  96461. * @returns a number defining stencil operation to use when stencil fails
  96462. */
  96463. getStencilOperationFail(): number;
  96464. /**
  96465. * Gets the current stencil operation when depth fails
  96466. * @returns a number defining stencil operation to use when depth fails
  96467. */
  96468. getStencilOperationDepthFail(): number;
  96469. /**
  96470. * Gets the current stencil operation when stencil passes
  96471. * @returns a number defining stencil operation to use when stencil passes
  96472. */
  96473. getStencilOperationPass(): number;
  96474. /**
  96475. * Sets the stencil operation to use when stencil fails
  96476. * @param operation defines the stencil operation to use when stencil fails
  96477. */
  96478. setStencilOperationFail(operation: number): void;
  96479. /**
  96480. * Sets the stencil operation to use when depth fails
  96481. * @param operation defines the stencil operation to use when depth fails
  96482. */
  96483. setStencilOperationDepthFail(operation: number): void;
  96484. /**
  96485. * Sets the stencil operation to use when stencil passes
  96486. * @param operation defines the stencil operation to use when stencil passes
  96487. */
  96488. setStencilOperationPass(operation: number): void;
  96489. /**
  96490. * Sets a boolean indicating if the dithering state is enabled or disabled
  96491. * @param value defines the dithering state
  96492. */
  96493. setDitheringState(value: boolean): void;
  96494. /**
  96495. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  96496. * @param value defines the rasterizer state
  96497. */
  96498. setRasterizerState(value: boolean): void;
  96499. /**
  96500. * stop executing a render loop function and remove it from the execution array
  96501. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96502. */
  96503. stopRenderLoop(renderFunction?: () => void): void;
  96504. /** @hidden */
  96505. _renderLoop(): void;
  96506. /**
  96507. * Can be used to override the current requestAnimationFrame requester.
  96508. * @hidden
  96509. */
  96510. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96511. /**
  96512. * Register and execute a render loop. The engine can have more than one render function
  96513. * @param renderFunction defines the function to continuously execute
  96514. */
  96515. runRenderLoop(renderFunction: () => void): void;
  96516. /**
  96517. * Toggle full screen mode
  96518. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96519. */
  96520. switchFullscreen(requestPointerLock: boolean): void;
  96521. /**
  96522. * Enters full screen mode
  96523. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96524. */
  96525. enterFullscreen(requestPointerLock: boolean): void;
  96526. /**
  96527. * Exits full screen mode
  96528. */
  96529. exitFullscreen(): void;
  96530. /**
  96531. * Enters Pointerlock mode
  96532. */
  96533. enterPointerlock(): void;
  96534. /**
  96535. * Exits Pointerlock mode
  96536. */
  96537. exitPointerlock(): void;
  96538. /**
  96539. * Clear the current render buffer or the current render target (if any is set up)
  96540. * @param color defines the color to use
  96541. * @param backBuffer defines if the back buffer must be cleared
  96542. * @param depth defines if the depth buffer must be cleared
  96543. * @param stencil defines if the stencil buffer must be cleared
  96544. */
  96545. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96546. /**
  96547. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  96548. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96549. * @param y defines the y-coordinate of the corner of the clear rectangle
  96550. * @param width defines the width of the clear rectangle
  96551. * @param height defines the height of the clear rectangle
  96552. * @param clearColor defines the clear color
  96553. */
  96554. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  96555. /**
  96556. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  96557. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96558. * @param y defines the y-coordinate of the corner of the clear rectangle
  96559. * @param width defines the width of the clear rectangle
  96560. * @param height defines the height of the clear rectangle
  96561. */
  96562. enableScissor(x: number, y: number, width: number, height: number): void;
  96563. /**
  96564. * Disable previously set scissor test rectangle
  96565. */
  96566. disableScissor(): void;
  96567. private _viewportCached;
  96568. /** @hidden */
  96569. _viewport(x: number, y: number, width: number, height: number): void;
  96570. /**
  96571. * Set the WebGL's viewport
  96572. * @param viewport defines the viewport element to be used
  96573. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96574. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96575. */
  96576. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96577. /**
  96578. * Directly set the WebGL Viewport
  96579. * @param x defines the x coordinate of the viewport (in screen space)
  96580. * @param y defines the y coordinate of the viewport (in screen space)
  96581. * @param width defines the width of the viewport (in screen space)
  96582. * @param height defines the height of the viewport (in screen space)
  96583. * @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
  96584. */
  96585. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  96586. /**
  96587. * Begin a new frame
  96588. */
  96589. beginFrame(): void;
  96590. /**
  96591. * Enf the current frame
  96592. */
  96593. endFrame(): void;
  96594. /**
  96595. * Resize the view according to the canvas' size
  96596. */
  96597. resize(): void;
  96598. /**
  96599. * Force a specific size of the canvas
  96600. * @param width defines the new canvas' width
  96601. * @param height defines the new canvas' height
  96602. */
  96603. setSize(width: number, height: number): void;
  96604. /**
  96605. * Binds the frame buffer to the specified texture.
  96606. * @param texture The texture to render to or null for the default canvas
  96607. * @param faceIndex The face of the texture to render to in case of cube texture
  96608. * @param requiredWidth The width of the target to render to
  96609. * @param requiredHeight The height of the target to render to
  96610. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96611. * @param depthStencilTexture The depth stencil texture to use to render
  96612. * @param lodLevel defines le lod level to bind to the frame buffer
  96613. */
  96614. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96615. /** @hidden */
  96616. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96617. /**
  96618. * Unbind the current render target texture from the webGL context
  96619. * @param texture defines the render target texture to unbind
  96620. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96621. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96622. */
  96623. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96624. /**
  96625. * Force the mipmap generation for the given render target texture
  96626. * @param texture defines the render target texture to use
  96627. */
  96628. generateMipMapsForCubemap(texture: InternalTexture): void;
  96629. /**
  96630. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96631. */
  96632. flushFramebuffer(): void;
  96633. /**
  96634. * Unbind the current render target and bind the default framebuffer
  96635. */
  96636. restoreDefaultFramebuffer(): void;
  96637. /**
  96638. * Create an uniform buffer
  96639. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96640. * @param elements defines the content of the uniform buffer
  96641. * @returns the webGL uniform buffer
  96642. */
  96643. createUniformBuffer(elements: FloatArray): DataBuffer;
  96644. /**
  96645. * Create a dynamic uniform buffer
  96646. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96647. * @param elements defines the content of the uniform buffer
  96648. * @returns the webGL uniform buffer
  96649. */
  96650. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  96651. /**
  96652. * Update an existing uniform buffer
  96653. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96654. * @param uniformBuffer defines the target uniform buffer
  96655. * @param elements defines the content to update
  96656. * @param offset defines the offset in the uniform buffer where update should start
  96657. * @param count defines the size of the data to update
  96658. */
  96659. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  96660. private _resetVertexBufferBinding;
  96661. /**
  96662. * Creates a vertex buffer
  96663. * @param data the data for the vertex buffer
  96664. * @returns the new WebGL static buffer
  96665. */
  96666. createVertexBuffer(data: DataArray): DataBuffer;
  96667. private _createVertexBuffer;
  96668. /**
  96669. * Creates a dynamic vertex buffer
  96670. * @param data the data for the dynamic vertex buffer
  96671. * @returns the new WebGL dynamic buffer
  96672. */
  96673. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96674. /**
  96675. * Update a dynamic index buffer
  96676. * @param indexBuffer defines the target index buffer
  96677. * @param indices defines the data to update
  96678. * @param offset defines the offset in the target index buffer where update should start
  96679. */
  96680. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  96681. /**
  96682. * Updates a dynamic vertex buffer.
  96683. * @param vertexBuffer the vertex buffer to update
  96684. * @param data the data used to update the vertex buffer
  96685. * @param byteOffset the byte offset of the data
  96686. * @param byteLength the byte length of the data
  96687. */
  96688. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96689. private _resetIndexBufferBinding;
  96690. /**
  96691. * Creates a new index buffer
  96692. * @param indices defines the content of the index buffer
  96693. * @param updatable defines if the index buffer must be updatable
  96694. * @returns a new webGL buffer
  96695. */
  96696. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96697. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96698. /**
  96699. * Bind a webGL buffer to the webGL context
  96700. * @param buffer defines the buffer to bind
  96701. */
  96702. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96703. /**
  96704. * Bind an uniform buffer to the current webGL context
  96705. * @param buffer defines the buffer to bind
  96706. */
  96707. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  96708. /**
  96709. * Bind a buffer to the current webGL context at a given location
  96710. * @param buffer defines the buffer to bind
  96711. * @param location defines the index where to bind the buffer
  96712. */
  96713. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  96714. /**
  96715. * Bind a specific block at a given index in a specific shader program
  96716. * @param pipelineContext defines the pipeline context to use
  96717. * @param blockName defines the block name
  96718. * @param index defines the index where to bind the block
  96719. */
  96720. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  96721. private bindIndexBuffer;
  96722. private bindBuffer;
  96723. /**
  96724. * update the bound buffer with the given data
  96725. * @param data defines the data to update
  96726. */
  96727. updateArrayBuffer(data: Float32Array): void;
  96728. private _vertexAttribPointer;
  96729. private _bindIndexBufferWithCache;
  96730. private _bindVertexBuffersAttributes;
  96731. /**
  96732. * Records a vertex array object
  96733. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96734. * @param vertexBuffers defines the list of vertex buffers to store
  96735. * @param indexBuffer defines the index buffer to store
  96736. * @param effect defines the effect to store
  96737. * @returns the new vertex array object
  96738. */
  96739. recordVertexArrayObject(vertexBuffers: {
  96740. [key: string]: VertexBuffer;
  96741. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96742. /**
  96743. * Bind a specific vertex array object
  96744. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96745. * @param vertexArrayObject defines the vertex array object to bind
  96746. * @param indexBuffer defines the index buffer to bind
  96747. */
  96748. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96749. /**
  96750. * Bind webGl buffers directly to the webGL context
  96751. * @param vertexBuffer defines the vertex buffer to bind
  96752. * @param indexBuffer defines the index buffer to bind
  96753. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96754. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96755. * @param effect defines the effect associated with the vertex buffer
  96756. */
  96757. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96758. private _unbindVertexArrayObject;
  96759. /**
  96760. * Bind a list of vertex buffers to the webGL context
  96761. * @param vertexBuffers defines the list of vertex buffers to bind
  96762. * @param indexBuffer defines the index buffer to bind
  96763. * @param effect defines the effect associated with the vertex buffers
  96764. */
  96765. bindBuffers(vertexBuffers: {
  96766. [key: string]: Nullable<VertexBuffer>;
  96767. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96768. /**
  96769. * Unbind all instance attributes
  96770. */
  96771. unbindInstanceAttributes(): void;
  96772. /**
  96773. * Release and free the memory of a vertex array object
  96774. * @param vao defines the vertex array object to delete
  96775. */
  96776. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96777. /** @hidden */
  96778. _releaseBuffer(buffer: DataBuffer): boolean;
  96779. protected _deleteBuffer(buffer: DataBuffer): void;
  96780. /**
  96781. * Creates a webGL buffer to use with instanciation
  96782. * @param capacity defines the size of the buffer
  96783. * @returns the webGL buffer
  96784. */
  96785. createInstancesBuffer(capacity: number): DataBuffer;
  96786. /**
  96787. * Delete a webGL buffer used with instanciation
  96788. * @param buffer defines the webGL buffer to delete
  96789. */
  96790. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96791. /**
  96792. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96793. * @param instancesBuffer defines the webGL buffer to update and bind
  96794. * @param data defines the data to store in the buffer
  96795. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96796. */
  96797. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96798. /**
  96799. * Apply all cached states (depth, culling, stencil and alpha)
  96800. */
  96801. applyStates(): void;
  96802. /**
  96803. * Send a draw order
  96804. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96805. * @param indexStart defines the starting index
  96806. * @param indexCount defines the number of index to draw
  96807. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96808. */
  96809. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96810. /**
  96811. * Draw a list of points
  96812. * @param verticesStart defines the index of first vertex to draw
  96813. * @param verticesCount defines the count of vertices to draw
  96814. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96815. */
  96816. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96817. /**
  96818. * Draw a list of unindexed primitives
  96819. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96820. * @param verticesStart defines the index of first vertex to draw
  96821. * @param verticesCount defines the count of vertices to draw
  96822. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96823. */
  96824. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96825. /**
  96826. * Draw a list of indexed primitives
  96827. * @param fillMode defines the primitive to use
  96828. * @param indexStart defines the starting index
  96829. * @param indexCount defines the number of index to draw
  96830. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96831. */
  96832. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96833. /**
  96834. * Draw a list of unindexed primitives
  96835. * @param fillMode defines the primitive to use
  96836. * @param verticesStart defines the index of first vertex to draw
  96837. * @param verticesCount defines the count of vertices to draw
  96838. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96839. */
  96840. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96841. private _drawMode;
  96842. /** @hidden */
  96843. _releaseEffect(effect: Effect): void;
  96844. /** @hidden */
  96845. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96846. /**
  96847. * Create a new effect (used to store vertex/fragment shaders)
  96848. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96849. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96850. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96851. * @param samplers defines an array of string used to represent textures
  96852. * @param defines defines the string containing the defines to use to compile the shaders
  96853. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96854. * @param onCompiled defines a function to call when the effect creation is successful
  96855. * @param onError defines a function to call when the effect creation has failed
  96856. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96857. * @returns the new Effect
  96858. */
  96859. 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;
  96860. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96861. private _compileShader;
  96862. private _compileRawShader;
  96863. /**
  96864. * Directly creates a webGL program
  96865. * @param pipelineContext defines the pipeline context to attach to
  96866. * @param vertexCode defines the vertex shader code to use
  96867. * @param fragmentCode defines the fragment shader code to use
  96868. * @param context defines the webGL context to use (if not set, the current one will be used)
  96869. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96870. * @returns the new webGL program
  96871. */
  96872. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96873. /**
  96874. * Creates a webGL program
  96875. * @param pipelineContext defines the pipeline context to attach to
  96876. * @param vertexCode defines the vertex shader code to use
  96877. * @param fragmentCode defines the fragment shader code to use
  96878. * @param defines defines the string containing the defines to use to compile the shaders
  96879. * @param context defines the webGL context to use (if not set, the current one will be used)
  96880. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96881. * @returns the new webGL program
  96882. */
  96883. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96884. /**
  96885. * Creates a new pipeline context
  96886. * @returns the new pipeline
  96887. */
  96888. createPipelineContext(): IPipelineContext;
  96889. private _createShaderProgram;
  96890. private _finalizePipelineContext;
  96891. /** @hidden */
  96892. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96893. /** @hidden */
  96894. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96895. /** @hidden */
  96896. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96897. /**
  96898. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96899. * @param pipelineContext defines the pipeline context to use
  96900. * @param uniformsNames defines the list of uniform names
  96901. * @returns an array of webGL uniform locations
  96902. */
  96903. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96904. /**
  96905. * Gets the lsit of active attributes for a given webGL program
  96906. * @param pipelineContext defines the pipeline context to use
  96907. * @param attributesNames defines the list of attribute names to get
  96908. * @returns an array of indices indicating the offset of each attribute
  96909. */
  96910. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96911. /**
  96912. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96913. * @param effect defines the effect to activate
  96914. */
  96915. enableEffect(effect: Nullable<Effect>): void;
  96916. /**
  96917. * Set the value of an uniform to an array of int32
  96918. * @param uniform defines the webGL uniform location where to store the value
  96919. * @param array defines the array of int32 to store
  96920. */
  96921. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96922. /**
  96923. * Set the value of an uniform to an array of int32 (stored as vec2)
  96924. * @param uniform defines the webGL uniform location where to store the value
  96925. * @param array defines the array of int32 to store
  96926. */
  96927. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96928. /**
  96929. * Set the value of an uniform to an array of int32 (stored as vec3)
  96930. * @param uniform defines the webGL uniform location where to store the value
  96931. * @param array defines the array of int32 to store
  96932. */
  96933. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96934. /**
  96935. * Set the value of an uniform to an array of int32 (stored as vec4)
  96936. * @param uniform defines the webGL uniform location where to store the value
  96937. * @param array defines the array of int32 to store
  96938. */
  96939. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96940. /**
  96941. * Set the value of an uniform to an array of float32
  96942. * @param uniform defines the webGL uniform location where to store the value
  96943. * @param array defines the array of float32 to store
  96944. */
  96945. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96946. /**
  96947. * Set the value of an uniform to an array of float32 (stored as vec2)
  96948. * @param uniform defines the webGL uniform location where to store the value
  96949. * @param array defines the array of float32 to store
  96950. */
  96951. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96952. /**
  96953. * Set the value of an uniform to an array of float32 (stored as vec3)
  96954. * @param uniform defines the webGL uniform location where to store the value
  96955. * @param array defines the array of float32 to store
  96956. */
  96957. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96958. /**
  96959. * Set the value of an uniform to an array of float32 (stored as vec4)
  96960. * @param uniform defines the webGL uniform location where to store the value
  96961. * @param array defines the array of float32 to store
  96962. */
  96963. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96964. /**
  96965. * Set the value of an uniform to an array of number
  96966. * @param uniform defines the webGL uniform location where to store the value
  96967. * @param array defines the array of number to store
  96968. */
  96969. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96970. /**
  96971. * Set the value of an uniform to an array of number (stored as vec2)
  96972. * @param uniform defines the webGL uniform location where to store the value
  96973. * @param array defines the array of number to store
  96974. */
  96975. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96976. /**
  96977. * Set the value of an uniform to an array of number (stored as vec3)
  96978. * @param uniform defines the webGL uniform location where to store the value
  96979. * @param array defines the array of number to store
  96980. */
  96981. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96982. /**
  96983. * Set the value of an uniform to an array of number (stored as vec4)
  96984. * @param uniform defines the webGL uniform location where to store the value
  96985. * @param array defines the array of number to store
  96986. */
  96987. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96988. /**
  96989. * Set the value of an uniform to an array of float32 (stored as matrices)
  96990. * @param uniform defines the webGL uniform location where to store the value
  96991. * @param matrices defines the array of float32 to store
  96992. */
  96993. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96994. /**
  96995. * Set the value of an uniform to a matrix (3x3)
  96996. * @param uniform defines the webGL uniform location where to store the value
  96997. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96998. */
  96999. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97000. /**
  97001. * Set the value of an uniform to a matrix (2x2)
  97002. * @param uniform defines the webGL uniform location where to store the value
  97003. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  97004. */
  97005. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97006. /**
  97007. * Set the value of an uniform to a number (int)
  97008. * @param uniform defines the webGL uniform location where to store the value
  97009. * @param value defines the int number to store
  97010. */
  97011. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97012. /**
  97013. * Set the value of an uniform to a number (float)
  97014. * @param uniform defines the webGL uniform location where to store the value
  97015. * @param value defines the float number to store
  97016. */
  97017. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97018. /**
  97019. * Set the value of an uniform to a vec2
  97020. * @param uniform defines the webGL uniform location where to store the value
  97021. * @param x defines the 1st component of the value
  97022. * @param y defines the 2nd component of the value
  97023. */
  97024. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  97025. /**
  97026. * Set the value of an uniform to a vec3
  97027. * @param uniform defines the webGL uniform location where to store the value
  97028. * @param x defines the 1st component of the value
  97029. * @param y defines the 2nd component of the value
  97030. * @param z defines the 3rd component of the value
  97031. */
  97032. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  97033. /**
  97034. * Set the value of an uniform to a boolean
  97035. * @param uniform defines the webGL uniform location where to store the value
  97036. * @param bool defines the boolean to store
  97037. */
  97038. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  97039. /**
  97040. * Set the value of an uniform to a vec4
  97041. * @param uniform defines the webGL uniform location where to store the value
  97042. * @param x defines the 1st component of the value
  97043. * @param y defines the 2nd component of the value
  97044. * @param z defines the 3rd component of the value
  97045. * @param w defines the 4th component of the value
  97046. */
  97047. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  97048. /**
  97049. * Sets a Color4 on a uniform variable
  97050. * @param uniform defines the uniform location
  97051. * @param color4 defines the value to be set
  97052. */
  97053. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  97054. /**
  97055. * Set various states to the webGL context
  97056. * @param culling defines backface culling state
  97057. * @param zOffset defines the value to apply to zOffset (0 by default)
  97058. * @param force defines if states must be applied even if cache is up to date
  97059. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  97060. */
  97061. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  97062. /**
  97063. * Set the z offset to apply to current rendering
  97064. * @param value defines the offset to apply
  97065. */
  97066. setZOffset(value: number): void;
  97067. /**
  97068. * Gets the current value of the zOffset
  97069. * @returns the current zOffset state
  97070. */
  97071. getZOffset(): number;
  97072. /**
  97073. * Enable or disable depth buffering
  97074. * @param enable defines the state to set
  97075. */
  97076. setDepthBuffer(enable: boolean): void;
  97077. /**
  97078. * Gets a boolean indicating if depth writing is enabled
  97079. * @returns the current depth writing state
  97080. */
  97081. getDepthWrite(): boolean;
  97082. /**
  97083. * Enable or disable depth writing
  97084. * @param enable defines the state to set
  97085. */
  97086. setDepthWrite(enable: boolean): void;
  97087. /**
  97088. * Enable or disable color writing
  97089. * @param enable defines the state to set
  97090. */
  97091. setColorWrite(enable: boolean): void;
  97092. /**
  97093. * Gets a boolean indicating if color writing is enabled
  97094. * @returns the current color writing state
  97095. */
  97096. getColorWrite(): boolean;
  97097. /**
  97098. * Sets alpha constants used by some alpha blending modes
  97099. * @param r defines the red component
  97100. * @param g defines the green component
  97101. * @param b defines the blue component
  97102. * @param a defines the alpha component
  97103. */
  97104. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  97105. /**
  97106. * Sets the current alpha mode
  97107. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  97108. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  97109. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97110. */
  97111. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  97112. /**
  97113. * Gets the current alpha mode
  97114. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97115. * @returns the current alpha mode
  97116. */
  97117. getAlphaMode(): number;
  97118. /**
  97119. * Sets the current alpha equation
  97120. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  97121. */
  97122. setAlphaEquation(equation: number): void;
  97123. /**
  97124. * Gets the current alpha equation.
  97125. * @returns the current alpha equation
  97126. */
  97127. getAlphaEquation(): number;
  97128. /**
  97129. * Clears the list of texture accessible through engine.
  97130. * This can help preventing texture load conflict due to name collision.
  97131. */
  97132. clearInternalTexturesCache(): void;
  97133. /**
  97134. * Force the entire cache to be cleared
  97135. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  97136. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  97137. */
  97138. wipeCaches(bruteForce?: boolean): void;
  97139. /**
  97140. * Set the compressed texture format to use, based on the formats you have, and the formats
  97141. * supported by the hardware / browser.
  97142. *
  97143. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  97144. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  97145. * to API arguments needed to compressed textures. This puts the burden on the container
  97146. * generator to house the arcane code for determining these for current & future formats.
  97147. *
  97148. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  97149. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  97150. *
  97151. * Note: The result of this call is not taken into account when a texture is base64.
  97152. *
  97153. * @param formatsAvailable defines the list of those format families you have created
  97154. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  97155. *
  97156. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  97157. * @returns The extension selected.
  97158. */
  97159. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  97160. /** @hidden */
  97161. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  97162. min: number;
  97163. mag: number;
  97164. };
  97165. /** @hidden */
  97166. _createTexture(): WebGLTexture;
  97167. /**
  97168. * Usually called from Texture.ts.
  97169. * Passed information to create a WebGLTexture
  97170. * @param urlArg defines a value which contains one of the following:
  97171. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  97172. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  97173. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  97174. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  97175. * @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)
  97176. * @param scene needed for loading to the correct scene
  97177. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  97178. * @param onLoad optional callback to be called upon successful completion
  97179. * @param onError optional callback to be called upon failure
  97180. * @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
  97181. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  97182. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  97183. * @param forcedExtension defines the extension to use to pick the right loader
  97184. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  97185. * @returns a InternalTexture for assignment back into BABYLON.Texture
  97186. */
  97187. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  97188. /**
  97189. * @hidden
  97190. * Rescales a texture
  97191. * @param source input texutre
  97192. * @param destination destination texture
  97193. * @param scene scene to use to render the resize
  97194. * @param internalFormat format to use when resizing
  97195. * @param onComplete callback to be called when resize has completed
  97196. */
  97197. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  97198. private _unpackFlipYCached;
  97199. /**
  97200. * In case you are sharing the context with other applications, it might
  97201. * be interested to not cache the unpack flip y state to ensure a consistent
  97202. * value would be set.
  97203. */
  97204. enableUnpackFlipYCached: boolean;
  97205. /** @hidden */
  97206. _unpackFlipY(value: boolean): void;
  97207. /** @hidden */
  97208. _getUnpackAlignement(): number;
  97209. /**
  97210. * Creates a dynamic texture
  97211. * @param width defines the width of the texture
  97212. * @param height defines the height of the texture
  97213. * @param generateMipMaps defines if the engine should generate the mip levels
  97214. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  97215. * @returns the dynamic texture inside an InternalTexture
  97216. */
  97217. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  97218. /**
  97219. * Update the sampling mode of a given texture
  97220. * @param samplingMode defines the required sampling mode
  97221. * @param texture defines the texture to update
  97222. */
  97223. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97224. /**
  97225. * Update the content of a dynamic texture
  97226. * @param texture defines the texture to update
  97227. * @param canvas defines the canvas containing the source
  97228. * @param invertY defines if data must be stored with Y axis inverted
  97229. * @param premulAlpha defines if alpha is stored as premultiplied
  97230. * @param format defines the format of the data
  97231. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  97232. */
  97233. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  97234. /**
  97235. * Update a video texture
  97236. * @param texture defines the texture to update
  97237. * @param video defines the video element to use
  97238. * @param invertY defines if data must be stored with Y axis inverted
  97239. */
  97240. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  97241. /**
  97242. * Updates a depth texture Comparison Mode and Function.
  97243. * If the comparison Function is equal to 0, the mode will be set to none.
  97244. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  97245. * @param texture The texture to set the comparison function for
  97246. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  97247. */
  97248. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  97249. /** @hidden */
  97250. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  97251. width: number;
  97252. height: number;
  97253. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  97254. /**
  97255. * Creates a depth stencil texture.
  97256. * This is only available in WebGL 2 or with the depth texture extension available.
  97257. * @param size The size of face edge in the texture.
  97258. * @param options The options defining the texture.
  97259. * @returns The texture
  97260. */
  97261. createDepthStencilTexture(size: number | {
  97262. width: number;
  97263. height: number;
  97264. }, options: DepthTextureCreationOptions): InternalTexture;
  97265. /**
  97266. * Creates a depth stencil texture.
  97267. * This is only available in WebGL 2 or with the depth texture extension available.
  97268. * @param size The size of face edge in the texture.
  97269. * @param options The options defining the texture.
  97270. * @returns The texture
  97271. */
  97272. private _createDepthStencilTexture;
  97273. /**
  97274. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  97275. * @param renderTarget The render target to set the frame buffer for
  97276. */
  97277. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  97278. /**
  97279. * Creates a new render target texture
  97280. * @param size defines the size of the texture
  97281. * @param options defines the options used to create the texture
  97282. * @returns a new render target texture stored in an InternalTexture
  97283. */
  97284. createRenderTargetTexture(size: number | {
  97285. width: number;
  97286. height: number;
  97287. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  97288. /** @hidden */
  97289. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  97290. /**
  97291. * Updates the sample count of a render target texture
  97292. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  97293. * @param texture defines the texture to update
  97294. * @param samples defines the sample count to set
  97295. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  97296. */
  97297. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  97298. /** @hidden */
  97299. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97300. /** @hidden */
  97301. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  97302. /** @hidden */
  97303. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97304. /** @hidden */
  97305. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  97306. /**
  97307. * @hidden
  97308. */
  97309. _setCubeMapTextureParams(loadMipmap: boolean): void;
  97310. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  97311. private _prepareWebGLTexture;
  97312. /** @hidden */
  97313. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  97314. /** @hidden */
  97315. _releaseFramebufferObjects(texture: InternalTexture): void;
  97316. /** @hidden */
  97317. _releaseTexture(texture: InternalTexture): void;
  97318. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  97319. protected _setProgram(program: WebGLProgram): void;
  97320. protected _boundUniforms: {
  97321. [key: number]: WebGLUniformLocation;
  97322. };
  97323. /**
  97324. * Binds an effect to the webGL context
  97325. * @param effect defines the effect to bind
  97326. */
  97327. bindSamplers(effect: Effect): void;
  97328. private _activateCurrentTexture;
  97329. /** @hidden */
  97330. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  97331. /** @hidden */
  97332. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  97333. /**
  97334. * Sets a texture to the webGL context from a postprocess
  97335. * @param channel defines the channel to use
  97336. * @param postProcess defines the source postprocess
  97337. */
  97338. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  97339. /**
  97340. * Binds the output of the passed in post process to the texture channel specified
  97341. * @param channel The channel the texture should be bound to
  97342. * @param postProcess The post process which's output should be bound
  97343. */
  97344. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  97345. /**
  97346. * Unbind all textures from the webGL context
  97347. */
  97348. unbindAllTextures(): void;
  97349. /**
  97350. * Sets a texture to the according uniform.
  97351. * @param channel The texture channel
  97352. * @param uniform The uniform to set
  97353. * @param texture The texture to apply
  97354. */
  97355. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  97356. /**
  97357. * Sets a depth stencil texture from a render target to the according uniform.
  97358. * @param channel The texture channel
  97359. * @param uniform The uniform to set
  97360. * @param texture The render target texture containing the depth stencil texture to apply
  97361. */
  97362. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  97363. private _bindSamplerUniformToChannel;
  97364. private _getTextureWrapMode;
  97365. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  97366. /**
  97367. * Sets an array of texture to the webGL context
  97368. * @param channel defines the channel where the texture array must be set
  97369. * @param uniform defines the associated uniform location
  97370. * @param textures defines the array of textures to bind
  97371. */
  97372. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  97373. /** @hidden */
  97374. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  97375. private _setTextureParameterFloat;
  97376. private _setTextureParameterInteger;
  97377. /**
  97378. * Reads pixels from the current frame buffer. Please note that this function can be slow
  97379. * @param x defines the x coordinate of the rectangle where pixels must be read
  97380. * @param y defines the y coordinate of the rectangle where pixels must be read
  97381. * @param width defines the width of the rectangle where pixels must be read
  97382. * @param height defines the height of the rectangle where pixels must be read
  97383. * @returns a Uint8Array containing RGBA colors
  97384. */
  97385. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  97386. /**
  97387. * Unbind all vertex attributes from the webGL context
  97388. */
  97389. unbindAllAttributes(): void;
  97390. /**
  97391. * 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
  97392. */
  97393. releaseEffects(): void;
  97394. /**
  97395. * Dispose and release all associated resources
  97396. */
  97397. dispose(): void;
  97398. /**
  97399. * Display the loading screen
  97400. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97401. */
  97402. displayLoadingUI(): void;
  97403. /**
  97404. * Hide the loading screen
  97405. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97406. */
  97407. hideLoadingUI(): void;
  97408. /**
  97409. * Gets the current loading screen object
  97410. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97411. */
  97412. /**
  97413. * Sets the current loading screen object
  97414. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97415. */
  97416. loadingScreen: ILoadingScreen;
  97417. /**
  97418. * Sets the current loading screen text
  97419. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97420. */
  97421. loadingUIText: string;
  97422. /**
  97423. * Sets the current loading screen background color
  97424. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97425. */
  97426. loadingUIBackgroundColor: string;
  97427. /**
  97428. * Attach a new callback raised when context lost event is fired
  97429. * @param callback defines the callback to call
  97430. */
  97431. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97432. /**
  97433. * Attach a new callback raised when context restored event is fired
  97434. * @param callback defines the callback to call
  97435. */
  97436. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97437. /**
  97438. * Gets the source code of the vertex shader associated with a specific webGL program
  97439. * @param program defines the program to use
  97440. * @returns a string containing the source code of the vertex shader associated with the program
  97441. */
  97442. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  97443. /**
  97444. * Gets the source code of the fragment shader associated with a specific webGL program
  97445. * @param program defines the program to use
  97446. * @returns a string containing the source code of the fragment shader associated with the program
  97447. */
  97448. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  97449. /**
  97450. * Get the current error code of the webGL context
  97451. * @returns the error code
  97452. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97453. */
  97454. getError(): number;
  97455. /**
  97456. * Gets the current framerate
  97457. * @returns a number representing the framerate
  97458. */
  97459. getFps(): number;
  97460. /**
  97461. * Gets the time spent between current and previous frame
  97462. * @returns a number representing the delta time in ms
  97463. */
  97464. getDeltaTime(): number;
  97465. private _measureFps;
  97466. /** @hidden */
  97467. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  97468. private _canRenderToFloatFramebuffer;
  97469. private _canRenderToHalfFloatFramebuffer;
  97470. private _canRenderToFramebuffer;
  97471. /** @hidden */
  97472. _getWebGLTextureType(type: number): number;
  97473. /** @hidden */
  97474. _getInternalFormat(format: number): number;
  97475. /** @hidden */
  97476. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97477. /** @hidden */
  97478. _getRGBAMultiSampleBufferFormat(type: number): number;
  97479. /** @hidden */
  97480. _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;
  97481. /** @hidden */
  97482. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  97483. /**
  97484. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97485. * @returns true if the engine can be created
  97486. * @ignorenaming
  97487. */
  97488. static isSupported(): boolean;
  97489. /**
  97490. * Find the next highest power of two.
  97491. * @param x Number to start search from.
  97492. * @return Next highest power of two.
  97493. */
  97494. static CeilingPOT(x: number): number;
  97495. /**
  97496. * Find the next lowest power of two.
  97497. * @param x Number to start search from.
  97498. * @return Next lowest power of two.
  97499. */
  97500. static FloorPOT(x: number): number;
  97501. /**
  97502. * Find the nearest power of two.
  97503. * @param x Number to start search from.
  97504. * @return Next nearest power of two.
  97505. */
  97506. static NearestPOT(x: number): number;
  97507. /**
  97508. * Get the closest exponent of two
  97509. * @param value defines the value to approximate
  97510. * @param max defines the maximum value to return
  97511. * @param mode defines how to define the closest value
  97512. * @returns closest exponent of two of the given value
  97513. */
  97514. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97515. /**
  97516. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97517. * @param func - the function to be called
  97518. * @param requester - the object that will request the next frame. Falls back to window.
  97519. * @returns frame number
  97520. */
  97521. static QueueNewFrame(func: () => void, requester?: any): number;
  97522. /**
  97523. * Ask the browser to promote the current element to pointerlock mode
  97524. * @param element defines the DOM element to promote
  97525. */
  97526. static _RequestPointerlock(element: HTMLElement): void;
  97527. /**
  97528. * Asks the browser to exit pointerlock mode
  97529. */
  97530. static _ExitPointerlock(): void;
  97531. /**
  97532. * Ask the browser to promote the current element to fullscreen rendering mode
  97533. * @param element defines the DOM element to promote
  97534. */
  97535. static _RequestFullscreen(element: HTMLElement): void;
  97536. /**
  97537. * Asks the browser to exit fullscreen mode
  97538. */
  97539. static _ExitFullscreen(): void;
  97540. }
  97541. }
  97542. declare module BABYLON {
  97543. /**
  97544. * The engine store class is responsible to hold all the instances of Engine and Scene created
  97545. * during the life time of the application.
  97546. */
  97547. export class EngineStore {
  97548. /** Gets the list of created engines */
  97549. static Instances: Engine[];
  97550. /** @hidden */
  97551. static _LastCreatedScene: Nullable<Scene>;
  97552. /**
  97553. * Gets the latest created engine
  97554. */
  97555. static readonly LastCreatedEngine: Nullable<Engine>;
  97556. /**
  97557. * Gets the latest created scene
  97558. */
  97559. static readonly LastCreatedScene: Nullable<Scene>;
  97560. /**
  97561. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97562. * @ignorenaming
  97563. */
  97564. static UseFallbackTexture: boolean;
  97565. /**
  97566. * Texture content used if a texture cannot loaded
  97567. * @ignorenaming
  97568. */
  97569. static FallbackTexture: string;
  97570. }
  97571. }
  97572. declare module BABYLON {
  97573. /**
  97574. * Helper class that provides a small promise polyfill
  97575. */
  97576. export class PromisePolyfill {
  97577. /**
  97578. * Static function used to check if the polyfill is required
  97579. * If this is the case then the function will inject the polyfill to window.Promise
  97580. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  97581. */
  97582. static Apply(force?: boolean): void;
  97583. }
  97584. }
  97585. declare module BABYLON {
  97586. /**
  97587. * Interface for screenshot methods with describe argument called `size` as object with options
  97588. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  97589. */
  97590. export interface IScreenshotSize {
  97591. /**
  97592. * number in pixels for canvas height
  97593. */
  97594. height?: number;
  97595. /**
  97596. * multiplier allowing render at a higher or lower resolution
  97597. * If value is defined then height and width will be ignored and taken from camera
  97598. */
  97599. precision?: number;
  97600. /**
  97601. * number in pixels for canvas width
  97602. */
  97603. width?: number;
  97604. }
  97605. }
  97606. declare module BABYLON {
  97607. interface IColor4Like {
  97608. r: float;
  97609. g: float;
  97610. b: float;
  97611. a: float;
  97612. }
  97613. /**
  97614. * Class containing a set of static utilities functions
  97615. */
  97616. export class Tools {
  97617. /**
  97618. * Gets or sets the base URL to use to load assets
  97619. */
  97620. static BaseUrl: string;
  97621. /**
  97622. * Enable/Disable Custom HTTP Request Headers globally.
  97623. * default = false
  97624. * @see CustomRequestHeaders
  97625. */
  97626. static UseCustomRequestHeaders: boolean;
  97627. /**
  97628. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  97629. * i.e. when loading files, where the server/service expects an Authorization header
  97630. */
  97631. static CustomRequestHeaders: {
  97632. [key: string]: string;
  97633. };
  97634. /**
  97635. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  97636. */
  97637. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  97638. /**
  97639. * Default behaviour for cors in the application.
  97640. * It can be a string if the expected behavior is identical in the entire app.
  97641. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  97642. */
  97643. static CorsBehavior: string | ((url: string | string[]) => string);
  97644. /**
  97645. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97646. * @ignorenaming
  97647. */
  97648. static UseFallbackTexture: boolean;
  97649. /**
  97650. * Use this object to register external classes like custom textures or material
  97651. * to allow the laoders to instantiate them
  97652. */
  97653. static RegisteredExternalClasses: {
  97654. [key: string]: Object;
  97655. };
  97656. /**
  97657. * Texture content used if a texture cannot loaded
  97658. * @ignorenaming
  97659. */
  97660. static fallbackTexture: string;
  97661. /**
  97662. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  97663. * @param u defines the coordinate on X axis
  97664. * @param v defines the coordinate on Y axis
  97665. * @param width defines the width of the source data
  97666. * @param height defines the height of the source data
  97667. * @param pixels defines the source byte array
  97668. * @param color defines the output color
  97669. */
  97670. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  97671. /**
  97672. * Interpolates between a and b via alpha
  97673. * @param a The lower value (returned when alpha = 0)
  97674. * @param b The upper value (returned when alpha = 1)
  97675. * @param alpha The interpolation-factor
  97676. * @return The mixed value
  97677. */
  97678. static Mix(a: number, b: number, alpha: number): number;
  97679. /**
  97680. * Tries to instantiate a new object from a given class name
  97681. * @param className defines the class name to instantiate
  97682. * @returns the new object or null if the system was not able to do the instantiation
  97683. */
  97684. static Instantiate(className: string): any;
  97685. /**
  97686. * Provides a slice function that will work even on IE
  97687. * @param data defines the array to slice
  97688. * @param start defines the start of the data (optional)
  97689. * @param end defines the end of the data (optional)
  97690. * @returns the new sliced array
  97691. */
  97692. static Slice<T>(data: T, start?: number, end?: number): T;
  97693. /**
  97694. * Polyfill for setImmediate
  97695. * @param action defines the action to execute after the current execution block
  97696. */
  97697. static SetImmediate(action: () => void): void;
  97698. /**
  97699. * Function indicating if a number is an exponent of 2
  97700. * @param value defines the value to test
  97701. * @returns true if the value is an exponent of 2
  97702. */
  97703. static IsExponentOfTwo(value: number): boolean;
  97704. private static _tmpFloatArray;
  97705. /**
  97706. * Returns the nearest 32-bit single precision float representation of a Number
  97707. * @param value A Number. If the parameter is of a different type, it will get converted
  97708. * to a number or to NaN if it cannot be converted
  97709. * @returns number
  97710. */
  97711. static FloatRound(value: number): number;
  97712. /**
  97713. * Extracts the filename from a path
  97714. * @param path defines the path to use
  97715. * @returns the filename
  97716. */
  97717. static GetFilename(path: string): string;
  97718. /**
  97719. * Extracts the "folder" part of a path (everything before the filename).
  97720. * @param uri The URI to extract the info from
  97721. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  97722. * @returns The "folder" part of the path
  97723. */
  97724. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  97725. /**
  97726. * Extracts text content from a DOM element hierarchy
  97727. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  97728. */
  97729. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  97730. /**
  97731. * Convert an angle in radians to degrees
  97732. * @param angle defines the angle to convert
  97733. * @returns the angle in degrees
  97734. */
  97735. static ToDegrees(angle: number): number;
  97736. /**
  97737. * Convert an angle in degrees to radians
  97738. * @param angle defines the angle to convert
  97739. * @returns the angle in radians
  97740. */
  97741. static ToRadians(angle: number): number;
  97742. /**
  97743. * Encode a buffer to a base64 string
  97744. * @param buffer defines the buffer to encode
  97745. * @returns the encoded string
  97746. */
  97747. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  97748. /**
  97749. * Returns an array if obj is not an array
  97750. * @param obj defines the object to evaluate as an array
  97751. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  97752. * @returns either obj directly if obj is an array or a new array containing obj
  97753. */
  97754. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  97755. /**
  97756. * Gets the pointer prefix to use
  97757. * @returns "pointer" if touch is enabled. Else returns "mouse"
  97758. */
  97759. static GetPointerPrefix(): string;
  97760. /**
  97761. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  97762. * @param url define the url we are trying
  97763. * @param element define the dom element where to configure the cors policy
  97764. */
  97765. static SetCorsBehavior(url: string | string[], element: {
  97766. crossOrigin: string | null;
  97767. }): void;
  97768. /**
  97769. * Removes unwanted characters from an url
  97770. * @param url defines the url to clean
  97771. * @returns the cleaned url
  97772. */
  97773. static CleanUrl(url: string): string;
  97774. /**
  97775. * Gets or sets a function used to pre-process url before using them to load assets
  97776. */
  97777. static PreprocessUrl: (url: string) => string;
  97778. /**
  97779. * Loads an image as an HTMLImageElement.
  97780. * @param input url string, ArrayBuffer, or Blob to load
  97781. * @param onLoad callback called when the image successfully loads
  97782. * @param onError callback called when the image fails to load
  97783. * @param offlineProvider offline provider for caching
  97784. * @returns the HTMLImageElement of the loaded image
  97785. */
  97786. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  97787. /**
  97788. * Loads a file
  97789. * @param url url string, ArrayBuffer, or Blob to load
  97790. * @param onSuccess callback called when the file successfully loads
  97791. * @param onProgress callback called while file is loading (if the server supports this mode)
  97792. * @param offlineProvider defines the offline provider for caching
  97793. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  97794. * @param onError callback called when the file fails to load
  97795. * @returns a file request object
  97796. */
  97797. 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;
  97798. /**
  97799. * Loads a file from a url
  97800. * @param url the file url to load
  97801. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  97802. */
  97803. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  97804. /**
  97805. * Load a script (identified by an url). When the url returns, the
  97806. * content of this file is added into a new script element, attached to the DOM (body element)
  97807. * @param scriptUrl defines the url of the script to laod
  97808. * @param onSuccess defines the callback called when the script is loaded
  97809. * @param onError defines the callback to call if an error occurs
  97810. * @param scriptId defines the id of the script element
  97811. */
  97812. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  97813. /**
  97814. * Load an asynchronous script (identified by an url). When the url returns, the
  97815. * content of this file is added into a new script element, attached to the DOM (body element)
  97816. * @param scriptUrl defines the url of the script to laod
  97817. * @param scriptId defines the id of the script element
  97818. * @returns a promise request object
  97819. */
  97820. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  97821. /**
  97822. * Loads a file from a blob
  97823. * @param fileToLoad defines the blob to use
  97824. * @param callback defines the callback to call when data is loaded
  97825. * @param progressCallback defines the callback to call during loading process
  97826. * @returns a file request object
  97827. */
  97828. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  97829. /**
  97830. * Loads a file
  97831. * @param fileToLoad defines the file to load
  97832. * @param callback defines the callback to call when data is loaded
  97833. * @param progressCallBack defines the callback to call during loading process
  97834. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  97835. * @returns a file request object
  97836. */
  97837. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  97838. /**
  97839. * Creates a data url from a given string content
  97840. * @param content defines the content to convert
  97841. * @returns the new data url link
  97842. */
  97843. static FileAsURL(content: string): string;
  97844. /**
  97845. * Format the given number to a specific decimal format
  97846. * @param value defines the number to format
  97847. * @param decimals defines the number of decimals to use
  97848. * @returns the formatted string
  97849. */
  97850. static Format(value: number, decimals?: number): string;
  97851. /**
  97852. * Tries to copy an object by duplicating every property
  97853. * @param source defines the source object
  97854. * @param destination defines the target object
  97855. * @param doNotCopyList defines a list of properties to avoid
  97856. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  97857. */
  97858. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  97859. /**
  97860. * Gets a boolean indicating if the given object has no own property
  97861. * @param obj defines the object to test
  97862. * @returns true if object has no own property
  97863. */
  97864. static IsEmpty(obj: any): boolean;
  97865. /**
  97866. * Function used to register events at window level
  97867. * @param windowElement defines the Window object to use
  97868. * @param events defines the events to register
  97869. */
  97870. static RegisterTopRootEvents(windowElement: Window, events: {
  97871. name: string;
  97872. handler: Nullable<(e: FocusEvent) => any>;
  97873. }[]): void;
  97874. /**
  97875. * Function used to unregister events from window level
  97876. * @param windowElement defines the Window object to use
  97877. * @param events defines the events to unregister
  97878. */
  97879. static UnregisterTopRootEvents(windowElement: Window, events: {
  97880. name: string;
  97881. handler: Nullable<(e: FocusEvent) => any>;
  97882. }[]): void;
  97883. /**
  97884. * @ignore
  97885. */
  97886. static _ScreenshotCanvas: HTMLCanvasElement;
  97887. /**
  97888. * Dumps the current bound framebuffer
  97889. * @param width defines the rendering width
  97890. * @param height defines the rendering height
  97891. * @param engine defines the hosting engine
  97892. * @param successCallback defines the callback triggered once the data are available
  97893. * @param mimeType defines the mime type of the result
  97894. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  97895. */
  97896. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97897. /**
  97898. * Converts the canvas data to blob.
  97899. * This acts as a polyfill for browsers not supporting the to blob function.
  97900. * @param canvas Defines the canvas to extract the data from
  97901. * @param successCallback Defines the callback triggered once the data are available
  97902. * @param mimeType Defines the mime type of the result
  97903. */
  97904. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  97905. /**
  97906. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  97907. * @param successCallback defines the callback triggered once the data are available
  97908. * @param mimeType defines the mime type of the result
  97909. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  97910. */
  97911. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97912. /**
  97913. * Downloads a blob in the browser
  97914. * @param blob defines the blob to download
  97915. * @param fileName defines the name of the downloaded file
  97916. */
  97917. static Download(blob: Blob, fileName: string): void;
  97918. /**
  97919. * Captures a screenshot of the current rendering
  97920. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97921. * @param engine defines the rendering engine
  97922. * @param camera defines the source camera
  97923. * @param size This parameter can be set to a single number or to an object with the
  97924. * following (optional) properties: precision, width, height. If a single number is passed,
  97925. * it will be used for both width and height. If an object is passed, the screenshot size
  97926. * will be derived from the parameters. The precision property is a multiplier allowing
  97927. * rendering at a higher or lower resolution
  97928. * @param successCallback defines the callback receives a single parameter which contains the
  97929. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97930. * src parameter of an <img> to display it
  97931. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97932. * Check your browser for supported MIME types
  97933. */
  97934. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  97935. /**
  97936. * Captures a screenshot of the current rendering
  97937. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97938. * @param engine defines the rendering engine
  97939. * @param camera defines the source camera
  97940. * @param size This parameter can be set to a single number or to an object with the
  97941. * following (optional) properties: precision, width, height. If a single number is passed,
  97942. * it will be used for both width and height. If an object is passed, the screenshot size
  97943. * will be derived from the parameters. The precision property is a multiplier allowing
  97944. * rendering at a higher or lower resolution
  97945. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97946. * Check your browser for supported MIME types
  97947. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97948. * to the src parameter of an <img> to display it
  97949. */
  97950. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  97951. /**
  97952. * Generates an image screenshot from the specified camera.
  97953. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97954. * @param engine The engine to use for rendering
  97955. * @param camera The camera to use for rendering
  97956. * @param size This parameter can be set to a single number or to an object with the
  97957. * following (optional) properties: precision, width, height. If a single number is passed,
  97958. * it will be used for both width and height. If an object is passed, the screenshot size
  97959. * will be derived from the parameters. The precision property is a multiplier allowing
  97960. * rendering at a higher or lower resolution
  97961. * @param successCallback The callback receives a single parameter which contains the
  97962. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97963. * src parameter of an <img> to display it
  97964. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97965. * Check your browser for supported MIME types
  97966. * @param samples Texture samples (default: 1)
  97967. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97968. * @param fileName A name for for the downloaded file.
  97969. */
  97970. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  97971. /**
  97972. * Generates an image screenshot from the specified camera.
  97973. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97974. * @param engine The engine to use for rendering
  97975. * @param camera The camera to use for rendering
  97976. * @param size This parameter can be set to a single number or to an object with the
  97977. * following (optional) properties: precision, width, height. If a single number is passed,
  97978. * it will be used for both width and height. If an object is passed, the screenshot size
  97979. * will be derived from the parameters. The precision property is a multiplier allowing
  97980. * rendering at a higher or lower resolution
  97981. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97982. * Check your browser for supported MIME types
  97983. * @param samples Texture samples (default: 1)
  97984. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97985. * @param fileName A name for for the downloaded file.
  97986. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97987. * to the src parameter of an <img> to display it
  97988. */
  97989. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  97990. /**
  97991. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  97992. * Be aware Math.random() could cause collisions, but:
  97993. * "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"
  97994. * @returns a pseudo random id
  97995. */
  97996. static RandomId(): string;
  97997. /**
  97998. * Test if the given uri is a base64 string
  97999. * @param uri The uri to test
  98000. * @return True if the uri is a base64 string or false otherwise
  98001. */
  98002. static IsBase64(uri: string): boolean;
  98003. /**
  98004. * Decode the given base64 uri.
  98005. * @param uri The uri to decode
  98006. * @return The decoded base64 data.
  98007. */
  98008. static DecodeBase64(uri: string): ArrayBuffer;
  98009. /**
  98010. * Gets the absolute url.
  98011. * @param url the input url
  98012. * @return the absolute url
  98013. */
  98014. static GetAbsoluteUrl(url: string): string;
  98015. /**
  98016. * No log
  98017. */
  98018. static readonly NoneLogLevel: number;
  98019. /**
  98020. * Only message logs
  98021. */
  98022. static readonly MessageLogLevel: number;
  98023. /**
  98024. * Only warning logs
  98025. */
  98026. static readonly WarningLogLevel: number;
  98027. /**
  98028. * Only error logs
  98029. */
  98030. static readonly ErrorLogLevel: number;
  98031. /**
  98032. * All logs
  98033. */
  98034. static readonly AllLogLevel: number;
  98035. /**
  98036. * Gets a value indicating the number of loading errors
  98037. * @ignorenaming
  98038. */
  98039. static readonly errorsCount: number;
  98040. /**
  98041. * Callback called when a new log is added
  98042. */
  98043. static OnNewCacheEntry: (entry: string) => void;
  98044. /**
  98045. * Log a message to the console
  98046. * @param message defines the message to log
  98047. */
  98048. static Log(message: string): void;
  98049. /**
  98050. * Write a warning message to the console
  98051. * @param message defines the message to log
  98052. */
  98053. static Warn(message: string): void;
  98054. /**
  98055. * Write an error message to the console
  98056. * @param message defines the message to log
  98057. */
  98058. static Error(message: string): void;
  98059. /**
  98060. * Gets current log cache (list of logs)
  98061. */
  98062. static readonly LogCache: string;
  98063. /**
  98064. * Clears the log cache
  98065. */
  98066. static ClearLogCache(): void;
  98067. /**
  98068. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  98069. */
  98070. static LogLevels: number;
  98071. /**
  98072. * Checks if the window object exists
  98073. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  98074. */
  98075. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  98076. /**
  98077. * No performance log
  98078. */
  98079. static readonly PerformanceNoneLogLevel: number;
  98080. /**
  98081. * Use user marks to log performance
  98082. */
  98083. static readonly PerformanceUserMarkLogLevel: number;
  98084. /**
  98085. * Log performance to the console
  98086. */
  98087. static readonly PerformanceConsoleLogLevel: number;
  98088. private static _performance;
  98089. /**
  98090. * Sets the current performance log level
  98091. */
  98092. static PerformanceLogLevel: number;
  98093. private static _StartPerformanceCounterDisabled;
  98094. private static _EndPerformanceCounterDisabled;
  98095. private static _StartUserMark;
  98096. private static _EndUserMark;
  98097. private static _StartPerformanceConsole;
  98098. private static _EndPerformanceConsole;
  98099. /**
  98100. * Starts a performance counter
  98101. */
  98102. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98103. /**
  98104. * Ends a specific performance coutner
  98105. */
  98106. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98107. /**
  98108. * Gets either window.performance.now() if supported or Date.now() else
  98109. */
  98110. static readonly Now: number;
  98111. /**
  98112. * This method will return the name of the class used to create the instance of the given object.
  98113. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  98114. * @param object the object to get the class name from
  98115. * @param isType defines if the object is actually a type
  98116. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  98117. */
  98118. static GetClassName(object: any, isType?: boolean): string;
  98119. /**
  98120. * Gets the first element of an array satisfying a given predicate
  98121. * @param array defines the array to browse
  98122. * @param predicate defines the predicate to use
  98123. * @returns null if not found or the element
  98124. */
  98125. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  98126. /**
  98127. * This method will return the name of the full name of the class, including its owning module (if any).
  98128. * 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).
  98129. * @param object the object to get the class name from
  98130. * @param isType defines if the object is actually a type
  98131. * @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.
  98132. * @ignorenaming
  98133. */
  98134. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  98135. /**
  98136. * Returns a promise that resolves after the given amount of time.
  98137. * @param delay Number of milliseconds to delay
  98138. * @returns Promise that resolves after the given amount of time
  98139. */
  98140. static DelayAsync(delay: number): Promise<void>;
  98141. }
  98142. /**
  98143. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  98144. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  98145. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  98146. * @param name The name of the class, case should be preserved
  98147. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  98148. */
  98149. export function className(name: string, module?: string): (target: Object) => void;
  98150. /**
  98151. * An implementation of a loop for asynchronous functions.
  98152. */
  98153. export class AsyncLoop {
  98154. /**
  98155. * Defines the number of iterations for the loop
  98156. */
  98157. iterations: number;
  98158. /**
  98159. * Defines the current index of the loop.
  98160. */
  98161. index: number;
  98162. private _done;
  98163. private _fn;
  98164. private _successCallback;
  98165. /**
  98166. * Constructor.
  98167. * @param iterations the number of iterations.
  98168. * @param func the function to run each iteration
  98169. * @param successCallback the callback that will be called upon succesful execution
  98170. * @param offset starting offset.
  98171. */
  98172. constructor(
  98173. /**
  98174. * Defines the number of iterations for the loop
  98175. */
  98176. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  98177. /**
  98178. * Execute the next iteration. Must be called after the last iteration was finished.
  98179. */
  98180. executeNext(): void;
  98181. /**
  98182. * Break the loop and run the success callback.
  98183. */
  98184. breakLoop(): void;
  98185. /**
  98186. * Create and run an async loop.
  98187. * @param iterations the number of iterations.
  98188. * @param fn the function to run each iteration
  98189. * @param successCallback the callback that will be called upon succesful execution
  98190. * @param offset starting offset.
  98191. * @returns the created async loop object
  98192. */
  98193. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  98194. /**
  98195. * A for-loop that will run a given number of iterations synchronous and the rest async.
  98196. * @param iterations total number of iterations
  98197. * @param syncedIterations number of synchronous iterations in each async iteration.
  98198. * @param fn the function to call each iteration.
  98199. * @param callback a success call back that will be called when iterating stops.
  98200. * @param breakFunction a break condition (optional)
  98201. * @param timeout timeout settings for the setTimeout function. default - 0.
  98202. * @returns the created async loop object
  98203. */
  98204. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  98205. }
  98206. }
  98207. declare module BABYLON {
  98208. /**
  98209. * This class implement a typical dictionary using a string as key and the generic type T as value.
  98210. * The underlying implementation relies on an associative array to ensure the best performances.
  98211. * The value can be anything including 'null' but except 'undefined'
  98212. */
  98213. export class StringDictionary<T> {
  98214. /**
  98215. * This will clear this dictionary and copy the content from the 'source' one.
  98216. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  98217. * @param source the dictionary to take the content from and copy to this dictionary
  98218. */
  98219. copyFrom(source: StringDictionary<T>): void;
  98220. /**
  98221. * Get a value based from its key
  98222. * @param key the given key to get the matching value from
  98223. * @return the value if found, otherwise undefined is returned
  98224. */
  98225. get(key: string): T | undefined;
  98226. /**
  98227. * Get a value from its key or add it if it doesn't exist.
  98228. * This method will ensure you that a given key/data will be present in the dictionary.
  98229. * @param key the given key to get the matching value from
  98230. * @param factory the factory that will create the value if the key is not present in the dictionary.
  98231. * The factory will only be invoked if there's no data for the given key.
  98232. * @return the value corresponding to the key.
  98233. */
  98234. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  98235. /**
  98236. * Get a value from its key if present in the dictionary otherwise add it
  98237. * @param key the key to get the value from
  98238. * @param val if there's no such key/value pair in the dictionary add it with this value
  98239. * @return the value corresponding to the key
  98240. */
  98241. getOrAdd(key: string, val: T): T;
  98242. /**
  98243. * Check if there's a given key in the dictionary
  98244. * @param key the key to check for
  98245. * @return true if the key is present, false otherwise
  98246. */
  98247. contains(key: string): boolean;
  98248. /**
  98249. * Add a new key and its corresponding value
  98250. * @param key the key to add
  98251. * @param value the value corresponding to the key
  98252. * @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
  98253. */
  98254. add(key: string, value: T): boolean;
  98255. /**
  98256. * Update a specific value associated to a key
  98257. * @param key defines the key to use
  98258. * @param value defines the value to store
  98259. * @returns true if the value was updated (or false if the key was not found)
  98260. */
  98261. set(key: string, value: T): boolean;
  98262. /**
  98263. * Get the element of the given key and remove it from the dictionary
  98264. * @param key defines the key to search
  98265. * @returns the value associated with the key or null if not found
  98266. */
  98267. getAndRemove(key: string): Nullable<T>;
  98268. /**
  98269. * Remove a key/value from the dictionary.
  98270. * @param key the key to remove
  98271. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  98272. */
  98273. remove(key: string): boolean;
  98274. /**
  98275. * Clear the whole content of the dictionary
  98276. */
  98277. clear(): void;
  98278. /**
  98279. * Gets the current count
  98280. */
  98281. readonly count: number;
  98282. /**
  98283. * Execute a callback on each key/val of the dictionary.
  98284. * Note that you can remove any element in this dictionary in the callback implementation
  98285. * @param callback the callback to execute on a given key/value pair
  98286. */
  98287. forEach(callback: (key: string, val: T) => void): void;
  98288. /**
  98289. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  98290. * If the callback returns null or undefined the method will iterate to the next key/value pair
  98291. * Note that you can remove any element in this dictionary in the callback implementation
  98292. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  98293. * @returns the first item
  98294. */
  98295. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  98296. private _count;
  98297. private _data;
  98298. }
  98299. }
  98300. declare module BABYLON {
  98301. /** @hidden */
  98302. export interface ICollisionCoordinator {
  98303. createCollider(): Collider;
  98304. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98305. init(scene: Scene): void;
  98306. }
  98307. /** @hidden */
  98308. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  98309. private _scene;
  98310. private _scaledPosition;
  98311. private _scaledVelocity;
  98312. private _finalPosition;
  98313. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98314. createCollider(): Collider;
  98315. init(scene: Scene): void;
  98316. private _collideWithWorld;
  98317. }
  98318. }
  98319. declare module BABYLON {
  98320. /**
  98321. * Class used to manage all inputs for the scene.
  98322. */
  98323. export class InputManager {
  98324. /** The distance in pixel that you have to move to prevent some events */
  98325. static DragMovementThreshold: number;
  98326. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  98327. static LongPressDelay: number;
  98328. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  98329. static DoubleClickDelay: number;
  98330. /** If you need to check double click without raising a single click at first click, enable this flag */
  98331. static ExclusiveDoubleClickMode: boolean;
  98332. private _wheelEventName;
  98333. private _onPointerMove;
  98334. private _onPointerDown;
  98335. private _onPointerUp;
  98336. private _initClickEvent;
  98337. private _initActionManager;
  98338. private _delayedSimpleClick;
  98339. private _delayedSimpleClickTimeout;
  98340. private _previousDelayedSimpleClickTimeout;
  98341. private _meshPickProceed;
  98342. private _previousButtonPressed;
  98343. private _currentPickResult;
  98344. private _previousPickResult;
  98345. private _totalPointersPressed;
  98346. private _doubleClickOccured;
  98347. private _pointerOverMesh;
  98348. private _pickedDownMesh;
  98349. private _pickedUpMesh;
  98350. private _pointerX;
  98351. private _pointerY;
  98352. private _unTranslatedPointerX;
  98353. private _unTranslatedPointerY;
  98354. private _startingPointerPosition;
  98355. private _previousStartingPointerPosition;
  98356. private _startingPointerTime;
  98357. private _previousStartingPointerTime;
  98358. private _pointerCaptures;
  98359. private _onKeyDown;
  98360. private _onKeyUp;
  98361. private _onCanvasFocusObserver;
  98362. private _onCanvasBlurObserver;
  98363. private _scene;
  98364. /**
  98365. * Creates a new InputManager
  98366. * @param scene defines the hosting scene
  98367. */
  98368. constructor(scene: Scene);
  98369. /**
  98370. * Gets the mesh that is currently under the pointer
  98371. */
  98372. readonly meshUnderPointer: Nullable<AbstractMesh>;
  98373. /**
  98374. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  98375. */
  98376. readonly unTranslatedPointer: Vector2;
  98377. /**
  98378. * Gets or sets the current on-screen X position of the pointer
  98379. */
  98380. pointerX: number;
  98381. /**
  98382. * Gets or sets the current on-screen Y position of the pointer
  98383. */
  98384. pointerY: number;
  98385. private _updatePointerPosition;
  98386. private _processPointerMove;
  98387. private _setRayOnPointerInfo;
  98388. private _checkPrePointerObservable;
  98389. /**
  98390. * Use this method to simulate a pointer move on a mesh
  98391. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98392. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98393. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98394. */
  98395. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98396. /**
  98397. * Use this method to simulate a pointer down on a mesh
  98398. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98399. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98400. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98401. */
  98402. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98403. private _processPointerDown;
  98404. /** @hidden */
  98405. _isPointerSwiping(): boolean;
  98406. /**
  98407. * Use this method to simulate a pointer up on a mesh
  98408. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98409. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98410. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98411. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  98412. */
  98413. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  98414. private _processPointerUp;
  98415. /**
  98416. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  98417. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  98418. * @returns true if the pointer was captured
  98419. */
  98420. isPointerCaptured(pointerId?: number): boolean;
  98421. /**
  98422. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  98423. * @param attachUp defines if you want to attach events to pointerup
  98424. * @param attachDown defines if you want to attach events to pointerdown
  98425. * @param attachMove defines if you want to attach events to pointermove
  98426. */
  98427. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  98428. /**
  98429. * Detaches all event handlers
  98430. */
  98431. detachControl(): void;
  98432. /**
  98433. * Force the value of meshUnderPointer
  98434. * @param mesh defines the mesh to use
  98435. */
  98436. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  98437. /**
  98438. * Gets the mesh under the pointer
  98439. * @returns a Mesh or null if no mesh is under the pointer
  98440. */
  98441. getPointerOverMesh(): Nullable<AbstractMesh>;
  98442. }
  98443. }
  98444. declare module BABYLON {
  98445. /**
  98446. * Helper class used to generate session unique ID
  98447. */
  98448. export class UniqueIdGenerator {
  98449. private static _UniqueIdCounter;
  98450. /**
  98451. * Gets an unique (relatively to the current scene) Id
  98452. */
  98453. static readonly UniqueId: number;
  98454. }
  98455. }
  98456. declare module BABYLON {
  98457. /**
  98458. * This class defines the direct association between an animation and a target
  98459. */
  98460. export class TargetedAnimation {
  98461. /**
  98462. * Animation to perform
  98463. */
  98464. animation: Animation;
  98465. /**
  98466. * Target to animate
  98467. */
  98468. target: any;
  98469. /**
  98470. * Serialize the object
  98471. * @returns the JSON object representing the current entity
  98472. */
  98473. serialize(): any;
  98474. }
  98475. /**
  98476. * Use this class to create coordinated animations on multiple targets
  98477. */
  98478. export class AnimationGroup implements IDisposable {
  98479. /** The name of the animation group */
  98480. name: string;
  98481. private _scene;
  98482. private _targetedAnimations;
  98483. private _animatables;
  98484. private _from;
  98485. private _to;
  98486. private _isStarted;
  98487. private _isPaused;
  98488. private _speedRatio;
  98489. private _loopAnimation;
  98490. /**
  98491. * Gets or sets the unique id of the node
  98492. */
  98493. uniqueId: number;
  98494. /**
  98495. * This observable will notify when one animation have ended
  98496. */
  98497. onAnimationEndObservable: Observable<TargetedAnimation>;
  98498. /**
  98499. * Observer raised when one animation loops
  98500. */
  98501. onAnimationLoopObservable: Observable<TargetedAnimation>;
  98502. /**
  98503. * This observable will notify when all animations have ended.
  98504. */
  98505. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  98506. /**
  98507. * This observable will notify when all animations have paused.
  98508. */
  98509. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  98510. /**
  98511. * This observable will notify when all animations are playing.
  98512. */
  98513. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  98514. /**
  98515. * Gets the first frame
  98516. */
  98517. readonly from: number;
  98518. /**
  98519. * Gets the last frame
  98520. */
  98521. readonly to: number;
  98522. /**
  98523. * Define if the animations are started
  98524. */
  98525. readonly isStarted: boolean;
  98526. /**
  98527. * Gets a value indicating that the current group is playing
  98528. */
  98529. readonly isPlaying: boolean;
  98530. /**
  98531. * Gets or sets the speed ratio to use for all animations
  98532. */
  98533. /**
  98534. * Gets or sets the speed ratio to use for all animations
  98535. */
  98536. speedRatio: number;
  98537. /**
  98538. * Gets or sets if all animations should loop or not
  98539. */
  98540. loopAnimation: boolean;
  98541. /**
  98542. * Gets the targeted animations for this animation group
  98543. */
  98544. readonly targetedAnimations: Array<TargetedAnimation>;
  98545. /**
  98546. * returning the list of animatables controlled by this animation group.
  98547. */
  98548. readonly animatables: Array<Animatable>;
  98549. /**
  98550. * Instantiates a new Animation Group.
  98551. * This helps managing several animations at once.
  98552. * @see http://doc.babylonjs.com/how_to/group
  98553. * @param name Defines the name of the group
  98554. * @param scene Defines the scene the group belongs to
  98555. */
  98556. constructor(
  98557. /** The name of the animation group */
  98558. name: string, scene?: Nullable<Scene>);
  98559. /**
  98560. * Add an animation (with its target) in the group
  98561. * @param animation defines the animation we want to add
  98562. * @param target defines the target of the animation
  98563. * @returns the TargetedAnimation object
  98564. */
  98565. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  98566. /**
  98567. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  98568. * It can add constant keys at begin or end
  98569. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  98570. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  98571. * @returns the animation group
  98572. */
  98573. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  98574. /**
  98575. * Start all animations on given targets
  98576. * @param loop defines if animations must loop
  98577. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  98578. * @param from defines the from key (optional)
  98579. * @param to defines the to key (optional)
  98580. * @returns the current animation group
  98581. */
  98582. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  98583. /**
  98584. * Pause all animations
  98585. * @returns the animation group
  98586. */
  98587. pause(): AnimationGroup;
  98588. /**
  98589. * Play all animations to initial state
  98590. * This function will start() the animations if they were not started or will restart() them if they were paused
  98591. * @param loop defines if animations must loop
  98592. * @returns the animation group
  98593. */
  98594. play(loop?: boolean): AnimationGroup;
  98595. /**
  98596. * Reset all animations to initial state
  98597. * @returns the animation group
  98598. */
  98599. reset(): AnimationGroup;
  98600. /**
  98601. * Restart animations from key 0
  98602. * @returns the animation group
  98603. */
  98604. restart(): AnimationGroup;
  98605. /**
  98606. * Stop all animations
  98607. * @returns the animation group
  98608. */
  98609. stop(): AnimationGroup;
  98610. /**
  98611. * Set animation weight for all animatables
  98612. * @param weight defines the weight to use
  98613. * @return the animationGroup
  98614. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98615. */
  98616. setWeightForAllAnimatables(weight: number): AnimationGroup;
  98617. /**
  98618. * Synchronize and normalize all animatables with a source animatable
  98619. * @param root defines the root animatable to synchronize with
  98620. * @return the animationGroup
  98621. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98622. */
  98623. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  98624. /**
  98625. * Goes to a specific frame in this animation group
  98626. * @param frame the frame number to go to
  98627. * @return the animationGroup
  98628. */
  98629. goToFrame(frame: number): AnimationGroup;
  98630. /**
  98631. * Dispose all associated resources
  98632. */
  98633. dispose(): void;
  98634. private _checkAnimationGroupEnded;
  98635. /**
  98636. * Clone the current animation group and returns a copy
  98637. * @param newName defines the name of the new group
  98638. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  98639. * @returns the new aniamtion group
  98640. */
  98641. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  98642. /**
  98643. * Serializes the animationGroup to an object
  98644. * @returns Serialized object
  98645. */
  98646. serialize(): any;
  98647. /**
  98648. * Returns a new AnimationGroup object parsed from the source provided.
  98649. * @param parsedAnimationGroup defines the source
  98650. * @param scene defines the scene that will receive the animationGroup
  98651. * @returns a new AnimationGroup
  98652. */
  98653. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  98654. /**
  98655. * Returns the string "AnimationGroup"
  98656. * @returns "AnimationGroup"
  98657. */
  98658. getClassName(): string;
  98659. /**
  98660. * Creates a detailled string about the object
  98661. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  98662. * @returns a string representing the object
  98663. */
  98664. toString(fullDetails?: boolean): string;
  98665. }
  98666. }
  98667. declare module BABYLON {
  98668. /**
  98669. * Define an interface for all classes that will hold resources
  98670. */
  98671. export interface IDisposable {
  98672. /**
  98673. * Releases all held resources
  98674. */
  98675. dispose(): void;
  98676. }
  98677. /** Interface defining initialization parameters for Scene class */
  98678. export interface SceneOptions {
  98679. /**
  98680. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  98681. * It will improve performance when the number of geometries becomes important.
  98682. */
  98683. useGeometryUniqueIdsMap?: boolean;
  98684. /**
  98685. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  98686. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98687. */
  98688. useMaterialMeshMap?: boolean;
  98689. /**
  98690. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  98691. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98692. */
  98693. useClonedMeshhMap?: boolean;
  98694. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  98695. virtual?: boolean;
  98696. }
  98697. /**
  98698. * Represents a scene to be rendered by the engine.
  98699. * @see http://doc.babylonjs.com/features/scene
  98700. */
  98701. export class Scene extends AbstractScene implements IAnimatable {
  98702. /** The fog is deactivated */
  98703. static readonly FOGMODE_NONE: number;
  98704. /** The fog density is following an exponential function */
  98705. static readonly FOGMODE_EXP: number;
  98706. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  98707. static readonly FOGMODE_EXP2: number;
  98708. /** The fog density is following a linear function. */
  98709. static readonly FOGMODE_LINEAR: number;
  98710. /**
  98711. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  98712. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98713. */
  98714. static MinDeltaTime: number;
  98715. /**
  98716. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  98717. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98718. */
  98719. static MaxDeltaTime: number;
  98720. /**
  98721. * Factory used to create the default material.
  98722. * @param name The name of the material to create
  98723. * @param scene The scene to create the material for
  98724. * @returns The default material
  98725. */
  98726. static DefaultMaterialFactory(scene: Scene): Material;
  98727. /**
  98728. * Factory used to create the a collision coordinator.
  98729. * @returns The collision coordinator
  98730. */
  98731. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  98732. /** @hidden */
  98733. _inputManager: InputManager;
  98734. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  98735. cameraToUseForPointers: Nullable<Camera>;
  98736. /** @hidden */
  98737. readonly _isScene: boolean;
  98738. /**
  98739. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  98740. */
  98741. autoClear: boolean;
  98742. /**
  98743. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  98744. */
  98745. autoClearDepthAndStencil: boolean;
  98746. /**
  98747. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  98748. */
  98749. clearColor: Color4;
  98750. /**
  98751. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  98752. */
  98753. ambientColor: Color3;
  98754. /**
  98755. * This is use to store the default BRDF lookup for PBR materials in your scene.
  98756. * It should only be one of the following (if not the default embedded one):
  98757. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  98758. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  98759. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  98760. * The material properties need to be setup according to the type of texture in use.
  98761. */
  98762. environmentBRDFTexture: BaseTexture;
  98763. /** @hidden */
  98764. protected _environmentTexture: Nullable<BaseTexture>;
  98765. /**
  98766. * Texture used in all pbr material as the reflection texture.
  98767. * As in the majority of the scene they are the same (exception for multi room and so on),
  98768. * this is easier to reference from here than from all the materials.
  98769. */
  98770. /**
  98771. * Texture used in all pbr material as the reflection texture.
  98772. * As in the majority of the scene they are the same (exception for multi room and so on),
  98773. * this is easier to set here than in all the materials.
  98774. */
  98775. environmentTexture: Nullable<BaseTexture>;
  98776. /** @hidden */
  98777. protected _environmentIntensity: number;
  98778. /**
  98779. * Intensity of the environment in all pbr material.
  98780. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98781. * As in the majority of the scene they are the same (exception for multi room and so on),
  98782. * this is easier to reference from here than from all the materials.
  98783. */
  98784. /**
  98785. * Intensity of the environment in all pbr material.
  98786. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98787. * As in the majority of the scene they are the same (exception for multi room and so on),
  98788. * this is easier to set here than in all the materials.
  98789. */
  98790. environmentIntensity: number;
  98791. /** @hidden */
  98792. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98793. /**
  98794. * Default image processing configuration used either in the rendering
  98795. * Forward main pass or through the imageProcessingPostProcess if present.
  98796. * As in the majority of the scene they are the same (exception for multi camera),
  98797. * this is easier to reference from here than from all the materials and post process.
  98798. *
  98799. * No setter as we it is a shared configuration, you can set the values instead.
  98800. */
  98801. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  98802. private _forceWireframe;
  98803. /**
  98804. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  98805. */
  98806. forceWireframe: boolean;
  98807. private _forcePointsCloud;
  98808. /**
  98809. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  98810. */
  98811. forcePointsCloud: boolean;
  98812. /**
  98813. * Gets or sets the active clipplane 1
  98814. */
  98815. clipPlane: Nullable<Plane>;
  98816. /**
  98817. * Gets or sets the active clipplane 2
  98818. */
  98819. clipPlane2: Nullable<Plane>;
  98820. /**
  98821. * Gets or sets the active clipplane 3
  98822. */
  98823. clipPlane3: Nullable<Plane>;
  98824. /**
  98825. * Gets or sets the active clipplane 4
  98826. */
  98827. clipPlane4: Nullable<Plane>;
  98828. /**
  98829. * Gets or sets a boolean indicating if animations are enabled
  98830. */
  98831. animationsEnabled: boolean;
  98832. private _animationPropertiesOverride;
  98833. /**
  98834. * Gets or sets the animation properties override
  98835. */
  98836. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  98837. /**
  98838. * Gets or sets a boolean indicating if a constant deltatime has to be used
  98839. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  98840. */
  98841. useConstantAnimationDeltaTime: boolean;
  98842. /**
  98843. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  98844. * Please note that it requires to run a ray cast through the scene on every frame
  98845. */
  98846. constantlyUpdateMeshUnderPointer: boolean;
  98847. /**
  98848. * Defines the HTML cursor to use when hovering over interactive elements
  98849. */
  98850. hoverCursor: string;
  98851. /**
  98852. * Defines the HTML default cursor to use (empty by default)
  98853. */
  98854. defaultCursor: string;
  98855. /**
  98856. * This is used to call preventDefault() on pointer down
  98857. * in order to block unwanted artifacts like system double clicks
  98858. */
  98859. preventDefaultOnPointerDown: boolean;
  98860. /**
  98861. * This is used to call preventDefault() on pointer up
  98862. * in order to block unwanted artifacts like system double clicks
  98863. */
  98864. preventDefaultOnPointerUp: boolean;
  98865. /**
  98866. * Gets or sets user defined metadata
  98867. */
  98868. metadata: any;
  98869. /**
  98870. * For internal use only. Please do not use.
  98871. */
  98872. reservedDataStore: any;
  98873. /**
  98874. * Gets the name of the plugin used to load this scene (null by default)
  98875. */
  98876. loadingPluginName: string;
  98877. /**
  98878. * Use this array to add regular expressions used to disable offline support for specific urls
  98879. */
  98880. disableOfflineSupportExceptionRules: RegExp[];
  98881. /**
  98882. * An event triggered when the scene is disposed.
  98883. */
  98884. onDisposeObservable: Observable<Scene>;
  98885. private _onDisposeObserver;
  98886. /** Sets a function to be executed when this scene is disposed. */
  98887. onDispose: () => void;
  98888. /**
  98889. * An event triggered before rendering the scene (right after animations and physics)
  98890. */
  98891. onBeforeRenderObservable: Observable<Scene>;
  98892. private _onBeforeRenderObserver;
  98893. /** Sets a function to be executed before rendering this scene */
  98894. beforeRender: Nullable<() => void>;
  98895. /**
  98896. * An event triggered after rendering the scene
  98897. */
  98898. onAfterRenderObservable: Observable<Scene>;
  98899. /**
  98900. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  98901. */
  98902. onAfterRenderCameraObservable: Observable<Camera>;
  98903. private _onAfterRenderObserver;
  98904. /** Sets a function to be executed after rendering this scene */
  98905. afterRender: Nullable<() => void>;
  98906. /**
  98907. * An event triggered before animating the scene
  98908. */
  98909. onBeforeAnimationsObservable: Observable<Scene>;
  98910. /**
  98911. * An event triggered after animations processing
  98912. */
  98913. onAfterAnimationsObservable: Observable<Scene>;
  98914. /**
  98915. * An event triggered before draw calls are ready to be sent
  98916. */
  98917. onBeforeDrawPhaseObservable: Observable<Scene>;
  98918. /**
  98919. * An event triggered after draw calls have been sent
  98920. */
  98921. onAfterDrawPhaseObservable: Observable<Scene>;
  98922. /**
  98923. * An event triggered when the scene is ready
  98924. */
  98925. onReadyObservable: Observable<Scene>;
  98926. /**
  98927. * An event triggered before rendering a camera
  98928. */
  98929. onBeforeCameraRenderObservable: Observable<Camera>;
  98930. private _onBeforeCameraRenderObserver;
  98931. /** Sets a function to be executed before rendering a camera*/
  98932. beforeCameraRender: () => void;
  98933. /**
  98934. * An event triggered after rendering a camera
  98935. */
  98936. onAfterCameraRenderObservable: Observable<Camera>;
  98937. private _onAfterCameraRenderObserver;
  98938. /** Sets a function to be executed after rendering a camera*/
  98939. afterCameraRender: () => void;
  98940. /**
  98941. * An event triggered when active meshes evaluation is about to start
  98942. */
  98943. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  98944. /**
  98945. * An event triggered when active meshes evaluation is done
  98946. */
  98947. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  98948. /**
  98949. * An event triggered when particles rendering is about to start
  98950. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98951. */
  98952. onBeforeParticlesRenderingObservable: Observable<Scene>;
  98953. /**
  98954. * An event triggered when particles rendering is done
  98955. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98956. */
  98957. onAfterParticlesRenderingObservable: Observable<Scene>;
  98958. /**
  98959. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  98960. */
  98961. onDataLoadedObservable: Observable<Scene>;
  98962. /**
  98963. * An event triggered when a camera is created
  98964. */
  98965. onNewCameraAddedObservable: Observable<Camera>;
  98966. /**
  98967. * An event triggered when a camera is removed
  98968. */
  98969. onCameraRemovedObservable: Observable<Camera>;
  98970. /**
  98971. * An event triggered when a light is created
  98972. */
  98973. onNewLightAddedObservable: Observable<Light>;
  98974. /**
  98975. * An event triggered when a light is removed
  98976. */
  98977. onLightRemovedObservable: Observable<Light>;
  98978. /**
  98979. * An event triggered when a geometry is created
  98980. */
  98981. onNewGeometryAddedObservable: Observable<Geometry>;
  98982. /**
  98983. * An event triggered when a geometry is removed
  98984. */
  98985. onGeometryRemovedObservable: Observable<Geometry>;
  98986. /**
  98987. * An event triggered when a transform node is created
  98988. */
  98989. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  98990. /**
  98991. * An event triggered when a transform node is removed
  98992. */
  98993. onTransformNodeRemovedObservable: Observable<TransformNode>;
  98994. /**
  98995. * An event triggered when a mesh is created
  98996. */
  98997. onNewMeshAddedObservable: Observable<AbstractMesh>;
  98998. /**
  98999. * An event triggered when a mesh is removed
  99000. */
  99001. onMeshRemovedObservable: Observable<AbstractMesh>;
  99002. /**
  99003. * An event triggered when a skeleton is created
  99004. */
  99005. onNewSkeletonAddedObservable: Observable<Skeleton>;
  99006. /**
  99007. * An event triggered when a skeleton is removed
  99008. */
  99009. onSkeletonRemovedObservable: Observable<Skeleton>;
  99010. /**
  99011. * An event triggered when a material is created
  99012. */
  99013. onNewMaterialAddedObservable: Observable<Material>;
  99014. /**
  99015. * An event triggered when a material is removed
  99016. */
  99017. onMaterialRemovedObservable: Observable<Material>;
  99018. /**
  99019. * An event triggered when a texture is created
  99020. */
  99021. onNewTextureAddedObservable: Observable<BaseTexture>;
  99022. /**
  99023. * An event triggered when a texture is removed
  99024. */
  99025. onTextureRemovedObservable: Observable<BaseTexture>;
  99026. /**
  99027. * An event triggered when render targets are about to be rendered
  99028. * Can happen multiple times per frame.
  99029. */
  99030. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  99031. /**
  99032. * An event triggered when render targets were rendered.
  99033. * Can happen multiple times per frame.
  99034. */
  99035. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  99036. /**
  99037. * An event triggered before calculating deterministic simulation step
  99038. */
  99039. onBeforeStepObservable: Observable<Scene>;
  99040. /**
  99041. * An event triggered after calculating deterministic simulation step
  99042. */
  99043. onAfterStepObservable: Observable<Scene>;
  99044. /**
  99045. * An event triggered when the activeCamera property is updated
  99046. */
  99047. onActiveCameraChanged: Observable<Scene>;
  99048. /**
  99049. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  99050. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  99051. * 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)
  99052. */
  99053. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  99054. /**
  99055. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  99056. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  99057. * 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)
  99058. */
  99059. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  99060. /**
  99061. * This Observable will when a mesh has been imported into the scene.
  99062. */
  99063. onMeshImportedObservable: Observable<AbstractMesh>;
  99064. /**
  99065. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  99066. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  99067. */
  99068. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  99069. /** @hidden */
  99070. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  99071. /**
  99072. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  99073. */
  99074. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  99075. /**
  99076. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  99077. */
  99078. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  99079. /**
  99080. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  99081. */
  99082. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  99083. /** Callback called when a pointer move is detected */
  99084. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  99085. /** Callback called when a pointer down is detected */
  99086. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  99087. /** Callback called when a pointer up is detected */
  99088. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  99089. /** Callback called when a pointer pick is detected */
  99090. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  99091. /**
  99092. * 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).
  99093. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  99094. */
  99095. onPrePointerObservable: Observable<PointerInfoPre>;
  99096. /**
  99097. * Observable event triggered each time an input event is received from the rendering canvas
  99098. */
  99099. onPointerObservable: Observable<PointerInfo>;
  99100. /**
  99101. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  99102. */
  99103. readonly unTranslatedPointer: Vector2;
  99104. /**
  99105. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  99106. */
  99107. static DragMovementThreshold: number;
  99108. /**
  99109. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  99110. */
  99111. static LongPressDelay: number;
  99112. /**
  99113. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  99114. */
  99115. static DoubleClickDelay: number;
  99116. /** If you need to check double click without raising a single click at first click, enable this flag */
  99117. static ExclusiveDoubleClickMode: boolean;
  99118. /** @hidden */
  99119. _mirroredCameraPosition: Nullable<Vector3>;
  99120. /**
  99121. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  99122. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  99123. */
  99124. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  99125. /**
  99126. * Observable event triggered each time an keyboard event is received from the hosting window
  99127. */
  99128. onKeyboardObservable: Observable<KeyboardInfo>;
  99129. private _useRightHandedSystem;
  99130. /**
  99131. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  99132. */
  99133. useRightHandedSystem: boolean;
  99134. private _timeAccumulator;
  99135. private _currentStepId;
  99136. private _currentInternalStep;
  99137. /**
  99138. * Sets the step Id used by deterministic lock step
  99139. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99140. * @param newStepId defines the step Id
  99141. */
  99142. setStepId(newStepId: number): void;
  99143. /**
  99144. * Gets the step Id used by deterministic lock step
  99145. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99146. * @returns the step Id
  99147. */
  99148. getStepId(): number;
  99149. /**
  99150. * Gets the internal step used by deterministic lock step
  99151. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99152. * @returns the internal step
  99153. */
  99154. getInternalStep(): number;
  99155. private _fogEnabled;
  99156. /**
  99157. * Gets or sets a boolean indicating if fog is enabled on this scene
  99158. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99159. * (Default is true)
  99160. */
  99161. fogEnabled: boolean;
  99162. private _fogMode;
  99163. /**
  99164. * Gets or sets the fog mode to use
  99165. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99166. * | mode | value |
  99167. * | --- | --- |
  99168. * | FOGMODE_NONE | 0 |
  99169. * | FOGMODE_EXP | 1 |
  99170. * | FOGMODE_EXP2 | 2 |
  99171. * | FOGMODE_LINEAR | 3 |
  99172. */
  99173. fogMode: number;
  99174. /**
  99175. * Gets or sets the fog color to use
  99176. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99177. * (Default is Color3(0.2, 0.2, 0.3))
  99178. */
  99179. fogColor: Color3;
  99180. /**
  99181. * Gets or sets the fog density to use
  99182. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99183. * (Default is 0.1)
  99184. */
  99185. fogDensity: number;
  99186. /**
  99187. * Gets or sets the fog start distance to use
  99188. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99189. * (Default is 0)
  99190. */
  99191. fogStart: number;
  99192. /**
  99193. * Gets or sets the fog end distance to use
  99194. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99195. * (Default is 1000)
  99196. */
  99197. fogEnd: number;
  99198. private _shadowsEnabled;
  99199. /**
  99200. * Gets or sets a boolean indicating if shadows are enabled on this scene
  99201. */
  99202. shadowsEnabled: boolean;
  99203. private _lightsEnabled;
  99204. /**
  99205. * Gets or sets a boolean indicating if lights are enabled on this scene
  99206. */
  99207. lightsEnabled: boolean;
  99208. /** All of the active cameras added to this scene. */
  99209. activeCameras: Camera[];
  99210. /** @hidden */
  99211. _activeCamera: Nullable<Camera>;
  99212. /** Gets or sets the current active camera */
  99213. activeCamera: Nullable<Camera>;
  99214. private _defaultMaterial;
  99215. /** The default material used on meshes when no material is affected */
  99216. /** The default material used on meshes when no material is affected */
  99217. defaultMaterial: Material;
  99218. private _texturesEnabled;
  99219. /**
  99220. * Gets or sets a boolean indicating if textures are enabled on this scene
  99221. */
  99222. texturesEnabled: boolean;
  99223. /**
  99224. * Gets or sets a boolean indicating if particles are enabled on this scene
  99225. */
  99226. particlesEnabled: boolean;
  99227. /**
  99228. * Gets or sets a boolean indicating if sprites are enabled on this scene
  99229. */
  99230. spritesEnabled: boolean;
  99231. private _skeletonsEnabled;
  99232. /**
  99233. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  99234. */
  99235. skeletonsEnabled: boolean;
  99236. /**
  99237. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  99238. */
  99239. lensFlaresEnabled: boolean;
  99240. /**
  99241. * Gets or sets a boolean indicating if collisions are enabled on this scene
  99242. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99243. */
  99244. collisionsEnabled: boolean;
  99245. private _collisionCoordinator;
  99246. /** @hidden */
  99247. readonly collisionCoordinator: ICollisionCoordinator;
  99248. /**
  99249. * Defines the gravity applied to this scene (used only for collisions)
  99250. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99251. */
  99252. gravity: Vector3;
  99253. /**
  99254. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  99255. */
  99256. postProcessesEnabled: boolean;
  99257. /**
  99258. * The list of postprocesses added to the scene
  99259. */
  99260. postProcesses: PostProcess[];
  99261. /**
  99262. * Gets the current postprocess manager
  99263. */
  99264. postProcessManager: PostProcessManager;
  99265. /**
  99266. * Gets or sets a boolean indicating if render targets are enabled on this scene
  99267. */
  99268. renderTargetsEnabled: boolean;
  99269. /**
  99270. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  99271. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  99272. */
  99273. dumpNextRenderTargets: boolean;
  99274. /**
  99275. * The list of user defined render targets added to the scene
  99276. */
  99277. customRenderTargets: RenderTargetTexture[];
  99278. /**
  99279. * Defines if texture loading must be delayed
  99280. * If true, textures will only be loaded when they need to be rendered
  99281. */
  99282. useDelayedTextureLoading: boolean;
  99283. /**
  99284. * Gets the list of meshes imported to the scene through SceneLoader
  99285. */
  99286. importedMeshesFiles: String[];
  99287. /**
  99288. * Gets or sets a boolean indicating if probes are enabled on this scene
  99289. */
  99290. probesEnabled: boolean;
  99291. /**
  99292. * Gets or sets the current offline provider to use to store scene data
  99293. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  99294. */
  99295. offlineProvider: IOfflineProvider;
  99296. /**
  99297. * Gets or sets the action manager associated with the scene
  99298. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99299. */
  99300. actionManager: AbstractActionManager;
  99301. private _meshesForIntersections;
  99302. /**
  99303. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  99304. */
  99305. proceduralTexturesEnabled: boolean;
  99306. private _engine;
  99307. private _totalVertices;
  99308. /** @hidden */
  99309. _activeIndices: PerfCounter;
  99310. /** @hidden */
  99311. _activeParticles: PerfCounter;
  99312. /** @hidden */
  99313. _activeBones: PerfCounter;
  99314. private _animationRatio;
  99315. /** @hidden */
  99316. _animationTimeLast: number;
  99317. /** @hidden */
  99318. _animationTime: number;
  99319. /**
  99320. * Gets or sets a general scale for animation speed
  99321. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  99322. */
  99323. animationTimeScale: number;
  99324. /** @hidden */
  99325. _cachedMaterial: Nullable<Material>;
  99326. /** @hidden */
  99327. _cachedEffect: Nullable<Effect>;
  99328. /** @hidden */
  99329. _cachedVisibility: Nullable<number>;
  99330. private _renderId;
  99331. private _frameId;
  99332. private _executeWhenReadyTimeoutId;
  99333. private _intermediateRendering;
  99334. private _viewUpdateFlag;
  99335. private _projectionUpdateFlag;
  99336. /** @hidden */
  99337. _toBeDisposed: Nullable<IDisposable>[];
  99338. private _activeRequests;
  99339. /** @hidden */
  99340. _pendingData: any[];
  99341. private _isDisposed;
  99342. /**
  99343. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  99344. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  99345. */
  99346. dispatchAllSubMeshesOfActiveMeshes: boolean;
  99347. private _activeMeshes;
  99348. private _processedMaterials;
  99349. private _renderTargets;
  99350. /** @hidden */
  99351. _activeParticleSystems: SmartArray<IParticleSystem>;
  99352. private _activeSkeletons;
  99353. private _softwareSkinnedMeshes;
  99354. private _renderingManager;
  99355. /** @hidden */
  99356. _activeAnimatables: Animatable[];
  99357. private _transformMatrix;
  99358. private _sceneUbo;
  99359. /** @hidden */
  99360. _viewMatrix: Matrix;
  99361. private _projectionMatrix;
  99362. /** @hidden */
  99363. _forcedViewPosition: Nullable<Vector3>;
  99364. /** @hidden */
  99365. _frustumPlanes: Plane[];
  99366. /**
  99367. * Gets the list of frustum planes (built from the active camera)
  99368. */
  99369. readonly frustumPlanes: Plane[];
  99370. /**
  99371. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  99372. * This is useful if there are more lights that the maximum simulteanous authorized
  99373. */
  99374. requireLightSorting: boolean;
  99375. /** @hidden */
  99376. readonly useMaterialMeshMap: boolean;
  99377. /** @hidden */
  99378. readonly useClonedMeshhMap: boolean;
  99379. private _externalData;
  99380. private _uid;
  99381. /**
  99382. * @hidden
  99383. * Backing store of defined scene components.
  99384. */
  99385. _components: ISceneComponent[];
  99386. /**
  99387. * @hidden
  99388. * Backing store of defined scene components.
  99389. */
  99390. _serializableComponents: ISceneSerializableComponent[];
  99391. /**
  99392. * List of components to register on the next registration step.
  99393. */
  99394. private _transientComponents;
  99395. /**
  99396. * Registers the transient components if needed.
  99397. */
  99398. private _registerTransientComponents;
  99399. /**
  99400. * @hidden
  99401. * Add a component to the scene.
  99402. * Note that the ccomponent could be registered on th next frame if this is called after
  99403. * the register component stage.
  99404. * @param component Defines the component to add to the scene
  99405. */
  99406. _addComponent(component: ISceneComponent): void;
  99407. /**
  99408. * @hidden
  99409. * Gets a component from the scene.
  99410. * @param name defines the name of the component to retrieve
  99411. * @returns the component or null if not present
  99412. */
  99413. _getComponent(name: string): Nullable<ISceneComponent>;
  99414. /**
  99415. * @hidden
  99416. * Defines the actions happening before camera updates.
  99417. */
  99418. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  99419. /**
  99420. * @hidden
  99421. * Defines the actions happening before clear the canvas.
  99422. */
  99423. _beforeClearStage: Stage<SimpleStageAction>;
  99424. /**
  99425. * @hidden
  99426. * Defines the actions when collecting render targets for the frame.
  99427. */
  99428. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99429. /**
  99430. * @hidden
  99431. * Defines the actions happening for one camera in the frame.
  99432. */
  99433. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99434. /**
  99435. * @hidden
  99436. * Defines the actions happening during the per mesh ready checks.
  99437. */
  99438. _isReadyForMeshStage: Stage<MeshStageAction>;
  99439. /**
  99440. * @hidden
  99441. * Defines the actions happening before evaluate active mesh checks.
  99442. */
  99443. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  99444. /**
  99445. * @hidden
  99446. * Defines the actions happening during the evaluate sub mesh checks.
  99447. */
  99448. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  99449. /**
  99450. * @hidden
  99451. * Defines the actions happening during the active mesh stage.
  99452. */
  99453. _activeMeshStage: Stage<ActiveMeshStageAction>;
  99454. /**
  99455. * @hidden
  99456. * Defines the actions happening during the per camera render target step.
  99457. */
  99458. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  99459. /**
  99460. * @hidden
  99461. * Defines the actions happening just before the active camera is drawing.
  99462. */
  99463. _beforeCameraDrawStage: Stage<CameraStageAction>;
  99464. /**
  99465. * @hidden
  99466. * Defines the actions happening just before a render target is drawing.
  99467. */
  99468. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99469. /**
  99470. * @hidden
  99471. * Defines the actions happening just before a rendering group is drawing.
  99472. */
  99473. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99474. /**
  99475. * @hidden
  99476. * Defines the actions happening just before a mesh is drawing.
  99477. */
  99478. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99479. /**
  99480. * @hidden
  99481. * Defines the actions happening just after a mesh has been drawn.
  99482. */
  99483. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99484. /**
  99485. * @hidden
  99486. * Defines the actions happening just after a rendering group has been drawn.
  99487. */
  99488. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99489. /**
  99490. * @hidden
  99491. * Defines the actions happening just after the active camera has been drawn.
  99492. */
  99493. _afterCameraDrawStage: Stage<CameraStageAction>;
  99494. /**
  99495. * @hidden
  99496. * Defines the actions happening just after a render target has been drawn.
  99497. */
  99498. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99499. /**
  99500. * @hidden
  99501. * Defines the actions happening just after rendering all cameras and computing intersections.
  99502. */
  99503. _afterRenderStage: Stage<SimpleStageAction>;
  99504. /**
  99505. * @hidden
  99506. * Defines the actions happening when a pointer move event happens.
  99507. */
  99508. _pointerMoveStage: Stage<PointerMoveStageAction>;
  99509. /**
  99510. * @hidden
  99511. * Defines the actions happening when a pointer down event happens.
  99512. */
  99513. _pointerDownStage: Stage<PointerUpDownStageAction>;
  99514. /**
  99515. * @hidden
  99516. * Defines the actions happening when a pointer up event happens.
  99517. */
  99518. _pointerUpStage: Stage<PointerUpDownStageAction>;
  99519. /**
  99520. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  99521. */
  99522. private geometriesByUniqueId;
  99523. /**
  99524. * Creates a new Scene
  99525. * @param engine defines the engine to use to render this scene
  99526. * @param options defines the scene options
  99527. */
  99528. constructor(engine: Engine, options?: SceneOptions);
  99529. /**
  99530. * Gets a string idenfifying the name of the class
  99531. * @returns "Scene" string
  99532. */
  99533. getClassName(): string;
  99534. private _defaultMeshCandidates;
  99535. /**
  99536. * @hidden
  99537. */
  99538. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99539. private _defaultSubMeshCandidates;
  99540. /**
  99541. * @hidden
  99542. */
  99543. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99544. /**
  99545. * Sets the default candidate providers for the scene.
  99546. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  99547. * and getCollidingSubMeshCandidates to their default function
  99548. */
  99549. setDefaultCandidateProviders(): void;
  99550. /**
  99551. * Gets the mesh that is currently under the pointer
  99552. */
  99553. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99554. /**
  99555. * Gets or sets the current on-screen X position of the pointer
  99556. */
  99557. pointerX: number;
  99558. /**
  99559. * Gets or sets the current on-screen Y position of the pointer
  99560. */
  99561. pointerY: number;
  99562. /**
  99563. * Gets the cached material (ie. the latest rendered one)
  99564. * @returns the cached material
  99565. */
  99566. getCachedMaterial(): Nullable<Material>;
  99567. /**
  99568. * Gets the cached effect (ie. the latest rendered one)
  99569. * @returns the cached effect
  99570. */
  99571. getCachedEffect(): Nullable<Effect>;
  99572. /**
  99573. * Gets the cached visibility state (ie. the latest rendered one)
  99574. * @returns the cached visibility state
  99575. */
  99576. getCachedVisibility(): Nullable<number>;
  99577. /**
  99578. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  99579. * @param material defines the current material
  99580. * @param effect defines the current effect
  99581. * @param visibility defines the current visibility state
  99582. * @returns true if one parameter is not cached
  99583. */
  99584. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  99585. /**
  99586. * Gets the engine associated with the scene
  99587. * @returns an Engine
  99588. */
  99589. getEngine(): Engine;
  99590. /**
  99591. * Gets the total number of vertices rendered per frame
  99592. * @returns the total number of vertices rendered per frame
  99593. */
  99594. getTotalVertices(): number;
  99595. /**
  99596. * Gets the performance counter for total vertices
  99597. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99598. */
  99599. readonly totalVerticesPerfCounter: PerfCounter;
  99600. /**
  99601. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  99602. * @returns the total number of active indices rendered per frame
  99603. */
  99604. getActiveIndices(): number;
  99605. /**
  99606. * Gets the performance counter for active indices
  99607. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99608. */
  99609. readonly totalActiveIndicesPerfCounter: PerfCounter;
  99610. /**
  99611. * Gets the total number of active particles rendered per frame
  99612. * @returns the total number of active particles rendered per frame
  99613. */
  99614. getActiveParticles(): number;
  99615. /**
  99616. * Gets the performance counter for active particles
  99617. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99618. */
  99619. readonly activeParticlesPerfCounter: PerfCounter;
  99620. /**
  99621. * Gets the total number of active bones rendered per frame
  99622. * @returns the total number of active bones rendered per frame
  99623. */
  99624. getActiveBones(): number;
  99625. /**
  99626. * Gets the performance counter for active bones
  99627. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99628. */
  99629. readonly activeBonesPerfCounter: PerfCounter;
  99630. /**
  99631. * Gets the array of active meshes
  99632. * @returns an array of AbstractMesh
  99633. */
  99634. getActiveMeshes(): SmartArray<AbstractMesh>;
  99635. /**
  99636. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  99637. * @returns a number
  99638. */
  99639. getAnimationRatio(): number;
  99640. /**
  99641. * Gets an unique Id for the current render phase
  99642. * @returns a number
  99643. */
  99644. getRenderId(): number;
  99645. /**
  99646. * Gets an unique Id for the current frame
  99647. * @returns a number
  99648. */
  99649. getFrameId(): number;
  99650. /** Call this function if you want to manually increment the render Id*/
  99651. incrementRenderId(): void;
  99652. private _createUbo;
  99653. /**
  99654. * Use this method to simulate a pointer move on a mesh
  99655. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99656. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99657. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99658. * @returns the current scene
  99659. */
  99660. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99661. /**
  99662. * Use this method to simulate a pointer down on a mesh
  99663. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99664. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99665. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99666. * @returns the current scene
  99667. */
  99668. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99669. /**
  99670. * Use this method to simulate a pointer up on a mesh
  99671. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99672. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99673. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99674. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99675. * @returns the current scene
  99676. */
  99677. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  99678. /**
  99679. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99680. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99681. * @returns true if the pointer was captured
  99682. */
  99683. isPointerCaptured(pointerId?: number): boolean;
  99684. /**
  99685. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99686. * @param attachUp defines if you want to attach events to pointerup
  99687. * @param attachDown defines if you want to attach events to pointerdown
  99688. * @param attachMove defines if you want to attach events to pointermove
  99689. */
  99690. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99691. /** Detaches all event handlers*/
  99692. detachControl(): void;
  99693. /**
  99694. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  99695. * Delay loaded resources are not taking in account
  99696. * @return true if all required resources are ready
  99697. */
  99698. isReady(): boolean;
  99699. /** Resets all cached information relative to material (including effect and visibility) */
  99700. resetCachedMaterial(): void;
  99701. /**
  99702. * Registers a function to be called before every frame render
  99703. * @param func defines the function to register
  99704. */
  99705. registerBeforeRender(func: () => void): void;
  99706. /**
  99707. * Unregisters a function called before every frame render
  99708. * @param func defines the function to unregister
  99709. */
  99710. unregisterBeforeRender(func: () => void): void;
  99711. /**
  99712. * Registers a function to be called after every frame render
  99713. * @param func defines the function to register
  99714. */
  99715. registerAfterRender(func: () => void): void;
  99716. /**
  99717. * Unregisters a function called after every frame render
  99718. * @param func defines the function to unregister
  99719. */
  99720. unregisterAfterRender(func: () => void): void;
  99721. private _executeOnceBeforeRender;
  99722. /**
  99723. * The provided function will run before render once and will be disposed afterwards.
  99724. * A timeout delay can be provided so that the function will be executed in N ms.
  99725. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  99726. * @param func The function to be executed.
  99727. * @param timeout optional delay in ms
  99728. */
  99729. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  99730. /** @hidden */
  99731. _addPendingData(data: any): void;
  99732. /** @hidden */
  99733. _removePendingData(data: any): void;
  99734. /**
  99735. * Returns the number of items waiting to be loaded
  99736. * @returns the number of items waiting to be loaded
  99737. */
  99738. getWaitingItemsCount(): number;
  99739. /**
  99740. * Returns a boolean indicating if the scene is still loading data
  99741. */
  99742. readonly isLoading: boolean;
  99743. /**
  99744. * Registers a function to be executed when the scene is ready
  99745. * @param {Function} func - the function to be executed
  99746. */
  99747. executeWhenReady(func: () => void): void;
  99748. /**
  99749. * Returns a promise that resolves when the scene is ready
  99750. * @returns A promise that resolves when the scene is ready
  99751. */
  99752. whenReadyAsync(): Promise<void>;
  99753. /** @hidden */
  99754. _checkIsReady(): void;
  99755. /**
  99756. * Gets all animatable attached to the scene
  99757. */
  99758. readonly animatables: Animatable[];
  99759. /**
  99760. * Resets the last animation time frame.
  99761. * Useful to override when animations start running when loading a scene for the first time.
  99762. */
  99763. resetLastAnimationTimeFrame(): void;
  99764. /**
  99765. * Gets the current view matrix
  99766. * @returns a Matrix
  99767. */
  99768. getViewMatrix(): Matrix;
  99769. /**
  99770. * Gets the current projection matrix
  99771. * @returns a Matrix
  99772. */
  99773. getProjectionMatrix(): Matrix;
  99774. /**
  99775. * Gets the current transform matrix
  99776. * @returns a Matrix made of View * Projection
  99777. */
  99778. getTransformMatrix(): Matrix;
  99779. /**
  99780. * Sets the current transform matrix
  99781. * @param viewL defines the View matrix to use
  99782. * @param projectionL defines the Projection matrix to use
  99783. * @param viewR defines the right View matrix to use (if provided)
  99784. * @param projectionR defines the right Projection matrix to use (if provided)
  99785. */
  99786. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  99787. /**
  99788. * Gets the uniform buffer used to store scene data
  99789. * @returns a UniformBuffer
  99790. */
  99791. getSceneUniformBuffer(): UniformBuffer;
  99792. /**
  99793. * Gets an unique (relatively to the current scene) Id
  99794. * @returns an unique number for the scene
  99795. */
  99796. getUniqueId(): number;
  99797. /**
  99798. * Add a mesh to the list of scene's meshes
  99799. * @param newMesh defines the mesh to add
  99800. * @param recursive if all child meshes should also be added to the scene
  99801. */
  99802. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  99803. /**
  99804. * Remove a mesh for the list of scene's meshes
  99805. * @param toRemove defines the mesh to remove
  99806. * @param recursive if all child meshes should also be removed from the scene
  99807. * @returns the index where the mesh was in the mesh list
  99808. */
  99809. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  99810. /**
  99811. * Add a transform node to the list of scene's transform nodes
  99812. * @param newTransformNode defines the transform node to add
  99813. */
  99814. addTransformNode(newTransformNode: TransformNode): void;
  99815. /**
  99816. * Remove a transform node for the list of scene's transform nodes
  99817. * @param toRemove defines the transform node to remove
  99818. * @returns the index where the transform node was in the transform node list
  99819. */
  99820. removeTransformNode(toRemove: TransformNode): number;
  99821. /**
  99822. * Remove a skeleton for the list of scene's skeletons
  99823. * @param toRemove defines the skeleton to remove
  99824. * @returns the index where the skeleton was in the skeleton list
  99825. */
  99826. removeSkeleton(toRemove: Skeleton): number;
  99827. /**
  99828. * Remove a morph target for the list of scene's morph targets
  99829. * @param toRemove defines the morph target to remove
  99830. * @returns the index where the morph target was in the morph target list
  99831. */
  99832. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  99833. /**
  99834. * Remove a light for the list of scene's lights
  99835. * @param toRemove defines the light to remove
  99836. * @returns the index where the light was in the light list
  99837. */
  99838. removeLight(toRemove: Light): number;
  99839. /**
  99840. * Remove a camera for the list of scene's cameras
  99841. * @param toRemove defines the camera to remove
  99842. * @returns the index where the camera was in the camera list
  99843. */
  99844. removeCamera(toRemove: Camera): number;
  99845. /**
  99846. * Remove a particle system for the list of scene's particle systems
  99847. * @param toRemove defines the particle system to remove
  99848. * @returns the index where the particle system was in the particle system list
  99849. */
  99850. removeParticleSystem(toRemove: IParticleSystem): number;
  99851. /**
  99852. * Remove a animation for the list of scene's animations
  99853. * @param toRemove defines the animation to remove
  99854. * @returns the index where the animation was in the animation list
  99855. */
  99856. removeAnimation(toRemove: Animation): number;
  99857. /**
  99858. * Will stop the animation of the given target
  99859. * @param target - the target
  99860. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  99861. * @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)
  99862. */
  99863. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  99864. /**
  99865. * Removes the given animation group from this scene.
  99866. * @param toRemove The animation group to remove
  99867. * @returns The index of the removed animation group
  99868. */
  99869. removeAnimationGroup(toRemove: AnimationGroup): number;
  99870. /**
  99871. * Removes the given multi-material from this scene.
  99872. * @param toRemove The multi-material to remove
  99873. * @returns The index of the removed multi-material
  99874. */
  99875. removeMultiMaterial(toRemove: MultiMaterial): number;
  99876. /**
  99877. * Removes the given material from this scene.
  99878. * @param toRemove The material to remove
  99879. * @returns The index of the removed material
  99880. */
  99881. removeMaterial(toRemove: Material): number;
  99882. /**
  99883. * Removes the given action manager from this scene.
  99884. * @param toRemove The action manager to remove
  99885. * @returns The index of the removed action manager
  99886. */
  99887. removeActionManager(toRemove: AbstractActionManager): number;
  99888. /**
  99889. * Removes the given texture from this scene.
  99890. * @param toRemove The texture to remove
  99891. * @returns The index of the removed texture
  99892. */
  99893. removeTexture(toRemove: BaseTexture): number;
  99894. /**
  99895. * Adds the given light to this scene
  99896. * @param newLight The light to add
  99897. */
  99898. addLight(newLight: Light): void;
  99899. /**
  99900. * Sorts the list list based on light priorities
  99901. */
  99902. sortLightsByPriority(): void;
  99903. /**
  99904. * Adds the given camera to this scene
  99905. * @param newCamera The camera to add
  99906. */
  99907. addCamera(newCamera: Camera): void;
  99908. /**
  99909. * Adds the given skeleton to this scene
  99910. * @param newSkeleton The skeleton to add
  99911. */
  99912. addSkeleton(newSkeleton: Skeleton): void;
  99913. /**
  99914. * Adds the given particle system to this scene
  99915. * @param newParticleSystem The particle system to add
  99916. */
  99917. addParticleSystem(newParticleSystem: IParticleSystem): void;
  99918. /**
  99919. * Adds the given animation to this scene
  99920. * @param newAnimation The animation to add
  99921. */
  99922. addAnimation(newAnimation: Animation): void;
  99923. /**
  99924. * Adds the given animation group to this scene.
  99925. * @param newAnimationGroup The animation group to add
  99926. */
  99927. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  99928. /**
  99929. * Adds the given multi-material to this scene
  99930. * @param newMultiMaterial The multi-material to add
  99931. */
  99932. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  99933. /**
  99934. * Adds the given material to this scene
  99935. * @param newMaterial The material to add
  99936. */
  99937. addMaterial(newMaterial: Material): void;
  99938. /**
  99939. * Adds the given morph target to this scene
  99940. * @param newMorphTargetManager The morph target to add
  99941. */
  99942. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  99943. /**
  99944. * Adds the given geometry to this scene
  99945. * @param newGeometry The geometry to add
  99946. */
  99947. addGeometry(newGeometry: Geometry): void;
  99948. /**
  99949. * Adds the given action manager to this scene
  99950. * @param newActionManager The action manager to add
  99951. */
  99952. addActionManager(newActionManager: AbstractActionManager): void;
  99953. /**
  99954. * Adds the given texture to this scene.
  99955. * @param newTexture The texture to add
  99956. */
  99957. addTexture(newTexture: BaseTexture): void;
  99958. /**
  99959. * Switch active camera
  99960. * @param newCamera defines the new active camera
  99961. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  99962. */
  99963. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  99964. /**
  99965. * sets the active camera of the scene using its ID
  99966. * @param id defines the camera's ID
  99967. * @return the new active camera or null if none found.
  99968. */
  99969. setActiveCameraByID(id: string): Nullable<Camera>;
  99970. /**
  99971. * sets the active camera of the scene using its name
  99972. * @param name defines the camera's name
  99973. * @returns the new active camera or null if none found.
  99974. */
  99975. setActiveCameraByName(name: string): Nullable<Camera>;
  99976. /**
  99977. * get an animation group using its name
  99978. * @param name defines the material's name
  99979. * @return the animation group or null if none found.
  99980. */
  99981. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  99982. /**
  99983. * Get a material using its unique id
  99984. * @param uniqueId defines the material's unique id
  99985. * @return the material or null if none found.
  99986. */
  99987. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  99988. /**
  99989. * get a material using its id
  99990. * @param id defines the material's ID
  99991. * @return the material or null if none found.
  99992. */
  99993. getMaterialByID(id: string): Nullable<Material>;
  99994. /**
  99995. * Gets a the last added material using a given id
  99996. * @param id defines the material's ID
  99997. * @return the last material with the given id or null if none found.
  99998. */
  99999. getLastMaterialByID(id: string): Nullable<Material>;
  100000. /**
  100001. * Gets a material using its name
  100002. * @param name defines the material's name
  100003. * @return the material or null if none found.
  100004. */
  100005. getMaterialByName(name: string): Nullable<Material>;
  100006. /**
  100007. * Get a texture using its unique id
  100008. * @param uniqueId defines the texture's unique id
  100009. * @return the texture or null if none found.
  100010. */
  100011. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  100012. /**
  100013. * Gets a camera using its id
  100014. * @param id defines the id to look for
  100015. * @returns the camera or null if not found
  100016. */
  100017. getCameraByID(id: string): Nullable<Camera>;
  100018. /**
  100019. * Gets a camera using its unique id
  100020. * @param uniqueId defines the unique id to look for
  100021. * @returns the camera or null if not found
  100022. */
  100023. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  100024. /**
  100025. * Gets a camera using its name
  100026. * @param name defines the camera's name
  100027. * @return the camera or null if none found.
  100028. */
  100029. getCameraByName(name: string): Nullable<Camera>;
  100030. /**
  100031. * Gets a bone using its id
  100032. * @param id defines the bone's id
  100033. * @return the bone or null if not found
  100034. */
  100035. getBoneByID(id: string): Nullable<Bone>;
  100036. /**
  100037. * Gets a bone using its id
  100038. * @param name defines the bone's name
  100039. * @return the bone or null if not found
  100040. */
  100041. getBoneByName(name: string): Nullable<Bone>;
  100042. /**
  100043. * Gets a light node using its name
  100044. * @param name defines the the light's name
  100045. * @return the light or null if none found.
  100046. */
  100047. getLightByName(name: string): Nullable<Light>;
  100048. /**
  100049. * Gets a light node using its id
  100050. * @param id defines the light's id
  100051. * @return the light or null if none found.
  100052. */
  100053. getLightByID(id: string): Nullable<Light>;
  100054. /**
  100055. * Gets a light node using its scene-generated unique ID
  100056. * @param uniqueId defines the light's unique id
  100057. * @return the light or null if none found.
  100058. */
  100059. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  100060. /**
  100061. * Gets a particle system by id
  100062. * @param id defines the particle system id
  100063. * @return the corresponding system or null if none found
  100064. */
  100065. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  100066. /**
  100067. * Gets a geometry using its ID
  100068. * @param id defines the geometry's id
  100069. * @return the geometry or null if none found.
  100070. */
  100071. getGeometryByID(id: string): Nullable<Geometry>;
  100072. private _getGeometryByUniqueID;
  100073. /**
  100074. * Add a new geometry to this scene
  100075. * @param geometry defines the geometry to be added to the scene.
  100076. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  100077. * @return a boolean defining if the geometry was added or not
  100078. */
  100079. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  100080. /**
  100081. * Removes an existing geometry
  100082. * @param geometry defines the geometry to be removed from the scene
  100083. * @return a boolean defining if the geometry was removed or not
  100084. */
  100085. removeGeometry(geometry: Geometry): boolean;
  100086. /**
  100087. * Gets the list of geometries attached to the scene
  100088. * @returns an array of Geometry
  100089. */
  100090. getGeometries(): Geometry[];
  100091. /**
  100092. * Gets the first added mesh found of a given ID
  100093. * @param id defines the id to search for
  100094. * @return the mesh found or null if not found at all
  100095. */
  100096. getMeshByID(id: string): Nullable<AbstractMesh>;
  100097. /**
  100098. * Gets a list of meshes using their id
  100099. * @param id defines the id to search for
  100100. * @returns a list of meshes
  100101. */
  100102. getMeshesByID(id: string): Array<AbstractMesh>;
  100103. /**
  100104. * Gets the first added transform node found of a given ID
  100105. * @param id defines the id to search for
  100106. * @return the found transform node or null if not found at all.
  100107. */
  100108. getTransformNodeByID(id: string): Nullable<TransformNode>;
  100109. /**
  100110. * Gets a transform node with its auto-generated unique id
  100111. * @param uniqueId efines the unique id to search for
  100112. * @return the found transform node or null if not found at all.
  100113. */
  100114. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  100115. /**
  100116. * Gets a list of transform nodes using their id
  100117. * @param id defines the id to search for
  100118. * @returns a list of transform nodes
  100119. */
  100120. getTransformNodesByID(id: string): Array<TransformNode>;
  100121. /**
  100122. * Gets a mesh with its auto-generated unique id
  100123. * @param uniqueId defines the unique id to search for
  100124. * @return the found mesh or null if not found at all.
  100125. */
  100126. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  100127. /**
  100128. * Gets a the last added mesh using a given id
  100129. * @param id defines the id to search for
  100130. * @return the found mesh or null if not found at all.
  100131. */
  100132. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  100133. /**
  100134. * Gets a the last added node (Mesh, Camera, Light) using a given id
  100135. * @param id defines the id to search for
  100136. * @return the found node or null if not found at all
  100137. */
  100138. getLastEntryByID(id: string): Nullable<Node>;
  100139. /**
  100140. * Gets a node (Mesh, Camera, Light) using a given id
  100141. * @param id defines the id to search for
  100142. * @return the found node or null if not found at all
  100143. */
  100144. getNodeByID(id: string): Nullable<Node>;
  100145. /**
  100146. * Gets a node (Mesh, Camera, Light) using a given name
  100147. * @param name defines the name to search for
  100148. * @return the found node or null if not found at all.
  100149. */
  100150. getNodeByName(name: string): Nullable<Node>;
  100151. /**
  100152. * Gets a mesh using a given name
  100153. * @param name defines the name to search for
  100154. * @return the found mesh or null if not found at all.
  100155. */
  100156. getMeshByName(name: string): Nullable<AbstractMesh>;
  100157. /**
  100158. * Gets a transform node using a given name
  100159. * @param name defines the name to search for
  100160. * @return the found transform node or null if not found at all.
  100161. */
  100162. getTransformNodeByName(name: string): Nullable<TransformNode>;
  100163. /**
  100164. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  100165. * @param id defines the id to search for
  100166. * @return the found skeleton or null if not found at all.
  100167. */
  100168. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  100169. /**
  100170. * Gets a skeleton using a given auto generated unique id
  100171. * @param uniqueId defines the unique id to search for
  100172. * @return the found skeleton or null if not found at all.
  100173. */
  100174. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  100175. /**
  100176. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  100177. * @param id defines the id to search for
  100178. * @return the found skeleton or null if not found at all.
  100179. */
  100180. getSkeletonById(id: string): Nullable<Skeleton>;
  100181. /**
  100182. * Gets a skeleton using a given name
  100183. * @param name defines the name to search for
  100184. * @return the found skeleton or null if not found at all.
  100185. */
  100186. getSkeletonByName(name: string): Nullable<Skeleton>;
  100187. /**
  100188. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  100189. * @param id defines the id to search for
  100190. * @return the found morph target manager or null if not found at all.
  100191. */
  100192. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  100193. /**
  100194. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  100195. * @param id defines the id to search for
  100196. * @return the found morph target or null if not found at all.
  100197. */
  100198. getMorphTargetById(id: string): Nullable<MorphTarget>;
  100199. /**
  100200. * Gets a boolean indicating if the given mesh is active
  100201. * @param mesh defines the mesh to look for
  100202. * @returns true if the mesh is in the active list
  100203. */
  100204. isActiveMesh(mesh: AbstractMesh): boolean;
  100205. /**
  100206. * Return a unique id as a string which can serve as an identifier for the scene
  100207. */
  100208. readonly uid: string;
  100209. /**
  100210. * Add an externaly attached data from its key.
  100211. * This method call will fail and return false, if such key already exists.
  100212. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  100213. * @param key the unique key that identifies the data
  100214. * @param data the data object to associate to the key for this Engine instance
  100215. * @return true if no such key were already present and the data was added successfully, false otherwise
  100216. */
  100217. addExternalData<T>(key: string, data: T): boolean;
  100218. /**
  100219. * Get an externaly attached data from its key
  100220. * @param key the unique key that identifies the data
  100221. * @return the associated data, if present (can be null), or undefined if not present
  100222. */
  100223. getExternalData<T>(key: string): Nullable<T>;
  100224. /**
  100225. * Get an externaly attached data from its key, create it using a factory if it's not already present
  100226. * @param key the unique key that identifies the data
  100227. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  100228. * @return the associated data, can be null if the factory returned null.
  100229. */
  100230. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  100231. /**
  100232. * Remove an externaly attached data from the Engine instance
  100233. * @param key the unique key that identifies the data
  100234. * @return true if the data was successfully removed, false if it doesn't exist
  100235. */
  100236. removeExternalData(key: string): boolean;
  100237. private _evaluateSubMesh;
  100238. /**
  100239. * Clear the processed materials smart array preventing retention point in material dispose.
  100240. */
  100241. freeProcessedMaterials(): void;
  100242. private _preventFreeActiveMeshesAndRenderingGroups;
  100243. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  100244. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  100245. * when disposing several meshes in a row or a hierarchy of meshes.
  100246. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  100247. */
  100248. blockfreeActiveMeshesAndRenderingGroups: boolean;
  100249. /**
  100250. * Clear the active meshes smart array preventing retention point in mesh dispose.
  100251. */
  100252. freeActiveMeshes(): void;
  100253. /**
  100254. * Clear the info related to rendering groups preventing retention points during dispose.
  100255. */
  100256. freeRenderingGroups(): void;
  100257. /** @hidden */
  100258. _isInIntermediateRendering(): boolean;
  100259. /**
  100260. * Lambda returning the list of potentially active meshes.
  100261. */
  100262. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  100263. /**
  100264. * Lambda returning the list of potentially active sub meshes.
  100265. */
  100266. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  100267. /**
  100268. * Lambda returning the list of potentially intersecting sub meshes.
  100269. */
  100270. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  100271. /**
  100272. * Lambda returning the list of potentially colliding sub meshes.
  100273. */
  100274. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  100275. private _activeMeshesFrozen;
  100276. /**
  100277. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  100278. * @returns the current scene
  100279. */
  100280. freezeActiveMeshes(): Scene;
  100281. /**
  100282. * Use this function to restart evaluating active meshes on every frame
  100283. * @returns the current scene
  100284. */
  100285. unfreezeActiveMeshes(): Scene;
  100286. private _evaluateActiveMeshes;
  100287. private _activeMesh;
  100288. /**
  100289. * Update the transform matrix to update from the current active camera
  100290. * @param force defines a boolean used to force the update even if cache is up to date
  100291. */
  100292. updateTransformMatrix(force?: boolean): void;
  100293. private _bindFrameBuffer;
  100294. /** @hidden */
  100295. _allowPostProcessClearColor: boolean;
  100296. /** @hidden */
  100297. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  100298. private _processSubCameras;
  100299. private _checkIntersections;
  100300. /** @hidden */
  100301. _advancePhysicsEngineStep(step: number): void;
  100302. /**
  100303. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  100304. */
  100305. getDeterministicFrameTime: () => number;
  100306. /** @hidden */
  100307. _animate(): void;
  100308. /** Execute all animations (for a frame) */
  100309. animate(): void;
  100310. /**
  100311. * Render the scene
  100312. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  100313. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  100314. */
  100315. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  100316. /**
  100317. * Freeze all materials
  100318. * A frozen material will not be updatable but should be faster to render
  100319. */
  100320. freezeMaterials(): void;
  100321. /**
  100322. * Unfreeze all materials
  100323. * A frozen material will not be updatable but should be faster to render
  100324. */
  100325. unfreezeMaterials(): void;
  100326. /**
  100327. * Releases all held ressources
  100328. */
  100329. dispose(): void;
  100330. /**
  100331. * Gets if the scene is already disposed
  100332. */
  100333. readonly isDisposed: boolean;
  100334. /**
  100335. * Call this function to reduce memory footprint of the scene.
  100336. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  100337. */
  100338. clearCachedVertexData(): void;
  100339. /**
  100340. * This function will remove the local cached buffer data from texture.
  100341. * It will save memory but will prevent the texture from being rebuilt
  100342. */
  100343. cleanCachedTextureBuffer(): void;
  100344. /**
  100345. * Get the world extend vectors with an optional filter
  100346. *
  100347. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  100348. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  100349. */
  100350. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  100351. min: Vector3;
  100352. max: Vector3;
  100353. };
  100354. /**
  100355. * Creates a ray that can be used to pick in the scene
  100356. * @param x defines the x coordinate of the origin (on-screen)
  100357. * @param y defines the y coordinate of the origin (on-screen)
  100358. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  100359. * @param camera defines the camera to use for the picking
  100360. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  100361. * @returns a Ray
  100362. */
  100363. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  100364. /**
  100365. * Creates a ray that can be used to pick in the scene
  100366. * @param x defines the x coordinate of the origin (on-screen)
  100367. * @param y defines the y coordinate of the origin (on-screen)
  100368. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  100369. * @param result defines the ray where to store the picking ray
  100370. * @param camera defines the camera to use for the picking
  100371. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  100372. * @returns the current scene
  100373. */
  100374. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  100375. /**
  100376. * Creates a ray that can be used to pick in the scene
  100377. * @param x defines the x coordinate of the origin (on-screen)
  100378. * @param y defines the y coordinate of the origin (on-screen)
  100379. * @param camera defines the camera to use for the picking
  100380. * @returns a Ray
  100381. */
  100382. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  100383. /**
  100384. * Creates a ray that can be used to pick in the scene
  100385. * @param x defines the x coordinate of the origin (on-screen)
  100386. * @param y defines the y coordinate of the origin (on-screen)
  100387. * @param result defines the ray where to store the picking ray
  100388. * @param camera defines the camera to use for the picking
  100389. * @returns the current scene
  100390. */
  100391. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  100392. /** Launch a ray to try to pick a mesh in the scene
  100393. * @param x position on screen
  100394. * @param y position on screen
  100395. * @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
  100396. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  100397. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100398. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100399. * @returns a PickingInfo
  100400. */
  100401. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100402. /** Use the given ray to pick a mesh in the scene
  100403. * @param ray The ray to use to pick meshes
  100404. * @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
  100405. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  100406. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100407. * @returns a PickingInfo
  100408. */
  100409. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100410. /**
  100411. * Launch a ray to try to pick a mesh in the scene
  100412. * @param x X position on screen
  100413. * @param y Y position on screen
  100414. * @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
  100415. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100416. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100417. * @returns an array of PickingInfo
  100418. */
  100419. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100420. /**
  100421. * Launch a ray to try to pick a mesh in the scene
  100422. * @param ray Ray to use
  100423. * @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
  100424. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100425. * @returns an array of PickingInfo
  100426. */
  100427. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100428. /**
  100429. * Force the value of meshUnderPointer
  100430. * @param mesh defines the mesh to use
  100431. */
  100432. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  100433. /**
  100434. * Gets the mesh under the pointer
  100435. * @returns a Mesh or null if no mesh is under the pointer
  100436. */
  100437. getPointerOverMesh(): Nullable<AbstractMesh>;
  100438. /** @hidden */
  100439. _rebuildGeometries(): void;
  100440. /** @hidden */
  100441. _rebuildTextures(): void;
  100442. private _getByTags;
  100443. /**
  100444. * Get a list of meshes by tags
  100445. * @param tagsQuery defines the tags query to use
  100446. * @param forEach defines a predicate used to filter results
  100447. * @returns an array of Mesh
  100448. */
  100449. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  100450. /**
  100451. * Get a list of cameras by tags
  100452. * @param tagsQuery defines the tags query to use
  100453. * @param forEach defines a predicate used to filter results
  100454. * @returns an array of Camera
  100455. */
  100456. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  100457. /**
  100458. * Get a list of lights by tags
  100459. * @param tagsQuery defines the tags query to use
  100460. * @param forEach defines a predicate used to filter results
  100461. * @returns an array of Light
  100462. */
  100463. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  100464. /**
  100465. * Get a list of materials by tags
  100466. * @param tagsQuery defines the tags query to use
  100467. * @param forEach defines a predicate used to filter results
  100468. * @returns an array of Material
  100469. */
  100470. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  100471. /**
  100472. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  100473. * This allowed control for front to back rendering or reversly depending of the special needs.
  100474. *
  100475. * @param renderingGroupId The rendering group id corresponding to its index
  100476. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  100477. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  100478. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  100479. */
  100480. 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;
  100481. /**
  100482. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  100483. *
  100484. * @param renderingGroupId The rendering group id corresponding to its index
  100485. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  100486. * @param depth Automatically clears depth between groups if true and autoClear is true.
  100487. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  100488. */
  100489. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  100490. /**
  100491. * Gets the current auto clear configuration for one rendering group of the rendering
  100492. * manager.
  100493. * @param index the rendering group index to get the information for
  100494. * @returns The auto clear setup for the requested rendering group
  100495. */
  100496. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  100497. private _blockMaterialDirtyMechanism;
  100498. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  100499. blockMaterialDirtyMechanism: boolean;
  100500. /**
  100501. * Will flag all materials as dirty to trigger new shader compilation
  100502. * @param flag defines the flag used to specify which material part must be marked as dirty
  100503. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  100504. */
  100505. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  100506. /** @hidden */
  100507. _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;
  100508. /** @hidden */
  100509. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  100510. }
  100511. }
  100512. declare module BABYLON {
  100513. /**
  100514. * Set of assets to keep when moving a scene into an asset container.
  100515. */
  100516. export class KeepAssets extends AbstractScene {
  100517. }
  100518. /**
  100519. * Container with a set of assets that can be added or removed from a scene.
  100520. */
  100521. export class AssetContainer extends AbstractScene {
  100522. /**
  100523. * The scene the AssetContainer belongs to.
  100524. */
  100525. scene: Scene;
  100526. /**
  100527. * Instantiates an AssetContainer.
  100528. * @param scene The scene the AssetContainer belongs to.
  100529. */
  100530. constructor(scene: Scene);
  100531. /**
  100532. * Adds all the assets from the container to the scene.
  100533. */
  100534. addAllToScene(): void;
  100535. /**
  100536. * Removes all the assets in the container from the scene
  100537. */
  100538. removeAllFromScene(): void;
  100539. /**
  100540. * Disposes all the assets in the container
  100541. */
  100542. dispose(): void;
  100543. private _moveAssets;
  100544. /**
  100545. * Removes all the assets contained in the scene and adds them to the container.
  100546. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  100547. */
  100548. moveAllFromScene(keepAssets?: KeepAssets): void;
  100549. /**
  100550. * 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.
  100551. * @returns the root mesh
  100552. */
  100553. createRootMesh(): Mesh;
  100554. }
  100555. }
  100556. declare module BABYLON {
  100557. /**
  100558. * Defines how the parser contract is defined.
  100559. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  100560. */
  100561. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  100562. /**
  100563. * Defines how the individual parser contract is defined.
  100564. * These parser can parse an individual asset
  100565. */
  100566. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  100567. /**
  100568. * Base class of the scene acting as a container for the different elements composing a scene.
  100569. * This class is dynamically extended by the different components of the scene increasing
  100570. * flexibility and reducing coupling
  100571. */
  100572. export abstract class AbstractScene {
  100573. /**
  100574. * Stores the list of available parsers in the application.
  100575. */
  100576. private static _BabylonFileParsers;
  100577. /**
  100578. * Stores the list of available individual parsers in the application.
  100579. */
  100580. private static _IndividualBabylonFileParsers;
  100581. /**
  100582. * Adds a parser in the list of available ones
  100583. * @param name Defines the name of the parser
  100584. * @param parser Defines the parser to add
  100585. */
  100586. static AddParser(name: string, parser: BabylonFileParser): void;
  100587. /**
  100588. * Gets a general parser from the list of avaialble ones
  100589. * @param name Defines the name of the parser
  100590. * @returns the requested parser or null
  100591. */
  100592. static GetParser(name: string): Nullable<BabylonFileParser>;
  100593. /**
  100594. * Adds n individual parser in the list of available ones
  100595. * @param name Defines the name of the parser
  100596. * @param parser Defines the parser to add
  100597. */
  100598. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  100599. /**
  100600. * Gets an individual parser from the list of avaialble ones
  100601. * @param name Defines the name of the parser
  100602. * @returns the requested parser or null
  100603. */
  100604. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  100605. /**
  100606. * Parser json data and populate both a scene and its associated container object
  100607. * @param jsonData Defines the data to parse
  100608. * @param scene Defines the scene to parse the data for
  100609. * @param container Defines the container attached to the parsing sequence
  100610. * @param rootUrl Defines the root url of the data
  100611. */
  100612. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  100613. /**
  100614. * Gets the list of root nodes (ie. nodes with no parent)
  100615. */
  100616. rootNodes: Node[];
  100617. /** All of the cameras added to this scene
  100618. * @see http://doc.babylonjs.com/babylon101/cameras
  100619. */
  100620. cameras: Camera[];
  100621. /**
  100622. * All of the lights added to this scene
  100623. * @see http://doc.babylonjs.com/babylon101/lights
  100624. */
  100625. lights: Light[];
  100626. /**
  100627. * All of the (abstract) meshes added to this scene
  100628. */
  100629. meshes: AbstractMesh[];
  100630. /**
  100631. * The list of skeletons added to the scene
  100632. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  100633. */
  100634. skeletons: Skeleton[];
  100635. /**
  100636. * All of the particle systems added to this scene
  100637. * @see http://doc.babylonjs.com/babylon101/particles
  100638. */
  100639. particleSystems: IParticleSystem[];
  100640. /**
  100641. * Gets a list of Animations associated with the scene
  100642. */
  100643. animations: Animation[];
  100644. /**
  100645. * All of the animation groups added to this scene
  100646. * @see http://doc.babylonjs.com/how_to/group
  100647. */
  100648. animationGroups: AnimationGroup[];
  100649. /**
  100650. * All of the multi-materials added to this scene
  100651. * @see http://doc.babylonjs.com/how_to/multi_materials
  100652. */
  100653. multiMaterials: MultiMaterial[];
  100654. /**
  100655. * All of the materials added to this scene
  100656. * In the context of a Scene, it is not supposed to be modified manually.
  100657. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  100658. * Note also that the order of the Material wihin the array is not significant and might change.
  100659. * @see http://doc.babylonjs.com/babylon101/materials
  100660. */
  100661. materials: Material[];
  100662. /**
  100663. * The list of morph target managers added to the scene
  100664. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  100665. */
  100666. morphTargetManagers: MorphTargetManager[];
  100667. /**
  100668. * The list of geometries used in the scene.
  100669. */
  100670. geometries: Geometry[];
  100671. /**
  100672. * All of the tranform nodes added to this scene
  100673. * In the context of a Scene, it is not supposed to be modified manually.
  100674. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  100675. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  100676. * @see http://doc.babylonjs.com/how_to/transformnode
  100677. */
  100678. transformNodes: TransformNode[];
  100679. /**
  100680. * ActionManagers available on the scene.
  100681. */
  100682. actionManagers: AbstractActionManager[];
  100683. /**
  100684. * Textures to keep.
  100685. */
  100686. textures: BaseTexture[];
  100687. /**
  100688. * Environment texture for the scene
  100689. */
  100690. environmentTexture: Nullable<BaseTexture>;
  100691. }
  100692. }
  100693. declare module BABYLON {
  100694. /**
  100695. * Interface used to define options for Sound class
  100696. */
  100697. export interface ISoundOptions {
  100698. /**
  100699. * Does the sound autoplay once loaded.
  100700. */
  100701. autoplay?: boolean;
  100702. /**
  100703. * Does the sound loop after it finishes playing once.
  100704. */
  100705. loop?: boolean;
  100706. /**
  100707. * Sound's volume
  100708. */
  100709. volume?: number;
  100710. /**
  100711. * Is it a spatial sound?
  100712. */
  100713. spatialSound?: boolean;
  100714. /**
  100715. * Maximum distance to hear that sound
  100716. */
  100717. maxDistance?: number;
  100718. /**
  100719. * Uses user defined attenuation function
  100720. */
  100721. useCustomAttenuation?: boolean;
  100722. /**
  100723. * Define the roll off factor of spatial sounds.
  100724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100725. */
  100726. rolloffFactor?: number;
  100727. /**
  100728. * Define the reference distance the sound should be heard perfectly.
  100729. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100730. */
  100731. refDistance?: number;
  100732. /**
  100733. * Define the distance attenuation model the sound will follow.
  100734. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100735. */
  100736. distanceModel?: string;
  100737. /**
  100738. * Defines the playback speed (1 by default)
  100739. */
  100740. playbackRate?: number;
  100741. /**
  100742. * Defines if the sound is from a streaming source
  100743. */
  100744. streaming?: boolean;
  100745. /**
  100746. * Defines an optional length (in seconds) inside the sound file
  100747. */
  100748. length?: number;
  100749. /**
  100750. * Defines an optional offset (in seconds) inside the sound file
  100751. */
  100752. offset?: number;
  100753. /**
  100754. * If true, URLs will not be required to state the audio file codec to use.
  100755. */
  100756. skipCodecCheck?: boolean;
  100757. }
  100758. /**
  100759. * Defines a sound that can be played in the application.
  100760. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  100761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100762. */
  100763. export class Sound {
  100764. /**
  100765. * The name of the sound in the scene.
  100766. */
  100767. name: string;
  100768. /**
  100769. * Does the sound autoplay once loaded.
  100770. */
  100771. autoplay: boolean;
  100772. /**
  100773. * Does the sound loop after it finishes playing once.
  100774. */
  100775. loop: boolean;
  100776. /**
  100777. * Does the sound use a custom attenuation curve to simulate the falloff
  100778. * happening when the source gets further away from the camera.
  100779. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100780. */
  100781. useCustomAttenuation: boolean;
  100782. /**
  100783. * The sound track id this sound belongs to.
  100784. */
  100785. soundTrackId: number;
  100786. /**
  100787. * Is this sound currently played.
  100788. */
  100789. isPlaying: boolean;
  100790. /**
  100791. * Is this sound currently paused.
  100792. */
  100793. isPaused: boolean;
  100794. /**
  100795. * Does this sound enables spatial sound.
  100796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100797. */
  100798. spatialSound: boolean;
  100799. /**
  100800. * Define the reference distance the sound should be heard perfectly.
  100801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100802. */
  100803. refDistance: number;
  100804. /**
  100805. * Define the roll off factor of spatial sounds.
  100806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100807. */
  100808. rolloffFactor: number;
  100809. /**
  100810. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  100811. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100812. */
  100813. maxDistance: number;
  100814. /**
  100815. * Define the distance attenuation model the sound will follow.
  100816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100817. */
  100818. distanceModel: string;
  100819. /**
  100820. * @hidden
  100821. * Back Compat
  100822. **/
  100823. onended: () => any;
  100824. /**
  100825. * Observable event when the current playing sound finishes.
  100826. */
  100827. onEndedObservable: Observable<Sound>;
  100828. private _panningModel;
  100829. private _playbackRate;
  100830. private _streaming;
  100831. private _startTime;
  100832. private _startOffset;
  100833. private _position;
  100834. /** @hidden */
  100835. _positionInEmitterSpace: boolean;
  100836. private _localDirection;
  100837. private _volume;
  100838. private _isReadyToPlay;
  100839. private _isDirectional;
  100840. private _readyToPlayCallback;
  100841. private _audioBuffer;
  100842. private _soundSource;
  100843. private _streamingSource;
  100844. private _soundPanner;
  100845. private _soundGain;
  100846. private _inputAudioNode;
  100847. private _outputAudioNode;
  100848. private _coneInnerAngle;
  100849. private _coneOuterAngle;
  100850. private _coneOuterGain;
  100851. private _scene;
  100852. private _connectedTransformNode;
  100853. private _customAttenuationFunction;
  100854. private _registerFunc;
  100855. private _isOutputConnected;
  100856. private _htmlAudioElement;
  100857. private _urlType;
  100858. private _length?;
  100859. private _offset?;
  100860. /** @hidden */
  100861. static _SceneComponentInitialization: (scene: Scene) => void;
  100862. /**
  100863. * Create a sound and attach it to a scene
  100864. * @param name Name of your sound
  100865. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  100866. * @param scene defines the scene the sound belongs to
  100867. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  100868. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  100869. */
  100870. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  100871. /**
  100872. * Release the sound and its associated resources
  100873. */
  100874. dispose(): void;
  100875. /**
  100876. * Gets if the sounds is ready to be played or not.
  100877. * @returns true if ready, otherwise false
  100878. */
  100879. isReady(): boolean;
  100880. private _soundLoaded;
  100881. /**
  100882. * Sets the data of the sound from an audiobuffer
  100883. * @param audioBuffer The audioBuffer containing the data
  100884. */
  100885. setAudioBuffer(audioBuffer: AudioBuffer): void;
  100886. /**
  100887. * Updates the current sounds options such as maxdistance, loop...
  100888. * @param options A JSON object containing values named as the object properties
  100889. */
  100890. updateOptions(options: ISoundOptions): void;
  100891. private _createSpatialParameters;
  100892. private _updateSpatialParameters;
  100893. /**
  100894. * Switch the panning model to HRTF:
  100895. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  100896. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100897. */
  100898. switchPanningModelToHRTF(): void;
  100899. /**
  100900. * Switch the panning model to Equal Power:
  100901. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  100902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100903. */
  100904. switchPanningModelToEqualPower(): void;
  100905. private _switchPanningModel;
  100906. /**
  100907. * Connect this sound to a sound track audio node like gain...
  100908. * @param soundTrackAudioNode the sound track audio node to connect to
  100909. */
  100910. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  100911. /**
  100912. * Transform this sound into a directional source
  100913. * @param coneInnerAngle Size of the inner cone in degree
  100914. * @param coneOuterAngle Size of the outer cone in degree
  100915. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  100916. */
  100917. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  100918. /**
  100919. * Gets or sets the inner angle for the directional cone.
  100920. */
  100921. /**
  100922. * Gets or sets the inner angle for the directional cone.
  100923. */
  100924. directionalConeInnerAngle: number;
  100925. /**
  100926. * Gets or sets the outer angle for the directional cone.
  100927. */
  100928. /**
  100929. * Gets or sets the outer angle for the directional cone.
  100930. */
  100931. directionalConeOuterAngle: number;
  100932. /**
  100933. * Sets the position of the emitter if spatial sound is enabled
  100934. * @param newPosition Defines the new posisiton
  100935. */
  100936. setPosition(newPosition: Vector3): void;
  100937. /**
  100938. * Sets the local direction of the emitter if spatial sound is enabled
  100939. * @param newLocalDirection Defines the new local direction
  100940. */
  100941. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  100942. private _updateDirection;
  100943. /** @hidden */
  100944. updateDistanceFromListener(): void;
  100945. /**
  100946. * Sets a new custom attenuation function for the sound.
  100947. * @param callback Defines the function used for the attenuation
  100948. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100949. */
  100950. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  100951. /**
  100952. * Play the sound
  100953. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  100954. * @param offset (optional) Start the sound at a specific time in seconds
  100955. * @param length (optional) Sound duration (in seconds)
  100956. */
  100957. play(time?: number, offset?: number, length?: number): void;
  100958. private _onended;
  100959. /**
  100960. * Stop the sound
  100961. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  100962. */
  100963. stop(time?: number): void;
  100964. /**
  100965. * Put the sound in pause
  100966. */
  100967. pause(): void;
  100968. /**
  100969. * Sets a dedicated volume for this sounds
  100970. * @param newVolume Define the new volume of the sound
  100971. * @param time Define time for gradual change to new volume
  100972. */
  100973. setVolume(newVolume: number, time?: number): void;
  100974. /**
  100975. * Set the sound play back rate
  100976. * @param newPlaybackRate Define the playback rate the sound should be played at
  100977. */
  100978. setPlaybackRate(newPlaybackRate: number): void;
  100979. /**
  100980. * Gets the volume of the sound.
  100981. * @returns the volume of the sound
  100982. */
  100983. getVolume(): number;
  100984. /**
  100985. * Attach the sound to a dedicated mesh
  100986. * @param transformNode The transform node to connect the sound with
  100987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  100988. */
  100989. attachToMesh(transformNode: TransformNode): void;
  100990. /**
  100991. * Detach the sound from the previously attached mesh
  100992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  100993. */
  100994. detachFromMesh(): void;
  100995. private _onRegisterAfterWorldMatrixUpdate;
  100996. /**
  100997. * Clone the current sound in the scene.
  100998. * @returns the new sound clone
  100999. */
  101000. clone(): Nullable<Sound>;
  101001. /**
  101002. * Gets the current underlying audio buffer containing the data
  101003. * @returns the audio buffer
  101004. */
  101005. getAudioBuffer(): Nullable<AudioBuffer>;
  101006. /**
  101007. * Serializes the Sound in a JSON representation
  101008. * @returns the JSON representation of the sound
  101009. */
  101010. serialize(): any;
  101011. /**
  101012. * Parse a JSON representation of a sound to innstantiate in a given scene
  101013. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  101014. * @param scene Define the scene the new parsed sound should be created in
  101015. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  101016. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  101017. * @returns the newly parsed sound
  101018. */
  101019. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  101020. }
  101021. }
  101022. declare module BABYLON {
  101023. /**
  101024. * This defines an action helpful to play a defined sound on a triggered action.
  101025. */
  101026. export class PlaySoundAction extends Action {
  101027. private _sound;
  101028. /**
  101029. * Instantiate the action
  101030. * @param triggerOptions defines the trigger options
  101031. * @param sound defines the sound to play
  101032. * @param condition defines the trigger related conditions
  101033. */
  101034. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  101035. /** @hidden */
  101036. _prepare(): void;
  101037. /**
  101038. * Execute the action and play the sound.
  101039. */
  101040. execute(): void;
  101041. /**
  101042. * Serializes the actions and its related information.
  101043. * @param parent defines the object to serialize in
  101044. * @returns the serialized object
  101045. */
  101046. serialize(parent: any): any;
  101047. }
  101048. /**
  101049. * This defines an action helpful to stop a defined sound on a triggered action.
  101050. */
  101051. export class StopSoundAction extends Action {
  101052. private _sound;
  101053. /**
  101054. * Instantiate the action
  101055. * @param triggerOptions defines the trigger options
  101056. * @param sound defines the sound to stop
  101057. * @param condition defines the trigger related conditions
  101058. */
  101059. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  101060. /** @hidden */
  101061. _prepare(): void;
  101062. /**
  101063. * Execute the action and stop the sound.
  101064. */
  101065. execute(): void;
  101066. /**
  101067. * Serializes the actions and its related information.
  101068. * @param parent defines the object to serialize in
  101069. * @returns the serialized object
  101070. */
  101071. serialize(parent: any): any;
  101072. }
  101073. }
  101074. declare module BABYLON {
  101075. /**
  101076. * This defines an action responsible to change the value of a property
  101077. * by interpolating between its current value and the newly set one once triggered.
  101078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101079. */
  101080. export class InterpolateValueAction extends Action {
  101081. /**
  101082. * Defines the path of the property where the value should be interpolated
  101083. */
  101084. propertyPath: string;
  101085. /**
  101086. * Defines the target value at the end of the interpolation.
  101087. */
  101088. value: any;
  101089. /**
  101090. * Defines the time it will take for the property to interpolate to the value.
  101091. */
  101092. duration: number;
  101093. /**
  101094. * Defines if the other scene animations should be stopped when the action has been triggered
  101095. */
  101096. stopOtherAnimations?: boolean;
  101097. /**
  101098. * Defines a callback raised once the interpolation animation has been done.
  101099. */
  101100. onInterpolationDone?: () => void;
  101101. /**
  101102. * Observable triggered once the interpolation animation has been done.
  101103. */
  101104. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  101105. private _target;
  101106. private _effectiveTarget;
  101107. private _property;
  101108. /**
  101109. * Instantiate the action
  101110. * @param triggerOptions defines the trigger options
  101111. * @param target defines the object containing the value to interpolate
  101112. * @param propertyPath defines the path to the property in the target object
  101113. * @param value defines the target value at the end of the interpolation
  101114. * @param duration deines the time it will take for the property to interpolate to the value.
  101115. * @param condition defines the trigger related conditions
  101116. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  101117. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  101118. */
  101119. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  101120. /** @hidden */
  101121. _prepare(): void;
  101122. /**
  101123. * Execute the action starts the value interpolation.
  101124. */
  101125. execute(): void;
  101126. /**
  101127. * Serializes the actions and its related information.
  101128. * @param parent defines the object to serialize in
  101129. * @returns the serialized object
  101130. */
  101131. serialize(parent: any): any;
  101132. }
  101133. }
  101134. declare module BABYLON {
  101135. /**
  101136. * Options allowed during the creation of a sound track.
  101137. */
  101138. export interface ISoundTrackOptions {
  101139. /**
  101140. * The volume the sound track should take during creation
  101141. */
  101142. volume?: number;
  101143. /**
  101144. * Define if the sound track is the main sound track of the scene
  101145. */
  101146. mainTrack?: boolean;
  101147. }
  101148. /**
  101149. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  101150. * It will be also used in a future release to apply effects on a specific track.
  101151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101152. */
  101153. export class SoundTrack {
  101154. /**
  101155. * The unique identifier of the sound track in the scene.
  101156. */
  101157. id: number;
  101158. /**
  101159. * The list of sounds included in the sound track.
  101160. */
  101161. soundCollection: Array<Sound>;
  101162. private _outputAudioNode;
  101163. private _scene;
  101164. private _isMainTrack;
  101165. private _connectedAnalyser;
  101166. private _options;
  101167. private _isInitialized;
  101168. /**
  101169. * Creates a new sound track.
  101170. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101171. * @param scene Define the scene the sound track belongs to
  101172. * @param options
  101173. */
  101174. constructor(scene: Scene, options?: ISoundTrackOptions);
  101175. private _initializeSoundTrackAudioGraph;
  101176. /**
  101177. * Release the sound track and its associated resources
  101178. */
  101179. dispose(): void;
  101180. /**
  101181. * Adds a sound to this sound track
  101182. * @param sound define the cound to add
  101183. * @ignoreNaming
  101184. */
  101185. AddSound(sound: Sound): void;
  101186. /**
  101187. * Removes a sound to this sound track
  101188. * @param sound define the cound to remove
  101189. * @ignoreNaming
  101190. */
  101191. RemoveSound(sound: Sound): void;
  101192. /**
  101193. * Set a global volume for the full sound track.
  101194. * @param newVolume Define the new volume of the sound track
  101195. */
  101196. setVolume(newVolume: number): void;
  101197. /**
  101198. * Switch the panning model to HRTF:
  101199. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101200. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101201. */
  101202. switchPanningModelToHRTF(): void;
  101203. /**
  101204. * Switch the panning model to Equal Power:
  101205. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101207. */
  101208. switchPanningModelToEqualPower(): void;
  101209. /**
  101210. * Connect the sound track to an audio analyser allowing some amazing
  101211. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  101212. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  101213. * @param analyser The analyser to connect to the engine
  101214. */
  101215. connectToAnalyser(analyser: Analyser): void;
  101216. }
  101217. }
  101218. declare module BABYLON {
  101219. interface AbstractScene {
  101220. /**
  101221. * The list of sounds used in the scene.
  101222. */
  101223. sounds: Nullable<Array<Sound>>;
  101224. }
  101225. interface Scene {
  101226. /**
  101227. * @hidden
  101228. * Backing field
  101229. */
  101230. _mainSoundTrack: SoundTrack;
  101231. /**
  101232. * The main sound track played by the scene.
  101233. * It cotains your primary collection of sounds.
  101234. */
  101235. mainSoundTrack: SoundTrack;
  101236. /**
  101237. * The list of sound tracks added to the scene
  101238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101239. */
  101240. soundTracks: Nullable<Array<SoundTrack>>;
  101241. /**
  101242. * Gets a sound using a given name
  101243. * @param name defines the name to search for
  101244. * @return the found sound or null if not found at all.
  101245. */
  101246. getSoundByName(name: string): Nullable<Sound>;
  101247. /**
  101248. * Gets or sets if audio support is enabled
  101249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101250. */
  101251. audioEnabled: boolean;
  101252. /**
  101253. * Gets or sets if audio will be output to headphones
  101254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101255. */
  101256. headphone: boolean;
  101257. /**
  101258. * Gets or sets custom audio listener position provider
  101259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101260. */
  101261. audioListenerPositionProvider: Nullable<() => Vector3>;
  101262. }
  101263. /**
  101264. * Defines the sound scene component responsible to manage any sounds
  101265. * in a given scene.
  101266. */
  101267. export class AudioSceneComponent implements ISceneSerializableComponent {
  101268. /**
  101269. * The component name helpfull to identify the component in the list of scene components.
  101270. */
  101271. readonly name: string;
  101272. /**
  101273. * The scene the component belongs to.
  101274. */
  101275. scene: Scene;
  101276. private _audioEnabled;
  101277. /**
  101278. * Gets whether audio is enabled or not.
  101279. * Please use related enable/disable method to switch state.
  101280. */
  101281. readonly audioEnabled: boolean;
  101282. private _headphone;
  101283. /**
  101284. * Gets whether audio is outputing to headphone or not.
  101285. * Please use the according Switch methods to change output.
  101286. */
  101287. readonly headphone: boolean;
  101288. private _audioListenerPositionProvider;
  101289. /**
  101290. * Gets the current audio listener position provider
  101291. */
  101292. /**
  101293. * Sets a custom listener position for all sounds in the scene
  101294. * By default, this is the position of the first active camera
  101295. */
  101296. audioListenerPositionProvider: Nullable<() => Vector3>;
  101297. /**
  101298. * Creates a new instance of the component for the given scene
  101299. * @param scene Defines the scene to register the component in
  101300. */
  101301. constructor(scene: Scene);
  101302. /**
  101303. * Registers the component in a given scene
  101304. */
  101305. register(): void;
  101306. /**
  101307. * Rebuilds the elements related to this component in case of
  101308. * context lost for instance.
  101309. */
  101310. rebuild(): void;
  101311. /**
  101312. * Serializes the component data to the specified json object
  101313. * @param serializationObject The object to serialize to
  101314. */
  101315. serialize(serializationObject: any): void;
  101316. /**
  101317. * Adds all the elements from the container to the scene
  101318. * @param container the container holding the elements
  101319. */
  101320. addFromContainer(container: AbstractScene): void;
  101321. /**
  101322. * Removes all the elements in the container from the scene
  101323. * @param container contains the elements to remove
  101324. * @param dispose if the removed element should be disposed (default: false)
  101325. */
  101326. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  101327. /**
  101328. * Disposes the component and the associated ressources.
  101329. */
  101330. dispose(): void;
  101331. /**
  101332. * Disables audio in the associated scene.
  101333. */
  101334. disableAudio(): void;
  101335. /**
  101336. * Enables audio in the associated scene.
  101337. */
  101338. enableAudio(): void;
  101339. /**
  101340. * Switch audio to headphone output.
  101341. */
  101342. switchAudioModeForHeadphones(): void;
  101343. /**
  101344. * Switch audio to normal speakers.
  101345. */
  101346. switchAudioModeForNormalSpeakers(): void;
  101347. private _afterRender;
  101348. }
  101349. }
  101350. declare module BABYLON {
  101351. /**
  101352. * Wraps one or more Sound objects and selects one with random weight for playback.
  101353. */
  101354. export class WeightedSound {
  101355. /** When true a Sound will be selected and played when the current playing Sound completes. */
  101356. loop: boolean;
  101357. private _coneInnerAngle;
  101358. private _coneOuterAngle;
  101359. private _volume;
  101360. /** A Sound is currently playing. */
  101361. isPlaying: boolean;
  101362. /** A Sound is currently paused. */
  101363. isPaused: boolean;
  101364. private _sounds;
  101365. private _weights;
  101366. private _currentIndex?;
  101367. /**
  101368. * Creates a new WeightedSound from the list of sounds given.
  101369. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  101370. * @param sounds Array of Sounds that will be selected from.
  101371. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  101372. */
  101373. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  101374. /**
  101375. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  101376. */
  101377. /**
  101378. * The size of cone in degress for a directional sound in which there will be no attenuation.
  101379. */
  101380. directionalConeInnerAngle: number;
  101381. /**
  101382. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101383. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101384. */
  101385. /**
  101386. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101387. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101388. */
  101389. directionalConeOuterAngle: number;
  101390. /**
  101391. * Playback volume.
  101392. */
  101393. /**
  101394. * Playback volume.
  101395. */
  101396. volume: number;
  101397. private _onended;
  101398. /**
  101399. * Suspend playback
  101400. */
  101401. pause(): void;
  101402. /**
  101403. * Stop playback
  101404. */
  101405. stop(): void;
  101406. /**
  101407. * Start playback.
  101408. * @param startOffset Position the clip head at a specific time in seconds.
  101409. */
  101410. play(startOffset?: number): void;
  101411. }
  101412. }
  101413. declare module BABYLON {
  101414. /**
  101415. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  101416. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101417. */
  101418. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  101419. /**
  101420. * Gets the name of the behavior.
  101421. */
  101422. readonly name: string;
  101423. /**
  101424. * The easing function used by animations
  101425. */
  101426. static EasingFunction: BackEase;
  101427. /**
  101428. * The easing mode used by animations
  101429. */
  101430. static EasingMode: number;
  101431. /**
  101432. * The duration of the animation, in milliseconds
  101433. */
  101434. transitionDuration: number;
  101435. /**
  101436. * Length of the distance animated by the transition when lower radius is reached
  101437. */
  101438. lowerRadiusTransitionRange: number;
  101439. /**
  101440. * Length of the distance animated by the transition when upper radius is reached
  101441. */
  101442. upperRadiusTransitionRange: number;
  101443. private _autoTransitionRange;
  101444. /**
  101445. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101446. */
  101447. /**
  101448. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101449. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  101450. */
  101451. autoTransitionRange: boolean;
  101452. private _attachedCamera;
  101453. private _onAfterCheckInputsObserver;
  101454. private _onMeshTargetChangedObserver;
  101455. /**
  101456. * Initializes the behavior.
  101457. */
  101458. init(): void;
  101459. /**
  101460. * Attaches the behavior to its arc rotate camera.
  101461. * @param camera Defines the camera to attach the behavior to
  101462. */
  101463. attach(camera: ArcRotateCamera): void;
  101464. /**
  101465. * Detaches the behavior from its current arc rotate camera.
  101466. */
  101467. detach(): void;
  101468. private _radiusIsAnimating;
  101469. private _radiusBounceTransition;
  101470. private _animatables;
  101471. private _cachedWheelPrecision;
  101472. /**
  101473. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  101474. * @param radiusLimit The limit to check against.
  101475. * @return Bool to indicate if at limit.
  101476. */
  101477. private _isRadiusAtLimit;
  101478. /**
  101479. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  101480. * @param radiusDelta The delta by which to animate to. Can be negative.
  101481. */
  101482. private _applyBoundRadiusAnimation;
  101483. /**
  101484. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  101485. */
  101486. protected _clearAnimationLocks(): void;
  101487. /**
  101488. * Stops and removes all animations that have been applied to the camera
  101489. */
  101490. stopAllAnimations(): void;
  101491. }
  101492. }
  101493. declare module BABYLON {
  101494. /**
  101495. * 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.
  101496. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101497. */
  101498. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  101499. /**
  101500. * Gets the name of the behavior.
  101501. */
  101502. readonly name: string;
  101503. private _mode;
  101504. private _radiusScale;
  101505. private _positionScale;
  101506. private _defaultElevation;
  101507. private _elevationReturnTime;
  101508. private _elevationReturnWaitTime;
  101509. private _zoomStopsAnimation;
  101510. private _framingTime;
  101511. /**
  101512. * The easing function used by animations
  101513. */
  101514. static EasingFunction: ExponentialEase;
  101515. /**
  101516. * The easing mode used by animations
  101517. */
  101518. static EasingMode: number;
  101519. /**
  101520. * Sets the current mode used by the behavior
  101521. */
  101522. /**
  101523. * Gets current mode used by the behavior.
  101524. */
  101525. mode: number;
  101526. /**
  101527. * Sets the scale applied to the radius (1 by default)
  101528. */
  101529. /**
  101530. * Gets the scale applied to the radius
  101531. */
  101532. radiusScale: number;
  101533. /**
  101534. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101535. */
  101536. /**
  101537. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101538. */
  101539. positionScale: number;
  101540. /**
  101541. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101542. * behaviour is triggered, in radians.
  101543. */
  101544. /**
  101545. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101546. * behaviour is triggered, in radians.
  101547. */
  101548. defaultElevation: number;
  101549. /**
  101550. * Sets the time (in milliseconds) taken to return to the default beta position.
  101551. * Negative value indicates camera should not return to default.
  101552. */
  101553. /**
  101554. * Gets the time (in milliseconds) taken to return to the default beta position.
  101555. * Negative value indicates camera should not return to default.
  101556. */
  101557. elevationReturnTime: number;
  101558. /**
  101559. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101560. */
  101561. /**
  101562. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101563. */
  101564. elevationReturnWaitTime: number;
  101565. /**
  101566. * Sets the flag that indicates if user zooming should stop animation.
  101567. */
  101568. /**
  101569. * Gets the flag that indicates if user zooming should stop animation.
  101570. */
  101571. zoomStopsAnimation: boolean;
  101572. /**
  101573. * Sets the transition time when framing the mesh, in milliseconds
  101574. */
  101575. /**
  101576. * Gets the transition time when framing the mesh, in milliseconds
  101577. */
  101578. framingTime: number;
  101579. /**
  101580. * Define if the behavior should automatically change the configured
  101581. * camera limits and sensibilities.
  101582. */
  101583. autoCorrectCameraLimitsAndSensibility: boolean;
  101584. private _onPrePointerObservableObserver;
  101585. private _onAfterCheckInputsObserver;
  101586. private _onMeshTargetChangedObserver;
  101587. private _attachedCamera;
  101588. private _isPointerDown;
  101589. private _lastInteractionTime;
  101590. /**
  101591. * Initializes the behavior.
  101592. */
  101593. init(): void;
  101594. /**
  101595. * Attaches the behavior to its arc rotate camera.
  101596. * @param camera Defines the camera to attach the behavior to
  101597. */
  101598. attach(camera: ArcRotateCamera): void;
  101599. /**
  101600. * Detaches the behavior from its current arc rotate camera.
  101601. */
  101602. detach(): void;
  101603. private _animatables;
  101604. private _betaIsAnimating;
  101605. private _betaTransition;
  101606. private _radiusTransition;
  101607. private _vectorTransition;
  101608. /**
  101609. * Targets the given mesh and updates zoom level accordingly.
  101610. * @param mesh The mesh to target.
  101611. * @param radius Optional. If a cached radius position already exists, overrides default.
  101612. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101613. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101614. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101615. */
  101616. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101617. /**
  101618. * Targets the given mesh with its children and updates zoom level accordingly.
  101619. * @param mesh The mesh to target.
  101620. * @param radius Optional. If a cached radius position already exists, overrides default.
  101621. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101622. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101623. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101624. */
  101625. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101626. /**
  101627. * Targets the given meshes with their children and updates zoom level accordingly.
  101628. * @param meshes The mesh to target.
  101629. * @param radius Optional. If a cached radius position already exists, overrides default.
  101630. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101631. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101632. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101633. */
  101634. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101635. /**
  101636. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  101637. * @param minimumWorld Determines the smaller position of the bounding box extend
  101638. * @param maximumWorld Determines the bigger position of the bounding box extend
  101639. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101640. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101641. */
  101642. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101643. /**
  101644. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  101645. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  101646. * frustum width.
  101647. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  101648. * to fully enclose the mesh in the viewing frustum.
  101649. */
  101650. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  101651. /**
  101652. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  101653. * is automatically returned to its default position (expected to be above ground plane).
  101654. */
  101655. private _maintainCameraAboveGround;
  101656. /**
  101657. * Returns the frustum slope based on the canvas ratio and camera FOV
  101658. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  101659. */
  101660. private _getFrustumSlope;
  101661. /**
  101662. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  101663. */
  101664. private _clearAnimationLocks;
  101665. /**
  101666. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  101667. */
  101668. private _applyUserInteraction;
  101669. /**
  101670. * Stops and removes all animations that have been applied to the camera
  101671. */
  101672. stopAllAnimations(): void;
  101673. /**
  101674. * Gets a value indicating if the user is moving the camera
  101675. */
  101676. readonly isUserIsMoving: boolean;
  101677. /**
  101678. * The camera can move all the way towards the mesh.
  101679. */
  101680. static IgnoreBoundsSizeMode: number;
  101681. /**
  101682. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  101683. */
  101684. static FitFrustumSidesMode: number;
  101685. }
  101686. }
  101687. declare module BABYLON {
  101688. /**
  101689. * Base class for Camera Pointer Inputs.
  101690. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  101691. * for example usage.
  101692. */
  101693. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  101694. /**
  101695. * Defines the camera the input is attached to.
  101696. */
  101697. abstract camera: Camera;
  101698. /**
  101699. * Whether keyboard modifier keys are pressed at time of last mouse event.
  101700. */
  101701. protected _altKey: boolean;
  101702. protected _ctrlKey: boolean;
  101703. protected _metaKey: boolean;
  101704. protected _shiftKey: boolean;
  101705. /**
  101706. * Which mouse buttons were pressed at time of last mouse event.
  101707. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  101708. */
  101709. protected _buttonsPressed: number;
  101710. /**
  101711. * Defines the buttons associated with the input to handle camera move.
  101712. */
  101713. buttons: number[];
  101714. /**
  101715. * Attach the input controls to a specific dom element to get the input from.
  101716. * @param element Defines the element the controls should be listened from
  101717. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101718. */
  101719. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101720. /**
  101721. * Detach the current controls from the specified dom element.
  101722. * @param element Defines the element to stop listening the inputs from
  101723. */
  101724. detachControl(element: Nullable<HTMLElement>): void;
  101725. /**
  101726. * Gets the class name of the current input.
  101727. * @returns the class name
  101728. */
  101729. getClassName(): string;
  101730. /**
  101731. * Get the friendly name associated with the input class.
  101732. * @returns the input friendly name
  101733. */
  101734. getSimpleName(): string;
  101735. /**
  101736. * Called on pointer POINTERDOUBLETAP event.
  101737. * Override this method to provide functionality on POINTERDOUBLETAP event.
  101738. */
  101739. protected onDoubleTap(type: string): void;
  101740. /**
  101741. * Called on pointer POINTERMOVE event if only a single touch is active.
  101742. * Override this method to provide functionality.
  101743. */
  101744. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101745. /**
  101746. * Called on pointer POINTERMOVE event if multiple touches are active.
  101747. * Override this method to provide functionality.
  101748. */
  101749. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101750. /**
  101751. * Called on JS contextmenu event.
  101752. * Override this method to provide functionality.
  101753. */
  101754. protected onContextMenu(evt: PointerEvent): void;
  101755. /**
  101756. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101757. * press.
  101758. * Override this method to provide functionality.
  101759. */
  101760. protected onButtonDown(evt: PointerEvent): void;
  101761. /**
  101762. * Called each time a new POINTERUP event occurs. Ie, for each button
  101763. * release.
  101764. * Override this method to provide functionality.
  101765. */
  101766. protected onButtonUp(evt: PointerEvent): void;
  101767. /**
  101768. * Called when window becomes inactive.
  101769. * Override this method to provide functionality.
  101770. */
  101771. protected onLostFocus(): void;
  101772. private _pointerInput;
  101773. private _observer;
  101774. private _onLostFocus;
  101775. private pointA;
  101776. private pointB;
  101777. }
  101778. }
  101779. declare module BABYLON {
  101780. /**
  101781. * Manage the pointers inputs to control an arc rotate camera.
  101782. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101783. */
  101784. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  101785. /**
  101786. * Defines the camera the input is attached to.
  101787. */
  101788. camera: ArcRotateCamera;
  101789. /**
  101790. * Gets the class name of the current input.
  101791. * @returns the class name
  101792. */
  101793. getClassName(): string;
  101794. /**
  101795. * Defines the buttons associated with the input to handle camera move.
  101796. */
  101797. buttons: number[];
  101798. /**
  101799. * Defines the pointer angular sensibility along the X axis or how fast is
  101800. * the camera rotating.
  101801. */
  101802. angularSensibilityX: number;
  101803. /**
  101804. * Defines the pointer angular sensibility along the Y axis or how fast is
  101805. * the camera rotating.
  101806. */
  101807. angularSensibilityY: number;
  101808. /**
  101809. * Defines the pointer pinch precision or how fast is the camera zooming.
  101810. */
  101811. pinchPrecision: number;
  101812. /**
  101813. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101814. * from 0.
  101815. * It defines the percentage of current camera.radius to use as delta when
  101816. * pinch zoom is used.
  101817. */
  101818. pinchDeltaPercentage: number;
  101819. /**
  101820. * Defines the pointer panning sensibility or how fast is the camera moving.
  101821. */
  101822. panningSensibility: number;
  101823. /**
  101824. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  101825. */
  101826. multiTouchPanning: boolean;
  101827. /**
  101828. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  101829. * zoom (pinch) through multitouch.
  101830. */
  101831. multiTouchPanAndZoom: boolean;
  101832. /**
  101833. * Revers pinch action direction.
  101834. */
  101835. pinchInwards: boolean;
  101836. private _isPanClick;
  101837. private _twoFingerActivityCount;
  101838. private _isPinching;
  101839. /**
  101840. * Called on pointer POINTERMOVE event if only a single touch is active.
  101841. */
  101842. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101843. /**
  101844. * Called on pointer POINTERDOUBLETAP event.
  101845. */
  101846. protected onDoubleTap(type: string): void;
  101847. /**
  101848. * Called on pointer POINTERMOVE event if multiple touches are active.
  101849. */
  101850. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101851. /**
  101852. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101853. * press.
  101854. */
  101855. protected onButtonDown(evt: PointerEvent): void;
  101856. /**
  101857. * Called each time a new POINTERUP event occurs. Ie, for each button
  101858. * release.
  101859. */
  101860. protected onButtonUp(evt: PointerEvent): void;
  101861. /**
  101862. * Called when window becomes inactive.
  101863. */
  101864. protected onLostFocus(): void;
  101865. }
  101866. }
  101867. declare module BABYLON {
  101868. /**
  101869. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  101870. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101871. */
  101872. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  101873. /**
  101874. * Defines the camera the input is attached to.
  101875. */
  101876. camera: ArcRotateCamera;
  101877. /**
  101878. * Defines the list of key codes associated with the up action (increase alpha)
  101879. */
  101880. keysUp: number[];
  101881. /**
  101882. * Defines the list of key codes associated with the down action (decrease alpha)
  101883. */
  101884. keysDown: number[];
  101885. /**
  101886. * Defines the list of key codes associated with the left action (increase beta)
  101887. */
  101888. keysLeft: number[];
  101889. /**
  101890. * Defines the list of key codes associated with the right action (decrease beta)
  101891. */
  101892. keysRight: number[];
  101893. /**
  101894. * Defines the list of key codes associated with the reset action.
  101895. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  101896. */
  101897. keysReset: number[];
  101898. /**
  101899. * Defines the panning sensibility of the inputs.
  101900. * (How fast is the camera paning)
  101901. */
  101902. panningSensibility: number;
  101903. /**
  101904. * Defines the zooming sensibility of the inputs.
  101905. * (How fast is the camera zooming)
  101906. */
  101907. zoomingSensibility: number;
  101908. /**
  101909. * Defines wether maintaining the alt key down switch the movement mode from
  101910. * orientation to zoom.
  101911. */
  101912. useAltToZoom: boolean;
  101913. /**
  101914. * Rotation speed of the camera
  101915. */
  101916. angularSpeed: number;
  101917. private _keys;
  101918. private _ctrlPressed;
  101919. private _altPressed;
  101920. private _onCanvasBlurObserver;
  101921. private _onKeyboardObserver;
  101922. private _engine;
  101923. private _scene;
  101924. /**
  101925. * Attach the input controls to a specific dom element to get the input from.
  101926. * @param element Defines the element the controls should be listened from
  101927. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101928. */
  101929. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101930. /**
  101931. * Detach the current controls from the specified dom element.
  101932. * @param element Defines the element to stop listening the inputs from
  101933. */
  101934. detachControl(element: Nullable<HTMLElement>): void;
  101935. /**
  101936. * Update the current camera state depending on the inputs that have been used this frame.
  101937. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101938. */
  101939. checkInputs(): void;
  101940. /**
  101941. * Gets the class name of the current intput.
  101942. * @returns the class name
  101943. */
  101944. getClassName(): string;
  101945. /**
  101946. * Get the friendly name associated with the input class.
  101947. * @returns the input friendly name
  101948. */
  101949. getSimpleName(): string;
  101950. }
  101951. }
  101952. declare module BABYLON {
  101953. /**
  101954. * Manage the mouse wheel inputs to control an arc rotate camera.
  101955. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101956. */
  101957. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  101958. /**
  101959. * Defines the camera the input is attached to.
  101960. */
  101961. camera: ArcRotateCamera;
  101962. /**
  101963. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  101964. */
  101965. wheelPrecision: number;
  101966. /**
  101967. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  101968. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  101969. */
  101970. wheelDeltaPercentage: number;
  101971. private _wheel;
  101972. private _observer;
  101973. private computeDeltaFromMouseWheelLegacyEvent;
  101974. /**
  101975. * Attach the input controls to a specific dom element to get the input from.
  101976. * @param element Defines the element the controls should be listened from
  101977. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101978. */
  101979. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101980. /**
  101981. * Detach the current controls from the specified dom element.
  101982. * @param element Defines the element to stop listening the inputs from
  101983. */
  101984. detachControl(element: Nullable<HTMLElement>): void;
  101985. /**
  101986. * Gets the class name of the current intput.
  101987. * @returns the class name
  101988. */
  101989. getClassName(): string;
  101990. /**
  101991. * Get the friendly name associated with the input class.
  101992. * @returns the input friendly name
  101993. */
  101994. getSimpleName(): string;
  101995. }
  101996. }
  101997. declare module BABYLON {
  101998. /**
  101999. * Default Inputs manager for the ArcRotateCamera.
  102000. * It groups all the default supported inputs for ease of use.
  102001. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102002. */
  102003. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  102004. /**
  102005. * Instantiates a new ArcRotateCameraInputsManager.
  102006. * @param camera Defines the camera the inputs belong to
  102007. */
  102008. constructor(camera: ArcRotateCamera);
  102009. /**
  102010. * Add mouse wheel input support to the input manager.
  102011. * @returns the current input manager
  102012. */
  102013. addMouseWheel(): ArcRotateCameraInputsManager;
  102014. /**
  102015. * Add pointers input support to the input manager.
  102016. * @returns the current input manager
  102017. */
  102018. addPointers(): ArcRotateCameraInputsManager;
  102019. /**
  102020. * Add keyboard input support to the input manager.
  102021. * @returns the current input manager
  102022. */
  102023. addKeyboard(): ArcRotateCameraInputsManager;
  102024. }
  102025. }
  102026. declare module BABYLON {
  102027. /**
  102028. * This represents an orbital type of camera.
  102029. *
  102030. * 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.
  102031. * 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.
  102032. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  102033. */
  102034. export class ArcRotateCamera extends TargetCamera {
  102035. /**
  102036. * Defines the rotation angle of the camera along the longitudinal axis.
  102037. */
  102038. alpha: number;
  102039. /**
  102040. * Defines the rotation angle of the camera along the latitudinal axis.
  102041. */
  102042. beta: number;
  102043. /**
  102044. * Defines the radius of the camera from it s target point.
  102045. */
  102046. radius: number;
  102047. protected _target: Vector3;
  102048. protected _targetHost: Nullable<AbstractMesh>;
  102049. /**
  102050. * Defines the target point of the camera.
  102051. * The camera looks towards it form the radius distance.
  102052. */
  102053. target: Vector3;
  102054. /**
  102055. * Define the current local position of the camera in the scene
  102056. */
  102057. position: Vector3;
  102058. protected _upVector: Vector3;
  102059. protected _upToYMatrix: Matrix;
  102060. protected _YToUpMatrix: Matrix;
  102061. /**
  102062. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  102063. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  102064. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  102065. */
  102066. upVector: Vector3;
  102067. /**
  102068. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  102069. */
  102070. setMatUp(): void;
  102071. /**
  102072. * Current inertia value on the longitudinal axis.
  102073. * The bigger this number the longer it will take for the camera to stop.
  102074. */
  102075. inertialAlphaOffset: number;
  102076. /**
  102077. * Current inertia value on the latitudinal axis.
  102078. * The bigger this number the longer it will take for the camera to stop.
  102079. */
  102080. inertialBetaOffset: number;
  102081. /**
  102082. * Current inertia value on the radius axis.
  102083. * The bigger this number the longer it will take for the camera to stop.
  102084. */
  102085. inertialRadiusOffset: number;
  102086. /**
  102087. * Minimum allowed angle on the longitudinal axis.
  102088. * This can help limiting how the Camera is able to move in the scene.
  102089. */
  102090. lowerAlphaLimit: Nullable<number>;
  102091. /**
  102092. * Maximum allowed angle on the longitudinal axis.
  102093. * This can help limiting how the Camera is able to move in the scene.
  102094. */
  102095. upperAlphaLimit: Nullable<number>;
  102096. /**
  102097. * Minimum allowed angle on the latitudinal axis.
  102098. * This can help limiting how the Camera is able to move in the scene.
  102099. */
  102100. lowerBetaLimit: number;
  102101. /**
  102102. * Maximum allowed angle on the latitudinal axis.
  102103. * This can help limiting how the Camera is able to move in the scene.
  102104. */
  102105. upperBetaLimit: number;
  102106. /**
  102107. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  102108. * This can help limiting how the Camera is able to move in the scene.
  102109. */
  102110. lowerRadiusLimit: Nullable<number>;
  102111. /**
  102112. * Maximum allowed distance of the camera to the target (The camera can not get further).
  102113. * This can help limiting how the Camera is able to move in the scene.
  102114. */
  102115. upperRadiusLimit: Nullable<number>;
  102116. /**
  102117. * Defines the current inertia value used during panning of the camera along the X axis.
  102118. */
  102119. inertialPanningX: number;
  102120. /**
  102121. * Defines the current inertia value used during panning of the camera along the Y axis.
  102122. */
  102123. inertialPanningY: number;
  102124. /**
  102125. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  102126. * Basically if your fingers moves away from more than this distance you will be considered
  102127. * in pinch mode.
  102128. */
  102129. pinchToPanMaxDistance: number;
  102130. /**
  102131. * Defines the maximum distance the camera can pan.
  102132. * This could help keeping the cammera always in your scene.
  102133. */
  102134. panningDistanceLimit: Nullable<number>;
  102135. /**
  102136. * Defines the target of the camera before paning.
  102137. */
  102138. panningOriginTarget: Vector3;
  102139. /**
  102140. * Defines the value of the inertia used during panning.
  102141. * 0 would mean stop inertia and one would mean no decelleration at all.
  102142. */
  102143. panningInertia: number;
  102144. /**
  102145. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  102146. */
  102147. angularSensibilityX: number;
  102148. /**
  102149. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  102150. */
  102151. angularSensibilityY: number;
  102152. /**
  102153. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  102154. */
  102155. pinchPrecision: number;
  102156. /**
  102157. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  102158. * It will be used instead of pinchDeltaPrecision if different from 0.
  102159. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102160. */
  102161. pinchDeltaPercentage: number;
  102162. /**
  102163. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  102164. */
  102165. panningSensibility: number;
  102166. /**
  102167. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  102168. */
  102169. keysUp: number[];
  102170. /**
  102171. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  102172. */
  102173. keysDown: number[];
  102174. /**
  102175. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  102176. */
  102177. keysLeft: number[];
  102178. /**
  102179. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  102180. */
  102181. keysRight: number[];
  102182. /**
  102183. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  102184. */
  102185. wheelPrecision: number;
  102186. /**
  102187. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  102188. * It will be used instead of pinchDeltaPrecision if different from 0.
  102189. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102190. */
  102191. wheelDeltaPercentage: number;
  102192. /**
  102193. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  102194. */
  102195. zoomOnFactor: number;
  102196. /**
  102197. * Defines a screen offset for the camera position.
  102198. */
  102199. targetScreenOffset: Vector2;
  102200. /**
  102201. * Allows the camera to be completely reversed.
  102202. * If false the camera can not arrive upside down.
  102203. */
  102204. allowUpsideDown: boolean;
  102205. /**
  102206. * Define if double tap/click is used to restore the previously saved state of the camera.
  102207. */
  102208. useInputToRestoreState: boolean;
  102209. /** @hidden */
  102210. _viewMatrix: Matrix;
  102211. /** @hidden */
  102212. _useCtrlForPanning: boolean;
  102213. /** @hidden */
  102214. _panningMouseButton: number;
  102215. /**
  102216. * Defines the input associated to the camera.
  102217. */
  102218. inputs: ArcRotateCameraInputsManager;
  102219. /** @hidden */
  102220. _reset: () => void;
  102221. /**
  102222. * Defines the allowed panning axis.
  102223. */
  102224. panningAxis: Vector3;
  102225. protected _localDirection: Vector3;
  102226. protected _transformedDirection: Vector3;
  102227. private _bouncingBehavior;
  102228. /**
  102229. * Gets the bouncing behavior of the camera if it has been enabled.
  102230. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102231. */
  102232. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  102233. /**
  102234. * Defines if the bouncing behavior of the camera is enabled on the camera.
  102235. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102236. */
  102237. useBouncingBehavior: boolean;
  102238. private _framingBehavior;
  102239. /**
  102240. * Gets the framing behavior of the camera if it has been enabled.
  102241. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102242. */
  102243. readonly framingBehavior: Nullable<FramingBehavior>;
  102244. /**
  102245. * Defines if the framing behavior of the camera is enabled on the camera.
  102246. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102247. */
  102248. useFramingBehavior: boolean;
  102249. private _autoRotationBehavior;
  102250. /**
  102251. * Gets the auto rotation behavior of the camera if it has been enabled.
  102252. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102253. */
  102254. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  102255. /**
  102256. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  102257. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102258. */
  102259. useAutoRotationBehavior: boolean;
  102260. /**
  102261. * Observable triggered when the mesh target has been changed on the camera.
  102262. */
  102263. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  102264. /**
  102265. * Event raised when the camera is colliding with a mesh.
  102266. */
  102267. onCollide: (collidedMesh: AbstractMesh) => void;
  102268. /**
  102269. * Defines whether the camera should check collision with the objects oh the scene.
  102270. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  102271. */
  102272. checkCollisions: boolean;
  102273. /**
  102274. * Defines the collision radius of the camera.
  102275. * This simulates a sphere around the camera.
  102276. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  102277. */
  102278. collisionRadius: Vector3;
  102279. protected _collider: Collider;
  102280. protected _previousPosition: Vector3;
  102281. protected _collisionVelocity: Vector3;
  102282. protected _newPosition: Vector3;
  102283. protected _previousAlpha: number;
  102284. protected _previousBeta: number;
  102285. protected _previousRadius: number;
  102286. protected _collisionTriggered: boolean;
  102287. protected _targetBoundingCenter: Nullable<Vector3>;
  102288. private _computationVector;
  102289. /**
  102290. * Instantiates a new ArcRotateCamera in a given scene
  102291. * @param name Defines the name of the camera
  102292. * @param alpha Defines the camera rotation along the logitudinal axis
  102293. * @param beta Defines the camera rotation along the latitudinal axis
  102294. * @param radius Defines the camera distance from its target
  102295. * @param target Defines the camera target
  102296. * @param scene Defines the scene the camera belongs to
  102297. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  102298. */
  102299. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102300. /** @hidden */
  102301. _initCache(): void;
  102302. /** @hidden */
  102303. _updateCache(ignoreParentClass?: boolean): void;
  102304. protected _getTargetPosition(): Vector3;
  102305. private _storedAlpha;
  102306. private _storedBeta;
  102307. private _storedRadius;
  102308. private _storedTarget;
  102309. private _storedTargetScreenOffset;
  102310. /**
  102311. * Stores the current state of the camera (alpha, beta, radius and target)
  102312. * @returns the camera itself
  102313. */
  102314. storeState(): Camera;
  102315. /**
  102316. * @hidden
  102317. * Restored camera state. You must call storeState() first
  102318. */
  102319. _restoreStateValues(): boolean;
  102320. /** @hidden */
  102321. _isSynchronizedViewMatrix(): boolean;
  102322. /**
  102323. * Attached controls to the current camera.
  102324. * @param element Defines the element the controls should be listened from
  102325. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102326. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  102327. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  102328. */
  102329. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  102330. /**
  102331. * Detach the current controls from the camera.
  102332. * The camera will stop reacting to inputs.
  102333. * @param element Defines the element to stop listening the inputs from
  102334. */
  102335. detachControl(element: HTMLElement): void;
  102336. /** @hidden */
  102337. _checkInputs(): void;
  102338. protected _checkLimits(): void;
  102339. /**
  102340. * Rebuilds angles (alpha, beta) and radius from the give position and target
  102341. */
  102342. rebuildAnglesAndRadius(): void;
  102343. /**
  102344. * Use a position to define the current camera related information like aplha, beta and radius
  102345. * @param position Defines the position to set the camera at
  102346. */
  102347. setPosition(position: Vector3): void;
  102348. /**
  102349. * Defines the target the camera should look at.
  102350. * This will automatically adapt alpha beta and radius to fit within the new target.
  102351. * @param target Defines the new target as a Vector or a mesh
  102352. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  102353. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  102354. */
  102355. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  102356. /** @hidden */
  102357. _getViewMatrix(): Matrix;
  102358. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  102359. /**
  102360. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  102361. * @param meshes Defines the mesh to zoom on
  102362. * @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)
  102363. */
  102364. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  102365. /**
  102366. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  102367. * The target will be changed but the radius
  102368. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  102369. * @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)
  102370. */
  102371. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  102372. min: Vector3;
  102373. max: Vector3;
  102374. distance: number;
  102375. }, doNotUpdateMaxZ?: boolean): void;
  102376. /**
  102377. * @override
  102378. * Override Camera.createRigCamera
  102379. */
  102380. createRigCamera(name: string, cameraIndex: number): Camera;
  102381. /**
  102382. * @hidden
  102383. * @override
  102384. * Override Camera._updateRigCameras
  102385. */
  102386. _updateRigCameras(): void;
  102387. /**
  102388. * Destroy the camera and release the current resources hold by it.
  102389. */
  102390. dispose(): void;
  102391. /**
  102392. * Gets the current object class name.
  102393. * @return the class name
  102394. */
  102395. getClassName(): string;
  102396. }
  102397. }
  102398. declare module BABYLON {
  102399. /**
  102400. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  102401. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102402. */
  102403. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  102404. /**
  102405. * Gets the name of the behavior.
  102406. */
  102407. readonly name: string;
  102408. private _zoomStopsAnimation;
  102409. private _idleRotationSpeed;
  102410. private _idleRotationWaitTime;
  102411. private _idleRotationSpinupTime;
  102412. /**
  102413. * Sets the flag that indicates if user zooming should stop animation.
  102414. */
  102415. /**
  102416. * Gets the flag that indicates if user zooming should stop animation.
  102417. */
  102418. zoomStopsAnimation: boolean;
  102419. /**
  102420. * Sets the default speed at which the camera rotates around the model.
  102421. */
  102422. /**
  102423. * Gets the default speed at which the camera rotates around the model.
  102424. */
  102425. idleRotationSpeed: number;
  102426. /**
  102427. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  102428. */
  102429. /**
  102430. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  102431. */
  102432. idleRotationWaitTime: number;
  102433. /**
  102434. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102435. */
  102436. /**
  102437. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102438. */
  102439. idleRotationSpinupTime: number;
  102440. /**
  102441. * Gets a value indicating if the camera is currently rotating because of this behavior
  102442. */
  102443. readonly rotationInProgress: boolean;
  102444. private _onPrePointerObservableObserver;
  102445. private _onAfterCheckInputsObserver;
  102446. private _attachedCamera;
  102447. private _isPointerDown;
  102448. private _lastFrameTime;
  102449. private _lastInteractionTime;
  102450. private _cameraRotationSpeed;
  102451. /**
  102452. * Initializes the behavior.
  102453. */
  102454. init(): void;
  102455. /**
  102456. * Attaches the behavior to its arc rotate camera.
  102457. * @param camera Defines the camera to attach the behavior to
  102458. */
  102459. attach(camera: ArcRotateCamera): void;
  102460. /**
  102461. * Detaches the behavior from its current arc rotate camera.
  102462. */
  102463. detach(): void;
  102464. /**
  102465. * Returns true if user is scrolling.
  102466. * @return true if user is scrolling.
  102467. */
  102468. private _userIsZooming;
  102469. private _lastFrameRadius;
  102470. private _shouldAnimationStopForInteraction;
  102471. /**
  102472. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102473. */
  102474. private _applyUserInteraction;
  102475. private _userIsMoving;
  102476. }
  102477. }
  102478. declare module BABYLON {
  102479. /**
  102480. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  102481. */
  102482. export class AttachToBoxBehavior implements Behavior<Mesh> {
  102483. private ui;
  102484. /**
  102485. * The name of the behavior
  102486. */
  102487. name: string;
  102488. /**
  102489. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  102490. */
  102491. distanceAwayFromFace: number;
  102492. /**
  102493. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  102494. */
  102495. distanceAwayFromBottomOfFace: number;
  102496. private _faceVectors;
  102497. private _target;
  102498. private _scene;
  102499. private _onRenderObserver;
  102500. private _tmpMatrix;
  102501. private _tmpVector;
  102502. /**
  102503. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  102504. * @param ui The transform node that should be attched to the mesh
  102505. */
  102506. constructor(ui: TransformNode);
  102507. /**
  102508. * Initializes the behavior
  102509. */
  102510. init(): void;
  102511. private _closestFace;
  102512. private _zeroVector;
  102513. private _lookAtTmpMatrix;
  102514. private _lookAtToRef;
  102515. /**
  102516. * Attaches the AttachToBoxBehavior to the passed in mesh
  102517. * @param target The mesh that the specified node will be attached to
  102518. */
  102519. attach(target: Mesh): void;
  102520. /**
  102521. * Detaches the behavior from the mesh
  102522. */
  102523. detach(): void;
  102524. }
  102525. }
  102526. declare module BABYLON {
  102527. /**
  102528. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  102529. */
  102530. export class FadeInOutBehavior implements Behavior<Mesh> {
  102531. /**
  102532. * Time in milliseconds to delay before fading in (Default: 0)
  102533. */
  102534. delay: number;
  102535. /**
  102536. * Time in milliseconds for the mesh to fade in (Default: 300)
  102537. */
  102538. fadeInTime: number;
  102539. private _millisecondsPerFrame;
  102540. private _hovered;
  102541. private _hoverValue;
  102542. private _ownerNode;
  102543. /**
  102544. * Instatiates the FadeInOutBehavior
  102545. */
  102546. constructor();
  102547. /**
  102548. * The name of the behavior
  102549. */
  102550. readonly name: string;
  102551. /**
  102552. * Initializes the behavior
  102553. */
  102554. init(): void;
  102555. /**
  102556. * Attaches the fade behavior on the passed in mesh
  102557. * @param ownerNode The mesh that will be faded in/out once attached
  102558. */
  102559. attach(ownerNode: Mesh): void;
  102560. /**
  102561. * Detaches the behavior from the mesh
  102562. */
  102563. detach(): void;
  102564. /**
  102565. * Triggers the mesh to begin fading in or out
  102566. * @param value if the object should fade in or out (true to fade in)
  102567. */
  102568. fadeIn(value: boolean): void;
  102569. private _update;
  102570. private _setAllVisibility;
  102571. }
  102572. }
  102573. declare module BABYLON {
  102574. /**
  102575. * Class containing a set of static utilities functions for managing Pivots
  102576. * @hidden
  102577. */
  102578. export class PivotTools {
  102579. private static _PivotCached;
  102580. private static _OldPivotPoint;
  102581. private static _PivotTranslation;
  102582. private static _PivotTmpVector;
  102583. /** @hidden */
  102584. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  102585. /** @hidden */
  102586. static _RestorePivotPoint(mesh: AbstractMesh): void;
  102587. }
  102588. }
  102589. declare module BABYLON {
  102590. /**
  102591. * Class containing static functions to help procedurally build meshes
  102592. */
  102593. export class PlaneBuilder {
  102594. /**
  102595. * Creates a plane mesh
  102596. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  102597. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  102598. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  102599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102600. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102602. * @param name defines the name of the mesh
  102603. * @param options defines the options used to create the mesh
  102604. * @param scene defines the hosting scene
  102605. * @returns the plane mesh
  102606. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  102607. */
  102608. static CreatePlane(name: string, options: {
  102609. size?: number;
  102610. width?: number;
  102611. height?: number;
  102612. sideOrientation?: number;
  102613. frontUVs?: Vector4;
  102614. backUVs?: Vector4;
  102615. updatable?: boolean;
  102616. sourcePlane?: Plane;
  102617. }, scene?: Nullable<Scene>): Mesh;
  102618. }
  102619. }
  102620. declare module BABYLON {
  102621. /**
  102622. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  102623. */
  102624. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  102625. private static _AnyMouseID;
  102626. /**
  102627. * Abstract mesh the behavior is set on
  102628. */
  102629. attachedNode: AbstractMesh;
  102630. private _dragPlane;
  102631. private _scene;
  102632. private _pointerObserver;
  102633. private _beforeRenderObserver;
  102634. private static _planeScene;
  102635. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  102636. /**
  102637. * 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)
  102638. */
  102639. maxDragAngle: number;
  102640. /**
  102641. * @hidden
  102642. */
  102643. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  102644. /**
  102645. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102646. */
  102647. currentDraggingPointerID: number;
  102648. /**
  102649. * The last position where the pointer hit the drag plane in world space
  102650. */
  102651. lastDragPosition: Vector3;
  102652. /**
  102653. * If the behavior is currently in a dragging state
  102654. */
  102655. dragging: boolean;
  102656. /**
  102657. * 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)
  102658. */
  102659. dragDeltaRatio: number;
  102660. /**
  102661. * If the drag plane orientation should be updated during the dragging (Default: true)
  102662. */
  102663. updateDragPlane: boolean;
  102664. private _debugMode;
  102665. private _moving;
  102666. /**
  102667. * Fires each time the attached mesh is dragged with the pointer
  102668. * * delta between last drag position and current drag position in world space
  102669. * * dragDistance along the drag axis
  102670. * * dragPlaneNormal normal of the current drag plane used during the drag
  102671. * * dragPlanePoint in world space where the drag intersects the drag plane
  102672. */
  102673. onDragObservable: Observable<{
  102674. delta: Vector3;
  102675. dragPlanePoint: Vector3;
  102676. dragPlaneNormal: Vector3;
  102677. dragDistance: number;
  102678. pointerId: number;
  102679. }>;
  102680. /**
  102681. * Fires each time a drag begins (eg. mouse down on mesh)
  102682. */
  102683. onDragStartObservable: Observable<{
  102684. dragPlanePoint: Vector3;
  102685. pointerId: number;
  102686. }>;
  102687. /**
  102688. * Fires each time a drag ends (eg. mouse release after drag)
  102689. */
  102690. onDragEndObservable: Observable<{
  102691. dragPlanePoint: Vector3;
  102692. pointerId: number;
  102693. }>;
  102694. /**
  102695. * If the attached mesh should be moved when dragged
  102696. */
  102697. moveAttached: boolean;
  102698. /**
  102699. * If the drag behavior will react to drag events (Default: true)
  102700. */
  102701. enabled: boolean;
  102702. /**
  102703. * If pointer events should start and release the drag (Default: true)
  102704. */
  102705. startAndReleaseDragOnPointerEvents: boolean;
  102706. /**
  102707. * If camera controls should be detached during the drag
  102708. */
  102709. detachCameraControls: boolean;
  102710. /**
  102711. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  102712. */
  102713. useObjectOrienationForDragging: boolean;
  102714. private _options;
  102715. /**
  102716. * Creates a pointer drag behavior that can be attached to a mesh
  102717. * @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)
  102718. */
  102719. constructor(options?: {
  102720. dragAxis?: Vector3;
  102721. dragPlaneNormal?: Vector3;
  102722. });
  102723. /**
  102724. * Predicate to determine if it is valid to move the object to a new position when it is moved
  102725. */
  102726. validateDrag: (targetPosition: Vector3) => boolean;
  102727. /**
  102728. * The name of the behavior
  102729. */
  102730. readonly name: string;
  102731. /**
  102732. * Initializes the behavior
  102733. */
  102734. init(): void;
  102735. private _tmpVector;
  102736. private _alternatePickedPoint;
  102737. private _worldDragAxis;
  102738. private _targetPosition;
  102739. private _attachedElement;
  102740. /**
  102741. * Attaches the drag behavior the passed in mesh
  102742. * @param ownerNode The mesh that will be dragged around once attached
  102743. * @param predicate Predicate to use for pick filtering
  102744. */
  102745. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  102746. /**
  102747. * Force relase the drag action by code.
  102748. */
  102749. releaseDrag(): void;
  102750. private _startDragRay;
  102751. private _lastPointerRay;
  102752. /**
  102753. * Simulates the start of a pointer drag event on the behavior
  102754. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  102755. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  102756. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  102757. */
  102758. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  102759. private _startDrag;
  102760. private _dragDelta;
  102761. private _moveDrag;
  102762. private _pickWithRayOnDragPlane;
  102763. private _pointA;
  102764. private _pointB;
  102765. private _pointC;
  102766. private _lineA;
  102767. private _lineB;
  102768. private _localAxis;
  102769. private _lookAt;
  102770. private _updateDragPlanePosition;
  102771. /**
  102772. * Detaches the behavior from the mesh
  102773. */
  102774. detach(): void;
  102775. }
  102776. }
  102777. declare module BABYLON {
  102778. /**
  102779. * A behavior that when attached to a mesh will allow the mesh to be scaled
  102780. */
  102781. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  102782. private _dragBehaviorA;
  102783. private _dragBehaviorB;
  102784. private _startDistance;
  102785. private _initialScale;
  102786. private _targetScale;
  102787. private _ownerNode;
  102788. private _sceneRenderObserver;
  102789. /**
  102790. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  102791. */
  102792. constructor();
  102793. /**
  102794. * The name of the behavior
  102795. */
  102796. readonly name: string;
  102797. /**
  102798. * Initializes the behavior
  102799. */
  102800. init(): void;
  102801. private _getCurrentDistance;
  102802. /**
  102803. * Attaches the scale behavior the passed in mesh
  102804. * @param ownerNode The mesh that will be scaled around once attached
  102805. */
  102806. attach(ownerNode: Mesh): void;
  102807. /**
  102808. * Detaches the behavior from the mesh
  102809. */
  102810. detach(): void;
  102811. }
  102812. }
  102813. declare module BABYLON {
  102814. /**
  102815. * 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
  102816. */
  102817. export class SixDofDragBehavior implements Behavior<Mesh> {
  102818. private static _virtualScene;
  102819. private _ownerNode;
  102820. private _sceneRenderObserver;
  102821. private _scene;
  102822. private _targetPosition;
  102823. private _virtualOriginMesh;
  102824. private _virtualDragMesh;
  102825. private _pointerObserver;
  102826. private _moving;
  102827. private _startingOrientation;
  102828. /**
  102829. * 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)
  102830. */
  102831. private zDragFactor;
  102832. /**
  102833. * If the object should rotate to face the drag origin
  102834. */
  102835. rotateDraggedObject: boolean;
  102836. /**
  102837. * If the behavior is currently in a dragging state
  102838. */
  102839. dragging: boolean;
  102840. /**
  102841. * 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)
  102842. */
  102843. dragDeltaRatio: number;
  102844. /**
  102845. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102846. */
  102847. currentDraggingPointerID: number;
  102848. /**
  102849. * If camera controls should be detached during the drag
  102850. */
  102851. detachCameraControls: boolean;
  102852. /**
  102853. * Fires each time a drag starts
  102854. */
  102855. onDragStartObservable: Observable<{}>;
  102856. /**
  102857. * Fires each time a drag ends (eg. mouse release after drag)
  102858. */
  102859. onDragEndObservable: Observable<{}>;
  102860. /**
  102861. * 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
  102862. */
  102863. constructor();
  102864. /**
  102865. * The name of the behavior
  102866. */
  102867. readonly name: string;
  102868. /**
  102869. * Initializes the behavior
  102870. */
  102871. init(): void;
  102872. /**
  102873. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  102874. */
  102875. private readonly _pointerCamera;
  102876. /**
  102877. * Attaches the scale behavior the passed in mesh
  102878. * @param ownerNode The mesh that will be scaled around once attached
  102879. */
  102880. attach(ownerNode: Mesh): void;
  102881. /**
  102882. * Detaches the behavior from the mesh
  102883. */
  102884. detach(): void;
  102885. }
  102886. }
  102887. declare module BABYLON {
  102888. /**
  102889. * Class used to apply inverse kinematics to bones
  102890. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  102891. */
  102892. export class BoneIKController {
  102893. private static _tmpVecs;
  102894. private static _tmpQuat;
  102895. private static _tmpMats;
  102896. /**
  102897. * Gets or sets the target mesh
  102898. */
  102899. targetMesh: AbstractMesh;
  102900. /** Gets or sets the mesh used as pole */
  102901. poleTargetMesh: AbstractMesh;
  102902. /**
  102903. * Gets or sets the bone used as pole
  102904. */
  102905. poleTargetBone: Nullable<Bone>;
  102906. /**
  102907. * Gets or sets the target position
  102908. */
  102909. targetPosition: Vector3;
  102910. /**
  102911. * Gets or sets the pole target position
  102912. */
  102913. poleTargetPosition: Vector3;
  102914. /**
  102915. * Gets or sets the pole target local offset
  102916. */
  102917. poleTargetLocalOffset: Vector3;
  102918. /**
  102919. * Gets or sets the pole angle
  102920. */
  102921. poleAngle: number;
  102922. /**
  102923. * Gets or sets the mesh associated with the controller
  102924. */
  102925. mesh: AbstractMesh;
  102926. /**
  102927. * 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)
  102928. */
  102929. slerpAmount: number;
  102930. private _bone1Quat;
  102931. private _bone1Mat;
  102932. private _bone2Ang;
  102933. private _bone1;
  102934. private _bone2;
  102935. private _bone1Length;
  102936. private _bone2Length;
  102937. private _maxAngle;
  102938. private _maxReach;
  102939. private _rightHandedSystem;
  102940. private _bendAxis;
  102941. private _slerping;
  102942. private _adjustRoll;
  102943. /**
  102944. * Gets or sets maximum allowed angle
  102945. */
  102946. maxAngle: number;
  102947. /**
  102948. * Creates a new BoneIKController
  102949. * @param mesh defines the mesh to control
  102950. * @param bone defines the bone to control
  102951. * @param options defines options to set up the controller
  102952. */
  102953. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  102954. targetMesh?: AbstractMesh;
  102955. poleTargetMesh?: AbstractMesh;
  102956. poleTargetBone?: Bone;
  102957. poleTargetLocalOffset?: Vector3;
  102958. poleAngle?: number;
  102959. bendAxis?: Vector3;
  102960. maxAngle?: number;
  102961. slerpAmount?: number;
  102962. });
  102963. private _setMaxAngle;
  102964. /**
  102965. * Force the controller to update the bones
  102966. */
  102967. update(): void;
  102968. }
  102969. }
  102970. declare module BABYLON {
  102971. /**
  102972. * Class used to make a bone look toward a point in space
  102973. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  102974. */
  102975. export class BoneLookController {
  102976. private static _tmpVecs;
  102977. private static _tmpQuat;
  102978. private static _tmpMats;
  102979. /**
  102980. * The target Vector3 that the bone will look at
  102981. */
  102982. target: Vector3;
  102983. /**
  102984. * The mesh that the bone is attached to
  102985. */
  102986. mesh: AbstractMesh;
  102987. /**
  102988. * The bone that will be looking to the target
  102989. */
  102990. bone: Bone;
  102991. /**
  102992. * The up axis of the coordinate system that is used when the bone is rotated
  102993. */
  102994. upAxis: Vector3;
  102995. /**
  102996. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  102997. */
  102998. upAxisSpace: Space;
  102999. /**
  103000. * Used to make an adjustment to the yaw of the bone
  103001. */
  103002. adjustYaw: number;
  103003. /**
  103004. * Used to make an adjustment to the pitch of the bone
  103005. */
  103006. adjustPitch: number;
  103007. /**
  103008. * Used to make an adjustment to the roll of the bone
  103009. */
  103010. adjustRoll: number;
  103011. /**
  103012. * 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)
  103013. */
  103014. slerpAmount: number;
  103015. private _minYaw;
  103016. private _maxYaw;
  103017. private _minPitch;
  103018. private _maxPitch;
  103019. private _minYawSin;
  103020. private _minYawCos;
  103021. private _maxYawSin;
  103022. private _maxYawCos;
  103023. private _midYawConstraint;
  103024. private _minPitchTan;
  103025. private _maxPitchTan;
  103026. private _boneQuat;
  103027. private _slerping;
  103028. private _transformYawPitch;
  103029. private _transformYawPitchInv;
  103030. private _firstFrameSkipped;
  103031. private _yawRange;
  103032. private _fowardAxis;
  103033. /**
  103034. * Gets or sets the minimum yaw angle that the bone can look to
  103035. */
  103036. minYaw: number;
  103037. /**
  103038. * Gets or sets the maximum yaw angle that the bone can look to
  103039. */
  103040. maxYaw: number;
  103041. /**
  103042. * Gets or sets the minimum pitch angle that the bone can look to
  103043. */
  103044. minPitch: number;
  103045. /**
  103046. * Gets or sets the maximum pitch angle that the bone can look to
  103047. */
  103048. maxPitch: number;
  103049. /**
  103050. * Create a BoneLookController
  103051. * @param mesh the mesh that the bone belongs to
  103052. * @param bone the bone that will be looking to the target
  103053. * @param target the target Vector3 to look at
  103054. * @param options optional settings:
  103055. * * maxYaw: the maximum angle the bone will yaw to
  103056. * * minYaw: the minimum angle the bone will yaw to
  103057. * * maxPitch: the maximum angle the bone will pitch to
  103058. * * minPitch: the minimum angle the bone will yaw to
  103059. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  103060. * * upAxis: the up axis of the coordinate system
  103061. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  103062. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  103063. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  103064. * * adjustYaw: used to make an adjustment to the yaw of the bone
  103065. * * adjustPitch: used to make an adjustment to the pitch of the bone
  103066. * * adjustRoll: used to make an adjustment to the roll of the bone
  103067. **/
  103068. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  103069. maxYaw?: number;
  103070. minYaw?: number;
  103071. maxPitch?: number;
  103072. minPitch?: number;
  103073. slerpAmount?: number;
  103074. upAxis?: Vector3;
  103075. upAxisSpace?: Space;
  103076. yawAxis?: Vector3;
  103077. pitchAxis?: Vector3;
  103078. adjustYaw?: number;
  103079. adjustPitch?: number;
  103080. adjustRoll?: number;
  103081. });
  103082. /**
  103083. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  103084. */
  103085. update(): void;
  103086. private _getAngleDiff;
  103087. private _getAngleBetween;
  103088. private _isAngleBetween;
  103089. }
  103090. }
  103091. declare module BABYLON {
  103092. /**
  103093. * Manage the gamepad inputs to control an arc rotate camera.
  103094. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103095. */
  103096. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  103097. /**
  103098. * Defines the camera the input is attached to.
  103099. */
  103100. camera: ArcRotateCamera;
  103101. /**
  103102. * Defines the gamepad the input is gathering event from.
  103103. */
  103104. gamepad: Nullable<Gamepad>;
  103105. /**
  103106. * Defines the gamepad rotation sensiblity.
  103107. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103108. */
  103109. gamepadRotationSensibility: number;
  103110. /**
  103111. * Defines the gamepad move sensiblity.
  103112. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103113. */
  103114. gamepadMoveSensibility: number;
  103115. private _onGamepadConnectedObserver;
  103116. private _onGamepadDisconnectedObserver;
  103117. /**
  103118. * Attach the input controls to a specific dom element to get the input from.
  103119. * @param element Defines the element the controls should be listened from
  103120. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103121. */
  103122. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103123. /**
  103124. * Detach the current controls from the specified dom element.
  103125. * @param element Defines the element to stop listening the inputs from
  103126. */
  103127. detachControl(element: Nullable<HTMLElement>): void;
  103128. /**
  103129. * Update the current camera state depending on the inputs that have been used this frame.
  103130. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103131. */
  103132. checkInputs(): void;
  103133. /**
  103134. * Gets the class name of the current intput.
  103135. * @returns the class name
  103136. */
  103137. getClassName(): string;
  103138. /**
  103139. * Get the friendly name associated with the input class.
  103140. * @returns the input friendly name
  103141. */
  103142. getSimpleName(): string;
  103143. }
  103144. }
  103145. declare module BABYLON {
  103146. interface ArcRotateCameraInputsManager {
  103147. /**
  103148. * Add orientation input support to the input manager.
  103149. * @returns the current input manager
  103150. */
  103151. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  103152. }
  103153. /**
  103154. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  103155. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103156. */
  103157. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  103158. /**
  103159. * Defines the camera the input is attached to.
  103160. */
  103161. camera: ArcRotateCamera;
  103162. /**
  103163. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  103164. */
  103165. alphaCorrection: number;
  103166. /**
  103167. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  103168. */
  103169. gammaCorrection: number;
  103170. private _alpha;
  103171. private _gamma;
  103172. private _dirty;
  103173. private _deviceOrientationHandler;
  103174. /**
  103175. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  103176. */
  103177. constructor();
  103178. /**
  103179. * Attach the input controls to a specific dom element to get the input from.
  103180. * @param element Defines the element the controls should be listened from
  103181. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103182. */
  103183. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103184. /** @hidden */
  103185. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  103186. /**
  103187. * Update the current camera state depending on the inputs that have been used this frame.
  103188. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103189. */
  103190. checkInputs(): void;
  103191. /**
  103192. * Detach the current controls from the specified dom element.
  103193. * @param element Defines the element to stop listening the inputs from
  103194. */
  103195. detachControl(element: Nullable<HTMLElement>): void;
  103196. /**
  103197. * Gets the class name of the current intput.
  103198. * @returns the class name
  103199. */
  103200. getClassName(): string;
  103201. /**
  103202. * Get the friendly name associated with the input class.
  103203. * @returns the input friendly name
  103204. */
  103205. getSimpleName(): string;
  103206. }
  103207. }
  103208. declare module BABYLON {
  103209. /**
  103210. * Listen to mouse events to control the camera.
  103211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103212. */
  103213. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  103214. /**
  103215. * Defines the camera the input is attached to.
  103216. */
  103217. camera: FlyCamera;
  103218. /**
  103219. * Defines if touch is enabled. (Default is true.)
  103220. */
  103221. touchEnabled: boolean;
  103222. /**
  103223. * Defines the buttons associated with the input to handle camera rotation.
  103224. */
  103225. buttons: number[];
  103226. /**
  103227. * Assign buttons for Yaw control.
  103228. */
  103229. buttonsYaw: number[];
  103230. /**
  103231. * Assign buttons for Pitch control.
  103232. */
  103233. buttonsPitch: number[];
  103234. /**
  103235. * Assign buttons for Roll control.
  103236. */
  103237. buttonsRoll: number[];
  103238. /**
  103239. * Detect if any button is being pressed while mouse is moved.
  103240. * -1 = Mouse locked.
  103241. * 0 = Left button.
  103242. * 1 = Middle Button.
  103243. * 2 = Right Button.
  103244. */
  103245. activeButton: number;
  103246. /**
  103247. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  103248. * Higher values reduce its sensitivity.
  103249. */
  103250. angularSensibility: number;
  103251. private _mousemoveCallback;
  103252. private _observer;
  103253. private _rollObserver;
  103254. private previousPosition;
  103255. private noPreventDefault;
  103256. private element;
  103257. /**
  103258. * Listen to mouse events to control the camera.
  103259. * @param touchEnabled Define if touch is enabled. (Default is true.)
  103260. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103261. */
  103262. constructor(touchEnabled?: boolean);
  103263. /**
  103264. * Attach the mouse control to the HTML DOM element.
  103265. * @param element Defines the element that listens to the input events.
  103266. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  103267. */
  103268. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103269. /**
  103270. * Detach the current controls from the specified dom element.
  103271. * @param element Defines the element to stop listening the inputs from
  103272. */
  103273. detachControl(element: Nullable<HTMLElement>): void;
  103274. /**
  103275. * Gets the class name of the current input.
  103276. * @returns the class name.
  103277. */
  103278. getClassName(): string;
  103279. /**
  103280. * Get the friendly name associated with the input class.
  103281. * @returns the input's friendly name.
  103282. */
  103283. getSimpleName(): string;
  103284. private _pointerInput;
  103285. private _onMouseMove;
  103286. /**
  103287. * Rotate camera by mouse offset.
  103288. */
  103289. private rotateCamera;
  103290. }
  103291. }
  103292. declare module BABYLON {
  103293. /**
  103294. * Default Inputs manager for the FlyCamera.
  103295. * It groups all the default supported inputs for ease of use.
  103296. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103297. */
  103298. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  103299. /**
  103300. * Instantiates a new FlyCameraInputsManager.
  103301. * @param camera Defines the camera the inputs belong to.
  103302. */
  103303. constructor(camera: FlyCamera);
  103304. /**
  103305. * Add keyboard input support to the input manager.
  103306. * @returns the new FlyCameraKeyboardMoveInput().
  103307. */
  103308. addKeyboard(): FlyCameraInputsManager;
  103309. /**
  103310. * Add mouse input support to the input manager.
  103311. * @param touchEnabled Enable touch screen support.
  103312. * @returns the new FlyCameraMouseInput().
  103313. */
  103314. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  103315. }
  103316. }
  103317. declare module BABYLON {
  103318. /**
  103319. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103320. * such as in a 3D Space Shooter or a Flight Simulator.
  103321. */
  103322. export class FlyCamera extends TargetCamera {
  103323. /**
  103324. * Define the collision ellipsoid of the camera.
  103325. * This is helpful for simulating a camera body, like a player's body.
  103326. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103327. */
  103328. ellipsoid: Vector3;
  103329. /**
  103330. * Define an offset for the position of the ellipsoid around the camera.
  103331. * This can be helpful if the camera is attached away from the player's body center,
  103332. * such as at its head.
  103333. */
  103334. ellipsoidOffset: Vector3;
  103335. /**
  103336. * Enable or disable collisions of the camera with the rest of the scene objects.
  103337. */
  103338. checkCollisions: boolean;
  103339. /**
  103340. * Enable or disable gravity on the camera.
  103341. */
  103342. applyGravity: boolean;
  103343. /**
  103344. * Define the current direction the camera is moving to.
  103345. */
  103346. cameraDirection: Vector3;
  103347. /**
  103348. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  103349. * This overrides and empties cameraRotation.
  103350. */
  103351. rotationQuaternion: Quaternion;
  103352. /**
  103353. * Track Roll to maintain the wanted Rolling when looking around.
  103354. */
  103355. _trackRoll: number;
  103356. /**
  103357. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  103358. */
  103359. rollCorrect: number;
  103360. /**
  103361. * Mimic a banked turn, Rolling the camera when Yawing.
  103362. * It's recommended to use rollCorrect = 10 for faster banking correction.
  103363. */
  103364. bankedTurn: boolean;
  103365. /**
  103366. * Limit in radians for how much Roll banking will add. (Default: 90°)
  103367. */
  103368. bankedTurnLimit: number;
  103369. /**
  103370. * Value of 0 disables the banked Roll.
  103371. * Value of 1 is equal to the Yaw angle in radians.
  103372. */
  103373. bankedTurnMultiplier: number;
  103374. /**
  103375. * The inputs manager loads all the input sources, such as keyboard and mouse.
  103376. */
  103377. inputs: FlyCameraInputsManager;
  103378. /**
  103379. * Gets the input sensibility for mouse input.
  103380. * Higher values reduce sensitivity.
  103381. */
  103382. /**
  103383. * Sets the input sensibility for a mouse input.
  103384. * Higher values reduce sensitivity.
  103385. */
  103386. angularSensibility: number;
  103387. /**
  103388. * Get the keys for camera movement forward.
  103389. */
  103390. /**
  103391. * Set the keys for camera movement forward.
  103392. */
  103393. keysForward: number[];
  103394. /**
  103395. * Get the keys for camera movement backward.
  103396. */
  103397. keysBackward: number[];
  103398. /**
  103399. * Get the keys for camera movement up.
  103400. */
  103401. /**
  103402. * Set the keys for camera movement up.
  103403. */
  103404. keysUp: number[];
  103405. /**
  103406. * Get the keys for camera movement down.
  103407. */
  103408. /**
  103409. * Set the keys for camera movement down.
  103410. */
  103411. keysDown: number[];
  103412. /**
  103413. * Get the keys for camera movement left.
  103414. */
  103415. /**
  103416. * Set the keys for camera movement left.
  103417. */
  103418. keysLeft: number[];
  103419. /**
  103420. * Set the keys for camera movement right.
  103421. */
  103422. /**
  103423. * Set the keys for camera movement right.
  103424. */
  103425. keysRight: number[];
  103426. /**
  103427. * Event raised when the camera collides with a mesh in the scene.
  103428. */
  103429. onCollide: (collidedMesh: AbstractMesh) => void;
  103430. private _collider;
  103431. private _needMoveForGravity;
  103432. private _oldPosition;
  103433. private _diffPosition;
  103434. private _newPosition;
  103435. /** @hidden */
  103436. _localDirection: Vector3;
  103437. /** @hidden */
  103438. _transformedDirection: Vector3;
  103439. /**
  103440. * Instantiates a FlyCamera.
  103441. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103442. * such as in a 3D Space Shooter or a Flight Simulator.
  103443. * @param name Define the name of the camera in the scene.
  103444. * @param position Define the starting position of the camera in the scene.
  103445. * @param scene Define the scene the camera belongs to.
  103446. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  103447. */
  103448. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103449. /**
  103450. * Attach a control to the HTML DOM element.
  103451. * @param element Defines the element that listens to the input events.
  103452. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  103453. */
  103454. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103455. /**
  103456. * Detach a control from the HTML DOM element.
  103457. * The camera will stop reacting to that input.
  103458. * @param element Defines the element that listens to the input events.
  103459. */
  103460. detachControl(element: HTMLElement): void;
  103461. private _collisionMask;
  103462. /**
  103463. * Get the mask that the camera ignores in collision events.
  103464. */
  103465. /**
  103466. * Set the mask that the camera ignores in collision events.
  103467. */
  103468. collisionMask: number;
  103469. /** @hidden */
  103470. _collideWithWorld(displacement: Vector3): void;
  103471. /** @hidden */
  103472. private _onCollisionPositionChange;
  103473. /** @hidden */
  103474. _checkInputs(): void;
  103475. /** @hidden */
  103476. _decideIfNeedsToMove(): boolean;
  103477. /** @hidden */
  103478. _updatePosition(): void;
  103479. /**
  103480. * Restore the Roll to its target value at the rate specified.
  103481. * @param rate - Higher means slower restoring.
  103482. * @hidden
  103483. */
  103484. restoreRoll(rate: number): void;
  103485. /**
  103486. * Destroy the camera and release the current resources held by it.
  103487. */
  103488. dispose(): void;
  103489. /**
  103490. * Get the current object class name.
  103491. * @returns the class name.
  103492. */
  103493. getClassName(): string;
  103494. }
  103495. }
  103496. declare module BABYLON {
  103497. /**
  103498. * Listen to keyboard events to control the camera.
  103499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103500. */
  103501. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  103502. /**
  103503. * Defines the camera the input is attached to.
  103504. */
  103505. camera: FlyCamera;
  103506. /**
  103507. * The list of keyboard keys used to control the forward move of the camera.
  103508. */
  103509. keysForward: number[];
  103510. /**
  103511. * The list of keyboard keys used to control the backward move of the camera.
  103512. */
  103513. keysBackward: number[];
  103514. /**
  103515. * The list of keyboard keys used to control the forward move of the camera.
  103516. */
  103517. keysUp: number[];
  103518. /**
  103519. * The list of keyboard keys used to control the backward move of the camera.
  103520. */
  103521. keysDown: number[];
  103522. /**
  103523. * The list of keyboard keys used to control the right strafe move of the camera.
  103524. */
  103525. keysRight: number[];
  103526. /**
  103527. * The list of keyboard keys used to control the left strafe move of the camera.
  103528. */
  103529. keysLeft: number[];
  103530. private _keys;
  103531. private _onCanvasBlurObserver;
  103532. private _onKeyboardObserver;
  103533. private _engine;
  103534. private _scene;
  103535. /**
  103536. * Attach the input controls to a specific dom element to get the input from.
  103537. * @param element Defines the element the controls should be listened from
  103538. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103539. */
  103540. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103541. /**
  103542. * Detach the current controls from the specified dom element.
  103543. * @param element Defines the element to stop listening the inputs from
  103544. */
  103545. detachControl(element: Nullable<HTMLElement>): void;
  103546. /**
  103547. * Gets the class name of the current intput.
  103548. * @returns the class name
  103549. */
  103550. getClassName(): string;
  103551. /** @hidden */
  103552. _onLostFocus(e: FocusEvent): void;
  103553. /**
  103554. * Get the friendly name associated with the input class.
  103555. * @returns the input friendly name
  103556. */
  103557. getSimpleName(): string;
  103558. /**
  103559. * Update the current camera state depending on the inputs that have been used this frame.
  103560. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103561. */
  103562. checkInputs(): void;
  103563. }
  103564. }
  103565. declare module BABYLON {
  103566. /**
  103567. * Manage the mouse wheel inputs to control a follow camera.
  103568. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103569. */
  103570. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  103571. /**
  103572. * Defines the camera the input is attached to.
  103573. */
  103574. camera: FollowCamera;
  103575. /**
  103576. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  103577. */
  103578. axisControlRadius: boolean;
  103579. /**
  103580. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  103581. */
  103582. axisControlHeight: boolean;
  103583. /**
  103584. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  103585. */
  103586. axisControlRotation: boolean;
  103587. /**
  103588. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  103589. * relation to mouseWheel events.
  103590. */
  103591. wheelPrecision: number;
  103592. /**
  103593. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103594. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103595. */
  103596. wheelDeltaPercentage: number;
  103597. private _wheel;
  103598. private _observer;
  103599. /**
  103600. * Attach the input controls to a specific dom element to get the input from.
  103601. * @param element Defines the element the controls should be listened from
  103602. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103603. */
  103604. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103605. /**
  103606. * Detach the current controls from the specified dom element.
  103607. * @param element Defines the element to stop listening the inputs from
  103608. */
  103609. detachControl(element: Nullable<HTMLElement>): void;
  103610. /**
  103611. * Gets the class name of the current intput.
  103612. * @returns the class name
  103613. */
  103614. getClassName(): string;
  103615. /**
  103616. * Get the friendly name associated with the input class.
  103617. * @returns the input friendly name
  103618. */
  103619. getSimpleName(): string;
  103620. }
  103621. }
  103622. declare module BABYLON {
  103623. /**
  103624. * Manage the pointers inputs to control an follow camera.
  103625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103626. */
  103627. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  103628. /**
  103629. * Defines the camera the input is attached to.
  103630. */
  103631. camera: FollowCamera;
  103632. /**
  103633. * Gets the class name of the current input.
  103634. * @returns the class name
  103635. */
  103636. getClassName(): string;
  103637. /**
  103638. * Defines the pointer angular sensibility along the X axis or how fast is
  103639. * the camera rotating.
  103640. * A negative number will reverse the axis direction.
  103641. */
  103642. angularSensibilityX: number;
  103643. /**
  103644. * Defines the pointer angular sensibility along the Y axis or how fast is
  103645. * the camera rotating.
  103646. * A negative number will reverse the axis direction.
  103647. */
  103648. angularSensibilityY: number;
  103649. /**
  103650. * Defines the pointer pinch precision or how fast is the camera zooming.
  103651. * A negative number will reverse the axis direction.
  103652. */
  103653. pinchPrecision: number;
  103654. /**
  103655. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  103656. * from 0.
  103657. * It defines the percentage of current camera.radius to use as delta when
  103658. * pinch zoom is used.
  103659. */
  103660. pinchDeltaPercentage: number;
  103661. /**
  103662. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  103663. */
  103664. axisXControlRadius: boolean;
  103665. /**
  103666. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  103667. */
  103668. axisXControlHeight: boolean;
  103669. /**
  103670. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  103671. */
  103672. axisXControlRotation: boolean;
  103673. /**
  103674. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  103675. */
  103676. axisYControlRadius: boolean;
  103677. /**
  103678. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  103679. */
  103680. axisYControlHeight: boolean;
  103681. /**
  103682. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  103683. */
  103684. axisYControlRotation: boolean;
  103685. /**
  103686. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  103687. */
  103688. axisPinchControlRadius: boolean;
  103689. /**
  103690. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  103691. */
  103692. axisPinchControlHeight: boolean;
  103693. /**
  103694. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  103695. */
  103696. axisPinchControlRotation: boolean;
  103697. /**
  103698. * Log error messages if basic misconfiguration has occurred.
  103699. */
  103700. warningEnable: boolean;
  103701. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103702. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103703. private _warningCounter;
  103704. private _warning;
  103705. }
  103706. }
  103707. declare module BABYLON {
  103708. /**
  103709. * Default Inputs manager for the FollowCamera.
  103710. * It groups all the default supported inputs for ease of use.
  103711. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103712. */
  103713. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  103714. /**
  103715. * Instantiates a new FollowCameraInputsManager.
  103716. * @param camera Defines the camera the inputs belong to
  103717. */
  103718. constructor(camera: FollowCamera);
  103719. /**
  103720. * Add keyboard input support to the input manager.
  103721. * @returns the current input manager
  103722. */
  103723. addKeyboard(): FollowCameraInputsManager;
  103724. /**
  103725. * Add mouse wheel input support to the input manager.
  103726. * @returns the current input manager
  103727. */
  103728. addMouseWheel(): FollowCameraInputsManager;
  103729. /**
  103730. * Add pointers input support to the input manager.
  103731. * @returns the current input manager
  103732. */
  103733. addPointers(): FollowCameraInputsManager;
  103734. /**
  103735. * Add orientation input support to the input manager.
  103736. * @returns the current input manager
  103737. */
  103738. addVRDeviceOrientation(): FollowCameraInputsManager;
  103739. }
  103740. }
  103741. declare module BABYLON {
  103742. /**
  103743. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  103744. * an arc rotate version arcFollowCamera are available.
  103745. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103746. */
  103747. export class FollowCamera extends TargetCamera {
  103748. /**
  103749. * Distance the follow camera should follow an object at
  103750. */
  103751. radius: number;
  103752. /**
  103753. * Minimum allowed distance of the camera to the axis of rotation
  103754. * (The camera can not get closer).
  103755. * This can help limiting how the Camera is able to move in the scene.
  103756. */
  103757. lowerRadiusLimit: Nullable<number>;
  103758. /**
  103759. * Maximum allowed distance of the camera to the axis of rotation
  103760. * (The camera can not get further).
  103761. * This can help limiting how the Camera is able to move in the scene.
  103762. */
  103763. upperRadiusLimit: Nullable<number>;
  103764. /**
  103765. * Define a rotation offset between the camera and the object it follows
  103766. */
  103767. rotationOffset: number;
  103768. /**
  103769. * Minimum allowed angle to camera position relative to target object.
  103770. * This can help limiting how the Camera is able to move in the scene.
  103771. */
  103772. lowerRotationOffsetLimit: Nullable<number>;
  103773. /**
  103774. * Maximum allowed angle to camera position relative to target object.
  103775. * This can help limiting how the Camera is able to move in the scene.
  103776. */
  103777. upperRotationOffsetLimit: Nullable<number>;
  103778. /**
  103779. * Define a height offset between the camera and the object it follows.
  103780. * It can help following an object from the top (like a car chaing a plane)
  103781. */
  103782. heightOffset: number;
  103783. /**
  103784. * Minimum allowed height of camera position relative to target object.
  103785. * This can help limiting how the Camera is able to move in the scene.
  103786. */
  103787. lowerHeightOffsetLimit: Nullable<number>;
  103788. /**
  103789. * Maximum allowed height of camera position relative to target object.
  103790. * This can help limiting how the Camera is able to move in the scene.
  103791. */
  103792. upperHeightOffsetLimit: Nullable<number>;
  103793. /**
  103794. * Define how fast the camera can accelerate to follow it s target.
  103795. */
  103796. cameraAcceleration: number;
  103797. /**
  103798. * Define the speed limit of the camera following an object.
  103799. */
  103800. maxCameraSpeed: number;
  103801. /**
  103802. * Define the target of the camera.
  103803. */
  103804. lockedTarget: Nullable<AbstractMesh>;
  103805. /**
  103806. * Defines the input associated with the camera.
  103807. */
  103808. inputs: FollowCameraInputsManager;
  103809. /**
  103810. * Instantiates the follow camera.
  103811. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103812. * @param name Define the name of the camera in the scene
  103813. * @param position Define the position of the camera
  103814. * @param scene Define the scene the camera belong to
  103815. * @param lockedTarget Define the target of the camera
  103816. */
  103817. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  103818. private _follow;
  103819. /**
  103820. * Attached controls to the current camera.
  103821. * @param element Defines the element the controls should be listened from
  103822. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103823. */
  103824. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103825. /**
  103826. * Detach the current controls from the camera.
  103827. * The camera will stop reacting to inputs.
  103828. * @param element Defines the element to stop listening the inputs from
  103829. */
  103830. detachControl(element: HTMLElement): void;
  103831. /** @hidden */
  103832. _checkInputs(): void;
  103833. private _checkLimits;
  103834. /**
  103835. * Gets the camera class name.
  103836. * @returns the class name
  103837. */
  103838. getClassName(): string;
  103839. }
  103840. /**
  103841. * Arc Rotate version of the follow camera.
  103842. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  103843. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103844. */
  103845. export class ArcFollowCamera extends TargetCamera {
  103846. /** The longitudinal angle of the camera */
  103847. alpha: number;
  103848. /** The latitudinal angle of the camera */
  103849. beta: number;
  103850. /** The radius of the camera from its target */
  103851. radius: number;
  103852. /** Define the camera target (the messh it should follow) */
  103853. target: Nullable<AbstractMesh>;
  103854. private _cartesianCoordinates;
  103855. /**
  103856. * Instantiates a new ArcFollowCamera
  103857. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103858. * @param name Define the name of the camera
  103859. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  103860. * @param beta Define the rotation angle of the camera around the elevation axis
  103861. * @param radius Define the radius of the camera from its target point
  103862. * @param target Define the target of the camera
  103863. * @param scene Define the scene the camera belongs to
  103864. */
  103865. constructor(name: string,
  103866. /** The longitudinal angle of the camera */
  103867. alpha: number,
  103868. /** The latitudinal angle of the camera */
  103869. beta: number,
  103870. /** The radius of the camera from its target */
  103871. radius: number,
  103872. /** Define the camera target (the messh it should follow) */
  103873. target: Nullable<AbstractMesh>, scene: Scene);
  103874. private _follow;
  103875. /** @hidden */
  103876. _checkInputs(): void;
  103877. /**
  103878. * Returns the class name of the object.
  103879. * It is mostly used internally for serialization purposes.
  103880. */
  103881. getClassName(): string;
  103882. }
  103883. }
  103884. declare module BABYLON {
  103885. /**
  103886. * Manage the keyboard inputs to control the movement of a follow camera.
  103887. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103888. */
  103889. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  103890. /**
  103891. * Defines the camera the input is attached to.
  103892. */
  103893. camera: FollowCamera;
  103894. /**
  103895. * Defines the list of key codes associated with the up action (increase heightOffset)
  103896. */
  103897. keysHeightOffsetIncr: number[];
  103898. /**
  103899. * Defines the list of key codes associated with the down action (decrease heightOffset)
  103900. */
  103901. keysHeightOffsetDecr: number[];
  103902. /**
  103903. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  103904. */
  103905. keysHeightOffsetModifierAlt: boolean;
  103906. /**
  103907. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  103908. */
  103909. keysHeightOffsetModifierCtrl: boolean;
  103910. /**
  103911. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  103912. */
  103913. keysHeightOffsetModifierShift: boolean;
  103914. /**
  103915. * Defines the list of key codes associated with the left action (increase rotationOffset)
  103916. */
  103917. keysRotationOffsetIncr: number[];
  103918. /**
  103919. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  103920. */
  103921. keysRotationOffsetDecr: number[];
  103922. /**
  103923. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  103924. */
  103925. keysRotationOffsetModifierAlt: boolean;
  103926. /**
  103927. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  103928. */
  103929. keysRotationOffsetModifierCtrl: boolean;
  103930. /**
  103931. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  103932. */
  103933. keysRotationOffsetModifierShift: boolean;
  103934. /**
  103935. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  103936. */
  103937. keysRadiusIncr: number[];
  103938. /**
  103939. * Defines the list of key codes associated with the zoom-out action (increase radius)
  103940. */
  103941. keysRadiusDecr: number[];
  103942. /**
  103943. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  103944. */
  103945. keysRadiusModifierAlt: boolean;
  103946. /**
  103947. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  103948. */
  103949. keysRadiusModifierCtrl: boolean;
  103950. /**
  103951. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  103952. */
  103953. keysRadiusModifierShift: boolean;
  103954. /**
  103955. * Defines the rate of change of heightOffset.
  103956. */
  103957. heightSensibility: number;
  103958. /**
  103959. * Defines the rate of change of rotationOffset.
  103960. */
  103961. rotationSensibility: number;
  103962. /**
  103963. * Defines the rate of change of radius.
  103964. */
  103965. radiusSensibility: number;
  103966. private _keys;
  103967. private _ctrlPressed;
  103968. private _altPressed;
  103969. private _shiftPressed;
  103970. private _onCanvasBlurObserver;
  103971. private _onKeyboardObserver;
  103972. private _engine;
  103973. private _scene;
  103974. /**
  103975. * Attach the input controls to a specific dom element to get the input from.
  103976. * @param element Defines the element the controls should be listened from
  103977. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103978. */
  103979. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103980. /**
  103981. * Detach the current controls from the specified dom element.
  103982. * @param element Defines the element to stop listening the inputs from
  103983. */
  103984. detachControl(element: Nullable<HTMLElement>): void;
  103985. /**
  103986. * Update the current camera state depending on the inputs that have been used this frame.
  103987. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103988. */
  103989. checkInputs(): void;
  103990. /**
  103991. * Gets the class name of the current input.
  103992. * @returns the class name
  103993. */
  103994. getClassName(): string;
  103995. /**
  103996. * Get the friendly name associated with the input class.
  103997. * @returns the input friendly name
  103998. */
  103999. getSimpleName(): string;
  104000. /**
  104001. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104002. * allow modification of the heightOffset value.
  104003. */
  104004. private _modifierHeightOffset;
  104005. /**
  104006. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104007. * allow modification of the rotationOffset value.
  104008. */
  104009. private _modifierRotationOffset;
  104010. /**
  104011. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104012. * allow modification of the radius value.
  104013. */
  104014. private _modifierRadius;
  104015. }
  104016. }
  104017. declare module BABYLON {
  104018. interface FreeCameraInputsManager {
  104019. /**
  104020. * @hidden
  104021. */
  104022. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  104023. /**
  104024. * Add orientation input support to the input manager.
  104025. * @returns the current input manager
  104026. */
  104027. addDeviceOrientation(): FreeCameraInputsManager;
  104028. }
  104029. /**
  104030. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  104031. * Screen rotation is taken into account.
  104032. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104033. */
  104034. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  104035. private _camera;
  104036. private _screenOrientationAngle;
  104037. private _constantTranform;
  104038. private _screenQuaternion;
  104039. private _alpha;
  104040. private _beta;
  104041. private _gamma;
  104042. /**
  104043. * Can be used to detect if a device orientation sensor is availible on a device
  104044. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  104045. * @returns a promise that will resolve on orientation change
  104046. */
  104047. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  104048. /**
  104049. * @hidden
  104050. */
  104051. _onDeviceOrientationChangedObservable: Observable<void>;
  104052. /**
  104053. * Instantiates a new input
  104054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104055. */
  104056. constructor();
  104057. /**
  104058. * Define the camera controlled by the input.
  104059. */
  104060. camera: FreeCamera;
  104061. /**
  104062. * Attach the input controls to a specific dom element to get the input from.
  104063. * @param element Defines the element the controls should be listened from
  104064. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104065. */
  104066. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104067. private _orientationChanged;
  104068. private _deviceOrientation;
  104069. /**
  104070. * Detach the current controls from the specified dom element.
  104071. * @param element Defines the element to stop listening the inputs from
  104072. */
  104073. detachControl(element: Nullable<HTMLElement>): void;
  104074. /**
  104075. * Update the current camera state depending on the inputs that have been used this frame.
  104076. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104077. */
  104078. checkInputs(): void;
  104079. /**
  104080. * Gets the class name of the current intput.
  104081. * @returns the class name
  104082. */
  104083. getClassName(): string;
  104084. /**
  104085. * Get the friendly name associated with the input class.
  104086. * @returns the input friendly name
  104087. */
  104088. getSimpleName(): string;
  104089. }
  104090. }
  104091. declare module BABYLON {
  104092. /**
  104093. * Manage the gamepad inputs to control a free camera.
  104094. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104095. */
  104096. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  104097. /**
  104098. * Define the camera the input is attached to.
  104099. */
  104100. camera: FreeCamera;
  104101. /**
  104102. * Define the Gamepad controlling the input
  104103. */
  104104. gamepad: Nullable<Gamepad>;
  104105. /**
  104106. * Defines the gamepad rotation sensiblity.
  104107. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104108. */
  104109. gamepadAngularSensibility: number;
  104110. /**
  104111. * Defines the gamepad move sensiblity.
  104112. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104113. */
  104114. gamepadMoveSensibility: number;
  104115. private _onGamepadConnectedObserver;
  104116. private _onGamepadDisconnectedObserver;
  104117. private _cameraTransform;
  104118. private _deltaTransform;
  104119. private _vector3;
  104120. private _vector2;
  104121. /**
  104122. * Attach the input controls to a specific dom element to get the input from.
  104123. * @param element Defines the element the controls should be listened from
  104124. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104125. */
  104126. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104127. /**
  104128. * Detach the current controls from the specified dom element.
  104129. * @param element Defines the element to stop listening the inputs from
  104130. */
  104131. detachControl(element: Nullable<HTMLElement>): void;
  104132. /**
  104133. * Update the current camera state depending on the inputs that have been used this frame.
  104134. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104135. */
  104136. checkInputs(): void;
  104137. /**
  104138. * Gets the class name of the current intput.
  104139. * @returns the class name
  104140. */
  104141. getClassName(): string;
  104142. /**
  104143. * Get the friendly name associated with the input class.
  104144. * @returns the input friendly name
  104145. */
  104146. getSimpleName(): string;
  104147. }
  104148. }
  104149. declare module BABYLON {
  104150. /**
  104151. * Defines the potential axis of a Joystick
  104152. */
  104153. export enum JoystickAxis {
  104154. /** X axis */
  104155. X = 0,
  104156. /** Y axis */
  104157. Y = 1,
  104158. /** Z axis */
  104159. Z = 2
  104160. }
  104161. /**
  104162. * Class used to define virtual joystick (used in touch mode)
  104163. */
  104164. export class VirtualJoystick {
  104165. /**
  104166. * Gets or sets a boolean indicating that left and right values must be inverted
  104167. */
  104168. reverseLeftRight: boolean;
  104169. /**
  104170. * Gets or sets a boolean indicating that up and down values must be inverted
  104171. */
  104172. reverseUpDown: boolean;
  104173. /**
  104174. * Gets the offset value for the position (ie. the change of the position value)
  104175. */
  104176. deltaPosition: Vector3;
  104177. /**
  104178. * Gets a boolean indicating if the virtual joystick was pressed
  104179. */
  104180. pressed: boolean;
  104181. /**
  104182. * Canvas the virtual joystick will render onto, default z-index of this is 5
  104183. */
  104184. static Canvas: Nullable<HTMLCanvasElement>;
  104185. private static _globalJoystickIndex;
  104186. private static vjCanvasContext;
  104187. private static vjCanvasWidth;
  104188. private static vjCanvasHeight;
  104189. private static halfWidth;
  104190. private _action;
  104191. private _axisTargetedByLeftAndRight;
  104192. private _axisTargetedByUpAndDown;
  104193. private _joystickSensibility;
  104194. private _inversedSensibility;
  104195. private _joystickPointerID;
  104196. private _joystickColor;
  104197. private _joystickPointerPos;
  104198. private _joystickPreviousPointerPos;
  104199. private _joystickPointerStartPos;
  104200. private _deltaJoystickVector;
  104201. private _leftJoystick;
  104202. private _touches;
  104203. private _onPointerDownHandlerRef;
  104204. private _onPointerMoveHandlerRef;
  104205. private _onPointerUpHandlerRef;
  104206. private _onResize;
  104207. /**
  104208. * Creates a new virtual joystick
  104209. * @param leftJoystick defines that the joystick is for left hand (false by default)
  104210. */
  104211. constructor(leftJoystick?: boolean);
  104212. /**
  104213. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  104214. * @param newJoystickSensibility defines the new sensibility
  104215. */
  104216. setJoystickSensibility(newJoystickSensibility: number): void;
  104217. private _onPointerDown;
  104218. private _onPointerMove;
  104219. private _onPointerUp;
  104220. /**
  104221. * Change the color of the virtual joystick
  104222. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  104223. */
  104224. setJoystickColor(newColor: string): void;
  104225. /**
  104226. * Defines a callback to call when the joystick is touched
  104227. * @param action defines the callback
  104228. */
  104229. setActionOnTouch(action: () => any): void;
  104230. /**
  104231. * Defines which axis you'd like to control for left & right
  104232. * @param axis defines the axis to use
  104233. */
  104234. setAxisForLeftRight(axis: JoystickAxis): void;
  104235. /**
  104236. * Defines which axis you'd like to control for up & down
  104237. * @param axis defines the axis to use
  104238. */
  104239. setAxisForUpDown(axis: JoystickAxis): void;
  104240. private _drawVirtualJoystick;
  104241. /**
  104242. * Release internal HTML canvas
  104243. */
  104244. releaseCanvas(): void;
  104245. }
  104246. }
  104247. declare module BABYLON {
  104248. interface FreeCameraInputsManager {
  104249. /**
  104250. * Add virtual joystick input support to the input manager.
  104251. * @returns the current input manager
  104252. */
  104253. addVirtualJoystick(): FreeCameraInputsManager;
  104254. }
  104255. /**
  104256. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  104257. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104258. */
  104259. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  104260. /**
  104261. * Defines the camera the input is attached to.
  104262. */
  104263. camera: FreeCamera;
  104264. private _leftjoystick;
  104265. private _rightjoystick;
  104266. /**
  104267. * Gets the left stick of the virtual joystick.
  104268. * @returns The virtual Joystick
  104269. */
  104270. getLeftJoystick(): VirtualJoystick;
  104271. /**
  104272. * Gets the right stick of the virtual joystick.
  104273. * @returns The virtual Joystick
  104274. */
  104275. getRightJoystick(): VirtualJoystick;
  104276. /**
  104277. * Update the current camera state depending on the inputs that have been used this frame.
  104278. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104279. */
  104280. checkInputs(): void;
  104281. /**
  104282. * Attach the input controls to a specific dom element to get the input from.
  104283. * @param element Defines the element the controls should be listened from
  104284. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104285. */
  104286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104287. /**
  104288. * Detach the current controls from the specified dom element.
  104289. * @param element Defines the element to stop listening the inputs from
  104290. */
  104291. detachControl(element: Nullable<HTMLElement>): void;
  104292. /**
  104293. * Gets the class name of the current intput.
  104294. * @returns the class name
  104295. */
  104296. getClassName(): string;
  104297. /**
  104298. * Get the friendly name associated with the input class.
  104299. * @returns the input friendly name
  104300. */
  104301. getSimpleName(): string;
  104302. }
  104303. }
  104304. declare module BABYLON {
  104305. /**
  104306. * This represents a FPS type of camera controlled by touch.
  104307. * This is like a universal camera minus the Gamepad controls.
  104308. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104309. */
  104310. export class TouchCamera extends FreeCamera {
  104311. /**
  104312. * Defines the touch sensibility for rotation.
  104313. * The higher the faster.
  104314. */
  104315. touchAngularSensibility: number;
  104316. /**
  104317. * Defines the touch sensibility for move.
  104318. * The higher the faster.
  104319. */
  104320. touchMoveSensibility: number;
  104321. /**
  104322. * Instantiates a new touch camera.
  104323. * This represents a FPS type of camera controlled by touch.
  104324. * This is like a universal camera minus the Gamepad controls.
  104325. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104326. * @param name Define the name of the camera in the scene
  104327. * @param position Define the start position of the camera in the scene
  104328. * @param scene Define the scene the camera belongs to
  104329. */
  104330. constructor(name: string, position: Vector3, scene: Scene);
  104331. /**
  104332. * Gets the current object class name.
  104333. * @return the class name
  104334. */
  104335. getClassName(): string;
  104336. /** @hidden */
  104337. _setupInputs(): void;
  104338. }
  104339. }
  104340. declare module BABYLON {
  104341. /**
  104342. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  104343. * being tilted forward or back and left or right.
  104344. */
  104345. export class DeviceOrientationCamera extends FreeCamera {
  104346. private _initialQuaternion;
  104347. private _quaternionCache;
  104348. private _tmpDragQuaternion;
  104349. private _disablePointerInputWhenUsingDeviceOrientation;
  104350. /**
  104351. * Creates a new device orientation camera
  104352. * @param name The name of the camera
  104353. * @param position The start position camera
  104354. * @param scene The scene the camera belongs to
  104355. */
  104356. constructor(name: string, position: Vector3, scene: Scene);
  104357. /**
  104358. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  104359. */
  104360. disablePointerInputWhenUsingDeviceOrientation: boolean;
  104361. private _dragFactor;
  104362. /**
  104363. * Enabled turning on the y axis when the orientation sensor is active
  104364. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  104365. */
  104366. enableHorizontalDragging(dragFactor?: number): void;
  104367. /**
  104368. * Gets the current instance class name ("DeviceOrientationCamera").
  104369. * This helps avoiding instanceof at run time.
  104370. * @returns the class name
  104371. */
  104372. getClassName(): string;
  104373. /**
  104374. * @hidden
  104375. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  104376. */
  104377. _checkInputs(): void;
  104378. /**
  104379. * Reset the camera to its default orientation on the specified axis only.
  104380. * @param axis The axis to reset
  104381. */
  104382. resetToCurrentRotation(axis?: Axis): void;
  104383. }
  104384. }
  104385. declare module BABYLON {
  104386. /**
  104387. * Defines supported buttons for XBox360 compatible gamepads
  104388. */
  104389. export enum Xbox360Button {
  104390. /** A */
  104391. A = 0,
  104392. /** B */
  104393. B = 1,
  104394. /** X */
  104395. X = 2,
  104396. /** Y */
  104397. Y = 3,
  104398. /** Start */
  104399. Start = 4,
  104400. /** Back */
  104401. Back = 5,
  104402. /** Left button */
  104403. LB = 6,
  104404. /** Right button */
  104405. RB = 7,
  104406. /** Left stick */
  104407. LeftStick = 8,
  104408. /** Right stick */
  104409. RightStick = 9
  104410. }
  104411. /** Defines values for XBox360 DPad */
  104412. export enum Xbox360Dpad {
  104413. /** Up */
  104414. Up = 0,
  104415. /** Down */
  104416. Down = 1,
  104417. /** Left */
  104418. Left = 2,
  104419. /** Right */
  104420. Right = 3
  104421. }
  104422. /**
  104423. * Defines a XBox360 gamepad
  104424. */
  104425. export class Xbox360Pad extends Gamepad {
  104426. private _leftTrigger;
  104427. private _rightTrigger;
  104428. private _onlefttriggerchanged;
  104429. private _onrighttriggerchanged;
  104430. private _onbuttondown;
  104431. private _onbuttonup;
  104432. private _ondpaddown;
  104433. private _ondpadup;
  104434. /** Observable raised when a button is pressed */
  104435. onButtonDownObservable: Observable<Xbox360Button>;
  104436. /** Observable raised when a button is released */
  104437. onButtonUpObservable: Observable<Xbox360Button>;
  104438. /** Observable raised when a pad is pressed */
  104439. onPadDownObservable: Observable<Xbox360Dpad>;
  104440. /** Observable raised when a pad is released */
  104441. onPadUpObservable: Observable<Xbox360Dpad>;
  104442. private _buttonA;
  104443. private _buttonB;
  104444. private _buttonX;
  104445. private _buttonY;
  104446. private _buttonBack;
  104447. private _buttonStart;
  104448. private _buttonLB;
  104449. private _buttonRB;
  104450. private _buttonLeftStick;
  104451. private _buttonRightStick;
  104452. private _dPadUp;
  104453. private _dPadDown;
  104454. private _dPadLeft;
  104455. private _dPadRight;
  104456. private _isXboxOnePad;
  104457. /**
  104458. * Creates a new XBox360 gamepad object
  104459. * @param id defines the id of this gamepad
  104460. * @param index defines its index
  104461. * @param gamepad defines the internal HTML gamepad object
  104462. * @param xboxOne defines if it is a XBox One gamepad
  104463. */
  104464. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  104465. /**
  104466. * Defines the callback to call when left trigger is pressed
  104467. * @param callback defines the callback to use
  104468. */
  104469. onlefttriggerchanged(callback: (value: number) => void): void;
  104470. /**
  104471. * Defines the callback to call when right trigger is pressed
  104472. * @param callback defines the callback to use
  104473. */
  104474. onrighttriggerchanged(callback: (value: number) => void): void;
  104475. /**
  104476. * Gets the left trigger value
  104477. */
  104478. /**
  104479. * Sets the left trigger value
  104480. */
  104481. leftTrigger: number;
  104482. /**
  104483. * Gets the right trigger value
  104484. */
  104485. /**
  104486. * Sets the right trigger value
  104487. */
  104488. rightTrigger: number;
  104489. /**
  104490. * Defines the callback to call when a button is pressed
  104491. * @param callback defines the callback to use
  104492. */
  104493. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  104494. /**
  104495. * Defines the callback to call when a button is released
  104496. * @param callback defines the callback to use
  104497. */
  104498. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  104499. /**
  104500. * Defines the callback to call when a pad is pressed
  104501. * @param callback defines the callback to use
  104502. */
  104503. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  104504. /**
  104505. * Defines the callback to call when a pad is released
  104506. * @param callback defines the callback to use
  104507. */
  104508. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  104509. private _setButtonValue;
  104510. private _setDPadValue;
  104511. /**
  104512. * Gets the value of the `A` button
  104513. */
  104514. /**
  104515. * Sets the value of the `A` button
  104516. */
  104517. buttonA: number;
  104518. /**
  104519. * Gets the value of the `B` button
  104520. */
  104521. /**
  104522. * Sets the value of the `B` button
  104523. */
  104524. buttonB: number;
  104525. /**
  104526. * Gets the value of the `X` button
  104527. */
  104528. /**
  104529. * Sets the value of the `X` button
  104530. */
  104531. buttonX: number;
  104532. /**
  104533. * Gets the value of the `Y` button
  104534. */
  104535. /**
  104536. * Sets the value of the `Y` button
  104537. */
  104538. buttonY: number;
  104539. /**
  104540. * Gets the value of the `Start` button
  104541. */
  104542. /**
  104543. * Sets the value of the `Start` button
  104544. */
  104545. buttonStart: number;
  104546. /**
  104547. * Gets the value of the `Back` button
  104548. */
  104549. /**
  104550. * Sets the value of the `Back` button
  104551. */
  104552. buttonBack: number;
  104553. /**
  104554. * Gets the value of the `Left` button
  104555. */
  104556. /**
  104557. * Sets the value of the `Left` button
  104558. */
  104559. buttonLB: number;
  104560. /**
  104561. * Gets the value of the `Right` button
  104562. */
  104563. /**
  104564. * Sets the value of the `Right` button
  104565. */
  104566. buttonRB: number;
  104567. /**
  104568. * Gets the value of the Left joystick
  104569. */
  104570. /**
  104571. * Sets the value of the Left joystick
  104572. */
  104573. buttonLeftStick: number;
  104574. /**
  104575. * Gets the value of the Right joystick
  104576. */
  104577. /**
  104578. * Sets the value of the Right joystick
  104579. */
  104580. buttonRightStick: number;
  104581. /**
  104582. * Gets the value of D-pad up
  104583. */
  104584. /**
  104585. * Sets the value of D-pad up
  104586. */
  104587. dPadUp: number;
  104588. /**
  104589. * Gets the value of D-pad down
  104590. */
  104591. /**
  104592. * Sets the value of D-pad down
  104593. */
  104594. dPadDown: number;
  104595. /**
  104596. * Gets the value of D-pad left
  104597. */
  104598. /**
  104599. * Sets the value of D-pad left
  104600. */
  104601. dPadLeft: number;
  104602. /**
  104603. * Gets the value of D-pad right
  104604. */
  104605. /**
  104606. * Sets the value of D-pad right
  104607. */
  104608. dPadRight: number;
  104609. /**
  104610. * Force the gamepad to synchronize with device values
  104611. */
  104612. update(): void;
  104613. /**
  104614. * Disposes the gamepad
  104615. */
  104616. dispose(): void;
  104617. }
  104618. }
  104619. declare module BABYLON {
  104620. /**
  104621. * Defines supported buttons for DualShock compatible gamepads
  104622. */
  104623. export enum DualShockButton {
  104624. /** Cross */
  104625. Cross = 0,
  104626. /** Circle */
  104627. Circle = 1,
  104628. /** Square */
  104629. Square = 2,
  104630. /** Triangle */
  104631. Triangle = 3,
  104632. /** Options */
  104633. Options = 4,
  104634. /** Share */
  104635. Share = 5,
  104636. /** L1 */
  104637. L1 = 6,
  104638. /** R1 */
  104639. R1 = 7,
  104640. /** Left stick */
  104641. LeftStick = 8,
  104642. /** Right stick */
  104643. RightStick = 9
  104644. }
  104645. /** Defines values for DualShock DPad */
  104646. export enum DualShockDpad {
  104647. /** Up */
  104648. Up = 0,
  104649. /** Down */
  104650. Down = 1,
  104651. /** Left */
  104652. Left = 2,
  104653. /** Right */
  104654. Right = 3
  104655. }
  104656. /**
  104657. * Defines a DualShock gamepad
  104658. */
  104659. export class DualShockPad extends Gamepad {
  104660. private _leftTrigger;
  104661. private _rightTrigger;
  104662. private _onlefttriggerchanged;
  104663. private _onrighttriggerchanged;
  104664. private _onbuttondown;
  104665. private _onbuttonup;
  104666. private _ondpaddown;
  104667. private _ondpadup;
  104668. /** Observable raised when a button is pressed */
  104669. onButtonDownObservable: Observable<DualShockButton>;
  104670. /** Observable raised when a button is released */
  104671. onButtonUpObservable: Observable<DualShockButton>;
  104672. /** Observable raised when a pad is pressed */
  104673. onPadDownObservable: Observable<DualShockDpad>;
  104674. /** Observable raised when a pad is released */
  104675. onPadUpObservable: Observable<DualShockDpad>;
  104676. private _buttonCross;
  104677. private _buttonCircle;
  104678. private _buttonSquare;
  104679. private _buttonTriangle;
  104680. private _buttonShare;
  104681. private _buttonOptions;
  104682. private _buttonL1;
  104683. private _buttonR1;
  104684. private _buttonLeftStick;
  104685. private _buttonRightStick;
  104686. private _dPadUp;
  104687. private _dPadDown;
  104688. private _dPadLeft;
  104689. private _dPadRight;
  104690. /**
  104691. * Creates a new DualShock gamepad object
  104692. * @param id defines the id of this gamepad
  104693. * @param index defines its index
  104694. * @param gamepad defines the internal HTML gamepad object
  104695. */
  104696. constructor(id: string, index: number, gamepad: any);
  104697. /**
  104698. * Defines the callback to call when left trigger is pressed
  104699. * @param callback defines the callback to use
  104700. */
  104701. onlefttriggerchanged(callback: (value: number) => void): void;
  104702. /**
  104703. * Defines the callback to call when right trigger is pressed
  104704. * @param callback defines the callback to use
  104705. */
  104706. onrighttriggerchanged(callback: (value: number) => void): void;
  104707. /**
  104708. * Gets the left trigger value
  104709. */
  104710. /**
  104711. * Sets the left trigger value
  104712. */
  104713. leftTrigger: number;
  104714. /**
  104715. * Gets the right trigger value
  104716. */
  104717. /**
  104718. * Sets the right trigger value
  104719. */
  104720. rightTrigger: number;
  104721. /**
  104722. * Defines the callback to call when a button is pressed
  104723. * @param callback defines the callback to use
  104724. */
  104725. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  104726. /**
  104727. * Defines the callback to call when a button is released
  104728. * @param callback defines the callback to use
  104729. */
  104730. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  104731. /**
  104732. * Defines the callback to call when a pad is pressed
  104733. * @param callback defines the callback to use
  104734. */
  104735. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  104736. /**
  104737. * Defines the callback to call when a pad is released
  104738. * @param callback defines the callback to use
  104739. */
  104740. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  104741. private _setButtonValue;
  104742. private _setDPadValue;
  104743. /**
  104744. * Gets the value of the `Cross` button
  104745. */
  104746. /**
  104747. * Sets the value of the `Cross` button
  104748. */
  104749. buttonCross: number;
  104750. /**
  104751. * Gets the value of the `Circle` button
  104752. */
  104753. /**
  104754. * Sets the value of the `Circle` button
  104755. */
  104756. buttonCircle: number;
  104757. /**
  104758. * Gets the value of the `Square` button
  104759. */
  104760. /**
  104761. * Sets the value of the `Square` button
  104762. */
  104763. buttonSquare: number;
  104764. /**
  104765. * Gets the value of the `Triangle` button
  104766. */
  104767. /**
  104768. * Sets the value of the `Triangle` button
  104769. */
  104770. buttonTriangle: number;
  104771. /**
  104772. * Gets the value of the `Options` button
  104773. */
  104774. /**
  104775. * Sets the value of the `Options` button
  104776. */
  104777. buttonOptions: number;
  104778. /**
  104779. * Gets the value of the `Share` button
  104780. */
  104781. /**
  104782. * Sets the value of the `Share` button
  104783. */
  104784. buttonShare: number;
  104785. /**
  104786. * Gets the value of the `L1` button
  104787. */
  104788. /**
  104789. * Sets the value of the `L1` button
  104790. */
  104791. buttonL1: number;
  104792. /**
  104793. * Gets the value of the `R1` button
  104794. */
  104795. /**
  104796. * Sets the value of the `R1` button
  104797. */
  104798. buttonR1: number;
  104799. /**
  104800. * Gets the value of the Left joystick
  104801. */
  104802. /**
  104803. * Sets the value of the Left joystick
  104804. */
  104805. buttonLeftStick: number;
  104806. /**
  104807. * Gets the value of the Right joystick
  104808. */
  104809. /**
  104810. * Sets the value of the Right joystick
  104811. */
  104812. buttonRightStick: number;
  104813. /**
  104814. * Gets the value of D-pad up
  104815. */
  104816. /**
  104817. * Sets the value of D-pad up
  104818. */
  104819. dPadUp: number;
  104820. /**
  104821. * Gets the value of D-pad down
  104822. */
  104823. /**
  104824. * Sets the value of D-pad down
  104825. */
  104826. dPadDown: number;
  104827. /**
  104828. * Gets the value of D-pad left
  104829. */
  104830. /**
  104831. * Sets the value of D-pad left
  104832. */
  104833. dPadLeft: number;
  104834. /**
  104835. * Gets the value of D-pad right
  104836. */
  104837. /**
  104838. * Sets the value of D-pad right
  104839. */
  104840. dPadRight: number;
  104841. /**
  104842. * Force the gamepad to synchronize with device values
  104843. */
  104844. update(): void;
  104845. /**
  104846. * Disposes the gamepad
  104847. */
  104848. dispose(): void;
  104849. }
  104850. }
  104851. declare module BABYLON {
  104852. /**
  104853. * Manager for handling gamepads
  104854. */
  104855. export class GamepadManager {
  104856. private _scene?;
  104857. private _babylonGamepads;
  104858. private _oneGamepadConnected;
  104859. /** @hidden */
  104860. _isMonitoring: boolean;
  104861. private _gamepadEventSupported;
  104862. private _gamepadSupport;
  104863. /**
  104864. * observable to be triggered when the gamepad controller has been connected
  104865. */
  104866. onGamepadConnectedObservable: Observable<Gamepad>;
  104867. /**
  104868. * observable to be triggered when the gamepad controller has been disconnected
  104869. */
  104870. onGamepadDisconnectedObservable: Observable<Gamepad>;
  104871. private _onGamepadConnectedEvent;
  104872. private _onGamepadDisconnectedEvent;
  104873. /**
  104874. * Initializes the gamepad manager
  104875. * @param _scene BabylonJS scene
  104876. */
  104877. constructor(_scene?: Scene | undefined);
  104878. /**
  104879. * The gamepads in the game pad manager
  104880. */
  104881. readonly gamepads: Gamepad[];
  104882. /**
  104883. * Get the gamepad controllers based on type
  104884. * @param type The type of gamepad controller
  104885. * @returns Nullable gamepad
  104886. */
  104887. getGamepadByType(type?: number): Nullable<Gamepad>;
  104888. /**
  104889. * Disposes the gamepad manager
  104890. */
  104891. dispose(): void;
  104892. private _addNewGamepad;
  104893. private _startMonitoringGamepads;
  104894. private _stopMonitoringGamepads;
  104895. /** @hidden */
  104896. _checkGamepadsStatus(): void;
  104897. private _updateGamepadObjects;
  104898. }
  104899. }
  104900. declare module BABYLON {
  104901. interface Scene {
  104902. /** @hidden */
  104903. _gamepadManager: Nullable<GamepadManager>;
  104904. /**
  104905. * Gets the gamepad manager associated with the scene
  104906. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  104907. */
  104908. gamepadManager: GamepadManager;
  104909. }
  104910. /**
  104911. * Interface representing a free camera inputs manager
  104912. */
  104913. interface FreeCameraInputsManager {
  104914. /**
  104915. * Adds gamepad input support to the FreeCameraInputsManager.
  104916. * @returns the FreeCameraInputsManager
  104917. */
  104918. addGamepad(): FreeCameraInputsManager;
  104919. }
  104920. /**
  104921. * Interface representing an arc rotate camera inputs manager
  104922. */
  104923. interface ArcRotateCameraInputsManager {
  104924. /**
  104925. * Adds gamepad input support to the ArcRotateCamera InputManager.
  104926. * @returns the camera inputs manager
  104927. */
  104928. addGamepad(): ArcRotateCameraInputsManager;
  104929. }
  104930. /**
  104931. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  104932. */
  104933. export class GamepadSystemSceneComponent implements ISceneComponent {
  104934. /**
  104935. * The component name helpfull to identify the component in the list of scene components.
  104936. */
  104937. readonly name: string;
  104938. /**
  104939. * The scene the component belongs to.
  104940. */
  104941. scene: Scene;
  104942. /**
  104943. * Creates a new instance of the component for the given scene
  104944. * @param scene Defines the scene to register the component in
  104945. */
  104946. constructor(scene: Scene);
  104947. /**
  104948. * Registers the component in a given scene
  104949. */
  104950. register(): void;
  104951. /**
  104952. * Rebuilds the elements related to this component in case of
  104953. * context lost for instance.
  104954. */
  104955. rebuild(): void;
  104956. /**
  104957. * Disposes the component and the associated ressources
  104958. */
  104959. dispose(): void;
  104960. private _beforeCameraUpdate;
  104961. }
  104962. }
  104963. declare module BABYLON {
  104964. /**
  104965. * 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,
  104966. * which still works and will still be found in many Playgrounds.
  104967. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104968. */
  104969. export class UniversalCamera extends TouchCamera {
  104970. /**
  104971. * Defines the gamepad rotation sensiblity.
  104972. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104973. */
  104974. gamepadAngularSensibility: number;
  104975. /**
  104976. * Defines the gamepad move sensiblity.
  104977. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104978. */
  104979. gamepadMoveSensibility: number;
  104980. /**
  104981. * 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,
  104982. * which still works and will still be found in many Playgrounds.
  104983. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104984. * @param name Define the name of the camera in the scene
  104985. * @param position Define the start position of the camera in the scene
  104986. * @param scene Define the scene the camera belongs to
  104987. */
  104988. constructor(name: string, position: Vector3, scene: Scene);
  104989. /**
  104990. * Gets the current object class name.
  104991. * @return the class name
  104992. */
  104993. getClassName(): string;
  104994. }
  104995. }
  104996. declare module BABYLON {
  104997. /**
  104998. * This represents a FPS type of camera. This is only here for back compat purpose.
  104999. * Please use the UniversalCamera instead as both are identical.
  105000. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105001. */
  105002. export class GamepadCamera extends UniversalCamera {
  105003. /**
  105004. * Instantiates a new Gamepad Camera
  105005. * This represents a FPS type of camera. This is only here for back compat purpose.
  105006. * Please use the UniversalCamera instead as both are identical.
  105007. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105008. * @param name Define the name of the camera in the scene
  105009. * @param position Define the start position of the camera in the scene
  105010. * @param scene Define the scene the camera belongs to
  105011. */
  105012. constructor(name: string, position: Vector3, scene: Scene);
  105013. /**
  105014. * Gets the current object class name.
  105015. * @return the class name
  105016. */
  105017. getClassName(): string;
  105018. }
  105019. }
  105020. declare module BABYLON {
  105021. /** @hidden */
  105022. export var passPixelShader: {
  105023. name: string;
  105024. shader: string;
  105025. };
  105026. }
  105027. declare module BABYLON {
  105028. /** @hidden */
  105029. export var passCubePixelShader: {
  105030. name: string;
  105031. shader: string;
  105032. };
  105033. }
  105034. declare module BABYLON {
  105035. /**
  105036. * PassPostProcess which produces an output the same as it's input
  105037. */
  105038. export class PassPostProcess extends PostProcess {
  105039. /**
  105040. * Creates the PassPostProcess
  105041. * @param name The name of the effect.
  105042. * @param options The required width/height ratio to downsize to before computing the render pass.
  105043. * @param camera The camera to apply the render pass to.
  105044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105045. * @param engine The engine which the post process will be applied. (default: current engine)
  105046. * @param reusable If the post process can be reused on the same frame. (default: false)
  105047. * @param textureType The type of texture to be used when performing the post processing.
  105048. * @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)
  105049. */
  105050. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105051. }
  105052. /**
  105053. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  105054. */
  105055. export class PassCubePostProcess extends PostProcess {
  105056. private _face;
  105057. /**
  105058. * Gets or sets the cube face to display.
  105059. * * 0 is +X
  105060. * * 1 is -X
  105061. * * 2 is +Y
  105062. * * 3 is -Y
  105063. * * 4 is +Z
  105064. * * 5 is -Z
  105065. */
  105066. face: number;
  105067. /**
  105068. * Creates the PassCubePostProcess
  105069. * @param name The name of the effect.
  105070. * @param options The required width/height ratio to downsize to before computing the render pass.
  105071. * @param camera The camera to apply the render pass to.
  105072. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105073. * @param engine The engine which the post process will be applied. (default: current engine)
  105074. * @param reusable If the post process can be reused on the same frame. (default: false)
  105075. * @param textureType The type of texture to be used when performing the post processing.
  105076. * @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)
  105077. */
  105078. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105079. }
  105080. }
  105081. declare module BABYLON {
  105082. /** @hidden */
  105083. export var anaglyphPixelShader: {
  105084. name: string;
  105085. shader: string;
  105086. };
  105087. }
  105088. declare module BABYLON {
  105089. /**
  105090. * Postprocess used to generate anaglyphic rendering
  105091. */
  105092. export class AnaglyphPostProcess extends PostProcess {
  105093. private _passedProcess;
  105094. /**
  105095. * Creates a new AnaglyphPostProcess
  105096. * @param name defines postprocess name
  105097. * @param options defines creation options or target ratio scale
  105098. * @param rigCameras defines cameras using this postprocess
  105099. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  105100. * @param engine defines hosting engine
  105101. * @param reusable defines if the postprocess will be reused multiple times per frame
  105102. */
  105103. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  105104. }
  105105. }
  105106. declare module BABYLON {
  105107. /**
  105108. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  105109. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105110. */
  105111. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  105112. /**
  105113. * Creates a new AnaglyphArcRotateCamera
  105114. * @param name defines camera name
  105115. * @param alpha defines alpha angle (in radians)
  105116. * @param beta defines beta angle (in radians)
  105117. * @param radius defines radius
  105118. * @param target defines camera target
  105119. * @param interaxialDistance defines distance between each color axis
  105120. * @param scene defines the hosting scene
  105121. */
  105122. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  105123. /**
  105124. * Gets camera class name
  105125. * @returns AnaglyphArcRotateCamera
  105126. */
  105127. getClassName(): string;
  105128. }
  105129. }
  105130. declare module BABYLON {
  105131. /**
  105132. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  105133. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105134. */
  105135. export class AnaglyphFreeCamera extends FreeCamera {
  105136. /**
  105137. * Creates a new AnaglyphFreeCamera
  105138. * @param name defines camera name
  105139. * @param position defines initial position
  105140. * @param interaxialDistance defines distance between each color axis
  105141. * @param scene defines the hosting scene
  105142. */
  105143. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105144. /**
  105145. * Gets camera class name
  105146. * @returns AnaglyphFreeCamera
  105147. */
  105148. getClassName(): string;
  105149. }
  105150. }
  105151. declare module BABYLON {
  105152. /**
  105153. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  105154. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105155. */
  105156. export class AnaglyphGamepadCamera extends GamepadCamera {
  105157. /**
  105158. * Creates a new AnaglyphGamepadCamera
  105159. * @param name defines camera name
  105160. * @param position defines initial position
  105161. * @param interaxialDistance defines distance between each color axis
  105162. * @param scene defines the hosting scene
  105163. */
  105164. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105165. /**
  105166. * Gets camera class name
  105167. * @returns AnaglyphGamepadCamera
  105168. */
  105169. getClassName(): string;
  105170. }
  105171. }
  105172. declare module BABYLON {
  105173. /**
  105174. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  105175. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105176. */
  105177. export class AnaglyphUniversalCamera extends UniversalCamera {
  105178. /**
  105179. * Creates a new AnaglyphUniversalCamera
  105180. * @param name defines camera name
  105181. * @param position defines initial position
  105182. * @param interaxialDistance defines distance between each color axis
  105183. * @param scene defines the hosting scene
  105184. */
  105185. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105186. /**
  105187. * Gets camera class name
  105188. * @returns AnaglyphUniversalCamera
  105189. */
  105190. getClassName(): string;
  105191. }
  105192. }
  105193. declare module BABYLON {
  105194. /** @hidden */
  105195. export var stereoscopicInterlacePixelShader: {
  105196. name: string;
  105197. shader: string;
  105198. };
  105199. }
  105200. declare module BABYLON {
  105201. /**
  105202. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  105203. */
  105204. export class StereoscopicInterlacePostProcess extends PostProcess {
  105205. private _stepSize;
  105206. private _passedProcess;
  105207. /**
  105208. * Initializes a StereoscopicInterlacePostProcess
  105209. * @param name The name of the effect.
  105210. * @param rigCameras The rig cameras to be appled to the post process
  105211. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  105212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105213. * @param engine The engine which the post process will be applied. (default: current engine)
  105214. * @param reusable If the post process can be reused on the same frame. (default: false)
  105215. */
  105216. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105217. }
  105218. }
  105219. declare module BABYLON {
  105220. /**
  105221. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  105222. * @see http://doc.babylonjs.com/features/cameras
  105223. */
  105224. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  105225. /**
  105226. * Creates a new StereoscopicArcRotateCamera
  105227. * @param name defines camera name
  105228. * @param alpha defines alpha angle (in radians)
  105229. * @param beta defines beta angle (in radians)
  105230. * @param radius defines radius
  105231. * @param target defines camera target
  105232. * @param interaxialDistance defines distance between each color axis
  105233. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105234. * @param scene defines the hosting scene
  105235. */
  105236. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105237. /**
  105238. * Gets camera class name
  105239. * @returns StereoscopicArcRotateCamera
  105240. */
  105241. getClassName(): string;
  105242. }
  105243. }
  105244. declare module BABYLON {
  105245. /**
  105246. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  105247. * @see http://doc.babylonjs.com/features/cameras
  105248. */
  105249. export class StereoscopicFreeCamera extends FreeCamera {
  105250. /**
  105251. * Creates a new StereoscopicFreeCamera
  105252. * @param name defines camera name
  105253. * @param position defines initial position
  105254. * @param interaxialDistance defines distance between each color axis
  105255. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105256. * @param scene defines the hosting scene
  105257. */
  105258. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105259. /**
  105260. * Gets camera class name
  105261. * @returns StereoscopicFreeCamera
  105262. */
  105263. getClassName(): string;
  105264. }
  105265. }
  105266. declare module BABYLON {
  105267. /**
  105268. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  105269. * @see http://doc.babylonjs.com/features/cameras
  105270. */
  105271. export class StereoscopicGamepadCamera extends GamepadCamera {
  105272. /**
  105273. * Creates a new StereoscopicGamepadCamera
  105274. * @param name defines camera name
  105275. * @param position defines initial position
  105276. * @param interaxialDistance defines distance between each color axis
  105277. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105278. * @param scene defines the hosting scene
  105279. */
  105280. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105281. /**
  105282. * Gets camera class name
  105283. * @returns StereoscopicGamepadCamera
  105284. */
  105285. getClassName(): string;
  105286. }
  105287. }
  105288. declare module BABYLON {
  105289. /**
  105290. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  105291. * @see http://doc.babylonjs.com/features/cameras
  105292. */
  105293. export class StereoscopicUniversalCamera extends UniversalCamera {
  105294. /**
  105295. * Creates a new StereoscopicUniversalCamera
  105296. * @param name defines camera name
  105297. * @param position defines initial position
  105298. * @param interaxialDistance defines distance between each color axis
  105299. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105300. * @param scene defines the hosting scene
  105301. */
  105302. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105303. /**
  105304. * Gets camera class name
  105305. * @returns StereoscopicUniversalCamera
  105306. */
  105307. getClassName(): string;
  105308. }
  105309. }
  105310. declare module BABYLON {
  105311. /**
  105312. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  105313. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105314. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105315. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105316. */
  105317. export class VirtualJoysticksCamera extends FreeCamera {
  105318. /**
  105319. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  105320. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105321. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105322. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105323. * @param name Define the name of the camera in the scene
  105324. * @param position Define the start position of the camera in the scene
  105325. * @param scene Define the scene the camera belongs to
  105326. */
  105327. constructor(name: string, position: Vector3, scene: Scene);
  105328. /**
  105329. * Gets the current object class name.
  105330. * @return the class name
  105331. */
  105332. getClassName(): string;
  105333. }
  105334. }
  105335. declare module BABYLON {
  105336. /**
  105337. * This represents all the required metrics to create a VR camera.
  105338. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  105339. */
  105340. export class VRCameraMetrics {
  105341. /**
  105342. * Define the horizontal resolution off the screen.
  105343. */
  105344. hResolution: number;
  105345. /**
  105346. * Define the vertical resolution off the screen.
  105347. */
  105348. vResolution: number;
  105349. /**
  105350. * Define the horizontal screen size.
  105351. */
  105352. hScreenSize: number;
  105353. /**
  105354. * Define the vertical screen size.
  105355. */
  105356. vScreenSize: number;
  105357. /**
  105358. * Define the vertical screen center position.
  105359. */
  105360. vScreenCenter: number;
  105361. /**
  105362. * Define the distance of the eyes to the screen.
  105363. */
  105364. eyeToScreenDistance: number;
  105365. /**
  105366. * Define the distance between both lenses
  105367. */
  105368. lensSeparationDistance: number;
  105369. /**
  105370. * Define the distance between both viewer's eyes.
  105371. */
  105372. interpupillaryDistance: number;
  105373. /**
  105374. * Define the distortion factor of the VR postprocess.
  105375. * Please, touch with care.
  105376. */
  105377. distortionK: number[];
  105378. /**
  105379. * Define the chromatic aberration correction factors for the VR post process.
  105380. */
  105381. chromaAbCorrection: number[];
  105382. /**
  105383. * Define the scale factor of the post process.
  105384. * The smaller the better but the slower.
  105385. */
  105386. postProcessScaleFactor: number;
  105387. /**
  105388. * Define an offset for the lens center.
  105389. */
  105390. lensCenterOffset: number;
  105391. /**
  105392. * Define if the current vr camera should compensate the distortion of the lense or not.
  105393. */
  105394. compensateDistortion: boolean;
  105395. /**
  105396. * Defines if multiview should be enabled when rendering (Default: false)
  105397. */
  105398. multiviewEnabled: boolean;
  105399. /**
  105400. * Gets the rendering aspect ratio based on the provided resolutions.
  105401. */
  105402. readonly aspectRatio: number;
  105403. /**
  105404. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  105405. */
  105406. readonly aspectRatioFov: number;
  105407. /**
  105408. * @hidden
  105409. */
  105410. readonly leftHMatrix: Matrix;
  105411. /**
  105412. * @hidden
  105413. */
  105414. readonly rightHMatrix: Matrix;
  105415. /**
  105416. * @hidden
  105417. */
  105418. readonly leftPreViewMatrix: Matrix;
  105419. /**
  105420. * @hidden
  105421. */
  105422. readonly rightPreViewMatrix: Matrix;
  105423. /**
  105424. * Get the default VRMetrics based on the most generic setup.
  105425. * @returns the default vr metrics
  105426. */
  105427. static GetDefault(): VRCameraMetrics;
  105428. }
  105429. }
  105430. declare module BABYLON {
  105431. /** @hidden */
  105432. export var vrDistortionCorrectionPixelShader: {
  105433. name: string;
  105434. shader: string;
  105435. };
  105436. }
  105437. declare module BABYLON {
  105438. /**
  105439. * VRDistortionCorrectionPostProcess used for mobile VR
  105440. */
  105441. export class VRDistortionCorrectionPostProcess extends PostProcess {
  105442. private _isRightEye;
  105443. private _distortionFactors;
  105444. private _postProcessScaleFactor;
  105445. private _lensCenterOffset;
  105446. private _scaleIn;
  105447. private _scaleFactor;
  105448. private _lensCenter;
  105449. /**
  105450. * Initializes the VRDistortionCorrectionPostProcess
  105451. * @param name The name of the effect.
  105452. * @param camera The camera to apply the render pass to.
  105453. * @param isRightEye If this is for the right eye distortion
  105454. * @param vrMetrics All the required metrics for the VR camera
  105455. */
  105456. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  105457. }
  105458. }
  105459. declare module BABYLON {
  105460. /**
  105461. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  105462. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105463. */
  105464. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  105465. /**
  105466. * Creates a new VRDeviceOrientationArcRotateCamera
  105467. * @param name defines camera name
  105468. * @param alpha defines the camera rotation along the logitudinal axis
  105469. * @param beta defines the camera rotation along the latitudinal axis
  105470. * @param radius defines the camera distance from its target
  105471. * @param target defines the camera target
  105472. * @param scene defines the scene the camera belongs to
  105473. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105474. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105475. */
  105476. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105477. /**
  105478. * Gets camera class name
  105479. * @returns VRDeviceOrientationArcRotateCamera
  105480. */
  105481. getClassName(): string;
  105482. }
  105483. }
  105484. declare module BABYLON {
  105485. /**
  105486. * Camera used to simulate VR rendering (based on FreeCamera)
  105487. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105488. */
  105489. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  105490. /**
  105491. * Creates a new VRDeviceOrientationFreeCamera
  105492. * @param name defines camera name
  105493. * @param position defines the start position of the camera
  105494. * @param scene defines the scene the camera belongs to
  105495. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105496. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105497. */
  105498. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105499. /**
  105500. * Gets camera class name
  105501. * @returns VRDeviceOrientationFreeCamera
  105502. */
  105503. getClassName(): string;
  105504. }
  105505. }
  105506. declare module BABYLON {
  105507. /**
  105508. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  105509. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105510. */
  105511. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  105512. /**
  105513. * Creates a new VRDeviceOrientationGamepadCamera
  105514. * @param name defines camera name
  105515. * @param position defines the start position of the camera
  105516. * @param scene defines the scene the camera belongs to
  105517. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105518. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105519. */
  105520. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105521. /**
  105522. * Gets camera class name
  105523. * @returns VRDeviceOrientationGamepadCamera
  105524. */
  105525. getClassName(): string;
  105526. }
  105527. }
  105528. declare module BABYLON {
  105529. /**
  105530. * Base class of materials working in push mode in babylon JS
  105531. * @hidden
  105532. */
  105533. export class PushMaterial extends Material {
  105534. protected _activeEffect: Effect;
  105535. protected _normalMatrix: Matrix;
  105536. /**
  105537. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  105538. * This means that the material can keep using a previous shader while a new one is being compiled.
  105539. * This is mostly used when shader parallel compilation is supported (true by default)
  105540. */
  105541. allowShaderHotSwapping: boolean;
  105542. constructor(name: string, scene: Scene);
  105543. getEffect(): Effect;
  105544. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105545. /**
  105546. * Binds the given world matrix to the active effect
  105547. *
  105548. * @param world the matrix to bind
  105549. */
  105550. bindOnlyWorldMatrix(world: Matrix): void;
  105551. /**
  105552. * Binds the given normal matrix to the active effect
  105553. *
  105554. * @param normalMatrix the matrix to bind
  105555. */
  105556. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  105557. bind(world: Matrix, mesh?: Mesh): void;
  105558. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  105559. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  105560. }
  105561. }
  105562. declare module BABYLON {
  105563. /**
  105564. * This groups all the flags used to control the materials channel.
  105565. */
  105566. export class MaterialFlags {
  105567. private static _DiffuseTextureEnabled;
  105568. /**
  105569. * Are diffuse textures enabled in the application.
  105570. */
  105571. static DiffuseTextureEnabled: boolean;
  105572. private static _AmbientTextureEnabled;
  105573. /**
  105574. * Are ambient textures enabled in the application.
  105575. */
  105576. static AmbientTextureEnabled: boolean;
  105577. private static _OpacityTextureEnabled;
  105578. /**
  105579. * Are opacity textures enabled in the application.
  105580. */
  105581. static OpacityTextureEnabled: boolean;
  105582. private static _ReflectionTextureEnabled;
  105583. /**
  105584. * Are reflection textures enabled in the application.
  105585. */
  105586. static ReflectionTextureEnabled: boolean;
  105587. private static _EmissiveTextureEnabled;
  105588. /**
  105589. * Are emissive textures enabled in the application.
  105590. */
  105591. static EmissiveTextureEnabled: boolean;
  105592. private static _SpecularTextureEnabled;
  105593. /**
  105594. * Are specular textures enabled in the application.
  105595. */
  105596. static SpecularTextureEnabled: boolean;
  105597. private static _BumpTextureEnabled;
  105598. /**
  105599. * Are bump textures enabled in the application.
  105600. */
  105601. static BumpTextureEnabled: boolean;
  105602. private static _LightmapTextureEnabled;
  105603. /**
  105604. * Are lightmap textures enabled in the application.
  105605. */
  105606. static LightmapTextureEnabled: boolean;
  105607. private static _RefractionTextureEnabled;
  105608. /**
  105609. * Are refraction textures enabled in the application.
  105610. */
  105611. static RefractionTextureEnabled: boolean;
  105612. private static _ColorGradingTextureEnabled;
  105613. /**
  105614. * Are color grading textures enabled in the application.
  105615. */
  105616. static ColorGradingTextureEnabled: boolean;
  105617. private static _FresnelEnabled;
  105618. /**
  105619. * Are fresnels enabled in the application.
  105620. */
  105621. static FresnelEnabled: boolean;
  105622. private static _ClearCoatTextureEnabled;
  105623. /**
  105624. * Are clear coat textures enabled in the application.
  105625. */
  105626. static ClearCoatTextureEnabled: boolean;
  105627. private static _ClearCoatBumpTextureEnabled;
  105628. /**
  105629. * Are clear coat bump textures enabled in the application.
  105630. */
  105631. static ClearCoatBumpTextureEnabled: boolean;
  105632. private static _ClearCoatTintTextureEnabled;
  105633. /**
  105634. * Are clear coat tint textures enabled in the application.
  105635. */
  105636. static ClearCoatTintTextureEnabled: boolean;
  105637. private static _SheenTextureEnabled;
  105638. /**
  105639. * Are sheen textures enabled in the application.
  105640. */
  105641. static SheenTextureEnabled: boolean;
  105642. private static _AnisotropicTextureEnabled;
  105643. /**
  105644. * Are anisotropic textures enabled in the application.
  105645. */
  105646. static AnisotropicTextureEnabled: boolean;
  105647. private static _ThicknessTextureEnabled;
  105648. /**
  105649. * Are thickness textures enabled in the application.
  105650. */
  105651. static ThicknessTextureEnabled: boolean;
  105652. }
  105653. }
  105654. declare module BABYLON {
  105655. /** @hidden */
  105656. export var defaultFragmentDeclaration: {
  105657. name: string;
  105658. shader: string;
  105659. };
  105660. }
  105661. declare module BABYLON {
  105662. /** @hidden */
  105663. export var defaultUboDeclaration: {
  105664. name: string;
  105665. shader: string;
  105666. };
  105667. }
  105668. declare module BABYLON {
  105669. /** @hidden */
  105670. export var lightFragmentDeclaration: {
  105671. name: string;
  105672. shader: string;
  105673. };
  105674. }
  105675. declare module BABYLON {
  105676. /** @hidden */
  105677. export var lightUboDeclaration: {
  105678. name: string;
  105679. shader: string;
  105680. };
  105681. }
  105682. declare module BABYLON {
  105683. /** @hidden */
  105684. export var lightsFragmentFunctions: {
  105685. name: string;
  105686. shader: string;
  105687. };
  105688. }
  105689. declare module BABYLON {
  105690. /** @hidden */
  105691. export var shadowsFragmentFunctions: {
  105692. name: string;
  105693. shader: string;
  105694. };
  105695. }
  105696. declare module BABYLON {
  105697. /** @hidden */
  105698. export var fresnelFunction: {
  105699. name: string;
  105700. shader: string;
  105701. };
  105702. }
  105703. declare module BABYLON {
  105704. /** @hidden */
  105705. export var reflectionFunction: {
  105706. name: string;
  105707. shader: string;
  105708. };
  105709. }
  105710. declare module BABYLON {
  105711. /** @hidden */
  105712. export var bumpFragmentFunctions: {
  105713. name: string;
  105714. shader: string;
  105715. };
  105716. }
  105717. declare module BABYLON {
  105718. /** @hidden */
  105719. export var logDepthDeclaration: {
  105720. name: string;
  105721. shader: string;
  105722. };
  105723. }
  105724. declare module BABYLON {
  105725. /** @hidden */
  105726. export var bumpFragment: {
  105727. name: string;
  105728. shader: string;
  105729. };
  105730. }
  105731. declare module BABYLON {
  105732. /** @hidden */
  105733. export var depthPrePass: {
  105734. name: string;
  105735. shader: string;
  105736. };
  105737. }
  105738. declare module BABYLON {
  105739. /** @hidden */
  105740. export var lightFragment: {
  105741. name: string;
  105742. shader: string;
  105743. };
  105744. }
  105745. declare module BABYLON {
  105746. /** @hidden */
  105747. export var logDepthFragment: {
  105748. name: string;
  105749. shader: string;
  105750. };
  105751. }
  105752. declare module BABYLON {
  105753. /** @hidden */
  105754. export var defaultPixelShader: {
  105755. name: string;
  105756. shader: string;
  105757. };
  105758. }
  105759. declare module BABYLON {
  105760. /** @hidden */
  105761. export var defaultVertexDeclaration: {
  105762. name: string;
  105763. shader: string;
  105764. };
  105765. }
  105766. declare module BABYLON {
  105767. /** @hidden */
  105768. export var bumpVertexDeclaration: {
  105769. name: string;
  105770. shader: string;
  105771. };
  105772. }
  105773. declare module BABYLON {
  105774. /** @hidden */
  105775. export var bumpVertex: {
  105776. name: string;
  105777. shader: string;
  105778. };
  105779. }
  105780. declare module BABYLON {
  105781. /** @hidden */
  105782. export var fogVertex: {
  105783. name: string;
  105784. shader: string;
  105785. };
  105786. }
  105787. declare module BABYLON {
  105788. /** @hidden */
  105789. export var shadowsVertex: {
  105790. name: string;
  105791. shader: string;
  105792. };
  105793. }
  105794. declare module BABYLON {
  105795. /** @hidden */
  105796. export var pointCloudVertex: {
  105797. name: string;
  105798. shader: string;
  105799. };
  105800. }
  105801. declare module BABYLON {
  105802. /** @hidden */
  105803. export var logDepthVertex: {
  105804. name: string;
  105805. shader: string;
  105806. };
  105807. }
  105808. declare module BABYLON {
  105809. /** @hidden */
  105810. export var defaultVertexShader: {
  105811. name: string;
  105812. shader: string;
  105813. };
  105814. }
  105815. declare module BABYLON {
  105816. /** @hidden */
  105817. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  105818. MAINUV1: boolean;
  105819. MAINUV2: boolean;
  105820. DIFFUSE: boolean;
  105821. DIFFUSEDIRECTUV: number;
  105822. AMBIENT: boolean;
  105823. AMBIENTDIRECTUV: number;
  105824. OPACITY: boolean;
  105825. OPACITYDIRECTUV: number;
  105826. OPACITYRGB: boolean;
  105827. REFLECTION: boolean;
  105828. EMISSIVE: boolean;
  105829. EMISSIVEDIRECTUV: number;
  105830. SPECULAR: boolean;
  105831. SPECULARDIRECTUV: number;
  105832. BUMP: boolean;
  105833. BUMPDIRECTUV: number;
  105834. PARALLAX: boolean;
  105835. PARALLAXOCCLUSION: boolean;
  105836. SPECULAROVERALPHA: boolean;
  105837. CLIPPLANE: boolean;
  105838. CLIPPLANE2: boolean;
  105839. CLIPPLANE3: boolean;
  105840. CLIPPLANE4: boolean;
  105841. ALPHATEST: boolean;
  105842. DEPTHPREPASS: boolean;
  105843. ALPHAFROMDIFFUSE: boolean;
  105844. POINTSIZE: boolean;
  105845. FOG: boolean;
  105846. SPECULARTERM: boolean;
  105847. DIFFUSEFRESNEL: boolean;
  105848. OPACITYFRESNEL: boolean;
  105849. REFLECTIONFRESNEL: boolean;
  105850. REFRACTIONFRESNEL: boolean;
  105851. EMISSIVEFRESNEL: boolean;
  105852. FRESNEL: boolean;
  105853. NORMAL: boolean;
  105854. UV1: boolean;
  105855. UV2: boolean;
  105856. VERTEXCOLOR: boolean;
  105857. VERTEXALPHA: boolean;
  105858. NUM_BONE_INFLUENCERS: number;
  105859. BonesPerMesh: number;
  105860. BONETEXTURE: boolean;
  105861. INSTANCES: boolean;
  105862. GLOSSINESS: boolean;
  105863. ROUGHNESS: boolean;
  105864. EMISSIVEASILLUMINATION: boolean;
  105865. LINKEMISSIVEWITHDIFFUSE: boolean;
  105866. REFLECTIONFRESNELFROMSPECULAR: boolean;
  105867. LIGHTMAP: boolean;
  105868. LIGHTMAPDIRECTUV: number;
  105869. OBJECTSPACE_NORMALMAP: boolean;
  105870. USELIGHTMAPASSHADOWMAP: boolean;
  105871. REFLECTIONMAP_3D: boolean;
  105872. REFLECTIONMAP_SPHERICAL: boolean;
  105873. REFLECTIONMAP_PLANAR: boolean;
  105874. REFLECTIONMAP_CUBIC: boolean;
  105875. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  105876. REFLECTIONMAP_PROJECTION: boolean;
  105877. REFLECTIONMAP_SKYBOX: boolean;
  105878. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  105879. REFLECTIONMAP_EXPLICIT: boolean;
  105880. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  105881. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  105882. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  105883. INVERTCUBICMAP: boolean;
  105884. LOGARITHMICDEPTH: boolean;
  105885. REFRACTION: boolean;
  105886. REFRACTIONMAP_3D: boolean;
  105887. REFLECTIONOVERALPHA: boolean;
  105888. TWOSIDEDLIGHTING: boolean;
  105889. SHADOWFLOAT: boolean;
  105890. MORPHTARGETS: boolean;
  105891. MORPHTARGETS_NORMAL: boolean;
  105892. MORPHTARGETS_TANGENT: boolean;
  105893. MORPHTARGETS_UV: boolean;
  105894. NUM_MORPH_INFLUENCERS: number;
  105895. NONUNIFORMSCALING: boolean;
  105896. PREMULTIPLYALPHA: boolean;
  105897. IMAGEPROCESSING: boolean;
  105898. VIGNETTE: boolean;
  105899. VIGNETTEBLENDMODEMULTIPLY: boolean;
  105900. VIGNETTEBLENDMODEOPAQUE: boolean;
  105901. TONEMAPPING: boolean;
  105902. TONEMAPPING_ACES: boolean;
  105903. CONTRAST: boolean;
  105904. COLORCURVES: boolean;
  105905. COLORGRADING: boolean;
  105906. COLORGRADING3D: boolean;
  105907. SAMPLER3DGREENDEPTH: boolean;
  105908. SAMPLER3DBGRMAP: boolean;
  105909. IMAGEPROCESSINGPOSTPROCESS: boolean;
  105910. MULTIVIEW: boolean;
  105911. /**
  105912. * If the reflection texture on this material is in linear color space
  105913. * @hidden
  105914. */
  105915. IS_REFLECTION_LINEAR: boolean;
  105916. /**
  105917. * If the refraction texture on this material is in linear color space
  105918. * @hidden
  105919. */
  105920. IS_REFRACTION_LINEAR: boolean;
  105921. EXPOSURE: boolean;
  105922. constructor();
  105923. setReflectionMode(modeToEnable: string): void;
  105924. }
  105925. /**
  105926. * This is the default material used in Babylon. It is the best trade off between quality
  105927. * and performances.
  105928. * @see http://doc.babylonjs.com/babylon101/materials
  105929. */
  105930. export class StandardMaterial extends PushMaterial {
  105931. private _diffuseTexture;
  105932. /**
  105933. * The basic texture of the material as viewed under a light.
  105934. */
  105935. diffuseTexture: Nullable<BaseTexture>;
  105936. private _ambientTexture;
  105937. /**
  105938. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  105939. */
  105940. ambientTexture: Nullable<BaseTexture>;
  105941. private _opacityTexture;
  105942. /**
  105943. * Define the transparency of the material from a texture.
  105944. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  105945. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  105946. */
  105947. opacityTexture: Nullable<BaseTexture>;
  105948. private _reflectionTexture;
  105949. /**
  105950. * Define the texture used to display the reflection.
  105951. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105952. */
  105953. reflectionTexture: Nullable<BaseTexture>;
  105954. private _emissiveTexture;
  105955. /**
  105956. * Define texture of the material as if self lit.
  105957. * This will be mixed in the final result even in the absence of light.
  105958. */
  105959. emissiveTexture: Nullable<BaseTexture>;
  105960. private _specularTexture;
  105961. /**
  105962. * Define how the color and intensity of the highlight given by the light in the material.
  105963. */
  105964. specularTexture: Nullable<BaseTexture>;
  105965. private _bumpTexture;
  105966. /**
  105967. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  105968. * 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.
  105969. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  105970. */
  105971. bumpTexture: Nullable<BaseTexture>;
  105972. private _lightmapTexture;
  105973. /**
  105974. * Complex lighting can be computationally expensive to compute at runtime.
  105975. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  105976. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  105977. */
  105978. lightmapTexture: Nullable<BaseTexture>;
  105979. private _refractionTexture;
  105980. /**
  105981. * Define the texture used to display the refraction.
  105982. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105983. */
  105984. refractionTexture: Nullable<BaseTexture>;
  105985. /**
  105986. * The color of the material lit by the environmental background lighting.
  105987. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  105988. */
  105989. ambientColor: Color3;
  105990. /**
  105991. * The basic color of the material as viewed under a light.
  105992. */
  105993. diffuseColor: Color3;
  105994. /**
  105995. * Define how the color and intensity of the highlight given by the light in the material.
  105996. */
  105997. specularColor: Color3;
  105998. /**
  105999. * Define the color of the material as if self lit.
  106000. * This will be mixed in the final result even in the absence of light.
  106001. */
  106002. emissiveColor: Color3;
  106003. /**
  106004. * Defines how sharp are the highlights in the material.
  106005. * The bigger the value the sharper giving a more glossy feeling to the result.
  106006. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  106007. */
  106008. specularPower: number;
  106009. private _useAlphaFromDiffuseTexture;
  106010. /**
  106011. * Does the transparency come from the diffuse texture alpha channel.
  106012. */
  106013. useAlphaFromDiffuseTexture: boolean;
  106014. private _useEmissiveAsIllumination;
  106015. /**
  106016. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  106017. */
  106018. useEmissiveAsIllumination: boolean;
  106019. private _linkEmissiveWithDiffuse;
  106020. /**
  106021. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  106022. * the emissive level when the final color is close to one.
  106023. */
  106024. linkEmissiveWithDiffuse: boolean;
  106025. private _useSpecularOverAlpha;
  106026. /**
  106027. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  106028. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106029. */
  106030. useSpecularOverAlpha: boolean;
  106031. private _useReflectionOverAlpha;
  106032. /**
  106033. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106034. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106035. */
  106036. useReflectionOverAlpha: boolean;
  106037. private _disableLighting;
  106038. /**
  106039. * Does lights from the scene impacts this material.
  106040. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  106041. */
  106042. disableLighting: boolean;
  106043. private _useObjectSpaceNormalMap;
  106044. /**
  106045. * Allows using an object space normal map (instead of tangent space).
  106046. */
  106047. useObjectSpaceNormalMap: boolean;
  106048. private _useParallax;
  106049. /**
  106050. * Is parallax enabled or not.
  106051. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106052. */
  106053. useParallax: boolean;
  106054. private _useParallaxOcclusion;
  106055. /**
  106056. * Is parallax occlusion enabled or not.
  106057. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  106058. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106059. */
  106060. useParallaxOcclusion: boolean;
  106061. /**
  106062. * 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.
  106063. */
  106064. parallaxScaleBias: number;
  106065. private _roughness;
  106066. /**
  106067. * Helps to define how blurry the reflections should appears in the material.
  106068. */
  106069. roughness: number;
  106070. /**
  106071. * In case of refraction, define the value of the index of refraction.
  106072. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106073. */
  106074. indexOfRefraction: number;
  106075. /**
  106076. * Invert the refraction texture alongside the y axis.
  106077. * It can be useful with procedural textures or probe for instance.
  106078. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106079. */
  106080. invertRefractionY: boolean;
  106081. /**
  106082. * Defines the alpha limits in alpha test mode.
  106083. */
  106084. alphaCutOff: number;
  106085. private _useLightmapAsShadowmap;
  106086. /**
  106087. * In case of light mapping, define whether the map contains light or shadow informations.
  106088. */
  106089. useLightmapAsShadowmap: boolean;
  106090. private _diffuseFresnelParameters;
  106091. /**
  106092. * Define the diffuse fresnel parameters of the material.
  106093. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106094. */
  106095. diffuseFresnelParameters: FresnelParameters;
  106096. private _opacityFresnelParameters;
  106097. /**
  106098. * Define the opacity fresnel parameters of the material.
  106099. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106100. */
  106101. opacityFresnelParameters: FresnelParameters;
  106102. private _reflectionFresnelParameters;
  106103. /**
  106104. * Define the reflection fresnel parameters of the material.
  106105. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106106. */
  106107. reflectionFresnelParameters: FresnelParameters;
  106108. private _refractionFresnelParameters;
  106109. /**
  106110. * Define the refraction fresnel parameters of the material.
  106111. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106112. */
  106113. refractionFresnelParameters: FresnelParameters;
  106114. private _emissiveFresnelParameters;
  106115. /**
  106116. * Define the emissive fresnel parameters of the material.
  106117. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106118. */
  106119. emissiveFresnelParameters: FresnelParameters;
  106120. private _useReflectionFresnelFromSpecular;
  106121. /**
  106122. * If true automatically deducts the fresnels values from the material specularity.
  106123. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106124. */
  106125. useReflectionFresnelFromSpecular: boolean;
  106126. private _useGlossinessFromSpecularMapAlpha;
  106127. /**
  106128. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  106129. */
  106130. useGlossinessFromSpecularMapAlpha: boolean;
  106131. private _maxSimultaneousLights;
  106132. /**
  106133. * Defines the maximum number of lights that can be used in the material
  106134. */
  106135. maxSimultaneousLights: number;
  106136. private _invertNormalMapX;
  106137. /**
  106138. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  106139. */
  106140. invertNormalMapX: boolean;
  106141. private _invertNormalMapY;
  106142. /**
  106143. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  106144. */
  106145. invertNormalMapY: boolean;
  106146. private _twoSidedLighting;
  106147. /**
  106148. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106149. */
  106150. twoSidedLighting: boolean;
  106151. /**
  106152. * Default configuration related to image processing available in the standard Material.
  106153. */
  106154. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106155. /**
  106156. * Gets the image processing configuration used either in this material.
  106157. */
  106158. /**
  106159. * Sets the Default image processing configuration used either in the this material.
  106160. *
  106161. * If sets to null, the scene one is in use.
  106162. */
  106163. imageProcessingConfiguration: ImageProcessingConfiguration;
  106164. /**
  106165. * Keep track of the image processing observer to allow dispose and replace.
  106166. */
  106167. private _imageProcessingObserver;
  106168. /**
  106169. * Attaches a new image processing configuration to the Standard Material.
  106170. * @param configuration
  106171. */
  106172. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106173. /**
  106174. * Gets wether the color curves effect is enabled.
  106175. */
  106176. /**
  106177. * Sets wether the color curves effect is enabled.
  106178. */
  106179. cameraColorCurvesEnabled: boolean;
  106180. /**
  106181. * Gets wether the color grading effect is enabled.
  106182. */
  106183. /**
  106184. * Gets wether the color grading effect is enabled.
  106185. */
  106186. cameraColorGradingEnabled: boolean;
  106187. /**
  106188. * Gets wether tonemapping is enabled or not.
  106189. */
  106190. /**
  106191. * Sets wether tonemapping is enabled or not
  106192. */
  106193. cameraToneMappingEnabled: boolean;
  106194. /**
  106195. * The camera exposure used on this material.
  106196. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106197. * This corresponds to a photographic exposure.
  106198. */
  106199. /**
  106200. * The camera exposure used on this material.
  106201. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106202. * This corresponds to a photographic exposure.
  106203. */
  106204. cameraExposure: number;
  106205. /**
  106206. * Gets The camera contrast used on this material.
  106207. */
  106208. /**
  106209. * Sets The camera contrast used on this material.
  106210. */
  106211. cameraContrast: number;
  106212. /**
  106213. * Gets the Color Grading 2D Lookup Texture.
  106214. */
  106215. /**
  106216. * Sets the Color Grading 2D Lookup Texture.
  106217. */
  106218. cameraColorGradingTexture: Nullable<BaseTexture>;
  106219. /**
  106220. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106221. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106222. * 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;
  106223. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106224. */
  106225. /**
  106226. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106227. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106228. * 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;
  106229. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106230. */
  106231. cameraColorCurves: Nullable<ColorCurves>;
  106232. /**
  106233. * Custom callback helping to override the default shader used in the material.
  106234. */
  106235. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  106236. protected _renderTargets: SmartArray<RenderTargetTexture>;
  106237. protected _worldViewProjectionMatrix: Matrix;
  106238. protected _globalAmbientColor: Color3;
  106239. protected _useLogarithmicDepth: boolean;
  106240. protected _rebuildInParallel: boolean;
  106241. /**
  106242. * Instantiates a new standard material.
  106243. * This is the default material used in Babylon. It is the best trade off between quality
  106244. * and performances.
  106245. * @see http://doc.babylonjs.com/babylon101/materials
  106246. * @param name Define the name of the material in the scene
  106247. * @param scene Define the scene the material belong to
  106248. */
  106249. constructor(name: string, scene: Scene);
  106250. /**
  106251. * Gets a boolean indicating that current material needs to register RTT
  106252. */
  106253. readonly hasRenderTargetTextures: boolean;
  106254. /**
  106255. * Gets the current class name of the material e.g. "StandardMaterial"
  106256. * Mainly use in serialization.
  106257. * @returns the class name
  106258. */
  106259. getClassName(): string;
  106260. /**
  106261. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  106262. * You can try switching to logarithmic depth.
  106263. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  106264. */
  106265. useLogarithmicDepth: boolean;
  106266. /**
  106267. * Specifies if the material will require alpha blending
  106268. * @returns a boolean specifying if alpha blending is needed
  106269. */
  106270. needAlphaBlending(): boolean;
  106271. /**
  106272. * Specifies if this material should be rendered in alpha test mode
  106273. * @returns a boolean specifying if an alpha test is needed.
  106274. */
  106275. needAlphaTesting(): boolean;
  106276. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  106277. /**
  106278. * Get the texture used for alpha test purpose.
  106279. * @returns the diffuse texture in case of the standard material.
  106280. */
  106281. getAlphaTestTexture(): Nullable<BaseTexture>;
  106282. /**
  106283. * Get if the submesh is ready to be used and all its information available.
  106284. * Child classes can use it to update shaders
  106285. * @param mesh defines the mesh to check
  106286. * @param subMesh defines which submesh to check
  106287. * @param useInstances specifies that instances should be used
  106288. * @returns a boolean indicating that the submesh is ready or not
  106289. */
  106290. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106291. /**
  106292. * Builds the material UBO layouts.
  106293. * Used internally during the effect preparation.
  106294. */
  106295. buildUniformLayout(): void;
  106296. /**
  106297. * Unbinds the material from the mesh
  106298. */
  106299. unbind(): void;
  106300. /**
  106301. * Binds the submesh to this material by preparing the effect and shader to draw
  106302. * @param world defines the world transformation matrix
  106303. * @param mesh defines the mesh containing the submesh
  106304. * @param subMesh defines the submesh to bind the material to
  106305. */
  106306. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106307. /**
  106308. * Get the list of animatables in the material.
  106309. * @returns the list of animatables object used in the material
  106310. */
  106311. getAnimatables(): IAnimatable[];
  106312. /**
  106313. * Gets the active textures from the material
  106314. * @returns an array of textures
  106315. */
  106316. getActiveTextures(): BaseTexture[];
  106317. /**
  106318. * Specifies if the material uses a texture
  106319. * @param texture defines the texture to check against the material
  106320. * @returns a boolean specifying if the material uses the texture
  106321. */
  106322. hasTexture(texture: BaseTexture): boolean;
  106323. /**
  106324. * Disposes the material
  106325. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  106326. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  106327. */
  106328. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106329. /**
  106330. * Makes a duplicate of the material, and gives it a new name
  106331. * @param name defines the new name for the duplicated material
  106332. * @returns the cloned material
  106333. */
  106334. clone(name: string): StandardMaterial;
  106335. /**
  106336. * Serializes this material in a JSON representation
  106337. * @returns the serialized material object
  106338. */
  106339. serialize(): any;
  106340. /**
  106341. * Creates a standard material from parsed material data
  106342. * @param source defines the JSON representation of the material
  106343. * @param scene defines the hosting scene
  106344. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  106345. * @returns a new standard material
  106346. */
  106347. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  106348. /**
  106349. * Are diffuse textures enabled in the application.
  106350. */
  106351. static DiffuseTextureEnabled: boolean;
  106352. /**
  106353. * Are ambient textures enabled in the application.
  106354. */
  106355. static AmbientTextureEnabled: boolean;
  106356. /**
  106357. * Are opacity textures enabled in the application.
  106358. */
  106359. static OpacityTextureEnabled: boolean;
  106360. /**
  106361. * Are reflection textures enabled in the application.
  106362. */
  106363. static ReflectionTextureEnabled: boolean;
  106364. /**
  106365. * Are emissive textures enabled in the application.
  106366. */
  106367. static EmissiveTextureEnabled: boolean;
  106368. /**
  106369. * Are specular textures enabled in the application.
  106370. */
  106371. static SpecularTextureEnabled: boolean;
  106372. /**
  106373. * Are bump textures enabled in the application.
  106374. */
  106375. static BumpTextureEnabled: boolean;
  106376. /**
  106377. * Are lightmap textures enabled in the application.
  106378. */
  106379. static LightmapTextureEnabled: boolean;
  106380. /**
  106381. * Are refraction textures enabled in the application.
  106382. */
  106383. static RefractionTextureEnabled: boolean;
  106384. /**
  106385. * Are color grading textures enabled in the application.
  106386. */
  106387. static ColorGradingTextureEnabled: boolean;
  106388. /**
  106389. * Are fresnels enabled in the application.
  106390. */
  106391. static FresnelEnabled: boolean;
  106392. }
  106393. }
  106394. declare module BABYLON {
  106395. /** @hidden */
  106396. export var imageProcessingPixelShader: {
  106397. name: string;
  106398. shader: string;
  106399. };
  106400. }
  106401. declare module BABYLON {
  106402. /**
  106403. * ImageProcessingPostProcess
  106404. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  106405. */
  106406. export class ImageProcessingPostProcess extends PostProcess {
  106407. /**
  106408. * Default configuration related to image processing available in the PBR Material.
  106409. */
  106410. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106411. /**
  106412. * Gets the image processing configuration used either in this material.
  106413. */
  106414. /**
  106415. * Sets the Default image processing configuration used either in the this material.
  106416. *
  106417. * If sets to null, the scene one is in use.
  106418. */
  106419. imageProcessingConfiguration: ImageProcessingConfiguration;
  106420. /**
  106421. * Keep track of the image processing observer to allow dispose and replace.
  106422. */
  106423. private _imageProcessingObserver;
  106424. /**
  106425. * Attaches a new image processing configuration to the PBR Material.
  106426. * @param configuration
  106427. */
  106428. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  106429. /**
  106430. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106431. */
  106432. /**
  106433. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106434. */
  106435. colorCurves: Nullable<ColorCurves>;
  106436. /**
  106437. * Gets wether the color curves effect is enabled.
  106438. */
  106439. /**
  106440. * Sets wether the color curves effect is enabled.
  106441. */
  106442. colorCurvesEnabled: boolean;
  106443. /**
  106444. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106445. */
  106446. /**
  106447. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106448. */
  106449. colorGradingTexture: Nullable<BaseTexture>;
  106450. /**
  106451. * Gets wether the color grading effect is enabled.
  106452. */
  106453. /**
  106454. * Gets wether the color grading effect is enabled.
  106455. */
  106456. colorGradingEnabled: boolean;
  106457. /**
  106458. * Gets exposure used in the effect.
  106459. */
  106460. /**
  106461. * Sets exposure used in the effect.
  106462. */
  106463. exposure: number;
  106464. /**
  106465. * Gets wether tonemapping is enabled or not.
  106466. */
  106467. /**
  106468. * Sets wether tonemapping is enabled or not
  106469. */
  106470. toneMappingEnabled: boolean;
  106471. /**
  106472. * Gets the type of tone mapping effect.
  106473. */
  106474. /**
  106475. * Sets the type of tone mapping effect.
  106476. */
  106477. toneMappingType: number;
  106478. /**
  106479. * Gets contrast used in the effect.
  106480. */
  106481. /**
  106482. * Sets contrast used in the effect.
  106483. */
  106484. contrast: number;
  106485. /**
  106486. * Gets Vignette stretch size.
  106487. */
  106488. /**
  106489. * Sets Vignette stretch size.
  106490. */
  106491. vignetteStretch: number;
  106492. /**
  106493. * Gets Vignette centre X Offset.
  106494. */
  106495. /**
  106496. * Sets Vignette centre X Offset.
  106497. */
  106498. vignetteCentreX: number;
  106499. /**
  106500. * Gets Vignette centre Y Offset.
  106501. */
  106502. /**
  106503. * Sets Vignette centre Y Offset.
  106504. */
  106505. vignetteCentreY: number;
  106506. /**
  106507. * Gets Vignette weight or intensity of the vignette effect.
  106508. */
  106509. /**
  106510. * Sets Vignette weight or intensity of the vignette effect.
  106511. */
  106512. vignetteWeight: number;
  106513. /**
  106514. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106515. * if vignetteEnabled is set to true.
  106516. */
  106517. /**
  106518. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106519. * if vignetteEnabled is set to true.
  106520. */
  106521. vignetteColor: Color4;
  106522. /**
  106523. * Gets Camera field of view used by the Vignette effect.
  106524. */
  106525. /**
  106526. * Sets Camera field of view used by the Vignette effect.
  106527. */
  106528. vignetteCameraFov: number;
  106529. /**
  106530. * Gets the vignette blend mode allowing different kind of effect.
  106531. */
  106532. /**
  106533. * Sets the vignette blend mode allowing different kind of effect.
  106534. */
  106535. vignetteBlendMode: number;
  106536. /**
  106537. * Gets wether the vignette effect is enabled.
  106538. */
  106539. /**
  106540. * Sets wether the vignette effect is enabled.
  106541. */
  106542. vignetteEnabled: boolean;
  106543. private _fromLinearSpace;
  106544. /**
  106545. * Gets wether the input of the processing is in Gamma or Linear Space.
  106546. */
  106547. /**
  106548. * Sets wether the input of the processing is in Gamma or Linear Space.
  106549. */
  106550. fromLinearSpace: boolean;
  106551. /**
  106552. * Defines cache preventing GC.
  106553. */
  106554. private _defines;
  106555. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  106556. /**
  106557. * "ImageProcessingPostProcess"
  106558. * @returns "ImageProcessingPostProcess"
  106559. */
  106560. getClassName(): string;
  106561. protected _updateParameters(): void;
  106562. dispose(camera?: Camera): void;
  106563. }
  106564. }
  106565. declare module BABYLON {
  106566. /**
  106567. * Class containing static functions to help procedurally build meshes
  106568. */
  106569. export class GroundBuilder {
  106570. /**
  106571. * Creates a ground mesh
  106572. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106573. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106575. * @param name defines the name of the mesh
  106576. * @param options defines the options used to create the mesh
  106577. * @param scene defines the hosting scene
  106578. * @returns the ground mesh
  106579. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106580. */
  106581. static CreateGround(name: string, options: {
  106582. width?: number;
  106583. height?: number;
  106584. subdivisions?: number;
  106585. subdivisionsX?: number;
  106586. subdivisionsY?: number;
  106587. updatable?: boolean;
  106588. }, scene: any): Mesh;
  106589. /**
  106590. * Creates a tiled ground mesh
  106591. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106592. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106593. * * 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
  106594. * * 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
  106595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106596. * @param name defines the name of the mesh
  106597. * @param options defines the options used to create the mesh
  106598. * @param scene defines the hosting scene
  106599. * @returns the tiled ground mesh
  106600. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106601. */
  106602. static CreateTiledGround(name: string, options: {
  106603. xmin: number;
  106604. zmin: number;
  106605. xmax: number;
  106606. zmax: number;
  106607. subdivisions?: {
  106608. w: number;
  106609. h: number;
  106610. };
  106611. precision?: {
  106612. w: number;
  106613. h: number;
  106614. };
  106615. updatable?: boolean;
  106616. }, scene?: Nullable<Scene>): Mesh;
  106617. /**
  106618. * Creates a ground mesh from a height map
  106619. * * The parameter `url` sets the URL of the height map image resource.
  106620. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106621. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106622. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106623. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106624. * * 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.
  106625. * * 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).
  106626. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106628. * @param name defines the name of the mesh
  106629. * @param url defines the url to the height map
  106630. * @param options defines the options used to create the mesh
  106631. * @param scene defines the hosting scene
  106632. * @returns the ground mesh
  106633. * @see https://doc.babylonjs.com/babylon101/height_map
  106634. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106635. */
  106636. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106637. width?: number;
  106638. height?: number;
  106639. subdivisions?: number;
  106640. minHeight?: number;
  106641. maxHeight?: number;
  106642. colorFilter?: Color3;
  106643. alphaFilter?: number;
  106644. updatable?: boolean;
  106645. onReady?: (mesh: GroundMesh) => void;
  106646. }, scene?: Nullable<Scene>): GroundMesh;
  106647. }
  106648. }
  106649. declare module BABYLON {
  106650. /**
  106651. * Class containing static functions to help procedurally build meshes
  106652. */
  106653. export class TorusBuilder {
  106654. /**
  106655. * Creates a torus mesh
  106656. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106657. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106658. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106660. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106662. * @param name defines the name of the mesh
  106663. * @param options defines the options used to create the mesh
  106664. * @param scene defines the hosting scene
  106665. * @returns the torus mesh
  106666. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106667. */
  106668. static CreateTorus(name: string, options: {
  106669. diameter?: number;
  106670. thickness?: number;
  106671. tessellation?: number;
  106672. updatable?: boolean;
  106673. sideOrientation?: number;
  106674. frontUVs?: Vector4;
  106675. backUVs?: Vector4;
  106676. }, scene: any): Mesh;
  106677. }
  106678. }
  106679. declare module BABYLON {
  106680. /**
  106681. * Class containing static functions to help procedurally build meshes
  106682. */
  106683. export class CylinderBuilder {
  106684. /**
  106685. * Creates a cylinder or a cone mesh
  106686. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  106687. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  106688. * * 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.
  106689. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106690. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106691. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106692. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106693. * * 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).
  106694. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106695. * * 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).
  106696. * * 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
  106697. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106698. * * 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
  106699. * * 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.
  106700. * * If `enclose` is false, a ring surface is one element.
  106701. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106702. * * 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
  106703. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106704. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106706. * @param name defines the name of the mesh
  106707. * @param options defines the options used to create the mesh
  106708. * @param scene defines the hosting scene
  106709. * @returns the cylinder mesh
  106710. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106711. */
  106712. static CreateCylinder(name: string, options: {
  106713. height?: number;
  106714. diameterTop?: number;
  106715. diameterBottom?: number;
  106716. diameter?: number;
  106717. tessellation?: number;
  106718. subdivisions?: number;
  106719. arc?: number;
  106720. faceColors?: Color4[];
  106721. faceUV?: Vector4[];
  106722. updatable?: boolean;
  106723. hasRings?: boolean;
  106724. enclose?: boolean;
  106725. cap?: number;
  106726. sideOrientation?: number;
  106727. frontUVs?: Vector4;
  106728. backUVs?: Vector4;
  106729. }, scene: any): Mesh;
  106730. }
  106731. }
  106732. declare module BABYLON {
  106733. /**
  106734. * Options to modify the vr teleportation behavior.
  106735. */
  106736. export interface VRTeleportationOptions {
  106737. /**
  106738. * The name of the mesh which should be used as the teleportation floor. (default: null)
  106739. */
  106740. floorMeshName?: string;
  106741. /**
  106742. * A list of meshes to be used as the teleportation floor. (default: empty)
  106743. */
  106744. floorMeshes?: Mesh[];
  106745. }
  106746. /**
  106747. * Options to modify the vr experience helper's behavior.
  106748. */
  106749. export interface VRExperienceHelperOptions extends WebVROptions {
  106750. /**
  106751. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  106752. */
  106753. createDeviceOrientationCamera?: boolean;
  106754. /**
  106755. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  106756. */
  106757. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  106758. /**
  106759. * Uses the main button on the controller to toggle the laser casted. (default: true)
  106760. */
  106761. laserToggle?: boolean;
  106762. /**
  106763. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  106764. */
  106765. floorMeshes?: Mesh[];
  106766. /**
  106767. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  106768. */
  106769. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  106770. }
  106771. /**
  106772. * Event containing information after VR has been entered
  106773. */
  106774. export class OnAfterEnteringVRObservableEvent {
  106775. /**
  106776. * If entering vr was successful
  106777. */
  106778. success: boolean;
  106779. }
  106780. /**
  106781. * Helps to quickly add VR support to an existing scene.
  106782. * See http://doc.babylonjs.com/how_to/webvr_helper
  106783. */
  106784. export class VRExperienceHelper {
  106785. /** Options to modify the vr experience helper's behavior. */
  106786. webVROptions: VRExperienceHelperOptions;
  106787. private _scene;
  106788. private _position;
  106789. private _btnVR;
  106790. private _btnVRDisplayed;
  106791. private _webVRsupported;
  106792. private _webVRready;
  106793. private _webVRrequesting;
  106794. private _webVRpresenting;
  106795. private _hasEnteredVR;
  106796. private _fullscreenVRpresenting;
  106797. private _canvas;
  106798. private _webVRCamera;
  106799. private _vrDeviceOrientationCamera;
  106800. private _deviceOrientationCamera;
  106801. private _existingCamera;
  106802. private _onKeyDown;
  106803. private _onVrDisplayPresentChange;
  106804. private _onVRDisplayChanged;
  106805. private _onVRRequestPresentStart;
  106806. private _onVRRequestPresentComplete;
  106807. /**
  106808. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  106809. */
  106810. enableGazeEvenWhenNoPointerLock: boolean;
  106811. /**
  106812. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  106813. */
  106814. exitVROnDoubleTap: boolean;
  106815. /**
  106816. * Observable raised right before entering VR.
  106817. */
  106818. onEnteringVRObservable: Observable<VRExperienceHelper>;
  106819. /**
  106820. * Observable raised when entering VR has completed.
  106821. */
  106822. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  106823. /**
  106824. * Observable raised when exiting VR.
  106825. */
  106826. onExitingVRObservable: Observable<VRExperienceHelper>;
  106827. /**
  106828. * Observable raised when controller mesh is loaded.
  106829. */
  106830. onControllerMeshLoadedObservable: Observable<WebVRController>;
  106831. /** Return this.onEnteringVRObservable
  106832. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  106833. */
  106834. readonly onEnteringVR: Observable<VRExperienceHelper>;
  106835. /** Return this.onExitingVRObservable
  106836. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  106837. */
  106838. readonly onExitingVR: Observable<VRExperienceHelper>;
  106839. /** Return this.onControllerMeshLoadedObservable
  106840. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  106841. */
  106842. readonly onControllerMeshLoaded: Observable<WebVRController>;
  106843. private _rayLength;
  106844. private _useCustomVRButton;
  106845. private _teleportationRequested;
  106846. private _teleportActive;
  106847. private _floorMeshName;
  106848. private _floorMeshesCollection;
  106849. private _rotationAllowed;
  106850. private _teleportBackwardsVector;
  106851. private _teleportationTarget;
  106852. private _isDefaultTeleportationTarget;
  106853. private _postProcessMove;
  106854. private _teleportationFillColor;
  106855. private _teleportationBorderColor;
  106856. private _rotationAngle;
  106857. private _haloCenter;
  106858. private _cameraGazer;
  106859. private _padSensibilityUp;
  106860. private _padSensibilityDown;
  106861. private _leftController;
  106862. private _rightController;
  106863. /**
  106864. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  106865. */
  106866. onNewMeshSelected: Observable<AbstractMesh>;
  106867. /**
  106868. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  106869. * This observable will provide the mesh and the controller used to select the mesh
  106870. */
  106871. onMeshSelectedWithController: Observable<{
  106872. mesh: AbstractMesh;
  106873. controller: WebVRController;
  106874. }>;
  106875. /**
  106876. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  106877. */
  106878. onNewMeshPicked: Observable<PickingInfo>;
  106879. private _circleEase;
  106880. /**
  106881. * Observable raised before camera teleportation
  106882. */
  106883. onBeforeCameraTeleport: Observable<Vector3>;
  106884. /**
  106885. * Observable raised after camera teleportation
  106886. */
  106887. onAfterCameraTeleport: Observable<Vector3>;
  106888. /**
  106889. * Observable raised when current selected mesh gets unselected
  106890. */
  106891. onSelectedMeshUnselected: Observable<AbstractMesh>;
  106892. private _raySelectionPredicate;
  106893. /**
  106894. * To be optionaly changed by user to define custom ray selection
  106895. */
  106896. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  106897. /**
  106898. * To be optionaly changed by user to define custom selection logic (after ray selection)
  106899. */
  106900. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106901. /**
  106902. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  106903. */
  106904. teleportationEnabled: boolean;
  106905. private _defaultHeight;
  106906. private _teleportationInitialized;
  106907. private _interactionsEnabled;
  106908. private _interactionsRequested;
  106909. private _displayGaze;
  106910. private _displayLaserPointer;
  106911. /**
  106912. * The mesh used to display where the user is going to teleport.
  106913. */
  106914. /**
  106915. * Sets the mesh to be used to display where the user is going to teleport.
  106916. */
  106917. teleportationTarget: Mesh;
  106918. /**
  106919. * 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
  106920. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  106921. * See http://doc.babylonjs.com/resources/baking_transformations
  106922. */
  106923. gazeTrackerMesh: Mesh;
  106924. /**
  106925. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  106926. */
  106927. updateGazeTrackerScale: boolean;
  106928. /**
  106929. * If the gaze trackers color should be updated when selecting meshes
  106930. */
  106931. updateGazeTrackerColor: boolean;
  106932. /**
  106933. * If the controller laser color should be updated when selecting meshes
  106934. */
  106935. updateControllerLaserColor: boolean;
  106936. /**
  106937. * The gaze tracking mesh corresponding to the left controller
  106938. */
  106939. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  106940. /**
  106941. * The gaze tracking mesh corresponding to the right controller
  106942. */
  106943. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  106944. /**
  106945. * If the ray of the gaze should be displayed.
  106946. */
  106947. /**
  106948. * Sets if the ray of the gaze should be displayed.
  106949. */
  106950. displayGaze: boolean;
  106951. /**
  106952. * If the ray of the LaserPointer should be displayed.
  106953. */
  106954. /**
  106955. * Sets if the ray of the LaserPointer should be displayed.
  106956. */
  106957. displayLaserPointer: boolean;
  106958. /**
  106959. * The deviceOrientationCamera used as the camera when not in VR.
  106960. */
  106961. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  106962. /**
  106963. * Based on the current WebVR support, returns the current VR camera used.
  106964. */
  106965. readonly currentVRCamera: Nullable<Camera>;
  106966. /**
  106967. * The webVRCamera which is used when in VR.
  106968. */
  106969. readonly webVRCamera: WebVRFreeCamera;
  106970. /**
  106971. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  106972. */
  106973. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  106974. /**
  106975. * The html button that is used to trigger entering into VR.
  106976. */
  106977. readonly vrButton: Nullable<HTMLButtonElement>;
  106978. private readonly _teleportationRequestInitiated;
  106979. /**
  106980. * Defines wether or not Pointer lock should be requested when switching to
  106981. * full screen.
  106982. */
  106983. requestPointerLockOnFullScreen: boolean;
  106984. /**
  106985. * Instantiates a VRExperienceHelper.
  106986. * Helps to quickly add VR support to an existing scene.
  106987. * @param scene The scene the VRExperienceHelper belongs to.
  106988. * @param webVROptions Options to modify the vr experience helper's behavior.
  106989. */
  106990. constructor(scene: Scene,
  106991. /** Options to modify the vr experience helper's behavior. */
  106992. webVROptions?: VRExperienceHelperOptions);
  106993. private _onDefaultMeshLoaded;
  106994. private _onResize;
  106995. private _onFullscreenChange;
  106996. /**
  106997. * Gets a value indicating if we are currently in VR mode.
  106998. */
  106999. readonly isInVRMode: boolean;
  107000. private onVrDisplayPresentChange;
  107001. private onVRDisplayChanged;
  107002. private moveButtonToBottomRight;
  107003. private displayVRButton;
  107004. private updateButtonVisibility;
  107005. private _cachedAngularSensibility;
  107006. /**
  107007. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  107008. * Otherwise, will use the fullscreen API.
  107009. */
  107010. enterVR(): void;
  107011. /**
  107012. * Attempt to exit VR, or fullscreen.
  107013. */
  107014. exitVR(): void;
  107015. /**
  107016. * The position of the vr experience helper.
  107017. */
  107018. /**
  107019. * Sets the position of the vr experience helper.
  107020. */
  107021. position: Vector3;
  107022. /**
  107023. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  107024. */
  107025. enableInteractions(): void;
  107026. private readonly _noControllerIsActive;
  107027. private beforeRender;
  107028. private _isTeleportationFloor;
  107029. /**
  107030. * Adds a floor mesh to be used for teleportation.
  107031. * @param floorMesh the mesh to be used for teleportation.
  107032. */
  107033. addFloorMesh(floorMesh: Mesh): void;
  107034. /**
  107035. * Removes a floor mesh from being used for teleportation.
  107036. * @param floorMesh the mesh to be removed.
  107037. */
  107038. removeFloorMesh(floorMesh: Mesh): void;
  107039. /**
  107040. * Enables interactions and teleportation using the VR controllers and gaze.
  107041. * @param vrTeleportationOptions options to modify teleportation behavior.
  107042. */
  107043. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  107044. private _onNewGamepadConnected;
  107045. private _tryEnableInteractionOnController;
  107046. private _onNewGamepadDisconnected;
  107047. private _enableInteractionOnController;
  107048. private _checkTeleportWithRay;
  107049. private _checkRotate;
  107050. private _checkTeleportBackwards;
  107051. private _enableTeleportationOnController;
  107052. private _createTeleportationCircles;
  107053. private _displayTeleportationTarget;
  107054. private _hideTeleportationTarget;
  107055. private _rotateCamera;
  107056. private _moveTeleportationSelectorTo;
  107057. private _workingVector;
  107058. private _workingQuaternion;
  107059. private _workingMatrix;
  107060. /**
  107061. * Teleports the users feet to the desired location
  107062. * @param location The location where the user's feet should be placed
  107063. */
  107064. teleportCamera(location: Vector3): void;
  107065. private _convertNormalToDirectionOfRay;
  107066. private _castRayAndSelectObject;
  107067. private _notifySelectedMeshUnselected;
  107068. /**
  107069. * Sets the color of the laser ray from the vr controllers.
  107070. * @param color new color for the ray.
  107071. */
  107072. changeLaserColor(color: Color3): void;
  107073. /**
  107074. * Sets the color of the ray from the vr headsets gaze.
  107075. * @param color new color for the ray.
  107076. */
  107077. changeGazeColor(color: Color3): void;
  107078. /**
  107079. * Exits VR and disposes of the vr experience helper
  107080. */
  107081. dispose(): void;
  107082. /**
  107083. * Gets the name of the VRExperienceHelper class
  107084. * @returns "VRExperienceHelper"
  107085. */
  107086. getClassName(): string;
  107087. }
  107088. }
  107089. declare module BABYLON {
  107090. /**
  107091. * Manages an XRSession to work with Babylon's engine
  107092. * @see https://doc.babylonjs.com/how_to/webxr
  107093. */
  107094. export class WebXRSessionManager implements IDisposable {
  107095. private scene;
  107096. /**
  107097. * Fires every time a new xrFrame arrives which can be used to update the camera
  107098. */
  107099. onXRFrameObservable: Observable<any>;
  107100. /**
  107101. * Fires when the xr session is ended either by the device or manually done
  107102. */
  107103. onXRSessionEnded: Observable<any>;
  107104. /**
  107105. * Underlying xr session
  107106. */
  107107. session: XRSession;
  107108. /**
  107109. * Type of reference space used when creating the session
  107110. */
  107111. referenceSpace: XRReferenceSpace;
  107112. /** @hidden */
  107113. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  107114. /**
  107115. * Current XR frame
  107116. */
  107117. currentFrame: Nullable<XRFrame>;
  107118. private _xrNavigator;
  107119. private baseLayer;
  107120. /**
  107121. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  107122. * @param scene The scene which the session should be created for
  107123. */
  107124. constructor(scene: Scene);
  107125. /**
  107126. * Initializes the manager
  107127. * After initialization enterXR can be called to start an XR session
  107128. * @returns Promise which resolves after it is initialized
  107129. */
  107130. initializeAsync(): Promise<void>;
  107131. /**
  107132. * Initializes an xr session
  107133. * @param xrSessionMode mode to initialize
  107134. * @returns a promise which will resolve once the session has been initialized
  107135. */
  107136. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  107137. /**
  107138. * Sets the reference space on the xr session
  107139. * @param referenceSpace space to set
  107140. * @returns a promise that will resolve once the reference space has been set
  107141. */
  107142. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  107143. /**
  107144. * Updates the render state of the session
  107145. * @param state state to set
  107146. * @returns a promise that resolves once the render state has been updated
  107147. */
  107148. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  107149. /**
  107150. * Starts rendering to the xr layer
  107151. * @returns a promise that will resolve once rendering has started
  107152. */
  107153. startRenderingToXRAsync(): Promise<void>;
  107154. /**
  107155. * Stops the xrSession and restores the renderloop
  107156. * @returns Promise which resolves after it exits XR
  107157. */
  107158. exitXRAsync(): Promise<unknown>;
  107159. /**
  107160. * Checks if a session would be supported for the creation options specified
  107161. * @param sessionMode session mode to check if supported eg. immersive-vr
  107162. * @returns true if supported
  107163. */
  107164. supportsSessionAsync(sessionMode: XRSessionMode): any;
  107165. /**
  107166. * @hidden
  107167. * Converts the render layer of xrSession to a render target
  107168. * @param session session to create render target for
  107169. * @param scene scene the new render target should be created for
  107170. */
  107171. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  107172. /**
  107173. * Disposes of the session manager
  107174. */
  107175. dispose(): void;
  107176. }
  107177. }
  107178. declare module BABYLON {
  107179. /**
  107180. * WebXR Camera which holds the views for the xrSession
  107181. * @see https://doc.babylonjs.com/how_to/webxr
  107182. */
  107183. export class WebXRCamera extends FreeCamera {
  107184. private static _TmpMatrix;
  107185. /**
  107186. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  107187. * @param name the name of the camera
  107188. * @param scene the scene to add the camera to
  107189. */
  107190. constructor(name: string, scene: Scene);
  107191. private _updateNumberOfRigCameras;
  107192. /** @hidden */
  107193. _updateForDualEyeDebugging(pupilDistance?: number): void;
  107194. /**
  107195. * Updates the cameras position from the current pose information of the XR session
  107196. * @param xrSessionManager the session containing pose information
  107197. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  107198. */
  107199. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  107200. }
  107201. }
  107202. declare module BABYLON {
  107203. /**
  107204. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  107205. */
  107206. export class WebXRManagedOutputCanvas implements IDisposable {
  107207. private helper;
  107208. private _canvas;
  107209. /**
  107210. * xrpresent context of the canvas which can be used to display/mirror xr content
  107211. */
  107212. canvasContext: WebGLRenderingContext;
  107213. /**
  107214. * xr layer for the canvas
  107215. */
  107216. xrLayer: Nullable<XRWebGLLayer>;
  107217. /**
  107218. * Initializes the xr layer for the session
  107219. * @param xrSession xr session
  107220. * @returns a promise that will resolve once the XR Layer has been created
  107221. */
  107222. initializeXRLayerAsync(xrSession: any): any;
  107223. /**
  107224. * Initializes the canvas to be added/removed upon entering/exiting xr
  107225. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  107226. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  107227. */
  107228. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  107229. /**
  107230. * Disposes of the object
  107231. */
  107232. dispose(): void;
  107233. private _setManagedOutputCanvas;
  107234. private _addCanvas;
  107235. private _removeCanvas;
  107236. }
  107237. }
  107238. declare module BABYLON {
  107239. /**
  107240. * States of the webXR experience
  107241. */
  107242. export enum WebXRState {
  107243. /**
  107244. * Transitioning to being in XR mode
  107245. */
  107246. ENTERING_XR = 0,
  107247. /**
  107248. * Transitioning to non XR mode
  107249. */
  107250. EXITING_XR = 1,
  107251. /**
  107252. * In XR mode and presenting
  107253. */
  107254. IN_XR = 2,
  107255. /**
  107256. * Not entered XR mode
  107257. */
  107258. NOT_IN_XR = 3
  107259. }
  107260. /**
  107261. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  107262. * @see https://doc.babylonjs.com/how_to/webxr
  107263. */
  107264. export class WebXRExperienceHelper implements IDisposable {
  107265. private scene;
  107266. /**
  107267. * 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
  107268. */
  107269. container: AbstractMesh;
  107270. /**
  107271. * Camera used to render xr content
  107272. */
  107273. camera: WebXRCamera;
  107274. /**
  107275. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  107276. */
  107277. state: WebXRState;
  107278. private _setState;
  107279. private static _TmpVector;
  107280. /**
  107281. * Fires when the state of the experience helper has changed
  107282. */
  107283. onStateChangedObservable: Observable<WebXRState>;
  107284. /** Session manager used to keep track of xr session */
  107285. sessionManager: WebXRSessionManager;
  107286. private _nonVRCamera;
  107287. private _originalSceneAutoClear;
  107288. private _supported;
  107289. /**
  107290. * Creates the experience helper
  107291. * @param scene the scene to attach the experience helper to
  107292. * @returns a promise for the experience helper
  107293. */
  107294. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  107295. /**
  107296. * Creates a WebXRExperienceHelper
  107297. * @param scene The scene the helper should be created in
  107298. */
  107299. private constructor();
  107300. /**
  107301. * Exits XR mode and returns the scene to its original state
  107302. * @returns promise that resolves after xr mode has exited
  107303. */
  107304. exitXRAsync(): Promise<unknown>;
  107305. /**
  107306. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  107307. * @param sessionCreationOptions options for the XR session
  107308. * @param referenceSpaceType frame of reference of the XR session
  107309. * @param outputCanvas the output canvas that will be used to enter XR mode
  107310. * @returns promise that resolves after xr mode has entered
  107311. */
  107312. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  107313. /**
  107314. * Updates the global position of the camera by moving the camera's container
  107315. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  107316. * @param position The desired global position of the camera
  107317. */
  107318. setPositionOfCameraUsingContainer(position: Vector3): void;
  107319. /**
  107320. * Rotates the xr camera by rotating the camera's container around the camera's position
  107321. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  107322. * @param rotation the desired quaternion rotation to apply to the camera
  107323. */
  107324. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  107325. /**
  107326. * Disposes of the experience helper
  107327. */
  107328. dispose(): void;
  107329. }
  107330. }
  107331. declare module BABYLON {
  107332. /**
  107333. * Button which can be used to enter a different mode of XR
  107334. */
  107335. export class WebXREnterExitUIButton {
  107336. /** button element */
  107337. element: HTMLElement;
  107338. /** XR initialization options for the button */
  107339. sessionMode: XRSessionMode;
  107340. /** Reference space type */
  107341. referenceSpaceType: XRReferenceSpaceType;
  107342. /**
  107343. * Creates a WebXREnterExitUIButton
  107344. * @param element button element
  107345. * @param sessionMode XR initialization session mode
  107346. * @param referenceSpaceType the type of reference space to be used
  107347. */
  107348. constructor(
  107349. /** button element */
  107350. element: HTMLElement,
  107351. /** XR initialization options for the button */
  107352. sessionMode: XRSessionMode,
  107353. /** Reference space type */
  107354. referenceSpaceType: XRReferenceSpaceType);
  107355. /**
  107356. * Overwritable function which can be used to update the button's visuals when the state changes
  107357. * @param activeButton the current active button in the UI
  107358. */
  107359. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  107360. }
  107361. /**
  107362. * Options to create the webXR UI
  107363. */
  107364. export class WebXREnterExitUIOptions {
  107365. /**
  107366. * Context to enter xr with
  107367. */
  107368. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  107369. /**
  107370. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  107371. */
  107372. customButtons?: Array<WebXREnterExitUIButton>;
  107373. }
  107374. /**
  107375. * UI to allow the user to enter/exit XR mode
  107376. */
  107377. export class WebXREnterExitUI implements IDisposable {
  107378. private scene;
  107379. private _overlay;
  107380. private _buttons;
  107381. private _activeButton;
  107382. /**
  107383. * Fired every time the active button is changed.
  107384. *
  107385. * When xr is entered via a button that launches xr that button will be the callback parameter
  107386. *
  107387. * When exiting xr the callback parameter will be null)
  107388. */
  107389. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  107390. /**
  107391. * Creates UI to allow the user to enter/exit XR mode
  107392. * @param scene the scene to add the ui to
  107393. * @param helper the xr experience helper to enter/exit xr with
  107394. * @param options options to configure the UI
  107395. * @returns the created ui
  107396. */
  107397. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  107398. private constructor();
  107399. private _updateButtons;
  107400. /**
  107401. * Disposes of the object
  107402. */
  107403. dispose(): void;
  107404. }
  107405. }
  107406. declare module BABYLON {
  107407. /**
  107408. * Represents an XR input
  107409. */
  107410. export class WebXRController {
  107411. private scene;
  107412. /** The underlying input source for the controller */
  107413. inputSource: XRInputSource;
  107414. private parentContainer;
  107415. /**
  107416. * 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
  107417. */
  107418. grip?: AbstractMesh;
  107419. /**
  107420. * Pointer which can be used to select objects or attach a visible laser to
  107421. */
  107422. pointer: AbstractMesh;
  107423. /**
  107424. * Event that fires when the controller is removed/disposed
  107425. */
  107426. onDisposeObservable: Observable<{}>;
  107427. private _tmpMatrix;
  107428. private _tmpQuaternion;
  107429. private _tmpVector;
  107430. /**
  107431. * Creates the controller
  107432. * @see https://doc.babylonjs.com/how_to/webxr
  107433. * @param scene the scene which the controller should be associated to
  107434. * @param inputSource the underlying input source for the controller
  107435. * @param parentContainer parent that the controller meshes should be children of
  107436. */
  107437. constructor(scene: Scene,
  107438. /** The underlying input source for the controller */
  107439. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  107440. /**
  107441. * Updates the controller pose based on the given XRFrame
  107442. * @param xrFrame xr frame to update the pose with
  107443. * @param referenceSpace reference space to use
  107444. */
  107445. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  107446. /**
  107447. * Gets a world space ray coming from the controller
  107448. * @param result the resulting ray
  107449. */
  107450. getWorldPointerRayToRef(result: Ray): void;
  107451. /**
  107452. * Disposes of the object
  107453. */
  107454. dispose(): void;
  107455. }
  107456. }
  107457. declare module BABYLON {
  107458. /**
  107459. * XR input used to track XR inputs such as controllers/rays
  107460. */
  107461. export class WebXRInput implements IDisposable {
  107462. /**
  107463. * Base experience the input listens to
  107464. */
  107465. baseExperience: WebXRExperienceHelper;
  107466. /**
  107467. * XR controllers being tracked
  107468. */
  107469. controllers: Array<WebXRController>;
  107470. private _frameObserver;
  107471. private _stateObserver;
  107472. /**
  107473. * Event when a controller has been connected/added
  107474. */
  107475. onControllerAddedObservable: Observable<WebXRController>;
  107476. /**
  107477. * Event when a controller has been removed/disconnected
  107478. */
  107479. onControllerRemovedObservable: Observable<WebXRController>;
  107480. /**
  107481. * Initializes the WebXRInput
  107482. * @param baseExperience experience helper which the input should be created for
  107483. */
  107484. constructor(
  107485. /**
  107486. * Base experience the input listens to
  107487. */
  107488. baseExperience: WebXRExperienceHelper);
  107489. private _onInputSourcesChange;
  107490. private _addAndRemoveControllers;
  107491. /**
  107492. * Disposes of the object
  107493. */
  107494. dispose(): void;
  107495. }
  107496. }
  107497. declare module BABYLON {
  107498. /**
  107499. * Enables teleportation
  107500. */
  107501. export class WebXRControllerTeleportation {
  107502. private _teleportationFillColor;
  107503. private _teleportationBorderColor;
  107504. private _tmpRay;
  107505. private _tmpVector;
  107506. /**
  107507. * Creates a WebXRControllerTeleportation
  107508. * @param input input manager to add teleportation to
  107509. * @param floorMeshes floormeshes which can be teleported to
  107510. */
  107511. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  107512. }
  107513. }
  107514. declare module BABYLON {
  107515. /**
  107516. * Handles pointer input automatically for the pointer of XR controllers
  107517. */
  107518. export class WebXRControllerPointerSelection {
  107519. private static _idCounter;
  107520. private _tmpRay;
  107521. /**
  107522. * Creates a WebXRControllerPointerSelection
  107523. * @param input input manager to setup pointer selection
  107524. */
  107525. constructor(input: WebXRInput);
  107526. private _convertNormalToDirectionOfRay;
  107527. private _updatePointerDistance;
  107528. }
  107529. }
  107530. declare module BABYLON {
  107531. /**
  107532. * Class used to represent data loading progression
  107533. */
  107534. export class SceneLoaderProgressEvent {
  107535. /** defines if data length to load can be evaluated */
  107536. readonly lengthComputable: boolean;
  107537. /** defines the loaded data length */
  107538. readonly loaded: number;
  107539. /** defines the data length to load */
  107540. readonly total: number;
  107541. /**
  107542. * Create a new progress event
  107543. * @param lengthComputable defines if data length to load can be evaluated
  107544. * @param loaded defines the loaded data length
  107545. * @param total defines the data length to load
  107546. */
  107547. constructor(
  107548. /** defines if data length to load can be evaluated */
  107549. lengthComputable: boolean,
  107550. /** defines the loaded data length */
  107551. loaded: number,
  107552. /** defines the data length to load */
  107553. total: number);
  107554. /**
  107555. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  107556. * @param event defines the source event
  107557. * @returns a new SceneLoaderProgressEvent
  107558. */
  107559. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  107560. }
  107561. /**
  107562. * Interface used by SceneLoader plugins to define supported file extensions
  107563. */
  107564. export interface ISceneLoaderPluginExtensions {
  107565. /**
  107566. * Defines the list of supported extensions
  107567. */
  107568. [extension: string]: {
  107569. isBinary: boolean;
  107570. };
  107571. }
  107572. /**
  107573. * Interface used by SceneLoader plugin factory
  107574. */
  107575. export interface ISceneLoaderPluginFactory {
  107576. /**
  107577. * Defines the name of the factory
  107578. */
  107579. name: string;
  107580. /**
  107581. * Function called to create a new plugin
  107582. * @return the new plugin
  107583. */
  107584. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  107585. /**
  107586. * Boolean indicating if the plugin can direct load specific data
  107587. */
  107588. canDirectLoad?: (data: string) => boolean;
  107589. }
  107590. /**
  107591. * Interface used to define a SceneLoader plugin
  107592. */
  107593. export interface ISceneLoaderPlugin {
  107594. /**
  107595. * The friendly name of this plugin.
  107596. */
  107597. name: string;
  107598. /**
  107599. * The file extensions supported by this plugin.
  107600. */
  107601. extensions: string | ISceneLoaderPluginExtensions;
  107602. /**
  107603. * Import meshes into a scene.
  107604. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107605. * @param scene The scene to import into
  107606. * @param data The data to import
  107607. * @param rootUrl The root url for scene and resources
  107608. * @param meshes The meshes array to import into
  107609. * @param particleSystems The particle systems array to import into
  107610. * @param skeletons The skeletons array to import into
  107611. * @param onError The callback when import fails
  107612. * @returns True if successful or false otherwise
  107613. */
  107614. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  107615. /**
  107616. * Load into a scene.
  107617. * @param scene The scene to load into
  107618. * @param data The data to import
  107619. * @param rootUrl The root url for scene and resources
  107620. * @param onError The callback when import fails
  107621. * @returns true if successful or false otherwise
  107622. */
  107623. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  107624. /**
  107625. * The callback that returns true if the data can be directly loaded.
  107626. */
  107627. canDirectLoad?: (data: string) => boolean;
  107628. /**
  107629. * The callback that allows custom handling of the root url based on the response url.
  107630. */
  107631. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107632. /**
  107633. * Load into an asset container.
  107634. * @param scene The scene to load into
  107635. * @param data The data to import
  107636. * @param rootUrl The root url for scene and resources
  107637. * @param onError The callback when import fails
  107638. * @returns The loaded asset container
  107639. */
  107640. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  107641. }
  107642. /**
  107643. * Interface used to define an async SceneLoader plugin
  107644. */
  107645. export interface ISceneLoaderPluginAsync {
  107646. /**
  107647. * The friendly name of this plugin.
  107648. */
  107649. name: string;
  107650. /**
  107651. * The file extensions supported by this plugin.
  107652. */
  107653. extensions: string | ISceneLoaderPluginExtensions;
  107654. /**
  107655. * Import meshes into a scene.
  107656. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107657. * @param scene The scene to import into
  107658. * @param data The data to import
  107659. * @param rootUrl The root url for scene and resources
  107660. * @param onProgress The callback when the load progresses
  107661. * @param fileName Defines the name of the file to load
  107662. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  107663. */
  107664. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  107665. meshes: AbstractMesh[];
  107666. particleSystems: IParticleSystem[];
  107667. skeletons: Skeleton[];
  107668. animationGroups: AnimationGroup[];
  107669. }>;
  107670. /**
  107671. * Load into a scene.
  107672. * @param scene The scene to load into
  107673. * @param data The data to import
  107674. * @param rootUrl The root url for scene and resources
  107675. * @param onProgress The callback when the load progresses
  107676. * @param fileName Defines the name of the file to load
  107677. * @returns Nothing
  107678. */
  107679. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  107680. /**
  107681. * The callback that returns true if the data can be directly loaded.
  107682. */
  107683. canDirectLoad?: (data: string) => boolean;
  107684. /**
  107685. * The callback that allows custom handling of the root url based on the response url.
  107686. */
  107687. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107688. /**
  107689. * Load into an asset container.
  107690. * @param scene The scene to load into
  107691. * @param data The data to import
  107692. * @param rootUrl The root url for scene and resources
  107693. * @param onProgress The callback when the load progresses
  107694. * @param fileName Defines the name of the file to load
  107695. * @returns The loaded asset container
  107696. */
  107697. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  107698. }
  107699. /**
  107700. * Class used to load scene from various file formats using registered plugins
  107701. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  107702. */
  107703. export class SceneLoader {
  107704. /**
  107705. * No logging while loading
  107706. */
  107707. static readonly NO_LOGGING: number;
  107708. /**
  107709. * Minimal logging while loading
  107710. */
  107711. static readonly MINIMAL_LOGGING: number;
  107712. /**
  107713. * Summary logging while loading
  107714. */
  107715. static readonly SUMMARY_LOGGING: number;
  107716. /**
  107717. * Detailled logging while loading
  107718. */
  107719. static readonly DETAILED_LOGGING: number;
  107720. /**
  107721. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  107722. */
  107723. static ForceFullSceneLoadingForIncremental: boolean;
  107724. /**
  107725. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  107726. */
  107727. static ShowLoadingScreen: boolean;
  107728. /**
  107729. * Defines the current logging level (while loading the scene)
  107730. * @ignorenaming
  107731. */
  107732. static loggingLevel: number;
  107733. /**
  107734. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  107735. */
  107736. static CleanBoneMatrixWeights: boolean;
  107737. /**
  107738. * Event raised when a plugin is used to load a scene
  107739. */
  107740. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  107741. private static _registeredPlugins;
  107742. private static _getDefaultPlugin;
  107743. private static _getPluginForExtension;
  107744. private static _getPluginForDirectLoad;
  107745. private static _getPluginForFilename;
  107746. private static _getDirectLoad;
  107747. private static _loadData;
  107748. private static _getFileInfo;
  107749. /**
  107750. * Gets a plugin that can load the given extension
  107751. * @param extension defines the extension to load
  107752. * @returns a plugin or null if none works
  107753. */
  107754. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  107755. /**
  107756. * Gets a boolean indicating that the given extension can be loaded
  107757. * @param extension defines the extension to load
  107758. * @returns true if the extension is supported
  107759. */
  107760. static IsPluginForExtensionAvailable(extension: string): boolean;
  107761. /**
  107762. * Adds a new plugin to the list of registered plugins
  107763. * @param plugin defines the plugin to add
  107764. */
  107765. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  107766. /**
  107767. * Import meshes into a scene
  107768. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107769. * @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)
  107770. * @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)
  107771. * @param scene the instance of BABYLON.Scene to append to
  107772. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  107773. * @param onProgress a callback with a progress event for each file being loaded
  107774. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107775. * @param pluginExtension the extension used to determine the plugin
  107776. * @returns The loaded plugin
  107777. */
  107778. 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>;
  107779. /**
  107780. * Import meshes into a scene
  107781. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107782. * @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)
  107783. * @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)
  107784. * @param scene the instance of BABYLON.Scene to append to
  107785. * @param onProgress a callback with a progress event for each file being loaded
  107786. * @param pluginExtension the extension used to determine the plugin
  107787. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  107788. */
  107789. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  107790. meshes: AbstractMesh[];
  107791. particleSystems: IParticleSystem[];
  107792. skeletons: Skeleton[];
  107793. animationGroups: AnimationGroup[];
  107794. }>;
  107795. /**
  107796. * Load a scene
  107797. * @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)
  107798. * @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)
  107799. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107800. * @param onSuccess a callback with the scene when import succeeds
  107801. * @param onProgress a callback with a progress event for each file being loaded
  107802. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107803. * @param pluginExtension the extension used to determine the plugin
  107804. * @returns The loaded plugin
  107805. */
  107806. 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>;
  107807. /**
  107808. * Load a scene
  107809. * @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)
  107810. * @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)
  107811. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107812. * @param onProgress a callback with a progress event for each file being loaded
  107813. * @param pluginExtension the extension used to determine the plugin
  107814. * @returns The loaded scene
  107815. */
  107816. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107817. /**
  107818. * Append a scene
  107819. * @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)
  107820. * @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)
  107821. * @param scene is the instance of BABYLON.Scene to append to
  107822. * @param onSuccess a callback with the scene when import succeeds
  107823. * @param onProgress a callback with a progress event for each file being loaded
  107824. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107825. * @param pluginExtension the extension used to determine the plugin
  107826. * @returns The loaded plugin
  107827. */
  107828. 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>;
  107829. /**
  107830. * Append a scene
  107831. * @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)
  107832. * @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)
  107833. * @param scene is the instance of BABYLON.Scene to append to
  107834. * @param onProgress a callback with a progress event for each file being loaded
  107835. * @param pluginExtension the extension used to determine the plugin
  107836. * @returns The given scene
  107837. */
  107838. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107839. /**
  107840. * Load a scene into an asset container
  107841. * @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)
  107842. * @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)
  107843. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  107844. * @param onSuccess a callback with the scene when import succeeds
  107845. * @param onProgress a callback with a progress event for each file being loaded
  107846. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107847. * @param pluginExtension the extension used to determine the plugin
  107848. * @returns The loaded plugin
  107849. */
  107850. 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>;
  107851. /**
  107852. * Load a scene into an asset container
  107853. * @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)
  107854. * @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)
  107855. * @param scene is the instance of Scene to append to
  107856. * @param onProgress a callback with a progress event for each file being loaded
  107857. * @param pluginExtension the extension used to determine the plugin
  107858. * @returns The loaded asset container
  107859. */
  107860. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  107861. }
  107862. }
  107863. declare module BABYLON {
  107864. /**
  107865. * Generic Controller
  107866. */
  107867. export class GenericController extends WebVRController {
  107868. /**
  107869. * Base Url for the controller model.
  107870. */
  107871. static readonly MODEL_BASE_URL: string;
  107872. /**
  107873. * File name for the controller model.
  107874. */
  107875. static readonly MODEL_FILENAME: string;
  107876. /**
  107877. * Creates a new GenericController from a gamepad
  107878. * @param vrGamepad the gamepad that the controller should be created from
  107879. */
  107880. constructor(vrGamepad: any);
  107881. /**
  107882. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107883. * @param scene scene in which to add meshes
  107884. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107885. */
  107886. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107887. /**
  107888. * Called once for each button that changed state since the last frame
  107889. * @param buttonIdx Which button index changed
  107890. * @param state New state of the button
  107891. * @param changes Which properties on the state changed since last frame
  107892. */
  107893. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107894. }
  107895. }
  107896. declare module BABYLON {
  107897. /**
  107898. * Defines the WindowsMotionController object that the state of the windows motion controller
  107899. */
  107900. export class WindowsMotionController extends WebVRController {
  107901. /**
  107902. * The base url used to load the left and right controller models
  107903. */
  107904. static MODEL_BASE_URL: string;
  107905. /**
  107906. * The name of the left controller model file
  107907. */
  107908. static MODEL_LEFT_FILENAME: string;
  107909. /**
  107910. * The name of the right controller model file
  107911. */
  107912. static MODEL_RIGHT_FILENAME: string;
  107913. /**
  107914. * The controller name prefix for this controller type
  107915. */
  107916. static readonly GAMEPAD_ID_PREFIX: string;
  107917. /**
  107918. * The controller id pattern for this controller type
  107919. */
  107920. private static readonly GAMEPAD_ID_PATTERN;
  107921. private _loadedMeshInfo;
  107922. private readonly _mapping;
  107923. /**
  107924. * Fired when the trackpad on this controller is clicked
  107925. */
  107926. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  107927. /**
  107928. * Fired when the trackpad on this controller is modified
  107929. */
  107930. onTrackpadValuesChangedObservable: Observable<StickValues>;
  107931. /**
  107932. * The current x and y values of this controller's trackpad
  107933. */
  107934. trackpad: StickValues;
  107935. /**
  107936. * Creates a new WindowsMotionController from a gamepad
  107937. * @param vrGamepad the gamepad that the controller should be created from
  107938. */
  107939. constructor(vrGamepad: any);
  107940. /**
  107941. * Fired when the trigger on this controller is modified
  107942. */
  107943. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107944. /**
  107945. * Fired when the menu button on this controller is modified
  107946. */
  107947. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107948. /**
  107949. * Fired when the grip button on this controller is modified
  107950. */
  107951. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107952. /**
  107953. * Fired when the thumbstick button on this controller is modified
  107954. */
  107955. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107956. /**
  107957. * Fired when the touchpad button on this controller is modified
  107958. */
  107959. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107960. /**
  107961. * Fired when the touchpad values on this controller are modified
  107962. */
  107963. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  107964. private _updateTrackpad;
  107965. /**
  107966. * Called once per frame by the engine.
  107967. */
  107968. update(): void;
  107969. /**
  107970. * Called once for each button that changed state since the last frame
  107971. * @param buttonIdx Which button index changed
  107972. * @param state New state of the button
  107973. * @param changes Which properties on the state changed since last frame
  107974. */
  107975. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107976. /**
  107977. * Moves the buttons on the controller mesh based on their current state
  107978. * @param buttonName the name of the button to move
  107979. * @param buttonValue the value of the button which determines the buttons new position
  107980. */
  107981. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  107982. /**
  107983. * Moves the axis on the controller mesh based on its current state
  107984. * @param axis the index of the axis
  107985. * @param axisValue the value of the axis which determines the meshes new position
  107986. * @hidden
  107987. */
  107988. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  107989. /**
  107990. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107991. * @param scene scene in which to add meshes
  107992. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107993. */
  107994. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  107995. /**
  107996. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  107997. * can be transformed by button presses and axes values, based on this._mapping.
  107998. *
  107999. * @param scene scene in which the meshes exist
  108000. * @param meshes list of meshes that make up the controller model to process
  108001. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  108002. */
  108003. private processModel;
  108004. private createMeshInfo;
  108005. /**
  108006. * Gets the ray of the controller in the direction the controller is pointing
  108007. * @param length the length the resulting ray should be
  108008. * @returns a ray in the direction the controller is pointing
  108009. */
  108010. getForwardRay(length?: number): Ray;
  108011. /**
  108012. * Disposes of the controller
  108013. */
  108014. dispose(): void;
  108015. }
  108016. }
  108017. declare module BABYLON {
  108018. /**
  108019. * Oculus Touch Controller
  108020. */
  108021. export class OculusTouchController extends WebVRController {
  108022. /**
  108023. * Base Url for the controller model.
  108024. */
  108025. static MODEL_BASE_URL: string;
  108026. /**
  108027. * File name for the left controller model.
  108028. */
  108029. static MODEL_LEFT_FILENAME: string;
  108030. /**
  108031. * File name for the right controller model.
  108032. */
  108033. static MODEL_RIGHT_FILENAME: string;
  108034. /**
  108035. * Base Url for the Quest controller model.
  108036. */
  108037. static QUEST_MODEL_BASE_URL: string;
  108038. /**
  108039. * @hidden
  108040. * If the controllers are running on a device that needs the updated Quest controller models
  108041. */
  108042. static _IsQuest: boolean;
  108043. /**
  108044. * Fired when the secondary trigger on this controller is modified
  108045. */
  108046. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  108047. /**
  108048. * Fired when the thumb rest on this controller is modified
  108049. */
  108050. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  108051. /**
  108052. * Creates a new OculusTouchController from a gamepad
  108053. * @param vrGamepad the gamepad that the controller should be created from
  108054. */
  108055. constructor(vrGamepad: any);
  108056. /**
  108057. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108058. * @param scene scene in which to add meshes
  108059. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108060. */
  108061. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108062. /**
  108063. * Fired when the A button on this controller is modified
  108064. */
  108065. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108066. /**
  108067. * Fired when the B button on this controller is modified
  108068. */
  108069. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108070. /**
  108071. * Fired when the X button on this controller is modified
  108072. */
  108073. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108074. /**
  108075. * Fired when the Y button on this controller is modified
  108076. */
  108077. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108078. /**
  108079. * Called once for each button that changed state since the last frame
  108080. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  108081. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  108082. * 2) secondary trigger (same)
  108083. * 3) A (right) X (left), touch, pressed = value
  108084. * 4) B / Y
  108085. * 5) thumb rest
  108086. * @param buttonIdx Which button index changed
  108087. * @param state New state of the button
  108088. * @param changes Which properties on the state changed since last frame
  108089. */
  108090. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108091. }
  108092. }
  108093. declare module BABYLON {
  108094. /**
  108095. * Vive Controller
  108096. */
  108097. export class ViveController extends WebVRController {
  108098. /**
  108099. * Base Url for the controller model.
  108100. */
  108101. static MODEL_BASE_URL: string;
  108102. /**
  108103. * File name for the controller model.
  108104. */
  108105. static MODEL_FILENAME: string;
  108106. /**
  108107. * Creates a new ViveController from a gamepad
  108108. * @param vrGamepad the gamepad that the controller should be created from
  108109. */
  108110. constructor(vrGamepad: any);
  108111. /**
  108112. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108113. * @param scene scene in which to add meshes
  108114. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108115. */
  108116. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108117. /**
  108118. * Fired when the left button on this controller is modified
  108119. */
  108120. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108121. /**
  108122. * Fired when the right button on this controller is modified
  108123. */
  108124. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108125. /**
  108126. * Fired when the menu button on this controller is modified
  108127. */
  108128. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108129. /**
  108130. * Called once for each button that changed state since the last frame
  108131. * Vive mapping:
  108132. * 0: touchpad
  108133. * 1: trigger
  108134. * 2: left AND right buttons
  108135. * 3: menu button
  108136. * @param buttonIdx Which button index changed
  108137. * @param state New state of the button
  108138. * @param changes Which properties on the state changed since last frame
  108139. */
  108140. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108141. }
  108142. }
  108143. declare module BABYLON {
  108144. /**
  108145. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  108146. */
  108147. export class WebXRControllerModelLoader {
  108148. /**
  108149. * Creates the WebXRControllerModelLoader
  108150. * @param input xr input that creates the controllers
  108151. */
  108152. constructor(input: WebXRInput);
  108153. }
  108154. }
  108155. declare module BABYLON {
  108156. /**
  108157. * Contains an array of blocks representing the octree
  108158. */
  108159. export interface IOctreeContainer<T> {
  108160. /**
  108161. * Blocks within the octree
  108162. */
  108163. blocks: Array<OctreeBlock<T>>;
  108164. }
  108165. /**
  108166. * Class used to store a cell in an octree
  108167. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108168. */
  108169. export class OctreeBlock<T> {
  108170. /**
  108171. * Gets the content of the current block
  108172. */
  108173. entries: T[];
  108174. /**
  108175. * Gets the list of block children
  108176. */
  108177. blocks: Array<OctreeBlock<T>>;
  108178. private _depth;
  108179. private _maxDepth;
  108180. private _capacity;
  108181. private _minPoint;
  108182. private _maxPoint;
  108183. private _boundingVectors;
  108184. private _creationFunc;
  108185. /**
  108186. * Creates a new block
  108187. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  108188. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  108189. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108190. * @param depth defines the current depth of this block in the octree
  108191. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  108192. * @param creationFunc defines a callback to call when an element is added to the block
  108193. */
  108194. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  108195. /**
  108196. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108197. */
  108198. readonly capacity: number;
  108199. /**
  108200. * Gets the minimum vector (in world space) of the block's bounding box
  108201. */
  108202. readonly minPoint: Vector3;
  108203. /**
  108204. * Gets the maximum vector (in world space) of the block's bounding box
  108205. */
  108206. readonly maxPoint: Vector3;
  108207. /**
  108208. * Add a new element to this block
  108209. * @param entry defines the element to add
  108210. */
  108211. addEntry(entry: T): void;
  108212. /**
  108213. * Remove an element from this block
  108214. * @param entry defines the element to remove
  108215. */
  108216. removeEntry(entry: T): void;
  108217. /**
  108218. * Add an array of elements to this block
  108219. * @param entries defines the array of elements to add
  108220. */
  108221. addEntries(entries: T[]): void;
  108222. /**
  108223. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  108224. * @param frustumPlanes defines the frustum planes to test
  108225. * @param selection defines the array to store current content if selection is positive
  108226. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108227. */
  108228. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108229. /**
  108230. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  108231. * @param sphereCenter defines the bounding sphere center
  108232. * @param sphereRadius defines the bounding sphere radius
  108233. * @param selection defines the array to store current content if selection is positive
  108234. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108235. */
  108236. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108237. /**
  108238. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  108239. * @param ray defines the ray to test with
  108240. * @param selection defines the array to store current content if selection is positive
  108241. */
  108242. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  108243. /**
  108244. * Subdivide the content into child blocks (this block will then be empty)
  108245. */
  108246. createInnerBlocks(): void;
  108247. /**
  108248. * @hidden
  108249. */
  108250. 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;
  108251. }
  108252. }
  108253. declare module BABYLON {
  108254. /**
  108255. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  108256. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108257. */
  108258. export class Octree<T> {
  108259. /** 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.) */
  108260. maxDepth: number;
  108261. /**
  108262. * Blocks within the octree containing objects
  108263. */
  108264. blocks: Array<OctreeBlock<T>>;
  108265. /**
  108266. * Content stored in the octree
  108267. */
  108268. dynamicContent: T[];
  108269. private _maxBlockCapacity;
  108270. private _selectionContent;
  108271. private _creationFunc;
  108272. /**
  108273. * Creates a octree
  108274. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108275. * @param creationFunc function to be used to instatiate the octree
  108276. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  108277. * @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.)
  108278. */
  108279. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  108280. /** 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.) */
  108281. maxDepth?: number);
  108282. /**
  108283. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  108284. * @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);
  108285. * @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);
  108286. * @param entries meshes to be added to the octree blocks
  108287. */
  108288. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  108289. /**
  108290. * Adds a mesh to the octree
  108291. * @param entry Mesh to add to the octree
  108292. */
  108293. addMesh(entry: T): void;
  108294. /**
  108295. * Remove an element from the octree
  108296. * @param entry defines the element to remove
  108297. */
  108298. removeMesh(entry: T): void;
  108299. /**
  108300. * Selects an array of meshes within the frustum
  108301. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  108302. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  108303. * @returns array of meshes within the frustum
  108304. */
  108305. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  108306. /**
  108307. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  108308. * @param sphereCenter defines the bounding sphere center
  108309. * @param sphereRadius defines the bounding sphere radius
  108310. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108311. * @returns an array of objects that intersect the sphere
  108312. */
  108313. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  108314. /**
  108315. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  108316. * @param ray defines the ray to test with
  108317. * @returns array of intersected objects
  108318. */
  108319. intersectsRay(ray: Ray): SmartArray<T>;
  108320. /**
  108321. * Adds a mesh into the octree block if it intersects the block
  108322. */
  108323. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  108324. /**
  108325. * Adds a submesh into the octree block if it intersects the block
  108326. */
  108327. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  108328. }
  108329. }
  108330. declare module BABYLON {
  108331. interface Scene {
  108332. /**
  108333. * @hidden
  108334. * Backing Filed
  108335. */
  108336. _selectionOctree: Octree<AbstractMesh>;
  108337. /**
  108338. * Gets the octree used to boost mesh selection (picking)
  108339. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108340. */
  108341. selectionOctree: Octree<AbstractMesh>;
  108342. /**
  108343. * Creates or updates the octree used to boost selection (picking)
  108344. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108345. * @param maxCapacity defines the maximum capacity per leaf
  108346. * @param maxDepth defines the maximum depth of the octree
  108347. * @returns an octree of AbstractMesh
  108348. */
  108349. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  108350. }
  108351. interface AbstractMesh {
  108352. /**
  108353. * @hidden
  108354. * Backing Field
  108355. */
  108356. _submeshesOctree: Octree<SubMesh>;
  108357. /**
  108358. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  108359. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  108360. * @param maxCapacity defines the maximum size of each block (64 by default)
  108361. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  108362. * @returns the new octree
  108363. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  108364. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108365. */
  108366. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  108367. }
  108368. /**
  108369. * Defines the octree scene component responsible to manage any octrees
  108370. * in a given scene.
  108371. */
  108372. export class OctreeSceneComponent {
  108373. /**
  108374. * The component name help to identify the component in the list of scene components.
  108375. */
  108376. readonly name: string;
  108377. /**
  108378. * The scene the component belongs to.
  108379. */
  108380. scene: Scene;
  108381. /**
  108382. * Indicates if the meshes have been checked to make sure they are isEnabled()
  108383. */
  108384. readonly checksIsEnabled: boolean;
  108385. /**
  108386. * Creates a new instance of the component for the given scene
  108387. * @param scene Defines the scene to register the component in
  108388. */
  108389. constructor(scene: Scene);
  108390. /**
  108391. * Registers the component in a given scene
  108392. */
  108393. register(): void;
  108394. /**
  108395. * Return the list of active meshes
  108396. * @returns the list of active meshes
  108397. */
  108398. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  108399. /**
  108400. * Return the list of active sub meshes
  108401. * @param mesh The mesh to get the candidates sub meshes from
  108402. * @returns the list of active sub meshes
  108403. */
  108404. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  108405. private _tempRay;
  108406. /**
  108407. * Return the list of sub meshes intersecting with a given local ray
  108408. * @param mesh defines the mesh to find the submesh for
  108409. * @param localRay defines the ray in local space
  108410. * @returns the list of intersecting sub meshes
  108411. */
  108412. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  108413. /**
  108414. * Return the list of sub meshes colliding with a collider
  108415. * @param mesh defines the mesh to find the submesh for
  108416. * @param collider defines the collider to evaluate the collision against
  108417. * @returns the list of colliding sub meshes
  108418. */
  108419. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  108420. /**
  108421. * Rebuilds the elements related to this component in case of
  108422. * context lost for instance.
  108423. */
  108424. rebuild(): void;
  108425. /**
  108426. * Disposes the component and the associated ressources.
  108427. */
  108428. dispose(): void;
  108429. }
  108430. }
  108431. declare module BABYLON {
  108432. /**
  108433. * Renders a layer on top of an existing scene
  108434. */
  108435. export class UtilityLayerRenderer implements IDisposable {
  108436. /** the original scene that will be rendered on top of */
  108437. originalScene: Scene;
  108438. private _pointerCaptures;
  108439. private _lastPointerEvents;
  108440. private static _DefaultUtilityLayer;
  108441. private static _DefaultKeepDepthUtilityLayer;
  108442. private _sharedGizmoLight;
  108443. private _renderCamera;
  108444. /**
  108445. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  108446. * @returns the camera that is used when rendering the utility layer
  108447. */
  108448. getRenderCamera(): Nullable<Camera>;
  108449. /**
  108450. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  108451. * @param cam the camera that should be used when rendering the utility layer
  108452. */
  108453. setRenderCamera(cam: Nullable<Camera>): void;
  108454. /**
  108455. * @hidden
  108456. * Light which used by gizmos to get light shading
  108457. */
  108458. _getSharedGizmoLight(): HemisphericLight;
  108459. /**
  108460. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  108461. */
  108462. pickUtilitySceneFirst: boolean;
  108463. /**
  108464. * 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)
  108465. */
  108466. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  108467. /**
  108468. * 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)
  108469. */
  108470. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  108471. /**
  108472. * The scene that is rendered on top of the original scene
  108473. */
  108474. utilityLayerScene: Scene;
  108475. /**
  108476. * If the utility layer should automatically be rendered on top of existing scene
  108477. */
  108478. shouldRender: boolean;
  108479. /**
  108480. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  108481. */
  108482. onlyCheckPointerDownEvents: boolean;
  108483. /**
  108484. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  108485. */
  108486. processAllEvents: boolean;
  108487. /**
  108488. * Observable raised when the pointer move from the utility layer scene to the main scene
  108489. */
  108490. onPointerOutObservable: Observable<number>;
  108491. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  108492. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  108493. private _afterRenderObserver;
  108494. private _sceneDisposeObserver;
  108495. private _originalPointerObserver;
  108496. /**
  108497. * Instantiates a UtilityLayerRenderer
  108498. * @param originalScene the original scene that will be rendered on top of
  108499. * @param handleEvents boolean indicating if the utility layer should handle events
  108500. */
  108501. constructor(
  108502. /** the original scene that will be rendered on top of */
  108503. originalScene: Scene, handleEvents?: boolean);
  108504. private _notifyObservers;
  108505. /**
  108506. * Renders the utility layers scene on top of the original scene
  108507. */
  108508. render(): void;
  108509. /**
  108510. * Disposes of the renderer
  108511. */
  108512. dispose(): void;
  108513. private _updateCamera;
  108514. }
  108515. }
  108516. declare module BABYLON {
  108517. /**
  108518. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  108519. */
  108520. export class Gizmo implements IDisposable {
  108521. /** The utility layer the gizmo will be added to */
  108522. gizmoLayer: UtilityLayerRenderer;
  108523. /**
  108524. * The root mesh of the gizmo
  108525. */
  108526. _rootMesh: Mesh;
  108527. private _attachedMesh;
  108528. /**
  108529. * Ratio for the scale of the gizmo (Default: 1)
  108530. */
  108531. scaleRatio: number;
  108532. /**
  108533. * If a custom mesh has been set (Default: false)
  108534. */
  108535. protected _customMeshSet: boolean;
  108536. /**
  108537. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  108538. * * When set, interactions will be enabled
  108539. */
  108540. attachedMesh: Nullable<AbstractMesh>;
  108541. /**
  108542. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  108543. * @param mesh The mesh to replace the default mesh of the gizmo
  108544. */
  108545. setCustomMesh(mesh: Mesh): void;
  108546. /**
  108547. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  108548. */
  108549. updateGizmoRotationToMatchAttachedMesh: boolean;
  108550. /**
  108551. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  108552. */
  108553. updateGizmoPositionToMatchAttachedMesh: boolean;
  108554. /**
  108555. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  108556. */
  108557. updateScale: boolean;
  108558. protected _interactionsEnabled: boolean;
  108559. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108560. private _beforeRenderObserver;
  108561. private _tempVector;
  108562. /**
  108563. * Creates a gizmo
  108564. * @param gizmoLayer The utility layer the gizmo will be added to
  108565. */
  108566. constructor(
  108567. /** The utility layer the gizmo will be added to */
  108568. gizmoLayer?: UtilityLayerRenderer);
  108569. /**
  108570. * Updates the gizmo to match the attached mesh's position/rotation
  108571. */
  108572. protected _update(): void;
  108573. /**
  108574. * Disposes of the gizmo
  108575. */
  108576. dispose(): void;
  108577. }
  108578. }
  108579. declare module BABYLON {
  108580. /**
  108581. * Single plane drag gizmo
  108582. */
  108583. export class PlaneDragGizmo extends Gizmo {
  108584. /**
  108585. * Drag behavior responsible for the gizmos dragging interactions
  108586. */
  108587. dragBehavior: PointerDragBehavior;
  108588. private _pointerObserver;
  108589. /**
  108590. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108591. */
  108592. snapDistance: number;
  108593. /**
  108594. * Event that fires each time the gizmo snaps to a new location.
  108595. * * snapDistance is the the change in distance
  108596. */
  108597. onSnapObservable: Observable<{
  108598. snapDistance: number;
  108599. }>;
  108600. private _plane;
  108601. private _coloredMaterial;
  108602. private _hoverMaterial;
  108603. private _isEnabled;
  108604. private _parent;
  108605. /** @hidden */
  108606. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  108607. /** @hidden */
  108608. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108609. /**
  108610. * Creates a PlaneDragGizmo
  108611. * @param gizmoLayer The utility layer the gizmo will be added to
  108612. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  108613. * @param color The color of the gizmo
  108614. */
  108615. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108616. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108617. /**
  108618. * If the gizmo is enabled
  108619. */
  108620. isEnabled: boolean;
  108621. /**
  108622. * Disposes of the gizmo
  108623. */
  108624. dispose(): void;
  108625. }
  108626. }
  108627. declare module BABYLON {
  108628. /**
  108629. * Gizmo that enables dragging a mesh along 3 axis
  108630. */
  108631. export class PositionGizmo extends Gizmo {
  108632. /**
  108633. * Internal gizmo used for interactions on the x axis
  108634. */
  108635. xGizmo: AxisDragGizmo;
  108636. /**
  108637. * Internal gizmo used for interactions on the y axis
  108638. */
  108639. yGizmo: AxisDragGizmo;
  108640. /**
  108641. * Internal gizmo used for interactions on the z axis
  108642. */
  108643. zGizmo: AxisDragGizmo;
  108644. /**
  108645. * Internal gizmo used for interactions on the yz plane
  108646. */
  108647. xPlaneGizmo: PlaneDragGizmo;
  108648. /**
  108649. * Internal gizmo used for interactions on the xz plane
  108650. */
  108651. yPlaneGizmo: PlaneDragGizmo;
  108652. /**
  108653. * Internal gizmo used for interactions on the xy plane
  108654. */
  108655. zPlaneGizmo: PlaneDragGizmo;
  108656. /**
  108657. * private variables
  108658. */
  108659. private _meshAttached;
  108660. private _updateGizmoRotationToMatchAttachedMesh;
  108661. private _snapDistance;
  108662. private _scaleRatio;
  108663. /** Fires an event when any of it's sub gizmos are dragged */
  108664. onDragStartObservable: Observable<unknown>;
  108665. /** Fires an event when any of it's sub gizmos are released from dragging */
  108666. onDragEndObservable: Observable<unknown>;
  108667. /**
  108668. * If set to true, planar drag is enabled
  108669. */
  108670. private _planarGizmoEnabled;
  108671. attachedMesh: Nullable<AbstractMesh>;
  108672. /**
  108673. * Creates a PositionGizmo
  108674. * @param gizmoLayer The utility layer the gizmo will be added to
  108675. */
  108676. constructor(gizmoLayer?: UtilityLayerRenderer);
  108677. /**
  108678. * If the planar drag gizmo is enabled
  108679. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  108680. */
  108681. planarGizmoEnabled: boolean;
  108682. updateGizmoRotationToMatchAttachedMesh: boolean;
  108683. /**
  108684. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108685. */
  108686. snapDistance: number;
  108687. /**
  108688. * Ratio for the scale of the gizmo (Default: 1)
  108689. */
  108690. scaleRatio: number;
  108691. /**
  108692. * Disposes of the gizmo
  108693. */
  108694. dispose(): void;
  108695. /**
  108696. * CustomMeshes are not supported by this gizmo
  108697. * @param mesh The mesh to replace the default mesh of the gizmo
  108698. */
  108699. setCustomMesh(mesh: Mesh): void;
  108700. }
  108701. }
  108702. declare module BABYLON {
  108703. /**
  108704. * Single axis drag gizmo
  108705. */
  108706. export class AxisDragGizmo extends Gizmo {
  108707. /**
  108708. * Drag behavior responsible for the gizmos dragging interactions
  108709. */
  108710. dragBehavior: PointerDragBehavior;
  108711. private _pointerObserver;
  108712. /**
  108713. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108714. */
  108715. snapDistance: number;
  108716. /**
  108717. * Event that fires each time the gizmo snaps to a new location.
  108718. * * snapDistance is the the change in distance
  108719. */
  108720. onSnapObservable: Observable<{
  108721. snapDistance: number;
  108722. }>;
  108723. private _isEnabled;
  108724. private _parent;
  108725. private _arrow;
  108726. private _coloredMaterial;
  108727. private _hoverMaterial;
  108728. /** @hidden */
  108729. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  108730. /** @hidden */
  108731. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108732. /**
  108733. * Creates an AxisDragGizmo
  108734. * @param gizmoLayer The utility layer the gizmo will be added to
  108735. * @param dragAxis The axis which the gizmo will be able to drag on
  108736. * @param color The color of the gizmo
  108737. */
  108738. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108739. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108740. /**
  108741. * If the gizmo is enabled
  108742. */
  108743. isEnabled: boolean;
  108744. /**
  108745. * Disposes of the gizmo
  108746. */
  108747. dispose(): void;
  108748. }
  108749. }
  108750. declare module BABYLON.Debug {
  108751. /**
  108752. * The Axes viewer will show 3 axes in a specific point in space
  108753. */
  108754. export class AxesViewer {
  108755. private _xAxis;
  108756. private _yAxis;
  108757. private _zAxis;
  108758. private _scaleLinesFactor;
  108759. private _instanced;
  108760. /**
  108761. * Gets the hosting scene
  108762. */
  108763. scene: Scene;
  108764. /**
  108765. * Gets or sets a number used to scale line length
  108766. */
  108767. scaleLines: number;
  108768. /** Gets the node hierarchy used to render x-axis */
  108769. readonly xAxis: TransformNode;
  108770. /** Gets the node hierarchy used to render y-axis */
  108771. readonly yAxis: TransformNode;
  108772. /** Gets the node hierarchy used to render z-axis */
  108773. readonly zAxis: TransformNode;
  108774. /**
  108775. * Creates a new AxesViewer
  108776. * @param scene defines the hosting scene
  108777. * @param scaleLines defines a number used to scale line length (1 by default)
  108778. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  108779. * @param xAxis defines the node hierarchy used to render the x-axis
  108780. * @param yAxis defines the node hierarchy used to render the y-axis
  108781. * @param zAxis defines the node hierarchy used to render the z-axis
  108782. */
  108783. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  108784. /**
  108785. * Force the viewer to update
  108786. * @param position defines the position of the viewer
  108787. * @param xaxis defines the x axis of the viewer
  108788. * @param yaxis defines the y axis of the viewer
  108789. * @param zaxis defines the z axis of the viewer
  108790. */
  108791. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  108792. /**
  108793. * Creates an instance of this axes viewer.
  108794. * @returns a new axes viewer with instanced meshes
  108795. */
  108796. createInstance(): AxesViewer;
  108797. /** Releases resources */
  108798. dispose(): void;
  108799. private static _SetRenderingGroupId;
  108800. }
  108801. }
  108802. declare module BABYLON.Debug {
  108803. /**
  108804. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  108805. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  108806. */
  108807. export class BoneAxesViewer extends AxesViewer {
  108808. /**
  108809. * Gets or sets the target mesh where to display the axes viewer
  108810. */
  108811. mesh: Nullable<Mesh>;
  108812. /**
  108813. * Gets or sets the target bone where to display the axes viewer
  108814. */
  108815. bone: Nullable<Bone>;
  108816. /** Gets current position */
  108817. pos: Vector3;
  108818. /** Gets direction of X axis */
  108819. xaxis: Vector3;
  108820. /** Gets direction of Y axis */
  108821. yaxis: Vector3;
  108822. /** Gets direction of Z axis */
  108823. zaxis: Vector3;
  108824. /**
  108825. * Creates a new BoneAxesViewer
  108826. * @param scene defines the hosting scene
  108827. * @param bone defines the target bone
  108828. * @param mesh defines the target mesh
  108829. * @param scaleLines defines a scaling factor for line length (1 by default)
  108830. */
  108831. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  108832. /**
  108833. * Force the viewer to update
  108834. */
  108835. update(): void;
  108836. /** Releases resources */
  108837. dispose(): void;
  108838. }
  108839. }
  108840. declare module BABYLON {
  108841. /**
  108842. * Interface used to define scene explorer extensibility option
  108843. */
  108844. export interface IExplorerExtensibilityOption {
  108845. /**
  108846. * Define the option label
  108847. */
  108848. label: string;
  108849. /**
  108850. * Defines the action to execute on click
  108851. */
  108852. action: (entity: any) => void;
  108853. }
  108854. /**
  108855. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  108856. */
  108857. export interface IExplorerExtensibilityGroup {
  108858. /**
  108859. * Defines a predicate to test if a given type mut be extended
  108860. */
  108861. predicate: (entity: any) => boolean;
  108862. /**
  108863. * Gets the list of options added to a type
  108864. */
  108865. entries: IExplorerExtensibilityOption[];
  108866. }
  108867. /**
  108868. * Interface used to define the options to use to create the Inspector
  108869. */
  108870. export interface IInspectorOptions {
  108871. /**
  108872. * Display in overlay mode (default: false)
  108873. */
  108874. overlay?: boolean;
  108875. /**
  108876. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  108877. */
  108878. globalRoot?: HTMLElement;
  108879. /**
  108880. * Display the Scene explorer
  108881. */
  108882. showExplorer?: boolean;
  108883. /**
  108884. * Display the property inspector
  108885. */
  108886. showInspector?: boolean;
  108887. /**
  108888. * Display in embed mode (both panes on the right)
  108889. */
  108890. embedMode?: boolean;
  108891. /**
  108892. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  108893. */
  108894. handleResize?: boolean;
  108895. /**
  108896. * Allow the panes to popup (default: true)
  108897. */
  108898. enablePopup?: boolean;
  108899. /**
  108900. * Allow the panes to be closed by users (default: true)
  108901. */
  108902. enableClose?: boolean;
  108903. /**
  108904. * Optional list of extensibility entries
  108905. */
  108906. explorerExtensibility?: IExplorerExtensibilityGroup[];
  108907. /**
  108908. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  108909. */
  108910. inspectorURL?: string;
  108911. }
  108912. interface Scene {
  108913. /**
  108914. * @hidden
  108915. * Backing field
  108916. */
  108917. _debugLayer: DebugLayer;
  108918. /**
  108919. * Gets the debug layer (aka Inspector) associated with the scene
  108920. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108921. */
  108922. debugLayer: DebugLayer;
  108923. }
  108924. /**
  108925. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108926. * what is happening in your scene
  108927. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108928. */
  108929. export class DebugLayer {
  108930. /**
  108931. * Define the url to get the inspector script from.
  108932. * By default it uses the babylonjs CDN.
  108933. * @ignoreNaming
  108934. */
  108935. static InspectorURL: string;
  108936. private _scene;
  108937. private BJSINSPECTOR;
  108938. private _onPropertyChangedObservable?;
  108939. /**
  108940. * Observable triggered when a property is changed through the inspector.
  108941. */
  108942. readonly onPropertyChangedObservable: any;
  108943. /**
  108944. * Instantiates a new debug layer.
  108945. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108946. * what is happening in your scene
  108947. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108948. * @param scene Defines the scene to inspect
  108949. */
  108950. constructor(scene: Scene);
  108951. /** Creates the inspector window. */
  108952. private _createInspector;
  108953. /**
  108954. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  108955. * @param entity defines the entity to select
  108956. * @param lineContainerTitle defines the specific block to highlight
  108957. */
  108958. select(entity: any, lineContainerTitle?: string): void;
  108959. /** Get the inspector from bundle or global */
  108960. private _getGlobalInspector;
  108961. /**
  108962. * Get if the inspector is visible or not.
  108963. * @returns true if visible otherwise, false
  108964. */
  108965. isVisible(): boolean;
  108966. /**
  108967. * Hide the inspector and close its window.
  108968. */
  108969. hide(): void;
  108970. /**
  108971. * Launch the debugLayer.
  108972. * @param config Define the configuration of the inspector
  108973. * @return a promise fulfilled when the debug layer is visible
  108974. */
  108975. show(config?: IInspectorOptions): Promise<DebugLayer>;
  108976. }
  108977. }
  108978. declare module BABYLON {
  108979. /**
  108980. * Class containing static functions to help procedurally build meshes
  108981. */
  108982. export class BoxBuilder {
  108983. /**
  108984. * Creates a box mesh
  108985. * * The parameter `size` sets the size (float) of each box side (default 1)
  108986. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  108987. * * 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)
  108988. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  108989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108990. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108992. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  108993. * @param name defines the name of the mesh
  108994. * @param options defines the options used to create the mesh
  108995. * @param scene defines the hosting scene
  108996. * @returns the box mesh
  108997. */
  108998. static CreateBox(name: string, options: {
  108999. size?: number;
  109000. width?: number;
  109001. height?: number;
  109002. depth?: number;
  109003. faceUV?: Vector4[];
  109004. faceColors?: Color4[];
  109005. sideOrientation?: number;
  109006. frontUVs?: Vector4;
  109007. backUVs?: Vector4;
  109008. wrap?: boolean;
  109009. topBaseAt?: number;
  109010. bottomBaseAt?: number;
  109011. updatable?: boolean;
  109012. }, scene?: Nullable<Scene>): Mesh;
  109013. }
  109014. }
  109015. declare module BABYLON {
  109016. /**
  109017. * Class containing static functions to help procedurally build meshes
  109018. */
  109019. export class SphereBuilder {
  109020. /**
  109021. * Creates a sphere mesh
  109022. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  109023. * * 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`)
  109024. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  109025. * * 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
  109026. * * 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)
  109027. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109028. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109030. * @param name defines the name of the mesh
  109031. * @param options defines the options used to create the mesh
  109032. * @param scene defines the hosting scene
  109033. * @returns the sphere mesh
  109034. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  109035. */
  109036. static CreateSphere(name: string, options: {
  109037. segments?: number;
  109038. diameter?: number;
  109039. diameterX?: number;
  109040. diameterY?: number;
  109041. diameterZ?: number;
  109042. arc?: number;
  109043. slice?: number;
  109044. sideOrientation?: number;
  109045. frontUVs?: Vector4;
  109046. backUVs?: Vector4;
  109047. updatable?: boolean;
  109048. }, scene?: Nullable<Scene>): Mesh;
  109049. }
  109050. }
  109051. declare module BABYLON.Debug {
  109052. /**
  109053. * Used to show the physics impostor around the specific mesh
  109054. */
  109055. export class PhysicsViewer {
  109056. /** @hidden */
  109057. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  109058. /** @hidden */
  109059. protected _meshes: Array<Nullable<AbstractMesh>>;
  109060. /** @hidden */
  109061. protected _scene: Nullable<Scene>;
  109062. /** @hidden */
  109063. protected _numMeshes: number;
  109064. /** @hidden */
  109065. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  109066. private _renderFunction;
  109067. private _utilityLayer;
  109068. private _debugBoxMesh;
  109069. private _debugSphereMesh;
  109070. private _debugCylinderMesh;
  109071. private _debugMaterial;
  109072. private _debugMeshMeshes;
  109073. /**
  109074. * Creates a new PhysicsViewer
  109075. * @param scene defines the hosting scene
  109076. */
  109077. constructor(scene: Scene);
  109078. /** @hidden */
  109079. protected _updateDebugMeshes(): void;
  109080. /**
  109081. * Renders a specified physic impostor
  109082. * @param impostor defines the impostor to render
  109083. * @param targetMesh defines the mesh represented by the impostor
  109084. * @returns the new debug mesh used to render the impostor
  109085. */
  109086. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  109087. /**
  109088. * Hides a specified physic impostor
  109089. * @param impostor defines the impostor to hide
  109090. */
  109091. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  109092. private _getDebugMaterial;
  109093. private _getDebugBoxMesh;
  109094. private _getDebugSphereMesh;
  109095. private _getDebugCylinderMesh;
  109096. private _getDebugMeshMesh;
  109097. private _getDebugMesh;
  109098. /** Releases all resources */
  109099. dispose(): void;
  109100. }
  109101. }
  109102. declare module BABYLON {
  109103. /**
  109104. * Class containing static functions to help procedurally build meshes
  109105. */
  109106. export class LinesBuilder {
  109107. /**
  109108. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  109109. * * 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
  109110. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  109111. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  109112. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  109113. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  109114. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  109115. * * 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
  109116. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  109117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109118. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  109119. * @param name defines the name of the new line system
  109120. * @param options defines the options used to create the line system
  109121. * @param scene defines the hosting scene
  109122. * @returns a new line system mesh
  109123. */
  109124. static CreateLineSystem(name: string, options: {
  109125. lines: Vector3[][];
  109126. updatable?: boolean;
  109127. instance?: Nullable<LinesMesh>;
  109128. colors?: Nullable<Color4[][]>;
  109129. useVertexAlpha?: boolean;
  109130. }, scene: Nullable<Scene>): LinesMesh;
  109131. /**
  109132. * Creates a line mesh
  109133. * 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
  109134. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109135. * * The parameter `points` is an array successive Vector3
  109136. * * 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
  109137. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109138. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109139. * * When updating an instance, remember that only point positions can change, not the number of points
  109140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109141. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109142. * @param name defines the name of the new line system
  109143. * @param options defines the options used to create the line system
  109144. * @param scene defines the hosting scene
  109145. * @returns a new line mesh
  109146. */
  109147. static CreateLines(name: string, options: {
  109148. points: Vector3[];
  109149. updatable?: boolean;
  109150. instance?: Nullable<LinesMesh>;
  109151. colors?: Color4[];
  109152. useVertexAlpha?: boolean;
  109153. }, scene?: Nullable<Scene>): LinesMesh;
  109154. /**
  109155. * Creates a dashed line mesh
  109156. * * 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
  109157. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109158. * * The parameter `points` is an array successive Vector3
  109159. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  109160. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  109161. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109162. * * 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
  109163. * * When updating an instance, remember that only point positions can change, not the number of points
  109164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109165. * @param name defines the name of the mesh
  109166. * @param options defines the options used to create the mesh
  109167. * @param scene defines the hosting scene
  109168. * @returns the dashed line mesh
  109169. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  109170. */
  109171. static CreateDashedLines(name: string, options: {
  109172. points: Vector3[];
  109173. dashSize?: number;
  109174. gapSize?: number;
  109175. dashNb?: number;
  109176. updatable?: boolean;
  109177. instance?: LinesMesh;
  109178. }, scene?: Nullable<Scene>): LinesMesh;
  109179. }
  109180. }
  109181. declare module BABYLON {
  109182. /**
  109183. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109184. * in order to better appreciate the issue one might have.
  109185. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109186. */
  109187. export class RayHelper {
  109188. /**
  109189. * Defines the ray we are currently tryin to visualize.
  109190. */
  109191. ray: Nullable<Ray>;
  109192. private _renderPoints;
  109193. private _renderLine;
  109194. private _renderFunction;
  109195. private _scene;
  109196. private _updateToMeshFunction;
  109197. private _attachedToMesh;
  109198. private _meshSpaceDirection;
  109199. private _meshSpaceOrigin;
  109200. /**
  109201. * Helper function to create a colored helper in a scene in one line.
  109202. * @param ray Defines the ray we are currently tryin to visualize
  109203. * @param scene Defines the scene the ray is used in
  109204. * @param color Defines the color we want to see the ray in
  109205. * @returns The newly created ray helper.
  109206. */
  109207. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  109208. /**
  109209. * Instantiate a new ray helper.
  109210. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109211. * in order to better appreciate the issue one might have.
  109212. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109213. * @param ray Defines the ray we are currently tryin to visualize
  109214. */
  109215. constructor(ray: Ray);
  109216. /**
  109217. * Shows the ray we are willing to debug.
  109218. * @param scene Defines the scene the ray needs to be rendered in
  109219. * @param color Defines the color the ray needs to be rendered in
  109220. */
  109221. show(scene: Scene, color?: Color3): void;
  109222. /**
  109223. * Hides the ray we are debugging.
  109224. */
  109225. hide(): void;
  109226. private _render;
  109227. /**
  109228. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  109229. * @param mesh Defines the mesh we want the helper attached to
  109230. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  109231. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  109232. * @param length Defines the length of the ray
  109233. */
  109234. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  109235. /**
  109236. * Detach the ray helper from the mesh it has previously been attached to.
  109237. */
  109238. detachFromMesh(): void;
  109239. private _updateToMesh;
  109240. /**
  109241. * Dispose the helper and release its associated resources.
  109242. */
  109243. dispose(): void;
  109244. }
  109245. }
  109246. declare module BABYLON.Debug {
  109247. /**
  109248. * Class used to render a debug view of a given skeleton
  109249. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  109250. */
  109251. export class SkeletonViewer {
  109252. /** defines the skeleton to render */
  109253. skeleton: Skeleton;
  109254. /** defines the mesh attached to the skeleton */
  109255. mesh: AbstractMesh;
  109256. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109257. autoUpdateBonesMatrices: boolean;
  109258. /** defines the rendering group id to use with the viewer */
  109259. renderingGroupId: number;
  109260. /** Gets or sets the color used to render the skeleton */
  109261. color: Color3;
  109262. private _scene;
  109263. private _debugLines;
  109264. private _debugMesh;
  109265. private _isEnabled;
  109266. private _renderFunction;
  109267. private _utilityLayer;
  109268. /**
  109269. * Returns the mesh used to render the bones
  109270. */
  109271. readonly debugMesh: Nullable<LinesMesh>;
  109272. /**
  109273. * Creates a new SkeletonViewer
  109274. * @param skeleton defines the skeleton to render
  109275. * @param mesh defines the mesh attached to the skeleton
  109276. * @param scene defines the hosting scene
  109277. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  109278. * @param renderingGroupId defines the rendering group id to use with the viewer
  109279. */
  109280. constructor(
  109281. /** defines the skeleton to render */
  109282. skeleton: Skeleton,
  109283. /** defines the mesh attached to the skeleton */
  109284. mesh: AbstractMesh, scene: Scene,
  109285. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109286. autoUpdateBonesMatrices?: boolean,
  109287. /** defines the rendering group id to use with the viewer */
  109288. renderingGroupId?: number);
  109289. /** Gets or sets a boolean indicating if the viewer is enabled */
  109290. isEnabled: boolean;
  109291. private _getBonePosition;
  109292. private _getLinesForBonesWithLength;
  109293. private _getLinesForBonesNoLength;
  109294. /** Update the viewer to sync with current skeleton state */
  109295. update(): void;
  109296. /** Release associated resources */
  109297. dispose(): void;
  109298. }
  109299. }
  109300. declare module BABYLON {
  109301. /**
  109302. * Options to create the null engine
  109303. */
  109304. export class NullEngineOptions {
  109305. /**
  109306. * Render width (Default: 512)
  109307. */
  109308. renderWidth: number;
  109309. /**
  109310. * Render height (Default: 256)
  109311. */
  109312. renderHeight: number;
  109313. /**
  109314. * Texture size (Default: 512)
  109315. */
  109316. textureSize: number;
  109317. /**
  109318. * If delta time between frames should be constant
  109319. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109320. */
  109321. deterministicLockstep: boolean;
  109322. /**
  109323. * Maximum about of steps between frames (Default: 4)
  109324. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109325. */
  109326. lockstepMaxSteps: number;
  109327. }
  109328. /**
  109329. * The null engine class provides support for headless version of babylon.js.
  109330. * This can be used in server side scenario or for testing purposes
  109331. */
  109332. export class NullEngine extends Engine {
  109333. private _options;
  109334. /**
  109335. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109336. */
  109337. isDeterministicLockStep(): boolean;
  109338. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  109339. getLockstepMaxSteps(): number;
  109340. /**
  109341. * Sets hardware scaling, used to save performance if needed
  109342. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109343. */
  109344. getHardwareScalingLevel(): number;
  109345. constructor(options?: NullEngineOptions);
  109346. createVertexBuffer(vertices: FloatArray): DataBuffer;
  109347. createIndexBuffer(indices: IndicesArray): DataBuffer;
  109348. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109349. getRenderWidth(useScreen?: boolean): number;
  109350. getRenderHeight(useScreen?: boolean): number;
  109351. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  109352. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  109353. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  109354. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109355. bindSamplers(effect: Effect): void;
  109356. enableEffect(effect: Effect): void;
  109357. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109358. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  109359. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  109360. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  109361. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  109362. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  109363. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  109364. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  109365. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  109366. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  109367. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  109368. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  109369. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  109370. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  109371. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109372. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109373. setFloat(uniform: WebGLUniformLocation, value: number): void;
  109374. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  109375. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  109376. setBool(uniform: WebGLUniformLocation, bool: number): void;
  109377. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  109378. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109379. bindBuffers(vertexBuffers: {
  109380. [key: string]: VertexBuffer;
  109381. }, indexBuffer: DataBuffer, effect: Effect): void;
  109382. wipeCaches(bruteForce?: boolean): void;
  109383. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  109384. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  109385. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  109386. /** @hidden */
  109387. _createTexture(): WebGLTexture;
  109388. /** @hidden */
  109389. _releaseTexture(texture: InternalTexture): void;
  109390. 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;
  109391. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  109392. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  109393. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  109394. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  109395. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  109396. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  109397. areAllEffectsReady(): boolean;
  109398. /**
  109399. * @hidden
  109400. * Get the current error code of the webGL context
  109401. * @returns the error code
  109402. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  109403. */
  109404. getError(): number;
  109405. /** @hidden */
  109406. _getUnpackAlignement(): number;
  109407. /** @hidden */
  109408. _unpackFlipY(value: boolean): void;
  109409. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  109410. /**
  109411. * Updates a dynamic vertex buffer.
  109412. * @param vertexBuffer the vertex buffer to update
  109413. * @param data the data used to update the vertex buffer
  109414. * @param byteOffset the byte offset of the data (optional)
  109415. * @param byteLength the byte length of the data (optional)
  109416. */
  109417. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  109418. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  109419. /** @hidden */
  109420. _bindTexture(channel: number, texture: InternalTexture): void;
  109421. protected _deleteBuffer(buffer: WebGLBuffer): void;
  109422. releaseEffects(): void;
  109423. displayLoadingUI(): void;
  109424. hideLoadingUI(): void;
  109425. /** @hidden */
  109426. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109427. /** @hidden */
  109428. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109429. /** @hidden */
  109430. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109431. /** @hidden */
  109432. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  109433. }
  109434. }
  109435. declare module BABYLON {
  109436. /** @hidden */
  109437. export class _OcclusionDataStorage {
  109438. /** @hidden */
  109439. occlusionInternalRetryCounter: number;
  109440. /** @hidden */
  109441. isOcclusionQueryInProgress: boolean;
  109442. /** @hidden */
  109443. isOccluded: boolean;
  109444. /** @hidden */
  109445. occlusionRetryCount: number;
  109446. /** @hidden */
  109447. occlusionType: number;
  109448. /** @hidden */
  109449. occlusionQueryAlgorithmType: number;
  109450. }
  109451. interface Engine {
  109452. /**
  109453. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  109454. * @return the new query
  109455. */
  109456. createQuery(): WebGLQuery;
  109457. /**
  109458. * Delete and release a webGL query
  109459. * @param query defines the query to delete
  109460. * @return the current engine
  109461. */
  109462. deleteQuery(query: WebGLQuery): Engine;
  109463. /**
  109464. * Check if a given query has resolved and got its value
  109465. * @param query defines the query to check
  109466. * @returns true if the query got its value
  109467. */
  109468. isQueryResultAvailable(query: WebGLQuery): boolean;
  109469. /**
  109470. * Gets the value of a given query
  109471. * @param query defines the query to check
  109472. * @returns the value of the query
  109473. */
  109474. getQueryResult(query: WebGLQuery): number;
  109475. /**
  109476. * Initiates an occlusion query
  109477. * @param algorithmType defines the algorithm to use
  109478. * @param query defines the query to use
  109479. * @returns the current engine
  109480. * @see http://doc.babylonjs.com/features/occlusionquery
  109481. */
  109482. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  109483. /**
  109484. * Ends an occlusion query
  109485. * @see http://doc.babylonjs.com/features/occlusionquery
  109486. * @param algorithmType defines the algorithm to use
  109487. * @returns the current engine
  109488. */
  109489. endOcclusionQuery(algorithmType: number): Engine;
  109490. /**
  109491. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  109492. * Please note that only one query can be issued at a time
  109493. * @returns a time token used to track the time span
  109494. */
  109495. startTimeQuery(): Nullable<_TimeToken>;
  109496. /**
  109497. * Ends a time query
  109498. * @param token defines the token used to measure the time span
  109499. * @returns the time spent (in ns)
  109500. */
  109501. endTimeQuery(token: _TimeToken): int;
  109502. /** @hidden */
  109503. _currentNonTimestampToken: Nullable<_TimeToken>;
  109504. /** @hidden */
  109505. _createTimeQuery(): WebGLQuery;
  109506. /** @hidden */
  109507. _deleteTimeQuery(query: WebGLQuery): void;
  109508. /** @hidden */
  109509. _getGlAlgorithmType(algorithmType: number): number;
  109510. /** @hidden */
  109511. _getTimeQueryResult(query: WebGLQuery): any;
  109512. /** @hidden */
  109513. _getTimeQueryAvailability(query: WebGLQuery): any;
  109514. }
  109515. interface AbstractMesh {
  109516. /**
  109517. * Backing filed
  109518. * @hidden
  109519. */
  109520. __occlusionDataStorage: _OcclusionDataStorage;
  109521. /**
  109522. * Access property
  109523. * @hidden
  109524. */
  109525. _occlusionDataStorage: _OcclusionDataStorage;
  109526. /**
  109527. * 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.
  109528. * The default value is -1 which means don't break the query and wait till the result
  109529. * @see http://doc.babylonjs.com/features/occlusionquery
  109530. */
  109531. occlusionRetryCount: number;
  109532. /**
  109533. * 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:
  109534. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  109535. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  109536. * * 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.
  109537. * @see http://doc.babylonjs.com/features/occlusionquery
  109538. */
  109539. occlusionType: number;
  109540. /**
  109541. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  109542. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  109543. * * 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.
  109544. * @see http://doc.babylonjs.com/features/occlusionquery
  109545. */
  109546. occlusionQueryAlgorithmType: number;
  109547. /**
  109548. * 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
  109549. * @see http://doc.babylonjs.com/features/occlusionquery
  109550. */
  109551. isOccluded: boolean;
  109552. /**
  109553. * Flag to check the progress status of the query
  109554. * @see http://doc.babylonjs.com/features/occlusionquery
  109555. */
  109556. isOcclusionQueryInProgress: boolean;
  109557. }
  109558. }
  109559. declare module BABYLON {
  109560. /** @hidden */
  109561. export var _forceTransformFeedbackToBundle: boolean;
  109562. interface Engine {
  109563. /**
  109564. * Creates a webGL transform feedback object
  109565. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  109566. * @returns the webGL transform feedback object
  109567. */
  109568. createTransformFeedback(): WebGLTransformFeedback;
  109569. /**
  109570. * Delete a webGL transform feedback object
  109571. * @param value defines the webGL transform feedback object to delete
  109572. */
  109573. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  109574. /**
  109575. * Bind a webGL transform feedback object to the webgl context
  109576. * @param value defines the webGL transform feedback object to bind
  109577. */
  109578. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  109579. /**
  109580. * Begins a transform feedback operation
  109581. * @param usePoints defines if points or triangles must be used
  109582. */
  109583. beginTransformFeedback(usePoints: boolean): void;
  109584. /**
  109585. * Ends a transform feedback operation
  109586. */
  109587. endTransformFeedback(): void;
  109588. /**
  109589. * Specify the varyings to use with transform feedback
  109590. * @param program defines the associated webGL program
  109591. * @param value defines the list of strings representing the varying names
  109592. */
  109593. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  109594. /**
  109595. * Bind a webGL buffer for a transform feedback operation
  109596. * @param value defines the webGL buffer to bind
  109597. */
  109598. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  109599. }
  109600. }
  109601. declare module BABYLON {
  109602. /**
  109603. * Creation options of the multi render target texture.
  109604. */
  109605. export interface IMultiRenderTargetOptions {
  109606. /**
  109607. * Define if the texture needs to create mip maps after render.
  109608. */
  109609. generateMipMaps?: boolean;
  109610. /**
  109611. * Define the types of all the draw buffers we want to create
  109612. */
  109613. types?: number[];
  109614. /**
  109615. * Define the sampling modes of all the draw buffers we want to create
  109616. */
  109617. samplingModes?: number[];
  109618. /**
  109619. * Define if a depth buffer is required
  109620. */
  109621. generateDepthBuffer?: boolean;
  109622. /**
  109623. * Define if a stencil buffer is required
  109624. */
  109625. generateStencilBuffer?: boolean;
  109626. /**
  109627. * Define if a depth texture is required instead of a depth buffer
  109628. */
  109629. generateDepthTexture?: boolean;
  109630. /**
  109631. * Define the number of desired draw buffers
  109632. */
  109633. textureCount?: number;
  109634. /**
  109635. * Define if aspect ratio should be adapted to the texture or stay the scene one
  109636. */
  109637. doNotChangeAspectRatio?: boolean;
  109638. /**
  109639. * Define the default type of the buffers we are creating
  109640. */
  109641. defaultType?: number;
  109642. }
  109643. /**
  109644. * A multi render target, like a render target provides the ability to render to a texture.
  109645. * Unlike the render target, it can render to several draw buffers in one draw.
  109646. * This is specially interesting in deferred rendering or for any effects requiring more than
  109647. * just one color from a single pass.
  109648. */
  109649. export class MultiRenderTarget extends RenderTargetTexture {
  109650. private _internalTextures;
  109651. private _textures;
  109652. private _multiRenderTargetOptions;
  109653. /**
  109654. * Get if draw buffers are currently supported by the used hardware and browser.
  109655. */
  109656. readonly isSupported: boolean;
  109657. /**
  109658. * Get the list of textures generated by the multi render target.
  109659. */
  109660. readonly textures: Texture[];
  109661. /**
  109662. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  109663. */
  109664. readonly depthTexture: Texture;
  109665. /**
  109666. * Set the wrapping mode on U of all the textures we are rendering to.
  109667. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109668. */
  109669. wrapU: number;
  109670. /**
  109671. * Set the wrapping mode on V of all the textures we are rendering to.
  109672. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109673. */
  109674. wrapV: number;
  109675. /**
  109676. * Instantiate a new multi render target texture.
  109677. * A multi render target, like a render target provides the ability to render to a texture.
  109678. * Unlike the render target, it can render to several draw buffers in one draw.
  109679. * This is specially interesting in deferred rendering or for any effects requiring more than
  109680. * just one color from a single pass.
  109681. * @param name Define the name of the texture
  109682. * @param size Define the size of the buffers to render to
  109683. * @param count Define the number of target we are rendering into
  109684. * @param scene Define the scene the texture belongs to
  109685. * @param options Define the options used to create the multi render target
  109686. */
  109687. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  109688. /** @hidden */
  109689. _rebuild(): void;
  109690. private _createInternalTextures;
  109691. private _createTextures;
  109692. /**
  109693. * Define the number of samples used if MSAA is enabled.
  109694. */
  109695. samples: number;
  109696. /**
  109697. * Resize all the textures in the multi render target.
  109698. * Be carrefull as it will recreate all the data in the new texture.
  109699. * @param size Define the new size
  109700. */
  109701. resize(size: any): void;
  109702. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  109703. /**
  109704. * Dispose the render targets and their associated resources
  109705. */
  109706. dispose(): void;
  109707. /**
  109708. * Release all the underlying texture used as draw buffers.
  109709. */
  109710. releaseInternalTextures(): void;
  109711. }
  109712. }
  109713. declare module BABYLON {
  109714. interface Engine {
  109715. /**
  109716. * Unbind a list of render target textures from the webGL context
  109717. * This is used only when drawBuffer extension or webGL2 are active
  109718. * @param textures defines the render target textures to unbind
  109719. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  109720. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  109721. */
  109722. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  109723. /**
  109724. * Create a multi render target texture
  109725. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  109726. * @param size defines the size of the texture
  109727. * @param options defines the creation options
  109728. * @returns the cube texture as an InternalTexture
  109729. */
  109730. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  109731. /**
  109732. * Update the sample count for a given multiple render target texture
  109733. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  109734. * @param textures defines the textures to update
  109735. * @param samples defines the sample count to set
  109736. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  109737. */
  109738. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  109739. }
  109740. }
  109741. declare module BABYLON {
  109742. /** @hidden */
  109743. export var rgbdEncodePixelShader: {
  109744. name: string;
  109745. shader: string;
  109746. };
  109747. }
  109748. declare module BABYLON {
  109749. /** @hidden */
  109750. export var rgbdDecodePixelShader: {
  109751. name: string;
  109752. shader: string;
  109753. };
  109754. }
  109755. declare module BABYLON {
  109756. /**
  109757. * Raw texture data and descriptor sufficient for WebGL texture upload
  109758. */
  109759. export interface EnvironmentTextureInfo {
  109760. /**
  109761. * Version of the environment map
  109762. */
  109763. version: number;
  109764. /**
  109765. * Width of image
  109766. */
  109767. width: number;
  109768. /**
  109769. * Irradiance information stored in the file.
  109770. */
  109771. irradiance: any;
  109772. /**
  109773. * Specular information stored in the file.
  109774. */
  109775. specular: any;
  109776. }
  109777. /**
  109778. * Defines One Image in the file. It requires only the position in the file
  109779. * as well as the length.
  109780. */
  109781. interface BufferImageData {
  109782. /**
  109783. * Length of the image data.
  109784. */
  109785. length: number;
  109786. /**
  109787. * Position of the data from the null terminator delimiting the end of the JSON.
  109788. */
  109789. position: number;
  109790. }
  109791. /**
  109792. * Defines the specular data enclosed in the file.
  109793. * This corresponds to the version 1 of the data.
  109794. */
  109795. export interface EnvironmentTextureSpecularInfoV1 {
  109796. /**
  109797. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  109798. */
  109799. specularDataPosition?: number;
  109800. /**
  109801. * This contains all the images data needed to reconstruct the cubemap.
  109802. */
  109803. mipmaps: Array<BufferImageData>;
  109804. /**
  109805. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  109806. */
  109807. lodGenerationScale: number;
  109808. }
  109809. /**
  109810. * Sets of helpers addressing the serialization and deserialization of environment texture
  109811. * stored in a BabylonJS env file.
  109812. * Those files are usually stored as .env files.
  109813. */
  109814. export class EnvironmentTextureTools {
  109815. /**
  109816. * Magic number identifying the env file.
  109817. */
  109818. private static _MagicBytes;
  109819. /**
  109820. * Gets the environment info from an env file.
  109821. * @param data The array buffer containing the .env bytes.
  109822. * @returns the environment file info (the json header) if successfully parsed.
  109823. */
  109824. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109825. /**
  109826. * Creates an environment texture from a loaded cube texture.
  109827. * @param texture defines the cube texture to convert in env file
  109828. * @return a promise containing the environment data if succesfull.
  109829. */
  109830. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109831. /**
  109832. * Creates a JSON representation of the spherical data.
  109833. * @param texture defines the texture containing the polynomials
  109834. * @return the JSON representation of the spherical info
  109835. */
  109836. private static _CreateEnvTextureIrradiance;
  109837. /**
  109838. * Creates the ArrayBufferViews used for initializing environment texture image data.
  109839. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  109840. * @param info parameters that determine what views will be created for accessing the underlying buffer
  109841. * @return the views described by info providing access to the underlying buffer
  109842. */
  109843. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  109844. /**
  109845. * Uploads the texture info contained in the env file to the GPU.
  109846. * @param texture defines the internal texture to upload to
  109847. * @param arrayBuffer defines the buffer cotaining the data to load
  109848. * @param info defines the texture info retrieved through the GetEnvInfo method
  109849. * @returns a promise
  109850. */
  109851. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109852. /**
  109853. * Uploads the levels of image data to the GPU.
  109854. * @param texture defines the internal texture to upload to
  109855. * @param imageData defines the array buffer views of image data [mipmap][face]
  109856. * @returns a promise
  109857. */
  109858. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109859. /**
  109860. * Uploads spherical polynomials information to the texture.
  109861. * @param texture defines the texture we are trying to upload the information to
  109862. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109863. */
  109864. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109865. /** @hidden */
  109866. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109867. }
  109868. }
  109869. declare module BABYLON {
  109870. /**
  109871. * Contains position and normal vectors for a vertex
  109872. */
  109873. export class PositionNormalVertex {
  109874. /** the position of the vertex (defaut: 0,0,0) */
  109875. position: Vector3;
  109876. /** the normal of the vertex (defaut: 0,1,0) */
  109877. normal: Vector3;
  109878. /**
  109879. * Creates a PositionNormalVertex
  109880. * @param position the position of the vertex (defaut: 0,0,0)
  109881. * @param normal the normal of the vertex (defaut: 0,1,0)
  109882. */
  109883. constructor(
  109884. /** the position of the vertex (defaut: 0,0,0) */
  109885. position?: Vector3,
  109886. /** the normal of the vertex (defaut: 0,1,0) */
  109887. normal?: Vector3);
  109888. /**
  109889. * Clones the PositionNormalVertex
  109890. * @returns the cloned PositionNormalVertex
  109891. */
  109892. clone(): PositionNormalVertex;
  109893. }
  109894. /**
  109895. * Contains position, normal and uv vectors for a vertex
  109896. */
  109897. export class PositionNormalTextureVertex {
  109898. /** the position of the vertex (defaut: 0,0,0) */
  109899. position: Vector3;
  109900. /** the normal of the vertex (defaut: 0,1,0) */
  109901. normal: Vector3;
  109902. /** the uv of the vertex (default: 0,0) */
  109903. uv: Vector2;
  109904. /**
  109905. * Creates a PositionNormalTextureVertex
  109906. * @param position the position of the vertex (defaut: 0,0,0)
  109907. * @param normal the normal of the vertex (defaut: 0,1,0)
  109908. * @param uv the uv of the vertex (default: 0,0)
  109909. */
  109910. constructor(
  109911. /** the position of the vertex (defaut: 0,0,0) */
  109912. position?: Vector3,
  109913. /** the normal of the vertex (defaut: 0,1,0) */
  109914. normal?: Vector3,
  109915. /** the uv of the vertex (default: 0,0) */
  109916. uv?: Vector2);
  109917. /**
  109918. * Clones the PositionNormalTextureVertex
  109919. * @returns the cloned PositionNormalTextureVertex
  109920. */
  109921. clone(): PositionNormalTextureVertex;
  109922. }
  109923. }
  109924. declare module BABYLON {
  109925. /** @hidden */
  109926. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  109927. private _genericAttributeLocation;
  109928. private _varyingLocationCount;
  109929. private _varyingLocationMap;
  109930. private _replacements;
  109931. private _textureCount;
  109932. private _uniforms;
  109933. lineProcessor(line: string): string;
  109934. attributeProcessor(attribute: string): string;
  109935. varyingProcessor(varying: string, isFragment: boolean): string;
  109936. uniformProcessor(uniform: string): string;
  109937. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  109938. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  109939. }
  109940. }
  109941. declare module BABYLON {
  109942. /**
  109943. * Container for accessors for natively-stored mesh data buffers.
  109944. */
  109945. class NativeDataBuffer extends DataBuffer {
  109946. /**
  109947. * Accessor value used to identify/retrieve a natively-stored index buffer.
  109948. */
  109949. nativeIndexBuffer?: any;
  109950. /**
  109951. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  109952. */
  109953. nativeVertexBuffer?: any;
  109954. }
  109955. /** @hidden */
  109956. export class NativeEngine extends Engine {
  109957. private readonly _native;
  109958. getHardwareScalingLevel(): number;
  109959. constructor();
  109960. /**
  109961. * Can be used to override the current requestAnimationFrame requester.
  109962. * @hidden
  109963. */
  109964. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  109965. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109966. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  109967. createVertexBuffer(data: DataArray): NativeDataBuffer;
  109968. recordVertexArrayObject(vertexBuffers: {
  109969. [key: string]: VertexBuffer;
  109970. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  109971. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  109972. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  109973. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109974. /**
  109975. * Draw a list of indexed primitives
  109976. * @param fillMode defines the primitive to use
  109977. * @param indexStart defines the starting index
  109978. * @param indexCount defines the number of index to draw
  109979. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109980. */
  109981. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  109982. /**
  109983. * Draw a list of unindexed primitives
  109984. * @param fillMode defines the primitive to use
  109985. * @param verticesStart defines the index of first vertex to draw
  109986. * @param verticesCount defines the count of vertices to draw
  109987. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109988. */
  109989. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  109990. createPipelineContext(): IPipelineContext;
  109991. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  109992. /** @hidden */
  109993. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  109994. /** @hidden */
  109995. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  109996. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  109997. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  109998. protected _setProgram(program: WebGLProgram): void;
  109999. _releaseEffect(effect: Effect): void;
  110000. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  110001. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  110002. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  110003. bindSamplers(effect: Effect): void;
  110004. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  110005. getRenderWidth(useScreen?: boolean): number;
  110006. getRenderHeight(useScreen?: boolean): number;
  110007. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  110008. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110009. /**
  110010. * Set the z offset to apply to current rendering
  110011. * @param value defines the offset to apply
  110012. */
  110013. setZOffset(value: number): void;
  110014. /**
  110015. * Gets the current value of the zOffset
  110016. * @returns the current zOffset state
  110017. */
  110018. getZOffset(): number;
  110019. /**
  110020. * Enable or disable depth buffering
  110021. * @param enable defines the state to set
  110022. */
  110023. setDepthBuffer(enable: boolean): void;
  110024. /**
  110025. * Gets a boolean indicating if depth writing is enabled
  110026. * @returns the current depth writing state
  110027. */
  110028. getDepthWrite(): boolean;
  110029. /**
  110030. * Enable or disable depth writing
  110031. * @param enable defines the state to set
  110032. */
  110033. setDepthWrite(enable: boolean): void;
  110034. /**
  110035. * Enable or disable color writing
  110036. * @param enable defines the state to set
  110037. */
  110038. setColorWrite(enable: boolean): void;
  110039. /**
  110040. * Gets a boolean indicating if color writing is enabled
  110041. * @returns the current color writing state
  110042. */
  110043. getColorWrite(): boolean;
  110044. /**
  110045. * Sets alpha constants used by some alpha blending modes
  110046. * @param r defines the red component
  110047. * @param g defines the green component
  110048. * @param b defines the blue component
  110049. * @param a defines the alpha component
  110050. */
  110051. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  110052. /**
  110053. * Sets the current alpha mode
  110054. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  110055. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  110056. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110057. */
  110058. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  110059. /**
  110060. * Gets the current alpha mode
  110061. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110062. * @returns the current alpha mode
  110063. */
  110064. getAlphaMode(): number;
  110065. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  110066. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  110067. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  110068. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  110069. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  110070. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  110071. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  110072. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  110073. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  110074. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  110075. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  110076. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  110077. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  110078. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110079. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110080. setFloat(uniform: WebGLUniformLocation, value: number): void;
  110081. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  110082. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  110083. setBool(uniform: WebGLUniformLocation, bool: number): void;
  110084. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  110085. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  110086. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  110087. wipeCaches(bruteForce?: boolean): void;
  110088. _createTexture(): WebGLTexture;
  110089. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  110090. /**
  110091. * Usually called from BABYLON.Texture.ts.
  110092. * Passed information to create a WebGLTexture
  110093. * @param urlArg defines a value which contains one of the following:
  110094. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  110095. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  110096. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  110097. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110098. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  110099. * @param scene needed for loading to the correct scene
  110100. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  110101. * @param onLoad optional callback to be called upon successful completion
  110102. * @param onError optional callback to be called upon failure
  110103. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  110104. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110105. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110106. * @param forcedExtension defines the extension to use to pick the right loader
  110107. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110108. */
  110109. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  110110. /**
  110111. * Creates a cube texture
  110112. * @param rootUrl defines the url where the files to load is located
  110113. * @param scene defines the current scene
  110114. * @param files defines the list of files to load (1 per face)
  110115. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  110116. * @param onLoad defines an optional callback raised when the texture is loaded
  110117. * @param onError defines an optional callback raised if there is an issue to load the texture
  110118. * @param format defines the format of the data
  110119. * @param forcedExtension defines the extension to use to pick the right loader
  110120. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  110121. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  110122. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  110123. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  110124. * @returns the cube texture as an InternalTexture
  110125. */
  110126. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  110127. private _getSamplingFilter;
  110128. private static _GetNativeTextureFormat;
  110129. createRenderTargetTexture(size: number | {
  110130. width: number;
  110131. height: number;
  110132. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110133. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110134. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110135. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110136. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  110137. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  110138. /**
  110139. * Updates a dynamic vertex buffer.
  110140. * @param vertexBuffer the vertex buffer to update
  110141. * @param data the data used to update the vertex buffer
  110142. * @param byteOffset the byte offset of the data (optional)
  110143. * @param byteLength the byte length of the data (optional)
  110144. */
  110145. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  110146. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  110147. private _updateAnisotropicLevel;
  110148. private _getAddressMode;
  110149. /** @hidden */
  110150. _bindTexture(channel: number, texture: InternalTexture): void;
  110151. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  110152. releaseEffects(): void;
  110153. /** @hidden */
  110154. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110155. /** @hidden */
  110156. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110157. /** @hidden */
  110158. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110159. /** @hidden */
  110160. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110161. }
  110162. }
  110163. declare module BABYLON {
  110164. /**
  110165. * Gather the list of clipboard event types as constants.
  110166. */
  110167. export class ClipboardEventTypes {
  110168. /**
  110169. * The clipboard event is fired when a copy command is active (pressed).
  110170. */
  110171. static readonly COPY: number;
  110172. /**
  110173. * The clipboard event is fired when a cut command is active (pressed).
  110174. */
  110175. static readonly CUT: number;
  110176. /**
  110177. * The clipboard event is fired when a paste command is active (pressed).
  110178. */
  110179. static readonly PASTE: number;
  110180. }
  110181. /**
  110182. * This class is used to store clipboard related info for the onClipboardObservable event.
  110183. */
  110184. export class ClipboardInfo {
  110185. /**
  110186. * Defines the type of event (BABYLON.ClipboardEventTypes)
  110187. */
  110188. type: number;
  110189. /**
  110190. * Defines the related dom event
  110191. */
  110192. event: ClipboardEvent;
  110193. /**
  110194. *Creates an instance of ClipboardInfo.
  110195. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  110196. * @param event Defines the related dom event
  110197. */
  110198. constructor(
  110199. /**
  110200. * Defines the type of event (BABYLON.ClipboardEventTypes)
  110201. */
  110202. type: number,
  110203. /**
  110204. * Defines the related dom event
  110205. */
  110206. event: ClipboardEvent);
  110207. /**
  110208. * Get the clipboard event's type from the keycode.
  110209. * @param keyCode Defines the keyCode for the current keyboard event.
  110210. * @return {number}
  110211. */
  110212. static GetTypeFromCharacter(keyCode: number): number;
  110213. }
  110214. }
  110215. declare module BABYLON {
  110216. /**
  110217. * Google Daydream controller
  110218. */
  110219. export class DaydreamController extends WebVRController {
  110220. /**
  110221. * Base Url for the controller model.
  110222. */
  110223. static MODEL_BASE_URL: string;
  110224. /**
  110225. * File name for the controller model.
  110226. */
  110227. static MODEL_FILENAME: string;
  110228. /**
  110229. * Gamepad Id prefix used to identify Daydream Controller.
  110230. */
  110231. static readonly GAMEPAD_ID_PREFIX: string;
  110232. /**
  110233. * Creates a new DaydreamController from a gamepad
  110234. * @param vrGamepad the gamepad that the controller should be created from
  110235. */
  110236. constructor(vrGamepad: any);
  110237. /**
  110238. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110239. * @param scene scene in which to add meshes
  110240. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110241. */
  110242. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110243. /**
  110244. * Called once for each button that changed state since the last frame
  110245. * @param buttonIdx Which button index changed
  110246. * @param state New state of the button
  110247. * @param changes Which properties on the state changed since last frame
  110248. */
  110249. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110250. }
  110251. }
  110252. declare module BABYLON {
  110253. /**
  110254. * Gear VR Controller
  110255. */
  110256. export class GearVRController extends WebVRController {
  110257. /**
  110258. * Base Url for the controller model.
  110259. */
  110260. static MODEL_BASE_URL: string;
  110261. /**
  110262. * File name for the controller model.
  110263. */
  110264. static MODEL_FILENAME: string;
  110265. /**
  110266. * Gamepad Id prefix used to identify this controller.
  110267. */
  110268. static readonly GAMEPAD_ID_PREFIX: string;
  110269. private readonly _buttonIndexToObservableNameMap;
  110270. /**
  110271. * Creates a new GearVRController from a gamepad
  110272. * @param vrGamepad the gamepad that the controller should be created from
  110273. */
  110274. constructor(vrGamepad: any);
  110275. /**
  110276. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110277. * @param scene scene in which to add meshes
  110278. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110279. */
  110280. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110281. /**
  110282. * Called once for each button that changed state since the last frame
  110283. * @param buttonIdx Which button index changed
  110284. * @param state New state of the button
  110285. * @param changes Which properties on the state changed since last frame
  110286. */
  110287. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110288. }
  110289. }
  110290. declare module BABYLON {
  110291. /**
  110292. * Class containing static functions to help procedurally build meshes
  110293. */
  110294. export class PolyhedronBuilder {
  110295. /**
  110296. * Creates a polyhedron mesh
  110297. * * 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
  110298. * * The parameter `size` (positive float, default 1) sets the polygon size
  110299. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110300. * * 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`
  110301. * * 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
  110302. * * 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)`)
  110303. * * 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
  110304. * * 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
  110305. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110306. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110308. * @param name defines the name of the mesh
  110309. * @param options defines the options used to create the mesh
  110310. * @param scene defines the hosting scene
  110311. * @returns the polyhedron mesh
  110312. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110313. */
  110314. static CreatePolyhedron(name: string, options: {
  110315. type?: number;
  110316. size?: number;
  110317. sizeX?: number;
  110318. sizeY?: number;
  110319. sizeZ?: number;
  110320. custom?: any;
  110321. faceUV?: Vector4[];
  110322. faceColors?: Color4[];
  110323. flat?: boolean;
  110324. updatable?: boolean;
  110325. sideOrientation?: number;
  110326. frontUVs?: Vector4;
  110327. backUVs?: Vector4;
  110328. }, scene?: Nullable<Scene>): Mesh;
  110329. }
  110330. }
  110331. declare module BABYLON {
  110332. /**
  110333. * Gizmo that enables scaling a mesh along 3 axis
  110334. */
  110335. export class ScaleGizmo extends Gizmo {
  110336. /**
  110337. * Internal gizmo used for interactions on the x axis
  110338. */
  110339. xGizmo: AxisScaleGizmo;
  110340. /**
  110341. * Internal gizmo used for interactions on the y axis
  110342. */
  110343. yGizmo: AxisScaleGizmo;
  110344. /**
  110345. * Internal gizmo used for interactions on the z axis
  110346. */
  110347. zGizmo: AxisScaleGizmo;
  110348. /**
  110349. * Internal gizmo used to scale all axis equally
  110350. */
  110351. uniformScaleGizmo: AxisScaleGizmo;
  110352. private _meshAttached;
  110353. private _updateGizmoRotationToMatchAttachedMesh;
  110354. private _snapDistance;
  110355. private _scaleRatio;
  110356. private _uniformScalingMesh;
  110357. private _octahedron;
  110358. /** Fires an event when any of it's sub gizmos are dragged */
  110359. onDragStartObservable: Observable<unknown>;
  110360. /** Fires an event when any of it's sub gizmos are released from dragging */
  110361. onDragEndObservable: Observable<unknown>;
  110362. attachedMesh: Nullable<AbstractMesh>;
  110363. /**
  110364. * Creates a ScaleGizmo
  110365. * @param gizmoLayer The utility layer the gizmo will be added to
  110366. */
  110367. constructor(gizmoLayer?: UtilityLayerRenderer);
  110368. updateGizmoRotationToMatchAttachedMesh: boolean;
  110369. /**
  110370. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110371. */
  110372. snapDistance: number;
  110373. /**
  110374. * Ratio for the scale of the gizmo (Default: 1)
  110375. */
  110376. scaleRatio: number;
  110377. /**
  110378. * Disposes of the gizmo
  110379. */
  110380. dispose(): void;
  110381. }
  110382. }
  110383. declare module BABYLON {
  110384. /**
  110385. * Single axis scale gizmo
  110386. */
  110387. export class AxisScaleGizmo extends Gizmo {
  110388. /**
  110389. * Drag behavior responsible for the gizmos dragging interactions
  110390. */
  110391. dragBehavior: PointerDragBehavior;
  110392. private _pointerObserver;
  110393. /**
  110394. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110395. */
  110396. snapDistance: number;
  110397. /**
  110398. * Event that fires each time the gizmo snaps to a new location.
  110399. * * snapDistance is the the change in distance
  110400. */
  110401. onSnapObservable: Observable<{
  110402. snapDistance: number;
  110403. }>;
  110404. /**
  110405. * If the scaling operation should be done on all axis (default: false)
  110406. */
  110407. uniformScaling: boolean;
  110408. private _isEnabled;
  110409. private _parent;
  110410. private _arrow;
  110411. private _coloredMaterial;
  110412. private _hoverMaterial;
  110413. /**
  110414. * Creates an AxisScaleGizmo
  110415. * @param gizmoLayer The utility layer the gizmo will be added to
  110416. * @param dragAxis The axis which the gizmo will be able to scale on
  110417. * @param color The color of the gizmo
  110418. */
  110419. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  110420. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110421. /**
  110422. * If the gizmo is enabled
  110423. */
  110424. isEnabled: boolean;
  110425. /**
  110426. * Disposes of the gizmo
  110427. */
  110428. dispose(): void;
  110429. /**
  110430. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  110431. * @param mesh The mesh to replace the default mesh of the gizmo
  110432. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  110433. */
  110434. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  110435. }
  110436. }
  110437. declare module BABYLON {
  110438. /**
  110439. * Bounding box gizmo
  110440. */
  110441. export class BoundingBoxGizmo extends Gizmo {
  110442. private _lineBoundingBox;
  110443. private _rotateSpheresParent;
  110444. private _scaleBoxesParent;
  110445. private _boundingDimensions;
  110446. private _renderObserver;
  110447. private _pointerObserver;
  110448. private _scaleDragSpeed;
  110449. private _tmpQuaternion;
  110450. private _tmpVector;
  110451. private _tmpRotationMatrix;
  110452. /**
  110453. * 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)
  110454. */
  110455. ignoreChildren: boolean;
  110456. /**
  110457. * 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)
  110458. */
  110459. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  110460. /**
  110461. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  110462. */
  110463. rotationSphereSize: number;
  110464. /**
  110465. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  110466. */
  110467. scaleBoxSize: number;
  110468. /**
  110469. * 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)
  110470. */
  110471. fixedDragMeshScreenSize: boolean;
  110472. /**
  110473. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  110474. */
  110475. fixedDragMeshScreenSizeDistanceFactor: number;
  110476. /**
  110477. * Fired when a rotation sphere or scale box is dragged
  110478. */
  110479. onDragStartObservable: Observable<{}>;
  110480. /**
  110481. * Fired when a scale box is dragged
  110482. */
  110483. onScaleBoxDragObservable: Observable<{}>;
  110484. /**
  110485. * Fired when a scale box drag is ended
  110486. */
  110487. onScaleBoxDragEndObservable: Observable<{}>;
  110488. /**
  110489. * Fired when a rotation sphere is dragged
  110490. */
  110491. onRotationSphereDragObservable: Observable<{}>;
  110492. /**
  110493. * Fired when a rotation sphere drag is ended
  110494. */
  110495. onRotationSphereDragEndObservable: Observable<{}>;
  110496. /**
  110497. * 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)
  110498. */
  110499. scalePivot: Nullable<Vector3>;
  110500. /**
  110501. * Mesh used as a pivot to rotate the attached mesh
  110502. */
  110503. private _anchorMesh;
  110504. private _existingMeshScale;
  110505. private _dragMesh;
  110506. private pointerDragBehavior;
  110507. private coloredMaterial;
  110508. private hoverColoredMaterial;
  110509. /**
  110510. * Sets the color of the bounding box gizmo
  110511. * @param color the color to set
  110512. */
  110513. setColor(color: Color3): void;
  110514. /**
  110515. * Creates an BoundingBoxGizmo
  110516. * @param gizmoLayer The utility layer the gizmo will be added to
  110517. * @param color The color of the gizmo
  110518. */
  110519. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  110520. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110521. private _selectNode;
  110522. /**
  110523. * Updates the bounding box information for the Gizmo
  110524. */
  110525. updateBoundingBox(): void;
  110526. private _updateRotationSpheres;
  110527. private _updateScaleBoxes;
  110528. /**
  110529. * Enables rotation on the specified axis and disables rotation on the others
  110530. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  110531. */
  110532. setEnabledRotationAxis(axis: string): void;
  110533. /**
  110534. * Enables/disables scaling
  110535. * @param enable if scaling should be enabled
  110536. */
  110537. setEnabledScaling(enable: boolean): void;
  110538. private _updateDummy;
  110539. /**
  110540. * Enables a pointer drag behavior on the bounding box of the gizmo
  110541. */
  110542. enableDragBehavior(): void;
  110543. /**
  110544. * Disposes of the gizmo
  110545. */
  110546. dispose(): void;
  110547. /**
  110548. * 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)
  110549. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  110550. * @returns the bounding box mesh with the passed in mesh as a child
  110551. */
  110552. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  110553. /**
  110554. * CustomMeshes are not supported by this gizmo
  110555. * @param mesh The mesh to replace the default mesh of the gizmo
  110556. */
  110557. setCustomMesh(mesh: Mesh): void;
  110558. }
  110559. }
  110560. declare module BABYLON {
  110561. /**
  110562. * Single plane rotation gizmo
  110563. */
  110564. export class PlaneRotationGizmo extends Gizmo {
  110565. /**
  110566. * Drag behavior responsible for the gizmos dragging interactions
  110567. */
  110568. dragBehavior: PointerDragBehavior;
  110569. private _pointerObserver;
  110570. /**
  110571. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  110572. */
  110573. snapDistance: number;
  110574. /**
  110575. * Event that fires each time the gizmo snaps to a new location.
  110576. * * snapDistance is the the change in distance
  110577. */
  110578. onSnapObservable: Observable<{
  110579. snapDistance: number;
  110580. }>;
  110581. private _isEnabled;
  110582. private _parent;
  110583. /**
  110584. * Creates a PlaneRotationGizmo
  110585. * @param gizmoLayer The utility layer the gizmo will be added to
  110586. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  110587. * @param color The color of the gizmo
  110588. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110589. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110590. */
  110591. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  110592. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110593. /**
  110594. * If the gizmo is enabled
  110595. */
  110596. isEnabled: boolean;
  110597. /**
  110598. * Disposes of the gizmo
  110599. */
  110600. dispose(): void;
  110601. }
  110602. }
  110603. declare module BABYLON {
  110604. /**
  110605. * Gizmo that enables rotating a mesh along 3 axis
  110606. */
  110607. export class RotationGizmo extends Gizmo {
  110608. /**
  110609. * Internal gizmo used for interactions on the x axis
  110610. */
  110611. xGizmo: PlaneRotationGizmo;
  110612. /**
  110613. * Internal gizmo used for interactions on the y axis
  110614. */
  110615. yGizmo: PlaneRotationGizmo;
  110616. /**
  110617. * Internal gizmo used for interactions on the z axis
  110618. */
  110619. zGizmo: PlaneRotationGizmo;
  110620. /** Fires an event when any of it's sub gizmos are dragged */
  110621. onDragStartObservable: Observable<unknown>;
  110622. /** Fires an event when any of it's sub gizmos are released from dragging */
  110623. onDragEndObservable: Observable<unknown>;
  110624. private _meshAttached;
  110625. attachedMesh: Nullable<AbstractMesh>;
  110626. /**
  110627. * Creates a RotationGizmo
  110628. * @param gizmoLayer The utility layer the gizmo will be added to
  110629. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110630. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110631. */
  110632. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  110633. updateGizmoRotationToMatchAttachedMesh: boolean;
  110634. /**
  110635. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110636. */
  110637. snapDistance: number;
  110638. /**
  110639. * Ratio for the scale of the gizmo (Default: 1)
  110640. */
  110641. scaleRatio: number;
  110642. /**
  110643. * Disposes of the gizmo
  110644. */
  110645. dispose(): void;
  110646. /**
  110647. * CustomMeshes are not supported by this gizmo
  110648. * @param mesh The mesh to replace the default mesh of the gizmo
  110649. */
  110650. setCustomMesh(mesh: Mesh): void;
  110651. }
  110652. }
  110653. declare module BABYLON {
  110654. /**
  110655. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  110656. */
  110657. export class GizmoManager implements IDisposable {
  110658. private scene;
  110659. /**
  110660. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  110661. */
  110662. gizmos: {
  110663. positionGizmo: Nullable<PositionGizmo>;
  110664. rotationGizmo: Nullable<RotationGizmo>;
  110665. scaleGizmo: Nullable<ScaleGizmo>;
  110666. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  110667. };
  110668. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  110669. clearGizmoOnEmptyPointerEvent: boolean;
  110670. /** Fires an event when the manager is attached to a mesh */
  110671. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  110672. private _gizmosEnabled;
  110673. private _pointerObserver;
  110674. private _attachedMesh;
  110675. private _boundingBoxColor;
  110676. private _defaultUtilityLayer;
  110677. private _defaultKeepDepthUtilityLayer;
  110678. /**
  110679. * When bounding box gizmo is enabled, this can be used to track drag/end events
  110680. */
  110681. boundingBoxDragBehavior: SixDofDragBehavior;
  110682. /**
  110683. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  110684. */
  110685. attachableMeshes: Nullable<Array<AbstractMesh>>;
  110686. /**
  110687. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  110688. */
  110689. usePointerToAttachGizmos: boolean;
  110690. /**
  110691. * Utility layer that the bounding box gizmo belongs to
  110692. */
  110693. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  110694. /**
  110695. * Utility layer that all gizmos besides bounding box belong to
  110696. */
  110697. readonly utilityLayer: UtilityLayerRenderer;
  110698. /**
  110699. * Instatiates a gizmo manager
  110700. * @param scene the scene to overlay the gizmos on top of
  110701. */
  110702. constructor(scene: Scene);
  110703. /**
  110704. * Attaches a set of gizmos to the specified mesh
  110705. * @param mesh The mesh the gizmo's should be attached to
  110706. */
  110707. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  110708. /**
  110709. * If the position gizmo is enabled
  110710. */
  110711. positionGizmoEnabled: boolean;
  110712. /**
  110713. * If the rotation gizmo is enabled
  110714. */
  110715. rotationGizmoEnabled: boolean;
  110716. /**
  110717. * If the scale gizmo is enabled
  110718. */
  110719. scaleGizmoEnabled: boolean;
  110720. /**
  110721. * If the boundingBox gizmo is enabled
  110722. */
  110723. boundingBoxGizmoEnabled: boolean;
  110724. /**
  110725. * Disposes of the gizmo manager
  110726. */
  110727. dispose(): void;
  110728. }
  110729. }
  110730. declare module BABYLON {
  110731. /**
  110732. * A directional light is defined by a direction (what a surprise!).
  110733. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  110734. * 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.
  110735. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110736. */
  110737. export class DirectionalLight extends ShadowLight {
  110738. private _shadowFrustumSize;
  110739. /**
  110740. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  110741. */
  110742. /**
  110743. * Specifies a fix frustum size for the shadow generation.
  110744. */
  110745. shadowFrustumSize: number;
  110746. private _shadowOrthoScale;
  110747. /**
  110748. * Gets the shadow projection scale against the optimal computed one.
  110749. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110750. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110751. */
  110752. /**
  110753. * Sets the shadow projection scale against the optimal computed one.
  110754. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110755. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110756. */
  110757. shadowOrthoScale: number;
  110758. /**
  110759. * Automatically compute the projection matrix to best fit (including all the casters)
  110760. * on each frame.
  110761. */
  110762. autoUpdateExtends: boolean;
  110763. private _orthoLeft;
  110764. private _orthoRight;
  110765. private _orthoTop;
  110766. private _orthoBottom;
  110767. /**
  110768. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  110769. * The directional light is emitted from everywhere in the given direction.
  110770. * It can cast shadows.
  110771. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110772. * @param name The friendly name of the light
  110773. * @param direction The direction of the light
  110774. * @param scene The scene the light belongs to
  110775. */
  110776. constructor(name: string, direction: Vector3, scene: Scene);
  110777. /**
  110778. * Returns the string "DirectionalLight".
  110779. * @return The class name
  110780. */
  110781. getClassName(): string;
  110782. /**
  110783. * Returns the integer 1.
  110784. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110785. */
  110786. getTypeID(): number;
  110787. /**
  110788. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  110789. * Returns the DirectionalLight Shadow projection matrix.
  110790. */
  110791. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110792. /**
  110793. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  110794. * Returns the DirectionalLight Shadow projection matrix.
  110795. */
  110796. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  110797. /**
  110798. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  110799. * Returns the DirectionalLight Shadow projection matrix.
  110800. */
  110801. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110802. protected _buildUniformLayout(): void;
  110803. /**
  110804. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  110805. * @param effect The effect to update
  110806. * @param lightIndex The index of the light in the effect to update
  110807. * @returns The directional light
  110808. */
  110809. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  110810. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  110811. /**
  110812. * Gets the minZ used for shadow according to both the scene and the light.
  110813. *
  110814. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110815. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110816. * @param activeCamera The camera we are returning the min for
  110817. * @returns the depth min z
  110818. */
  110819. getDepthMinZ(activeCamera: Camera): number;
  110820. /**
  110821. * Gets the maxZ used for shadow according to both the scene and the light.
  110822. *
  110823. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110824. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110825. * @param activeCamera The camera we are returning the max for
  110826. * @returns the depth max z
  110827. */
  110828. getDepthMaxZ(activeCamera: Camera): number;
  110829. /**
  110830. * Prepares the list of defines specific to the light type.
  110831. * @param defines the list of defines
  110832. * @param lightIndex defines the index of the light for the effect
  110833. */
  110834. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110835. }
  110836. }
  110837. declare module BABYLON {
  110838. /**
  110839. * Class containing static functions to help procedurally build meshes
  110840. */
  110841. export class HemisphereBuilder {
  110842. /**
  110843. * Creates a hemisphere mesh
  110844. * @param name defines the name of the mesh
  110845. * @param options defines the options used to create the mesh
  110846. * @param scene defines the hosting scene
  110847. * @returns the hemisphere mesh
  110848. */
  110849. static CreateHemisphere(name: string, options: {
  110850. segments?: number;
  110851. diameter?: number;
  110852. sideOrientation?: number;
  110853. }, scene: any): Mesh;
  110854. }
  110855. }
  110856. declare module BABYLON {
  110857. /**
  110858. * A spot light is defined by a position, a direction, an angle, and an exponent.
  110859. * These values define a cone of light starting from the position, emitting toward the direction.
  110860. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  110861. * and the exponent defines the speed of the decay of the light with distance (reach).
  110862. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110863. */
  110864. export class SpotLight extends ShadowLight {
  110865. private _angle;
  110866. private _innerAngle;
  110867. private _cosHalfAngle;
  110868. private _lightAngleScale;
  110869. private _lightAngleOffset;
  110870. /**
  110871. * Gets the cone angle of the spot light in Radians.
  110872. */
  110873. /**
  110874. * Sets the cone angle of the spot light in Radians.
  110875. */
  110876. angle: number;
  110877. /**
  110878. * Only used in gltf falloff mode, this defines the angle where
  110879. * the directional falloff will start before cutting at angle which could be seen
  110880. * as outer angle.
  110881. */
  110882. /**
  110883. * Only used in gltf falloff mode, this defines the angle where
  110884. * the directional falloff will start before cutting at angle which could be seen
  110885. * as outer angle.
  110886. */
  110887. innerAngle: number;
  110888. private _shadowAngleScale;
  110889. /**
  110890. * Allows scaling the angle of the light for shadow generation only.
  110891. */
  110892. /**
  110893. * Allows scaling the angle of the light for shadow generation only.
  110894. */
  110895. shadowAngleScale: number;
  110896. /**
  110897. * The light decay speed with the distance from the emission spot.
  110898. */
  110899. exponent: number;
  110900. private _projectionTextureMatrix;
  110901. /**
  110902. * Allows reading the projecton texture
  110903. */
  110904. readonly projectionTextureMatrix: Matrix;
  110905. protected _projectionTextureLightNear: number;
  110906. /**
  110907. * Gets the near clip of the Spotlight for texture projection.
  110908. */
  110909. /**
  110910. * Sets the near clip of the Spotlight for texture projection.
  110911. */
  110912. projectionTextureLightNear: number;
  110913. protected _projectionTextureLightFar: number;
  110914. /**
  110915. * Gets the far clip of the Spotlight for texture projection.
  110916. */
  110917. /**
  110918. * Sets the far clip of the Spotlight for texture projection.
  110919. */
  110920. projectionTextureLightFar: number;
  110921. protected _projectionTextureUpDirection: Vector3;
  110922. /**
  110923. * Gets the Up vector of the Spotlight for texture projection.
  110924. */
  110925. /**
  110926. * Sets the Up vector of the Spotlight for texture projection.
  110927. */
  110928. projectionTextureUpDirection: Vector3;
  110929. private _projectionTexture;
  110930. /**
  110931. * Gets the projection texture of the light.
  110932. */
  110933. /**
  110934. * Sets the projection texture of the light.
  110935. */
  110936. projectionTexture: Nullable<BaseTexture>;
  110937. private _projectionTextureViewLightDirty;
  110938. private _projectionTextureProjectionLightDirty;
  110939. private _projectionTextureDirty;
  110940. private _projectionTextureViewTargetVector;
  110941. private _projectionTextureViewLightMatrix;
  110942. private _projectionTextureProjectionLightMatrix;
  110943. private _projectionTextureScalingMatrix;
  110944. /**
  110945. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  110946. * It can cast shadows.
  110947. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110948. * @param name The light friendly name
  110949. * @param position The position of the spot light in the scene
  110950. * @param direction The direction of the light in the scene
  110951. * @param angle The cone angle of the light in Radians
  110952. * @param exponent The light decay speed with the distance from the emission spot
  110953. * @param scene The scene the lights belongs to
  110954. */
  110955. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  110956. /**
  110957. * Returns the string "SpotLight".
  110958. * @returns the class name
  110959. */
  110960. getClassName(): string;
  110961. /**
  110962. * Returns the integer 2.
  110963. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110964. */
  110965. getTypeID(): number;
  110966. /**
  110967. * Overrides the direction setter to recompute the projection texture view light Matrix.
  110968. */
  110969. protected _setDirection(value: Vector3): void;
  110970. /**
  110971. * Overrides the position setter to recompute the projection texture view light Matrix.
  110972. */
  110973. protected _setPosition(value: Vector3): void;
  110974. /**
  110975. * 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.
  110976. * Returns the SpotLight.
  110977. */
  110978. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110979. protected _computeProjectionTextureViewLightMatrix(): void;
  110980. protected _computeProjectionTextureProjectionLightMatrix(): void;
  110981. /**
  110982. * Main function for light texture projection matrix computing.
  110983. */
  110984. protected _computeProjectionTextureMatrix(): void;
  110985. protected _buildUniformLayout(): void;
  110986. private _computeAngleValues;
  110987. /**
  110988. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  110989. * @param effect The effect to update
  110990. * @param lightIndex The index of the light in the effect to update
  110991. * @returns The spot light
  110992. */
  110993. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  110994. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  110995. /**
  110996. * Disposes the light and the associated resources.
  110997. */
  110998. dispose(): void;
  110999. /**
  111000. * Prepares the list of defines specific to the light type.
  111001. * @param defines the list of defines
  111002. * @param lightIndex defines the index of the light for the effect
  111003. */
  111004. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111005. }
  111006. }
  111007. declare module BABYLON {
  111008. /**
  111009. * Gizmo that enables viewing a light
  111010. */
  111011. export class LightGizmo extends Gizmo {
  111012. private _lightMesh;
  111013. private _material;
  111014. private cachedPosition;
  111015. private cachedForward;
  111016. /**
  111017. * Creates a LightGizmo
  111018. * @param gizmoLayer The utility layer the gizmo will be added to
  111019. */
  111020. constructor(gizmoLayer?: UtilityLayerRenderer);
  111021. private _light;
  111022. /**
  111023. * The light that the gizmo is attached to
  111024. */
  111025. light: Nullable<Light>;
  111026. /**
  111027. * Gets the material used to render the light gizmo
  111028. */
  111029. readonly material: StandardMaterial;
  111030. /**
  111031. * @hidden
  111032. * Updates the gizmo to match the attached mesh's position/rotation
  111033. */
  111034. protected _update(): void;
  111035. private static _Scale;
  111036. /**
  111037. * Creates the lines for a light mesh
  111038. */
  111039. private static _createLightLines;
  111040. /**
  111041. * Disposes of the light gizmo
  111042. */
  111043. dispose(): void;
  111044. private static _CreateHemisphericLightMesh;
  111045. private static _CreatePointLightMesh;
  111046. private static _CreateSpotLightMesh;
  111047. private static _CreateDirectionalLightMesh;
  111048. }
  111049. }
  111050. declare module BABYLON {
  111051. /** @hidden */
  111052. export var backgroundFragmentDeclaration: {
  111053. name: string;
  111054. shader: string;
  111055. };
  111056. }
  111057. declare module BABYLON {
  111058. /** @hidden */
  111059. export var backgroundUboDeclaration: {
  111060. name: string;
  111061. shader: string;
  111062. };
  111063. }
  111064. declare module BABYLON {
  111065. /** @hidden */
  111066. export var backgroundPixelShader: {
  111067. name: string;
  111068. shader: string;
  111069. };
  111070. }
  111071. declare module BABYLON {
  111072. /** @hidden */
  111073. export var backgroundVertexDeclaration: {
  111074. name: string;
  111075. shader: string;
  111076. };
  111077. }
  111078. declare module BABYLON {
  111079. /** @hidden */
  111080. export var backgroundVertexShader: {
  111081. name: string;
  111082. shader: string;
  111083. };
  111084. }
  111085. declare module BABYLON {
  111086. /**
  111087. * Background material used to create an efficient environement around your scene.
  111088. */
  111089. export class BackgroundMaterial extends PushMaterial {
  111090. /**
  111091. * Standard reflectance value at parallel view angle.
  111092. */
  111093. static StandardReflectance0: number;
  111094. /**
  111095. * Standard reflectance value at grazing angle.
  111096. */
  111097. static StandardReflectance90: number;
  111098. protected _primaryColor: Color3;
  111099. /**
  111100. * Key light Color (multiply against the environement texture)
  111101. */
  111102. primaryColor: Color3;
  111103. protected __perceptualColor: Nullable<Color3>;
  111104. /**
  111105. * Experimental Internal Use Only.
  111106. *
  111107. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  111108. * This acts as a helper to set the primary color to a more "human friendly" value.
  111109. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  111110. * output color as close as possible from the chosen value.
  111111. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  111112. * part of lighting setup.)
  111113. */
  111114. _perceptualColor: Nullable<Color3>;
  111115. protected _primaryColorShadowLevel: float;
  111116. /**
  111117. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  111118. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  111119. */
  111120. primaryColorShadowLevel: float;
  111121. protected _primaryColorHighlightLevel: float;
  111122. /**
  111123. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  111124. * The primary color is used at the level chosen to define what the white area would look.
  111125. */
  111126. primaryColorHighlightLevel: float;
  111127. protected _reflectionTexture: Nullable<BaseTexture>;
  111128. /**
  111129. * Reflection Texture used in the material.
  111130. * Should be author in a specific way for the best result (refer to the documentation).
  111131. */
  111132. reflectionTexture: Nullable<BaseTexture>;
  111133. protected _reflectionBlur: float;
  111134. /**
  111135. * Reflection Texture level of blur.
  111136. *
  111137. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  111138. * texture twice.
  111139. */
  111140. reflectionBlur: float;
  111141. protected _diffuseTexture: Nullable<BaseTexture>;
  111142. /**
  111143. * Diffuse Texture used in the material.
  111144. * Should be author in a specific way for the best result (refer to the documentation).
  111145. */
  111146. diffuseTexture: Nullable<BaseTexture>;
  111147. protected _shadowLights: Nullable<IShadowLight[]>;
  111148. /**
  111149. * Specify the list of lights casting shadow on the material.
  111150. * All scene shadow lights will be included if null.
  111151. */
  111152. shadowLights: Nullable<IShadowLight[]>;
  111153. protected _shadowLevel: float;
  111154. /**
  111155. * Helps adjusting the shadow to a softer level if required.
  111156. * 0 means black shadows and 1 means no shadows.
  111157. */
  111158. shadowLevel: float;
  111159. protected _sceneCenter: Vector3;
  111160. /**
  111161. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  111162. * It is usually zero but might be interesting to modify according to your setup.
  111163. */
  111164. sceneCenter: Vector3;
  111165. protected _opacityFresnel: boolean;
  111166. /**
  111167. * This helps specifying that the material is falling off to the sky box at grazing angle.
  111168. * This helps ensuring a nice transition when the camera goes under the ground.
  111169. */
  111170. opacityFresnel: boolean;
  111171. protected _reflectionFresnel: boolean;
  111172. /**
  111173. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  111174. * This helps adding a mirror texture on the ground.
  111175. */
  111176. reflectionFresnel: boolean;
  111177. protected _reflectionFalloffDistance: number;
  111178. /**
  111179. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  111180. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  111181. */
  111182. reflectionFalloffDistance: number;
  111183. protected _reflectionAmount: number;
  111184. /**
  111185. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  111186. */
  111187. reflectionAmount: number;
  111188. protected _reflectionReflectance0: number;
  111189. /**
  111190. * This specifies the weight of the reflection at grazing angle.
  111191. */
  111192. reflectionReflectance0: number;
  111193. protected _reflectionReflectance90: number;
  111194. /**
  111195. * This specifies the weight of the reflection at a perpendicular point of view.
  111196. */
  111197. reflectionReflectance90: number;
  111198. /**
  111199. * Sets the reflection reflectance fresnel values according to the default standard
  111200. * empirically know to work well :-)
  111201. */
  111202. reflectionStandardFresnelWeight: number;
  111203. protected _useRGBColor: boolean;
  111204. /**
  111205. * Helps to directly use the maps channels instead of their level.
  111206. */
  111207. useRGBColor: boolean;
  111208. protected _enableNoise: boolean;
  111209. /**
  111210. * This helps reducing the banding effect that could occur on the background.
  111211. */
  111212. enableNoise: boolean;
  111213. /**
  111214. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111215. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  111216. * Recommended to be keep at 1.0 except for special cases.
  111217. */
  111218. fovMultiplier: number;
  111219. private _fovMultiplier;
  111220. /**
  111221. * Enable the FOV adjustment feature controlled by fovMultiplier.
  111222. */
  111223. useEquirectangularFOV: boolean;
  111224. private _maxSimultaneousLights;
  111225. /**
  111226. * Number of Simultaneous lights allowed on the material.
  111227. */
  111228. maxSimultaneousLights: int;
  111229. /**
  111230. * Default configuration related to image processing available in the Background Material.
  111231. */
  111232. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111233. /**
  111234. * Keep track of the image processing observer to allow dispose and replace.
  111235. */
  111236. private _imageProcessingObserver;
  111237. /**
  111238. * Attaches a new image processing configuration to the PBR Material.
  111239. * @param configuration (if null the scene configuration will be use)
  111240. */
  111241. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111242. /**
  111243. * Gets the image processing configuration used either in this material.
  111244. */
  111245. /**
  111246. * Sets the Default image processing configuration used either in the this material.
  111247. *
  111248. * If sets to null, the scene one is in use.
  111249. */
  111250. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  111251. /**
  111252. * Gets wether the color curves effect is enabled.
  111253. */
  111254. /**
  111255. * Sets wether the color curves effect is enabled.
  111256. */
  111257. cameraColorCurvesEnabled: boolean;
  111258. /**
  111259. * Gets wether the color grading effect is enabled.
  111260. */
  111261. /**
  111262. * Gets wether the color grading effect is enabled.
  111263. */
  111264. cameraColorGradingEnabled: boolean;
  111265. /**
  111266. * Gets wether tonemapping is enabled or not.
  111267. */
  111268. /**
  111269. * Sets wether tonemapping is enabled or not
  111270. */
  111271. cameraToneMappingEnabled: boolean;
  111272. /**
  111273. * The camera exposure used on this material.
  111274. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111275. * This corresponds to a photographic exposure.
  111276. */
  111277. /**
  111278. * The camera exposure used on this material.
  111279. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111280. * This corresponds to a photographic exposure.
  111281. */
  111282. cameraExposure: float;
  111283. /**
  111284. * Gets The camera contrast used on this material.
  111285. */
  111286. /**
  111287. * Sets The camera contrast used on this material.
  111288. */
  111289. cameraContrast: float;
  111290. /**
  111291. * Gets the Color Grading 2D Lookup Texture.
  111292. */
  111293. /**
  111294. * Sets the Color Grading 2D Lookup Texture.
  111295. */
  111296. cameraColorGradingTexture: Nullable<BaseTexture>;
  111297. /**
  111298. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111299. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111300. * 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;
  111301. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111302. */
  111303. /**
  111304. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111305. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111306. * 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;
  111307. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111308. */
  111309. cameraColorCurves: Nullable<ColorCurves>;
  111310. /**
  111311. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  111312. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  111313. */
  111314. switchToBGR: boolean;
  111315. private _renderTargets;
  111316. private _reflectionControls;
  111317. private _white;
  111318. private _primaryShadowColor;
  111319. private _primaryHighlightColor;
  111320. /**
  111321. * Instantiates a Background Material in the given scene
  111322. * @param name The friendly name of the material
  111323. * @param scene The scene to add the material to
  111324. */
  111325. constructor(name: string, scene: Scene);
  111326. /**
  111327. * Gets a boolean indicating that current material needs to register RTT
  111328. */
  111329. readonly hasRenderTargetTextures: boolean;
  111330. /**
  111331. * The entire material has been created in order to prevent overdraw.
  111332. * @returns false
  111333. */
  111334. needAlphaTesting(): boolean;
  111335. /**
  111336. * The entire material has been created in order to prevent overdraw.
  111337. * @returns true if blending is enable
  111338. */
  111339. needAlphaBlending(): boolean;
  111340. /**
  111341. * Checks wether the material is ready to be rendered for a given mesh.
  111342. * @param mesh The mesh to render
  111343. * @param subMesh The submesh to check against
  111344. * @param useInstances Specify wether or not the material is used with instances
  111345. * @returns true if all the dependencies are ready (Textures, Effects...)
  111346. */
  111347. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111348. /**
  111349. * Compute the primary color according to the chosen perceptual color.
  111350. */
  111351. private _computePrimaryColorFromPerceptualColor;
  111352. /**
  111353. * Compute the highlights and shadow colors according to their chosen levels.
  111354. */
  111355. private _computePrimaryColors;
  111356. /**
  111357. * Build the uniform buffer used in the material.
  111358. */
  111359. buildUniformLayout(): void;
  111360. /**
  111361. * Unbind the material.
  111362. */
  111363. unbind(): void;
  111364. /**
  111365. * Bind only the world matrix to the material.
  111366. * @param world The world matrix to bind.
  111367. */
  111368. bindOnlyWorldMatrix(world: Matrix): void;
  111369. /**
  111370. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  111371. * @param world The world matrix to bind.
  111372. * @param subMesh The submesh to bind for.
  111373. */
  111374. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111375. /**
  111376. * Checks to see if a texture is used in the material.
  111377. * @param texture - Base texture to use.
  111378. * @returns - Boolean specifying if a texture is used in the material.
  111379. */
  111380. hasTexture(texture: BaseTexture): boolean;
  111381. /**
  111382. * Dispose the material.
  111383. * @param forceDisposeEffect Force disposal of the associated effect.
  111384. * @param forceDisposeTextures Force disposal of the associated textures.
  111385. */
  111386. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111387. /**
  111388. * Clones the material.
  111389. * @param name The cloned name.
  111390. * @returns The cloned material.
  111391. */
  111392. clone(name: string): BackgroundMaterial;
  111393. /**
  111394. * Serializes the current material to its JSON representation.
  111395. * @returns The JSON representation.
  111396. */
  111397. serialize(): any;
  111398. /**
  111399. * Gets the class name of the material
  111400. * @returns "BackgroundMaterial"
  111401. */
  111402. getClassName(): string;
  111403. /**
  111404. * Parse a JSON input to create back a background material.
  111405. * @param source The JSON data to parse
  111406. * @param scene The scene to create the parsed material in
  111407. * @param rootUrl The root url of the assets the material depends upon
  111408. * @returns the instantiated BackgroundMaterial.
  111409. */
  111410. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  111411. }
  111412. }
  111413. declare module BABYLON {
  111414. /**
  111415. * Represents the different options available during the creation of
  111416. * a Environment helper.
  111417. *
  111418. * This can control the default ground, skybox and image processing setup of your scene.
  111419. */
  111420. export interface IEnvironmentHelperOptions {
  111421. /**
  111422. * Specifies wether or not to create a ground.
  111423. * True by default.
  111424. */
  111425. createGround: boolean;
  111426. /**
  111427. * Specifies the ground size.
  111428. * 15 by default.
  111429. */
  111430. groundSize: number;
  111431. /**
  111432. * The texture used on the ground for the main color.
  111433. * Comes from the BabylonJS CDN by default.
  111434. *
  111435. * Remarks: Can be either a texture or a url.
  111436. */
  111437. groundTexture: string | BaseTexture;
  111438. /**
  111439. * The color mixed in the ground texture by default.
  111440. * BabylonJS clearColor by default.
  111441. */
  111442. groundColor: Color3;
  111443. /**
  111444. * Specifies the ground opacity.
  111445. * 1 by default.
  111446. */
  111447. groundOpacity: number;
  111448. /**
  111449. * Enables the ground to receive shadows.
  111450. * True by default.
  111451. */
  111452. enableGroundShadow: boolean;
  111453. /**
  111454. * Helps preventing the shadow to be fully black on the ground.
  111455. * 0.5 by default.
  111456. */
  111457. groundShadowLevel: number;
  111458. /**
  111459. * Creates a mirror texture attach to the ground.
  111460. * false by default.
  111461. */
  111462. enableGroundMirror: boolean;
  111463. /**
  111464. * Specifies the ground mirror size ratio.
  111465. * 0.3 by default as the default kernel is 64.
  111466. */
  111467. groundMirrorSizeRatio: number;
  111468. /**
  111469. * Specifies the ground mirror blur kernel size.
  111470. * 64 by default.
  111471. */
  111472. groundMirrorBlurKernel: number;
  111473. /**
  111474. * Specifies the ground mirror visibility amount.
  111475. * 1 by default
  111476. */
  111477. groundMirrorAmount: number;
  111478. /**
  111479. * Specifies the ground mirror reflectance weight.
  111480. * This uses the standard weight of the background material to setup the fresnel effect
  111481. * of the mirror.
  111482. * 1 by default.
  111483. */
  111484. groundMirrorFresnelWeight: number;
  111485. /**
  111486. * Specifies the ground mirror Falloff distance.
  111487. * This can helps reducing the size of the reflection.
  111488. * 0 by Default.
  111489. */
  111490. groundMirrorFallOffDistance: number;
  111491. /**
  111492. * Specifies the ground mirror texture type.
  111493. * Unsigned Int by Default.
  111494. */
  111495. groundMirrorTextureType: number;
  111496. /**
  111497. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  111498. * the shown objects.
  111499. */
  111500. groundYBias: number;
  111501. /**
  111502. * Specifies wether or not to create a skybox.
  111503. * True by default.
  111504. */
  111505. createSkybox: boolean;
  111506. /**
  111507. * Specifies the skybox size.
  111508. * 20 by default.
  111509. */
  111510. skyboxSize: number;
  111511. /**
  111512. * The texture used on the skybox for the main color.
  111513. * Comes from the BabylonJS CDN by default.
  111514. *
  111515. * Remarks: Can be either a texture or a url.
  111516. */
  111517. skyboxTexture: string | BaseTexture;
  111518. /**
  111519. * The color mixed in the skybox texture by default.
  111520. * BabylonJS clearColor by default.
  111521. */
  111522. skyboxColor: Color3;
  111523. /**
  111524. * The background rotation around the Y axis of the scene.
  111525. * This helps aligning the key lights of your scene with the background.
  111526. * 0 by default.
  111527. */
  111528. backgroundYRotation: number;
  111529. /**
  111530. * Compute automatically the size of the elements to best fit with the scene.
  111531. */
  111532. sizeAuto: boolean;
  111533. /**
  111534. * Default position of the rootMesh if autoSize is not true.
  111535. */
  111536. rootPosition: Vector3;
  111537. /**
  111538. * Sets up the image processing in the scene.
  111539. * true by default.
  111540. */
  111541. setupImageProcessing: boolean;
  111542. /**
  111543. * The texture used as your environment texture in the scene.
  111544. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  111545. *
  111546. * Remarks: Can be either a texture or a url.
  111547. */
  111548. environmentTexture: string | BaseTexture;
  111549. /**
  111550. * The value of the exposure to apply to the scene.
  111551. * 0.6 by default if setupImageProcessing is true.
  111552. */
  111553. cameraExposure: number;
  111554. /**
  111555. * The value of the contrast to apply to the scene.
  111556. * 1.6 by default if setupImageProcessing is true.
  111557. */
  111558. cameraContrast: number;
  111559. /**
  111560. * Specifies wether or not tonemapping should be enabled in the scene.
  111561. * true by default if setupImageProcessing is true.
  111562. */
  111563. toneMappingEnabled: boolean;
  111564. }
  111565. /**
  111566. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  111567. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  111568. * It also helps with the default setup of your imageProcessing configuration.
  111569. */
  111570. export class EnvironmentHelper {
  111571. /**
  111572. * Default ground texture URL.
  111573. */
  111574. private static _groundTextureCDNUrl;
  111575. /**
  111576. * Default skybox texture URL.
  111577. */
  111578. private static _skyboxTextureCDNUrl;
  111579. /**
  111580. * Default environment texture URL.
  111581. */
  111582. private static _environmentTextureCDNUrl;
  111583. /**
  111584. * Creates the default options for the helper.
  111585. */
  111586. private static _getDefaultOptions;
  111587. private _rootMesh;
  111588. /**
  111589. * Gets the root mesh created by the helper.
  111590. */
  111591. readonly rootMesh: Mesh;
  111592. private _skybox;
  111593. /**
  111594. * Gets the skybox created by the helper.
  111595. */
  111596. readonly skybox: Nullable<Mesh>;
  111597. private _skyboxTexture;
  111598. /**
  111599. * Gets the skybox texture created by the helper.
  111600. */
  111601. readonly skyboxTexture: Nullable<BaseTexture>;
  111602. private _skyboxMaterial;
  111603. /**
  111604. * Gets the skybox material created by the helper.
  111605. */
  111606. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  111607. private _ground;
  111608. /**
  111609. * Gets the ground mesh created by the helper.
  111610. */
  111611. readonly ground: Nullable<Mesh>;
  111612. private _groundTexture;
  111613. /**
  111614. * Gets the ground texture created by the helper.
  111615. */
  111616. readonly groundTexture: Nullable<BaseTexture>;
  111617. private _groundMirror;
  111618. /**
  111619. * Gets the ground mirror created by the helper.
  111620. */
  111621. readonly groundMirror: Nullable<MirrorTexture>;
  111622. /**
  111623. * Gets the ground mirror render list to helps pushing the meshes
  111624. * you wish in the ground reflection.
  111625. */
  111626. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  111627. private _groundMaterial;
  111628. /**
  111629. * Gets the ground material created by the helper.
  111630. */
  111631. readonly groundMaterial: Nullable<BackgroundMaterial>;
  111632. /**
  111633. * Stores the creation options.
  111634. */
  111635. private readonly _scene;
  111636. private _options;
  111637. /**
  111638. * This observable will be notified with any error during the creation of the environment,
  111639. * mainly texture creation errors.
  111640. */
  111641. onErrorObservable: Observable<{
  111642. message?: string;
  111643. exception?: any;
  111644. }>;
  111645. /**
  111646. * constructor
  111647. * @param options Defines the options we want to customize the helper
  111648. * @param scene The scene to add the material to
  111649. */
  111650. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  111651. /**
  111652. * Updates the background according to the new options
  111653. * @param options
  111654. */
  111655. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  111656. /**
  111657. * Sets the primary color of all the available elements.
  111658. * @param color the main color to affect to the ground and the background
  111659. */
  111660. setMainColor(color: Color3): void;
  111661. /**
  111662. * Setup the image processing according to the specified options.
  111663. */
  111664. private _setupImageProcessing;
  111665. /**
  111666. * Setup the environment texture according to the specified options.
  111667. */
  111668. private _setupEnvironmentTexture;
  111669. /**
  111670. * Setup the background according to the specified options.
  111671. */
  111672. private _setupBackground;
  111673. /**
  111674. * Get the scene sizes according to the setup.
  111675. */
  111676. private _getSceneSize;
  111677. /**
  111678. * Setup the ground according to the specified options.
  111679. */
  111680. private _setupGround;
  111681. /**
  111682. * Setup the ground material according to the specified options.
  111683. */
  111684. private _setupGroundMaterial;
  111685. /**
  111686. * Setup the ground diffuse texture according to the specified options.
  111687. */
  111688. private _setupGroundDiffuseTexture;
  111689. /**
  111690. * Setup the ground mirror texture according to the specified options.
  111691. */
  111692. private _setupGroundMirrorTexture;
  111693. /**
  111694. * Setup the ground to receive the mirror texture.
  111695. */
  111696. private _setupMirrorInGroundMaterial;
  111697. /**
  111698. * Setup the skybox according to the specified options.
  111699. */
  111700. private _setupSkybox;
  111701. /**
  111702. * Setup the skybox material according to the specified options.
  111703. */
  111704. private _setupSkyboxMaterial;
  111705. /**
  111706. * Setup the skybox reflection texture according to the specified options.
  111707. */
  111708. private _setupSkyboxReflectionTexture;
  111709. private _errorHandler;
  111710. /**
  111711. * Dispose all the elements created by the Helper.
  111712. */
  111713. dispose(): void;
  111714. }
  111715. }
  111716. declare module BABYLON {
  111717. /**
  111718. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  111719. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  111720. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  111721. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  111722. */
  111723. export class PhotoDome extends TransformNode {
  111724. /**
  111725. * Define the image as a Monoscopic panoramic 360 image.
  111726. */
  111727. static readonly MODE_MONOSCOPIC: number;
  111728. /**
  111729. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111730. */
  111731. static readonly MODE_TOPBOTTOM: number;
  111732. /**
  111733. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111734. */
  111735. static readonly MODE_SIDEBYSIDE: number;
  111736. private _useDirectMapping;
  111737. /**
  111738. * The texture being displayed on the sphere
  111739. */
  111740. protected _photoTexture: Texture;
  111741. /**
  111742. * Gets or sets the texture being displayed on the sphere
  111743. */
  111744. photoTexture: Texture;
  111745. /**
  111746. * Observable raised when an error occured while loading the 360 image
  111747. */
  111748. onLoadErrorObservable: Observable<string>;
  111749. /**
  111750. * The skybox material
  111751. */
  111752. protected _material: BackgroundMaterial;
  111753. /**
  111754. * The surface used for the skybox
  111755. */
  111756. protected _mesh: Mesh;
  111757. /**
  111758. * Gets the mesh used for the skybox.
  111759. */
  111760. readonly mesh: Mesh;
  111761. /**
  111762. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111763. * Also see the options.resolution property.
  111764. */
  111765. fovMultiplier: number;
  111766. private _imageMode;
  111767. /**
  111768. * Gets or set the current video mode for the video. It can be:
  111769. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  111770. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111771. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111772. */
  111773. imageMode: number;
  111774. /**
  111775. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  111776. * @param name Element's name, child elements will append suffixes for their own names.
  111777. * @param urlsOfPhoto defines the url of the photo to display
  111778. * @param options defines an object containing optional or exposed sub element properties
  111779. * @param onError defines a callback called when an error occured while loading the texture
  111780. */
  111781. constructor(name: string, urlOfPhoto: string, options: {
  111782. resolution?: number;
  111783. size?: number;
  111784. useDirectMapping?: boolean;
  111785. faceForward?: boolean;
  111786. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  111787. private _onBeforeCameraRenderObserver;
  111788. private _changeImageMode;
  111789. /**
  111790. * Releases resources associated with this node.
  111791. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111792. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111793. */
  111794. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111795. }
  111796. }
  111797. declare module BABYLON {
  111798. /**
  111799. * Class used to host RGBD texture specific utilities
  111800. */
  111801. export class RGBDTextureTools {
  111802. /**
  111803. * Expand the RGBD Texture from RGBD to Half Float if possible.
  111804. * @param texture the texture to expand.
  111805. */
  111806. static ExpandRGBDTexture(texture: Texture): void;
  111807. }
  111808. }
  111809. declare module BABYLON {
  111810. /**
  111811. * Class used to host texture specific utilities
  111812. */
  111813. export class BRDFTextureTools {
  111814. /**
  111815. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  111816. * @param scene defines the hosting scene
  111817. * @returns the environment BRDF texture
  111818. */
  111819. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  111820. private static _environmentBRDFBase64Texture;
  111821. }
  111822. }
  111823. declare module BABYLON {
  111824. /**
  111825. * @hidden
  111826. */
  111827. export interface IMaterialClearCoatDefines {
  111828. CLEARCOAT: boolean;
  111829. CLEARCOAT_DEFAULTIOR: boolean;
  111830. CLEARCOAT_TEXTURE: boolean;
  111831. CLEARCOAT_TEXTUREDIRECTUV: number;
  111832. CLEARCOAT_BUMP: boolean;
  111833. CLEARCOAT_BUMPDIRECTUV: number;
  111834. CLEARCOAT_TINT: boolean;
  111835. CLEARCOAT_TINT_TEXTURE: boolean;
  111836. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  111837. /** @hidden */
  111838. _areTexturesDirty: boolean;
  111839. }
  111840. /**
  111841. * Define the code related to the clear coat parameters of the pbr material.
  111842. */
  111843. export class PBRClearCoatConfiguration {
  111844. /**
  111845. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111846. * The default fits with a polyurethane material.
  111847. */
  111848. private static readonly _DefaultIndexOfRefraction;
  111849. private _isEnabled;
  111850. /**
  111851. * Defines if the clear coat is enabled in the material.
  111852. */
  111853. isEnabled: boolean;
  111854. /**
  111855. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  111856. */
  111857. intensity: number;
  111858. /**
  111859. * Defines the clear coat layer roughness.
  111860. */
  111861. roughness: number;
  111862. private _indexOfRefraction;
  111863. /**
  111864. * Defines the index of refraction of the clear coat.
  111865. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111866. * The default fits with a polyurethane material.
  111867. * Changing the default value is more performance intensive.
  111868. */
  111869. indexOfRefraction: number;
  111870. private _texture;
  111871. /**
  111872. * Stores the clear coat values in a texture.
  111873. */
  111874. texture: Nullable<BaseTexture>;
  111875. private _bumpTexture;
  111876. /**
  111877. * Define the clear coat specific bump texture.
  111878. */
  111879. bumpTexture: Nullable<BaseTexture>;
  111880. private _isTintEnabled;
  111881. /**
  111882. * Defines if the clear coat tint is enabled in the material.
  111883. */
  111884. isTintEnabled: boolean;
  111885. /**
  111886. * Defines the clear coat tint of the material.
  111887. * This is only use if tint is enabled
  111888. */
  111889. tintColor: Color3;
  111890. /**
  111891. * Defines the distance at which the tint color should be found in the
  111892. * clear coat media.
  111893. * This is only use if tint is enabled
  111894. */
  111895. tintColorAtDistance: number;
  111896. /**
  111897. * Defines the clear coat layer thickness.
  111898. * This is only use if tint is enabled
  111899. */
  111900. tintThickness: number;
  111901. private _tintTexture;
  111902. /**
  111903. * Stores the clear tint values in a texture.
  111904. * rgb is tint
  111905. * a is a thickness factor
  111906. */
  111907. tintTexture: Nullable<BaseTexture>;
  111908. /** @hidden */
  111909. private _internalMarkAllSubMeshesAsTexturesDirty;
  111910. /** @hidden */
  111911. _markAllSubMeshesAsTexturesDirty(): void;
  111912. /**
  111913. * Instantiate a new istance of clear coat configuration.
  111914. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111915. */
  111916. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111917. /**
  111918. * Gets wehter the submesh is ready to be used or not.
  111919. * @param defines the list of "defines" to update.
  111920. * @param scene defines the scene the material belongs to.
  111921. * @param engine defines the engine the material belongs to.
  111922. * @param disableBumpMap defines wether the material disables bump or not.
  111923. * @returns - boolean indicating that the submesh is ready or not.
  111924. */
  111925. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  111926. /**
  111927. * Checks to see if a texture is used in the material.
  111928. * @param defines the list of "defines" to update.
  111929. * @param scene defines the scene to the material belongs to.
  111930. */
  111931. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  111932. /**
  111933. * Binds the material data.
  111934. * @param uniformBuffer defines the Uniform buffer to fill in.
  111935. * @param scene defines the scene the material belongs to.
  111936. * @param engine defines the engine the material belongs to.
  111937. * @param disableBumpMap defines wether the material disables bump or not.
  111938. * @param isFrozen defines wether the material is frozen or not.
  111939. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  111940. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  111941. */
  111942. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  111943. /**
  111944. * Checks to see if a texture is used in the material.
  111945. * @param texture - Base texture to use.
  111946. * @returns - Boolean specifying if a texture is used in the material.
  111947. */
  111948. hasTexture(texture: BaseTexture): boolean;
  111949. /**
  111950. * Returns an array of the actively used textures.
  111951. * @param activeTextures Array of BaseTextures
  111952. */
  111953. getActiveTextures(activeTextures: BaseTexture[]): void;
  111954. /**
  111955. * Returns the animatable textures.
  111956. * @param animatables Array of animatable textures.
  111957. */
  111958. getAnimatables(animatables: IAnimatable[]): void;
  111959. /**
  111960. * Disposes the resources of the material.
  111961. * @param forceDisposeTextures - Forces the disposal of all textures.
  111962. */
  111963. dispose(forceDisposeTextures?: boolean): void;
  111964. /**
  111965. * Get the current class name of the texture useful for serialization or dynamic coding.
  111966. * @returns "PBRClearCoatConfiguration"
  111967. */
  111968. getClassName(): string;
  111969. /**
  111970. * Add fallbacks to the effect fallbacks list.
  111971. * @param defines defines the Base texture to use.
  111972. * @param fallbacks defines the current fallback list.
  111973. * @param currentRank defines the current fallback rank.
  111974. * @returns the new fallback rank.
  111975. */
  111976. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  111977. /**
  111978. * Add the required uniforms to the current list.
  111979. * @param uniforms defines the current uniform list.
  111980. */
  111981. static AddUniforms(uniforms: string[]): void;
  111982. /**
  111983. * Add the required samplers to the current list.
  111984. * @param samplers defines the current sampler list.
  111985. */
  111986. static AddSamplers(samplers: string[]): void;
  111987. /**
  111988. * Add the required uniforms to the current buffer.
  111989. * @param uniformBuffer defines the current uniform buffer.
  111990. */
  111991. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111992. /**
  111993. * Makes a duplicate of the current configuration into another one.
  111994. * @param clearCoatConfiguration define the config where to copy the info
  111995. */
  111996. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  111997. /**
  111998. * Serializes this clear coat configuration.
  111999. * @returns - An object with the serialized config.
  112000. */
  112001. serialize(): any;
  112002. /**
  112003. * Parses a anisotropy Configuration from a serialized object.
  112004. * @param source - Serialized object.
  112005. * @param scene Defines the scene we are parsing for
  112006. * @param rootUrl Defines the rootUrl to load from
  112007. */
  112008. parse(source: any, scene: Scene, rootUrl: string): void;
  112009. }
  112010. }
  112011. declare module BABYLON {
  112012. /**
  112013. * @hidden
  112014. */
  112015. export interface IMaterialAnisotropicDefines {
  112016. ANISOTROPIC: boolean;
  112017. ANISOTROPIC_TEXTURE: boolean;
  112018. ANISOTROPIC_TEXTUREDIRECTUV: number;
  112019. MAINUV1: boolean;
  112020. _areTexturesDirty: boolean;
  112021. _needUVs: boolean;
  112022. }
  112023. /**
  112024. * Define the code related to the anisotropic parameters of the pbr material.
  112025. */
  112026. export class PBRAnisotropicConfiguration {
  112027. private _isEnabled;
  112028. /**
  112029. * Defines if the anisotropy is enabled in the material.
  112030. */
  112031. isEnabled: boolean;
  112032. /**
  112033. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  112034. */
  112035. intensity: number;
  112036. /**
  112037. * Defines if the effect is along the tangents, bitangents or in between.
  112038. * By default, the effect is "strectching" the highlights along the tangents.
  112039. */
  112040. direction: Vector2;
  112041. private _texture;
  112042. /**
  112043. * Stores the anisotropy values in a texture.
  112044. * rg is direction (like normal from -1 to 1)
  112045. * b is a intensity
  112046. */
  112047. texture: Nullable<BaseTexture>;
  112048. /** @hidden */
  112049. private _internalMarkAllSubMeshesAsTexturesDirty;
  112050. /** @hidden */
  112051. _markAllSubMeshesAsTexturesDirty(): void;
  112052. /**
  112053. * Instantiate a new istance of anisotropy configuration.
  112054. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112055. */
  112056. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112057. /**
  112058. * Specifies that the submesh is ready to be used.
  112059. * @param defines the list of "defines" to update.
  112060. * @param scene defines the scene the material belongs to.
  112061. * @returns - boolean indicating that the submesh is ready or not.
  112062. */
  112063. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  112064. /**
  112065. * Checks to see if a texture is used in the material.
  112066. * @param defines the list of "defines" to update.
  112067. * @param mesh the mesh we are preparing the defines for.
  112068. * @param scene defines the scene the material belongs to.
  112069. */
  112070. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  112071. /**
  112072. * Binds the material data.
  112073. * @param uniformBuffer defines the Uniform buffer to fill in.
  112074. * @param scene defines the scene the material belongs to.
  112075. * @param isFrozen defines wether the material is frozen or not.
  112076. */
  112077. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  112078. /**
  112079. * Checks to see if a texture is used in the material.
  112080. * @param texture - Base texture to use.
  112081. * @returns - Boolean specifying if a texture is used in the material.
  112082. */
  112083. hasTexture(texture: BaseTexture): boolean;
  112084. /**
  112085. * Returns an array of the actively used textures.
  112086. * @param activeTextures Array of BaseTextures
  112087. */
  112088. getActiveTextures(activeTextures: BaseTexture[]): void;
  112089. /**
  112090. * Returns the animatable textures.
  112091. * @param animatables Array of animatable textures.
  112092. */
  112093. getAnimatables(animatables: IAnimatable[]): void;
  112094. /**
  112095. * Disposes the resources of the material.
  112096. * @param forceDisposeTextures - Forces the disposal of all textures.
  112097. */
  112098. dispose(forceDisposeTextures?: boolean): void;
  112099. /**
  112100. * Get the current class name of the texture useful for serialization or dynamic coding.
  112101. * @returns "PBRAnisotropicConfiguration"
  112102. */
  112103. getClassName(): string;
  112104. /**
  112105. * Add fallbacks to the effect fallbacks list.
  112106. * @param defines defines the Base texture to use.
  112107. * @param fallbacks defines the current fallback list.
  112108. * @param currentRank defines the current fallback rank.
  112109. * @returns the new fallback rank.
  112110. */
  112111. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112112. /**
  112113. * Add the required uniforms to the current list.
  112114. * @param uniforms defines the current uniform list.
  112115. */
  112116. static AddUniforms(uniforms: string[]): void;
  112117. /**
  112118. * Add the required uniforms to the current buffer.
  112119. * @param uniformBuffer defines the current uniform buffer.
  112120. */
  112121. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112122. /**
  112123. * Add the required samplers to the current list.
  112124. * @param samplers defines the current sampler list.
  112125. */
  112126. static AddSamplers(samplers: string[]): void;
  112127. /**
  112128. * Makes a duplicate of the current configuration into another one.
  112129. * @param anisotropicConfiguration define the config where to copy the info
  112130. */
  112131. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  112132. /**
  112133. * Serializes this anisotropy configuration.
  112134. * @returns - An object with the serialized config.
  112135. */
  112136. serialize(): any;
  112137. /**
  112138. * Parses a anisotropy Configuration from a serialized object.
  112139. * @param source - Serialized object.
  112140. * @param scene Defines the scene we are parsing for
  112141. * @param rootUrl Defines the rootUrl to load from
  112142. */
  112143. parse(source: any, scene: Scene, rootUrl: string): void;
  112144. }
  112145. }
  112146. declare module BABYLON {
  112147. /**
  112148. * @hidden
  112149. */
  112150. export interface IMaterialBRDFDefines {
  112151. BRDF_V_HEIGHT_CORRELATED: boolean;
  112152. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112153. SPHERICAL_HARMONICS: boolean;
  112154. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  112155. /** @hidden */
  112156. _areMiscDirty: boolean;
  112157. }
  112158. /**
  112159. * Define the code related to the BRDF parameters of the pbr material.
  112160. */
  112161. export class PBRBRDFConfiguration {
  112162. /**
  112163. * Default value used for the energy conservation.
  112164. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  112165. */
  112166. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  112167. /**
  112168. * Default value used for the Smith Visibility Height Correlated mode.
  112169. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  112170. */
  112171. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  112172. /**
  112173. * Default value used for the IBL diffuse part.
  112174. * This can help switching back to the polynomials mode globally which is a tiny bit
  112175. * less GPU intensive at the drawback of a lower quality.
  112176. */
  112177. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  112178. /**
  112179. * Default value used for activating energy conservation for the specular workflow.
  112180. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  112181. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  112182. */
  112183. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  112184. private _useEnergyConservation;
  112185. /**
  112186. * Defines if the material uses energy conservation.
  112187. */
  112188. useEnergyConservation: boolean;
  112189. private _useSmithVisibilityHeightCorrelated;
  112190. /**
  112191. * LEGACY Mode set to false
  112192. * Defines if the material uses height smith correlated visibility term.
  112193. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  112194. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  112195. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  112196. * Not relying on height correlated will also disable energy conservation.
  112197. */
  112198. useSmithVisibilityHeightCorrelated: boolean;
  112199. private _useSphericalHarmonics;
  112200. /**
  112201. * LEGACY Mode set to false
  112202. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  112203. * diffuse part of the IBL.
  112204. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  112205. * to the ground truth.
  112206. */
  112207. useSphericalHarmonics: boolean;
  112208. private _useSpecularGlossinessInputEnergyConservation;
  112209. /**
  112210. * Defines if the material uses energy conservation, when the specular workflow is active.
  112211. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  112212. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  112213. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  112214. */
  112215. useSpecularGlossinessInputEnergyConservation: boolean;
  112216. /** @hidden */
  112217. private _internalMarkAllSubMeshesAsMiscDirty;
  112218. /** @hidden */
  112219. _markAllSubMeshesAsMiscDirty(): void;
  112220. /**
  112221. * Instantiate a new istance of clear coat configuration.
  112222. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  112223. */
  112224. constructor(markAllSubMeshesAsMiscDirty: () => void);
  112225. /**
  112226. * Checks to see if a texture is used in the material.
  112227. * @param defines the list of "defines" to update.
  112228. */
  112229. prepareDefines(defines: IMaterialBRDFDefines): void;
  112230. /**
  112231. * Get the current class name of the texture useful for serialization or dynamic coding.
  112232. * @returns "PBRClearCoatConfiguration"
  112233. */
  112234. getClassName(): string;
  112235. /**
  112236. * Makes a duplicate of the current configuration into another one.
  112237. * @param brdfConfiguration define the config where to copy the info
  112238. */
  112239. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  112240. /**
  112241. * Serializes this BRDF configuration.
  112242. * @returns - An object with the serialized config.
  112243. */
  112244. serialize(): any;
  112245. /**
  112246. * Parses a anisotropy Configuration from a serialized object.
  112247. * @param source - Serialized object.
  112248. * @param scene Defines the scene we are parsing for
  112249. * @param rootUrl Defines the rootUrl to load from
  112250. */
  112251. parse(source: any, scene: Scene, rootUrl: string): void;
  112252. }
  112253. }
  112254. declare module BABYLON {
  112255. /**
  112256. * @hidden
  112257. */
  112258. export interface IMaterialSheenDefines {
  112259. SHEEN: boolean;
  112260. SHEEN_TEXTURE: boolean;
  112261. SHEEN_TEXTUREDIRECTUV: number;
  112262. SHEEN_LINKWITHALBEDO: boolean;
  112263. /** @hidden */
  112264. _areTexturesDirty: boolean;
  112265. }
  112266. /**
  112267. * Define the code related to the Sheen parameters of the pbr material.
  112268. */
  112269. export class PBRSheenConfiguration {
  112270. private _isEnabled;
  112271. /**
  112272. * Defines if the material uses sheen.
  112273. */
  112274. isEnabled: boolean;
  112275. private _linkSheenWithAlbedo;
  112276. /**
  112277. * Defines if the sheen is linked to the sheen color.
  112278. */
  112279. linkSheenWithAlbedo: boolean;
  112280. /**
  112281. * Defines the sheen intensity.
  112282. */
  112283. intensity: number;
  112284. /**
  112285. * Defines the sheen color.
  112286. */
  112287. color: Color3;
  112288. private _texture;
  112289. /**
  112290. * Stores the sheen tint values in a texture.
  112291. * rgb is tint
  112292. * a is a intensity
  112293. */
  112294. texture: Nullable<BaseTexture>;
  112295. /** @hidden */
  112296. private _internalMarkAllSubMeshesAsTexturesDirty;
  112297. /** @hidden */
  112298. _markAllSubMeshesAsTexturesDirty(): void;
  112299. /**
  112300. * Instantiate a new istance of clear coat configuration.
  112301. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112302. */
  112303. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112304. /**
  112305. * Specifies that the submesh is ready to be used.
  112306. * @param defines the list of "defines" to update.
  112307. * @param scene defines the scene the material belongs to.
  112308. * @returns - boolean indicating that the submesh is ready or not.
  112309. */
  112310. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  112311. /**
  112312. * Checks to see if a texture is used in the material.
  112313. * @param defines the list of "defines" to update.
  112314. * @param scene defines the scene the material belongs to.
  112315. */
  112316. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  112317. /**
  112318. * Binds the material data.
  112319. * @param uniformBuffer defines the Uniform buffer to fill in.
  112320. * @param scene defines the scene the material belongs to.
  112321. * @param isFrozen defines wether the material is frozen or not.
  112322. */
  112323. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  112324. /**
  112325. * Checks to see if a texture is used in the material.
  112326. * @param texture - Base texture to use.
  112327. * @returns - Boolean specifying if a texture is used in the material.
  112328. */
  112329. hasTexture(texture: BaseTexture): boolean;
  112330. /**
  112331. * Returns an array of the actively used textures.
  112332. * @param activeTextures Array of BaseTextures
  112333. */
  112334. getActiveTextures(activeTextures: BaseTexture[]): void;
  112335. /**
  112336. * Returns the animatable textures.
  112337. * @param animatables Array of animatable textures.
  112338. */
  112339. getAnimatables(animatables: IAnimatable[]): void;
  112340. /**
  112341. * Disposes the resources of the material.
  112342. * @param forceDisposeTextures - Forces the disposal of all textures.
  112343. */
  112344. dispose(forceDisposeTextures?: boolean): void;
  112345. /**
  112346. * Get the current class name of the texture useful for serialization or dynamic coding.
  112347. * @returns "PBRSheenConfiguration"
  112348. */
  112349. getClassName(): string;
  112350. /**
  112351. * Add fallbacks to the effect fallbacks list.
  112352. * @param defines defines the Base texture to use.
  112353. * @param fallbacks defines the current fallback list.
  112354. * @param currentRank defines the current fallback rank.
  112355. * @returns the new fallback rank.
  112356. */
  112357. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112358. /**
  112359. * Add the required uniforms to the current list.
  112360. * @param uniforms defines the current uniform list.
  112361. */
  112362. static AddUniforms(uniforms: string[]): void;
  112363. /**
  112364. * Add the required uniforms to the current buffer.
  112365. * @param uniformBuffer defines the current uniform buffer.
  112366. */
  112367. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112368. /**
  112369. * Add the required samplers to the current list.
  112370. * @param samplers defines the current sampler list.
  112371. */
  112372. static AddSamplers(samplers: string[]): void;
  112373. /**
  112374. * Makes a duplicate of the current configuration into another one.
  112375. * @param sheenConfiguration define the config where to copy the info
  112376. */
  112377. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  112378. /**
  112379. * Serializes this BRDF configuration.
  112380. * @returns - An object with the serialized config.
  112381. */
  112382. serialize(): any;
  112383. /**
  112384. * Parses a anisotropy Configuration from a serialized object.
  112385. * @param source - Serialized object.
  112386. * @param scene Defines the scene we are parsing for
  112387. * @param rootUrl Defines the rootUrl to load from
  112388. */
  112389. parse(source: any, scene: Scene, rootUrl: string): void;
  112390. }
  112391. }
  112392. declare module BABYLON {
  112393. /**
  112394. * @hidden
  112395. */
  112396. export interface IMaterialSubSurfaceDefines {
  112397. SUBSURFACE: boolean;
  112398. SS_REFRACTION: boolean;
  112399. SS_TRANSLUCENCY: boolean;
  112400. SS_SCATERRING: boolean;
  112401. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112402. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112403. SS_REFRACTIONMAP_3D: boolean;
  112404. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112405. SS_LODINREFRACTIONALPHA: boolean;
  112406. SS_GAMMAREFRACTION: boolean;
  112407. SS_RGBDREFRACTION: boolean;
  112408. SS_LINEARSPECULARREFRACTION: boolean;
  112409. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112410. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112411. /** @hidden */
  112412. _areTexturesDirty: boolean;
  112413. }
  112414. /**
  112415. * Define the code related to the sub surface parameters of the pbr material.
  112416. */
  112417. export class PBRSubSurfaceConfiguration {
  112418. private _isRefractionEnabled;
  112419. /**
  112420. * Defines if the refraction is enabled in the material.
  112421. */
  112422. isRefractionEnabled: boolean;
  112423. private _isTranslucencyEnabled;
  112424. /**
  112425. * Defines if the translucency is enabled in the material.
  112426. */
  112427. isTranslucencyEnabled: boolean;
  112428. private _isScatteringEnabled;
  112429. /**
  112430. * Defines the refraction intensity of the material.
  112431. * The refraction when enabled replaces the Diffuse part of the material.
  112432. * The intensity helps transitionning between diffuse and refraction.
  112433. */
  112434. refractionIntensity: number;
  112435. /**
  112436. * Defines the translucency intensity of the material.
  112437. * When translucency has been enabled, this defines how much of the "translucency"
  112438. * is addded to the diffuse part of the material.
  112439. */
  112440. translucencyIntensity: number;
  112441. /**
  112442. * Defines the scattering intensity of the material.
  112443. * When scattering has been enabled, this defines how much of the "scattered light"
  112444. * is addded to the diffuse part of the material.
  112445. */
  112446. scatteringIntensity: number;
  112447. private _thicknessTexture;
  112448. /**
  112449. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  112450. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  112451. * 0 would mean minimumThickness
  112452. * 1 would mean maximumThickness
  112453. * The other channels might be use as a mask to vary the different effects intensity.
  112454. */
  112455. thicknessTexture: Nullable<BaseTexture>;
  112456. private _refractionTexture;
  112457. /**
  112458. * Defines the texture to use for refraction.
  112459. */
  112460. refractionTexture: Nullable<BaseTexture>;
  112461. private _indexOfRefraction;
  112462. /**
  112463. * Defines the index of refraction used in the material.
  112464. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  112465. */
  112466. indexOfRefraction: number;
  112467. private _invertRefractionY;
  112468. /**
  112469. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  112470. */
  112471. invertRefractionY: boolean;
  112472. private _linkRefractionWithTransparency;
  112473. /**
  112474. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  112475. * Materials half opaque for instance using refraction could benefit from this control.
  112476. */
  112477. linkRefractionWithTransparency: boolean;
  112478. /**
  112479. * Defines the minimum thickness stored in the thickness map.
  112480. * If no thickness map is defined, this value will be used to simulate thickness.
  112481. */
  112482. minimumThickness: number;
  112483. /**
  112484. * Defines the maximum thickness stored in the thickness map.
  112485. */
  112486. maximumThickness: number;
  112487. /**
  112488. * Defines the volume tint of the material.
  112489. * This is used for both translucency and scattering.
  112490. */
  112491. tintColor: Color3;
  112492. /**
  112493. * Defines the distance at which the tint color should be found in the media.
  112494. * This is used for refraction only.
  112495. */
  112496. tintColorAtDistance: number;
  112497. /**
  112498. * Defines how far each channel transmit through the media.
  112499. * It is defined as a color to simplify it selection.
  112500. */
  112501. diffusionDistance: Color3;
  112502. private _useMaskFromThicknessTexture;
  112503. /**
  112504. * Stores the intensity of the different subsurface effects in the thickness texture.
  112505. * * the green channel is the translucency intensity.
  112506. * * the blue channel is the scattering intensity.
  112507. * * the alpha channel is the refraction intensity.
  112508. */
  112509. useMaskFromThicknessTexture: boolean;
  112510. /** @hidden */
  112511. private _internalMarkAllSubMeshesAsTexturesDirty;
  112512. /** @hidden */
  112513. _markAllSubMeshesAsTexturesDirty(): void;
  112514. /**
  112515. * Instantiate a new istance of sub surface configuration.
  112516. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112517. */
  112518. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112519. /**
  112520. * Gets wehter the submesh is ready to be used or not.
  112521. * @param defines the list of "defines" to update.
  112522. * @param scene defines the scene the material belongs to.
  112523. * @returns - boolean indicating that the submesh is ready or not.
  112524. */
  112525. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  112526. /**
  112527. * Checks to see if a texture is used in the material.
  112528. * @param defines the list of "defines" to update.
  112529. * @param scene defines the scene to the material belongs to.
  112530. */
  112531. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  112532. /**
  112533. * Binds the material data.
  112534. * @param uniformBuffer defines the Uniform buffer to fill in.
  112535. * @param scene defines the scene the material belongs to.
  112536. * @param engine defines the engine the material belongs to.
  112537. * @param isFrozen defines wether the material is frozen or not.
  112538. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  112539. */
  112540. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  112541. /**
  112542. * Unbinds the material from the mesh.
  112543. * @param activeEffect defines the effect that should be unbound from.
  112544. * @returns true if unbound, otherwise false
  112545. */
  112546. unbind(activeEffect: Effect): boolean;
  112547. /**
  112548. * Returns the texture used for refraction or null if none is used.
  112549. * @param scene defines the scene the material belongs to.
  112550. * @returns - Refraction texture if present. If no refraction texture and refraction
  112551. * is linked with transparency, returns environment texture. Otherwise, returns null.
  112552. */
  112553. private _getRefractionTexture;
  112554. /**
  112555. * Returns true if alpha blending should be disabled.
  112556. */
  112557. readonly disableAlphaBlending: boolean;
  112558. /**
  112559. * Fills the list of render target textures.
  112560. * @param renderTargets the list of render targets to update
  112561. */
  112562. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  112563. /**
  112564. * Checks to see if a texture is used in the material.
  112565. * @param texture - Base texture to use.
  112566. * @returns - Boolean specifying if a texture is used in the material.
  112567. */
  112568. hasTexture(texture: BaseTexture): boolean;
  112569. /**
  112570. * Gets a boolean indicating that current material needs to register RTT
  112571. * @returns true if this uses a render target otherwise false.
  112572. */
  112573. hasRenderTargetTextures(): boolean;
  112574. /**
  112575. * Returns an array of the actively used textures.
  112576. * @param activeTextures Array of BaseTextures
  112577. */
  112578. getActiveTextures(activeTextures: BaseTexture[]): void;
  112579. /**
  112580. * Returns the animatable textures.
  112581. * @param animatables Array of animatable textures.
  112582. */
  112583. getAnimatables(animatables: IAnimatable[]): void;
  112584. /**
  112585. * Disposes the resources of the material.
  112586. * @param forceDisposeTextures - Forces the disposal of all textures.
  112587. */
  112588. dispose(forceDisposeTextures?: boolean): void;
  112589. /**
  112590. * Get the current class name of the texture useful for serialization or dynamic coding.
  112591. * @returns "PBRSubSurfaceConfiguration"
  112592. */
  112593. getClassName(): string;
  112594. /**
  112595. * Add fallbacks to the effect fallbacks list.
  112596. * @param defines defines the Base texture to use.
  112597. * @param fallbacks defines the current fallback list.
  112598. * @param currentRank defines the current fallback rank.
  112599. * @returns the new fallback rank.
  112600. */
  112601. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112602. /**
  112603. * Add the required uniforms to the current list.
  112604. * @param uniforms defines the current uniform list.
  112605. */
  112606. static AddUniforms(uniforms: string[]): void;
  112607. /**
  112608. * Add the required samplers to the current list.
  112609. * @param samplers defines the current sampler list.
  112610. */
  112611. static AddSamplers(samplers: string[]): void;
  112612. /**
  112613. * Add the required uniforms to the current buffer.
  112614. * @param uniformBuffer defines the current uniform buffer.
  112615. */
  112616. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112617. /**
  112618. * Makes a duplicate of the current configuration into another one.
  112619. * @param configuration define the config where to copy the info
  112620. */
  112621. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  112622. /**
  112623. * Serializes this Sub Surface configuration.
  112624. * @returns - An object with the serialized config.
  112625. */
  112626. serialize(): any;
  112627. /**
  112628. * Parses a anisotropy Configuration from a serialized object.
  112629. * @param source - Serialized object.
  112630. * @param scene Defines the scene we are parsing for
  112631. * @param rootUrl Defines the rootUrl to load from
  112632. */
  112633. parse(source: any, scene: Scene, rootUrl: string): void;
  112634. }
  112635. }
  112636. declare module BABYLON {
  112637. /** @hidden */
  112638. export var pbrFragmentDeclaration: {
  112639. name: string;
  112640. shader: string;
  112641. };
  112642. }
  112643. declare module BABYLON {
  112644. /** @hidden */
  112645. export var pbrUboDeclaration: {
  112646. name: string;
  112647. shader: string;
  112648. };
  112649. }
  112650. declare module BABYLON {
  112651. /** @hidden */
  112652. export var pbrFragmentExtraDeclaration: {
  112653. name: string;
  112654. shader: string;
  112655. };
  112656. }
  112657. declare module BABYLON {
  112658. /** @hidden */
  112659. export var pbrFragmentSamplersDeclaration: {
  112660. name: string;
  112661. shader: string;
  112662. };
  112663. }
  112664. declare module BABYLON {
  112665. /** @hidden */
  112666. export var pbrHelperFunctions: {
  112667. name: string;
  112668. shader: string;
  112669. };
  112670. }
  112671. declare module BABYLON {
  112672. /** @hidden */
  112673. export var harmonicsFunctions: {
  112674. name: string;
  112675. shader: string;
  112676. };
  112677. }
  112678. declare module BABYLON {
  112679. /** @hidden */
  112680. export var pbrDirectLightingSetupFunctions: {
  112681. name: string;
  112682. shader: string;
  112683. };
  112684. }
  112685. declare module BABYLON {
  112686. /** @hidden */
  112687. export var pbrDirectLightingFalloffFunctions: {
  112688. name: string;
  112689. shader: string;
  112690. };
  112691. }
  112692. declare module BABYLON {
  112693. /** @hidden */
  112694. export var pbrBRDFFunctions: {
  112695. name: string;
  112696. shader: string;
  112697. };
  112698. }
  112699. declare module BABYLON {
  112700. /** @hidden */
  112701. export var pbrDirectLightingFunctions: {
  112702. name: string;
  112703. shader: string;
  112704. };
  112705. }
  112706. declare module BABYLON {
  112707. /** @hidden */
  112708. export var pbrIBLFunctions: {
  112709. name: string;
  112710. shader: string;
  112711. };
  112712. }
  112713. declare module BABYLON {
  112714. /** @hidden */
  112715. export var pbrDebug: {
  112716. name: string;
  112717. shader: string;
  112718. };
  112719. }
  112720. declare module BABYLON {
  112721. /** @hidden */
  112722. export var pbrPixelShader: {
  112723. name: string;
  112724. shader: string;
  112725. };
  112726. }
  112727. declare module BABYLON {
  112728. /** @hidden */
  112729. export var pbrVertexDeclaration: {
  112730. name: string;
  112731. shader: string;
  112732. };
  112733. }
  112734. declare module BABYLON {
  112735. /** @hidden */
  112736. export var pbrVertexShader: {
  112737. name: string;
  112738. shader: string;
  112739. };
  112740. }
  112741. declare module BABYLON {
  112742. /**
  112743. * Manages the defines for the PBR Material.
  112744. * @hidden
  112745. */
  112746. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  112747. PBR: boolean;
  112748. MAINUV1: boolean;
  112749. MAINUV2: boolean;
  112750. UV1: boolean;
  112751. UV2: boolean;
  112752. ALBEDO: boolean;
  112753. ALBEDODIRECTUV: number;
  112754. VERTEXCOLOR: boolean;
  112755. AMBIENT: boolean;
  112756. AMBIENTDIRECTUV: number;
  112757. AMBIENTINGRAYSCALE: boolean;
  112758. OPACITY: boolean;
  112759. VERTEXALPHA: boolean;
  112760. OPACITYDIRECTUV: number;
  112761. OPACITYRGB: boolean;
  112762. ALPHATEST: boolean;
  112763. DEPTHPREPASS: boolean;
  112764. ALPHABLEND: boolean;
  112765. ALPHAFROMALBEDO: boolean;
  112766. ALPHATESTVALUE: string;
  112767. SPECULAROVERALPHA: boolean;
  112768. RADIANCEOVERALPHA: boolean;
  112769. ALPHAFRESNEL: boolean;
  112770. LINEARALPHAFRESNEL: boolean;
  112771. PREMULTIPLYALPHA: boolean;
  112772. EMISSIVE: boolean;
  112773. EMISSIVEDIRECTUV: number;
  112774. REFLECTIVITY: boolean;
  112775. REFLECTIVITYDIRECTUV: number;
  112776. SPECULARTERM: boolean;
  112777. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  112778. MICROSURFACEAUTOMATIC: boolean;
  112779. LODBASEDMICROSFURACE: boolean;
  112780. MICROSURFACEMAP: boolean;
  112781. MICROSURFACEMAPDIRECTUV: number;
  112782. METALLICWORKFLOW: boolean;
  112783. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  112784. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  112785. METALLNESSSTOREINMETALMAPBLUE: boolean;
  112786. AOSTOREINMETALMAPRED: boolean;
  112787. ENVIRONMENTBRDF: boolean;
  112788. ENVIRONMENTBRDF_RGBD: boolean;
  112789. NORMAL: boolean;
  112790. TANGENT: boolean;
  112791. BUMP: boolean;
  112792. BUMPDIRECTUV: number;
  112793. OBJECTSPACE_NORMALMAP: boolean;
  112794. PARALLAX: boolean;
  112795. PARALLAXOCCLUSION: boolean;
  112796. NORMALXYSCALE: boolean;
  112797. LIGHTMAP: boolean;
  112798. LIGHTMAPDIRECTUV: number;
  112799. USELIGHTMAPASSHADOWMAP: boolean;
  112800. GAMMALIGHTMAP: boolean;
  112801. RGBDLIGHTMAP: boolean;
  112802. REFLECTION: boolean;
  112803. REFLECTIONMAP_3D: boolean;
  112804. REFLECTIONMAP_SPHERICAL: boolean;
  112805. REFLECTIONMAP_PLANAR: boolean;
  112806. REFLECTIONMAP_CUBIC: boolean;
  112807. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  112808. REFLECTIONMAP_PROJECTION: boolean;
  112809. REFLECTIONMAP_SKYBOX: boolean;
  112810. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  112811. REFLECTIONMAP_EXPLICIT: boolean;
  112812. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  112813. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  112814. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  112815. INVERTCUBICMAP: boolean;
  112816. USESPHERICALFROMREFLECTIONMAP: boolean;
  112817. USEIRRADIANCEMAP: boolean;
  112818. SPHERICAL_HARMONICS: boolean;
  112819. USESPHERICALINVERTEX: boolean;
  112820. REFLECTIONMAP_OPPOSITEZ: boolean;
  112821. LODINREFLECTIONALPHA: boolean;
  112822. GAMMAREFLECTION: boolean;
  112823. RGBDREFLECTION: boolean;
  112824. LINEARSPECULARREFLECTION: boolean;
  112825. RADIANCEOCCLUSION: boolean;
  112826. HORIZONOCCLUSION: boolean;
  112827. INSTANCES: boolean;
  112828. NUM_BONE_INFLUENCERS: number;
  112829. BonesPerMesh: number;
  112830. BONETEXTURE: boolean;
  112831. NONUNIFORMSCALING: boolean;
  112832. MORPHTARGETS: boolean;
  112833. MORPHTARGETS_NORMAL: boolean;
  112834. MORPHTARGETS_TANGENT: boolean;
  112835. MORPHTARGETS_UV: boolean;
  112836. NUM_MORPH_INFLUENCERS: number;
  112837. IMAGEPROCESSING: boolean;
  112838. VIGNETTE: boolean;
  112839. VIGNETTEBLENDMODEMULTIPLY: boolean;
  112840. VIGNETTEBLENDMODEOPAQUE: boolean;
  112841. TONEMAPPING: boolean;
  112842. TONEMAPPING_ACES: boolean;
  112843. CONTRAST: boolean;
  112844. COLORCURVES: boolean;
  112845. COLORGRADING: boolean;
  112846. COLORGRADING3D: boolean;
  112847. SAMPLER3DGREENDEPTH: boolean;
  112848. SAMPLER3DBGRMAP: boolean;
  112849. IMAGEPROCESSINGPOSTPROCESS: boolean;
  112850. EXPOSURE: boolean;
  112851. MULTIVIEW: boolean;
  112852. USEPHYSICALLIGHTFALLOFF: boolean;
  112853. USEGLTFLIGHTFALLOFF: boolean;
  112854. TWOSIDEDLIGHTING: boolean;
  112855. SHADOWFLOAT: boolean;
  112856. CLIPPLANE: boolean;
  112857. CLIPPLANE2: boolean;
  112858. CLIPPLANE3: boolean;
  112859. CLIPPLANE4: boolean;
  112860. POINTSIZE: boolean;
  112861. FOG: boolean;
  112862. LOGARITHMICDEPTH: boolean;
  112863. FORCENORMALFORWARD: boolean;
  112864. SPECULARAA: boolean;
  112865. CLEARCOAT: boolean;
  112866. CLEARCOAT_DEFAULTIOR: boolean;
  112867. CLEARCOAT_TEXTURE: boolean;
  112868. CLEARCOAT_TEXTUREDIRECTUV: number;
  112869. CLEARCOAT_BUMP: boolean;
  112870. CLEARCOAT_BUMPDIRECTUV: number;
  112871. CLEARCOAT_TINT: boolean;
  112872. CLEARCOAT_TINT_TEXTURE: boolean;
  112873. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  112874. ANISOTROPIC: boolean;
  112875. ANISOTROPIC_TEXTURE: boolean;
  112876. ANISOTROPIC_TEXTUREDIRECTUV: number;
  112877. BRDF_V_HEIGHT_CORRELATED: boolean;
  112878. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112879. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  112880. SHEEN: boolean;
  112881. SHEEN_TEXTURE: boolean;
  112882. SHEEN_TEXTUREDIRECTUV: number;
  112883. SHEEN_LINKWITHALBEDO: boolean;
  112884. SUBSURFACE: boolean;
  112885. SS_REFRACTION: boolean;
  112886. SS_TRANSLUCENCY: boolean;
  112887. SS_SCATERRING: boolean;
  112888. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112889. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112890. SS_REFRACTIONMAP_3D: boolean;
  112891. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112892. SS_LODINREFRACTIONALPHA: boolean;
  112893. SS_GAMMAREFRACTION: boolean;
  112894. SS_RGBDREFRACTION: boolean;
  112895. SS_LINEARSPECULARREFRACTION: boolean;
  112896. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112897. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112898. UNLIT: boolean;
  112899. DEBUGMODE: number;
  112900. /**
  112901. * Initializes the PBR Material defines.
  112902. */
  112903. constructor();
  112904. /**
  112905. * Resets the PBR Material defines.
  112906. */
  112907. reset(): void;
  112908. }
  112909. /**
  112910. * The Physically based material base class of BJS.
  112911. *
  112912. * This offers the main features of a standard PBR material.
  112913. * For more information, please refer to the documentation :
  112914. * https://doc.babylonjs.com/how_to/physically_based_rendering
  112915. */
  112916. export abstract class PBRBaseMaterial extends PushMaterial {
  112917. /**
  112918. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  112919. */
  112920. static readonly PBRMATERIAL_OPAQUE: number;
  112921. /**
  112922. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  112923. */
  112924. static readonly PBRMATERIAL_ALPHATEST: number;
  112925. /**
  112926. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112927. */
  112928. static readonly PBRMATERIAL_ALPHABLEND: number;
  112929. /**
  112930. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112931. * They are also discarded below the alpha cutoff threshold to improve performances.
  112932. */
  112933. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  112934. /**
  112935. * Defines the default value of how much AO map is occluding the analytical lights
  112936. * (point spot...).
  112937. */
  112938. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  112939. /**
  112940. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  112941. */
  112942. static readonly LIGHTFALLOFF_PHYSICAL: number;
  112943. /**
  112944. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  112945. * to enhance interoperability with other engines.
  112946. */
  112947. static readonly LIGHTFALLOFF_GLTF: number;
  112948. /**
  112949. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  112950. * to enhance interoperability with other materials.
  112951. */
  112952. static readonly LIGHTFALLOFF_STANDARD: number;
  112953. /**
  112954. * Intensity of the direct lights e.g. the four lights available in your scene.
  112955. * This impacts both the direct diffuse and specular highlights.
  112956. */
  112957. protected _directIntensity: number;
  112958. /**
  112959. * Intensity of the emissive part of the material.
  112960. * This helps controlling the emissive effect without modifying the emissive color.
  112961. */
  112962. protected _emissiveIntensity: number;
  112963. /**
  112964. * Intensity of the environment e.g. how much the environment will light the object
  112965. * either through harmonics for rough material or through the refelction for shiny ones.
  112966. */
  112967. protected _environmentIntensity: number;
  112968. /**
  112969. * This is a special control allowing the reduction of the specular highlights coming from the
  112970. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  112971. */
  112972. protected _specularIntensity: number;
  112973. /**
  112974. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  112975. */
  112976. private _lightingInfos;
  112977. /**
  112978. * Debug Control allowing disabling the bump map on this material.
  112979. */
  112980. protected _disableBumpMap: boolean;
  112981. /**
  112982. * AKA Diffuse Texture in standard nomenclature.
  112983. */
  112984. protected _albedoTexture: Nullable<BaseTexture>;
  112985. /**
  112986. * AKA Occlusion Texture in other nomenclature.
  112987. */
  112988. protected _ambientTexture: Nullable<BaseTexture>;
  112989. /**
  112990. * AKA Occlusion Texture Intensity in other nomenclature.
  112991. */
  112992. protected _ambientTextureStrength: number;
  112993. /**
  112994. * Defines how much the AO map is occluding the analytical lights (point spot...).
  112995. * 1 means it completely occludes it
  112996. * 0 mean it has no impact
  112997. */
  112998. protected _ambientTextureImpactOnAnalyticalLights: number;
  112999. /**
  113000. * Stores the alpha values in a texture.
  113001. */
  113002. protected _opacityTexture: Nullable<BaseTexture>;
  113003. /**
  113004. * Stores the reflection values in a texture.
  113005. */
  113006. protected _reflectionTexture: Nullable<BaseTexture>;
  113007. /**
  113008. * Stores the emissive values in a texture.
  113009. */
  113010. protected _emissiveTexture: Nullable<BaseTexture>;
  113011. /**
  113012. * AKA Specular texture in other nomenclature.
  113013. */
  113014. protected _reflectivityTexture: Nullable<BaseTexture>;
  113015. /**
  113016. * Used to switch from specular/glossiness to metallic/roughness workflow.
  113017. */
  113018. protected _metallicTexture: Nullable<BaseTexture>;
  113019. /**
  113020. * Specifies the metallic scalar of the metallic/roughness workflow.
  113021. * Can also be used to scale the metalness values of the metallic texture.
  113022. */
  113023. protected _metallic: Nullable<number>;
  113024. /**
  113025. * Specifies the roughness scalar of the metallic/roughness workflow.
  113026. * Can also be used to scale the roughness values of the metallic texture.
  113027. */
  113028. protected _roughness: Nullable<number>;
  113029. /**
  113030. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  113031. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  113032. */
  113033. protected _microSurfaceTexture: Nullable<BaseTexture>;
  113034. /**
  113035. * Stores surface normal data used to displace a mesh in a texture.
  113036. */
  113037. protected _bumpTexture: Nullable<BaseTexture>;
  113038. /**
  113039. * Stores the pre-calculated light information of a mesh in a texture.
  113040. */
  113041. protected _lightmapTexture: Nullable<BaseTexture>;
  113042. /**
  113043. * The color of a material in ambient lighting.
  113044. */
  113045. protected _ambientColor: Color3;
  113046. /**
  113047. * AKA Diffuse Color in other nomenclature.
  113048. */
  113049. protected _albedoColor: Color3;
  113050. /**
  113051. * AKA Specular Color in other nomenclature.
  113052. */
  113053. protected _reflectivityColor: Color3;
  113054. /**
  113055. * The color applied when light is reflected from a material.
  113056. */
  113057. protected _reflectionColor: Color3;
  113058. /**
  113059. * The color applied when light is emitted from a material.
  113060. */
  113061. protected _emissiveColor: Color3;
  113062. /**
  113063. * AKA Glossiness in other nomenclature.
  113064. */
  113065. protected _microSurface: number;
  113066. /**
  113067. * Specifies that the material will use the light map as a show map.
  113068. */
  113069. protected _useLightmapAsShadowmap: boolean;
  113070. /**
  113071. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  113072. * makes the reflect vector face the model (under horizon).
  113073. */
  113074. protected _useHorizonOcclusion: boolean;
  113075. /**
  113076. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  113077. * too much the area relying on ambient texture to define their ambient occlusion.
  113078. */
  113079. protected _useRadianceOcclusion: boolean;
  113080. /**
  113081. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  113082. */
  113083. protected _useAlphaFromAlbedoTexture: boolean;
  113084. /**
  113085. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  113086. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  113087. */
  113088. protected _useSpecularOverAlpha: boolean;
  113089. /**
  113090. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  113091. */
  113092. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  113093. /**
  113094. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  113095. */
  113096. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  113097. /**
  113098. * Specifies if the metallic texture contains the roughness information in its green channel.
  113099. */
  113100. protected _useRoughnessFromMetallicTextureGreen: boolean;
  113101. /**
  113102. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113103. */
  113104. protected _useMetallnessFromMetallicTextureBlue: boolean;
  113105. /**
  113106. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113107. */
  113108. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  113109. /**
  113110. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113111. */
  113112. protected _useAmbientInGrayScale: boolean;
  113113. /**
  113114. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113115. * The material will try to infer what glossiness each pixel should be.
  113116. */
  113117. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  113118. /**
  113119. * Defines the falloff type used in this material.
  113120. * It by default is Physical.
  113121. */
  113122. protected _lightFalloff: number;
  113123. /**
  113124. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113125. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113126. */
  113127. protected _useRadianceOverAlpha: boolean;
  113128. /**
  113129. * Allows using an object space normal map (instead of tangent space).
  113130. */
  113131. protected _useObjectSpaceNormalMap: boolean;
  113132. /**
  113133. * Allows using the bump map in parallax mode.
  113134. */
  113135. protected _useParallax: boolean;
  113136. /**
  113137. * Allows using the bump map in parallax occlusion mode.
  113138. */
  113139. protected _useParallaxOcclusion: boolean;
  113140. /**
  113141. * Controls the scale bias of the parallax mode.
  113142. */
  113143. protected _parallaxScaleBias: number;
  113144. /**
  113145. * If sets to true, disables all the lights affecting the material.
  113146. */
  113147. protected _disableLighting: boolean;
  113148. /**
  113149. * Number of Simultaneous lights allowed on the material.
  113150. */
  113151. protected _maxSimultaneousLights: number;
  113152. /**
  113153. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113154. */
  113155. protected _invertNormalMapX: boolean;
  113156. /**
  113157. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113158. */
  113159. protected _invertNormalMapY: boolean;
  113160. /**
  113161. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113162. */
  113163. protected _twoSidedLighting: boolean;
  113164. /**
  113165. * Defines the alpha limits in alpha test mode.
  113166. */
  113167. protected _alphaCutOff: number;
  113168. /**
  113169. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113170. */
  113171. protected _forceAlphaTest: boolean;
  113172. /**
  113173. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113174. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113175. */
  113176. protected _useAlphaFresnel: boolean;
  113177. /**
  113178. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113179. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113180. */
  113181. protected _useLinearAlphaFresnel: boolean;
  113182. /**
  113183. * The transparency mode of the material.
  113184. */
  113185. protected _transparencyMode: Nullable<number>;
  113186. /**
  113187. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  113188. * from cos thetav and roughness:
  113189. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  113190. */
  113191. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  113192. /**
  113193. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113194. */
  113195. protected _forceIrradianceInFragment: boolean;
  113196. /**
  113197. * Force normal to face away from face.
  113198. */
  113199. protected _forceNormalForward: boolean;
  113200. /**
  113201. * Enables specular anti aliasing in the PBR shader.
  113202. * It will both interacts on the Geometry for analytical and IBL lighting.
  113203. * It also prefilter the roughness map based on the bump values.
  113204. */
  113205. protected _enableSpecularAntiAliasing: boolean;
  113206. /**
  113207. * Default configuration related to image processing available in the PBR Material.
  113208. */
  113209. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113210. /**
  113211. * Keep track of the image processing observer to allow dispose and replace.
  113212. */
  113213. private _imageProcessingObserver;
  113214. /**
  113215. * Attaches a new image processing configuration to the PBR Material.
  113216. * @param configuration
  113217. */
  113218. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113219. /**
  113220. * Stores the available render targets.
  113221. */
  113222. private _renderTargets;
  113223. /**
  113224. * Sets the global ambient color for the material used in lighting calculations.
  113225. */
  113226. private _globalAmbientColor;
  113227. /**
  113228. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  113229. */
  113230. private _useLogarithmicDepth;
  113231. /**
  113232. * If set to true, no lighting calculations will be applied.
  113233. */
  113234. private _unlit;
  113235. private _debugMode;
  113236. /**
  113237. * @hidden
  113238. * This is reserved for the inspector.
  113239. * Defines the material debug mode.
  113240. * It helps seeing only some components of the material while troubleshooting.
  113241. */
  113242. debugMode: number;
  113243. /**
  113244. * @hidden
  113245. * This is reserved for the inspector.
  113246. * Specify from where on screen the debug mode should start.
  113247. * The value goes from -1 (full screen) to 1 (not visible)
  113248. * It helps with side by side comparison against the final render
  113249. * This defaults to -1
  113250. */
  113251. private debugLimit;
  113252. /**
  113253. * @hidden
  113254. * This is reserved for the inspector.
  113255. * As the default viewing range might not be enough (if the ambient is really small for instance)
  113256. * You can use the factor to better multiply the final value.
  113257. */
  113258. private debugFactor;
  113259. /**
  113260. * Defines the clear coat layer parameters for the material.
  113261. */
  113262. readonly clearCoat: PBRClearCoatConfiguration;
  113263. /**
  113264. * Defines the anisotropic parameters for the material.
  113265. */
  113266. readonly anisotropy: PBRAnisotropicConfiguration;
  113267. /**
  113268. * Defines the BRDF parameters for the material.
  113269. */
  113270. readonly brdf: PBRBRDFConfiguration;
  113271. /**
  113272. * Defines the Sheen parameters for the material.
  113273. */
  113274. readonly sheen: PBRSheenConfiguration;
  113275. /**
  113276. * Defines the SubSurface parameters for the material.
  113277. */
  113278. readonly subSurface: PBRSubSurfaceConfiguration;
  113279. /**
  113280. * Custom callback helping to override the default shader used in the material.
  113281. */
  113282. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  113283. protected _rebuildInParallel: boolean;
  113284. /**
  113285. * Instantiates a new PBRMaterial instance.
  113286. *
  113287. * @param name The material name
  113288. * @param scene The scene the material will be use in.
  113289. */
  113290. constructor(name: string, scene: Scene);
  113291. /**
  113292. * Gets a boolean indicating that current material needs to register RTT
  113293. */
  113294. readonly hasRenderTargetTextures: boolean;
  113295. /**
  113296. * Gets the name of the material class.
  113297. */
  113298. getClassName(): string;
  113299. /**
  113300. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  113301. */
  113302. /**
  113303. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  113304. */
  113305. useLogarithmicDepth: boolean;
  113306. /**
  113307. * Gets the current transparency mode.
  113308. */
  113309. /**
  113310. * Sets the transparency mode of the material.
  113311. *
  113312. * | Value | Type | Description |
  113313. * | ----- | ----------------------------------- | ----------- |
  113314. * | 0 | OPAQUE | |
  113315. * | 1 | ALPHATEST | |
  113316. * | 2 | ALPHABLEND | |
  113317. * | 3 | ALPHATESTANDBLEND | |
  113318. *
  113319. */
  113320. transparencyMode: Nullable<number>;
  113321. /**
  113322. * Returns true if alpha blending should be disabled.
  113323. */
  113324. private readonly _disableAlphaBlending;
  113325. /**
  113326. * Specifies whether or not this material should be rendered in alpha blend mode.
  113327. */
  113328. needAlphaBlending(): boolean;
  113329. /**
  113330. * Specifies if the mesh will require alpha blending.
  113331. * @param mesh - BJS mesh.
  113332. */
  113333. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  113334. /**
  113335. * Specifies whether or not this material should be rendered in alpha test mode.
  113336. */
  113337. needAlphaTesting(): boolean;
  113338. /**
  113339. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  113340. */
  113341. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  113342. /**
  113343. * Gets the texture used for the alpha test.
  113344. */
  113345. getAlphaTestTexture(): Nullable<BaseTexture>;
  113346. /**
  113347. * Specifies that the submesh is ready to be used.
  113348. * @param mesh - BJS mesh.
  113349. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  113350. * @param useInstances - Specifies that instances should be used.
  113351. * @returns - boolean indicating that the submesh is ready or not.
  113352. */
  113353. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113354. /**
  113355. * Specifies if the material uses metallic roughness workflow.
  113356. * @returns boolean specifiying if the material uses metallic roughness workflow.
  113357. */
  113358. isMetallicWorkflow(): boolean;
  113359. private _prepareEffect;
  113360. private _prepareDefines;
  113361. /**
  113362. * Force shader compilation
  113363. */
  113364. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  113365. clipPlane: boolean;
  113366. }>): void;
  113367. /**
  113368. * Initializes the uniform buffer layout for the shader.
  113369. */
  113370. buildUniformLayout(): void;
  113371. /**
  113372. * Unbinds the material from the mesh
  113373. */
  113374. unbind(): void;
  113375. /**
  113376. * Binds the submesh data.
  113377. * @param world - The world matrix.
  113378. * @param mesh - The BJS mesh.
  113379. * @param subMesh - A submesh of the BJS mesh.
  113380. */
  113381. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113382. /**
  113383. * Returns the animatable textures.
  113384. * @returns - Array of animatable textures.
  113385. */
  113386. getAnimatables(): IAnimatable[];
  113387. /**
  113388. * Returns the texture used for reflections.
  113389. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  113390. */
  113391. private _getReflectionTexture;
  113392. /**
  113393. * Returns an array of the actively used textures.
  113394. * @returns - Array of BaseTextures
  113395. */
  113396. getActiveTextures(): BaseTexture[];
  113397. /**
  113398. * Checks to see if a texture is used in the material.
  113399. * @param texture - Base texture to use.
  113400. * @returns - Boolean specifying if a texture is used in the material.
  113401. */
  113402. hasTexture(texture: BaseTexture): boolean;
  113403. /**
  113404. * Disposes the resources of the material.
  113405. * @param forceDisposeEffect - Forces the disposal of effects.
  113406. * @param forceDisposeTextures - Forces the disposal of all textures.
  113407. */
  113408. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  113409. }
  113410. }
  113411. declare module BABYLON {
  113412. /**
  113413. * The Physically based material of BJS.
  113414. *
  113415. * This offers the main features of a standard PBR material.
  113416. * For more information, please refer to the documentation :
  113417. * https://doc.babylonjs.com/how_to/physically_based_rendering
  113418. */
  113419. export class PBRMaterial extends PBRBaseMaterial {
  113420. /**
  113421. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  113422. */
  113423. static readonly PBRMATERIAL_OPAQUE: number;
  113424. /**
  113425. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  113426. */
  113427. static readonly PBRMATERIAL_ALPHATEST: number;
  113428. /**
  113429. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113430. */
  113431. static readonly PBRMATERIAL_ALPHABLEND: number;
  113432. /**
  113433. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113434. * They are also discarded below the alpha cutoff threshold to improve performances.
  113435. */
  113436. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  113437. /**
  113438. * Defines the default value of how much AO map is occluding the analytical lights
  113439. * (point spot...).
  113440. */
  113441. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  113442. /**
  113443. * Intensity of the direct lights e.g. the four lights available in your scene.
  113444. * This impacts both the direct diffuse and specular highlights.
  113445. */
  113446. directIntensity: number;
  113447. /**
  113448. * Intensity of the emissive part of the material.
  113449. * This helps controlling the emissive effect without modifying the emissive color.
  113450. */
  113451. emissiveIntensity: number;
  113452. /**
  113453. * Intensity of the environment e.g. how much the environment will light the object
  113454. * either through harmonics for rough material or through the refelction for shiny ones.
  113455. */
  113456. environmentIntensity: number;
  113457. /**
  113458. * This is a special control allowing the reduction of the specular highlights coming from the
  113459. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  113460. */
  113461. specularIntensity: number;
  113462. /**
  113463. * Debug Control allowing disabling the bump map on this material.
  113464. */
  113465. disableBumpMap: boolean;
  113466. /**
  113467. * AKA Diffuse Texture in standard nomenclature.
  113468. */
  113469. albedoTexture: BaseTexture;
  113470. /**
  113471. * AKA Occlusion Texture in other nomenclature.
  113472. */
  113473. ambientTexture: BaseTexture;
  113474. /**
  113475. * AKA Occlusion Texture Intensity in other nomenclature.
  113476. */
  113477. ambientTextureStrength: number;
  113478. /**
  113479. * Defines how much the AO map is occluding the analytical lights (point spot...).
  113480. * 1 means it completely occludes it
  113481. * 0 mean it has no impact
  113482. */
  113483. ambientTextureImpactOnAnalyticalLights: number;
  113484. /**
  113485. * Stores the alpha values in a texture.
  113486. */
  113487. opacityTexture: BaseTexture;
  113488. /**
  113489. * Stores the reflection values in a texture.
  113490. */
  113491. reflectionTexture: Nullable<BaseTexture>;
  113492. /**
  113493. * Stores the emissive values in a texture.
  113494. */
  113495. emissiveTexture: BaseTexture;
  113496. /**
  113497. * AKA Specular texture in other nomenclature.
  113498. */
  113499. reflectivityTexture: BaseTexture;
  113500. /**
  113501. * Used to switch from specular/glossiness to metallic/roughness workflow.
  113502. */
  113503. metallicTexture: BaseTexture;
  113504. /**
  113505. * Specifies the metallic scalar of the metallic/roughness workflow.
  113506. * Can also be used to scale the metalness values of the metallic texture.
  113507. */
  113508. metallic: Nullable<number>;
  113509. /**
  113510. * Specifies the roughness scalar of the metallic/roughness workflow.
  113511. * Can also be used to scale the roughness values of the metallic texture.
  113512. */
  113513. roughness: Nullable<number>;
  113514. /**
  113515. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  113516. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  113517. */
  113518. microSurfaceTexture: BaseTexture;
  113519. /**
  113520. * Stores surface normal data used to displace a mesh in a texture.
  113521. */
  113522. bumpTexture: BaseTexture;
  113523. /**
  113524. * Stores the pre-calculated light information of a mesh in a texture.
  113525. */
  113526. lightmapTexture: BaseTexture;
  113527. /**
  113528. * Stores the refracted light information in a texture.
  113529. */
  113530. refractionTexture: Nullable<BaseTexture>;
  113531. /**
  113532. * The color of a material in ambient lighting.
  113533. */
  113534. ambientColor: Color3;
  113535. /**
  113536. * AKA Diffuse Color in other nomenclature.
  113537. */
  113538. albedoColor: Color3;
  113539. /**
  113540. * AKA Specular Color in other nomenclature.
  113541. */
  113542. reflectivityColor: Color3;
  113543. /**
  113544. * The color reflected from the material.
  113545. */
  113546. reflectionColor: Color3;
  113547. /**
  113548. * The color emitted from the material.
  113549. */
  113550. emissiveColor: Color3;
  113551. /**
  113552. * AKA Glossiness in other nomenclature.
  113553. */
  113554. microSurface: number;
  113555. /**
  113556. * source material index of refraction (IOR)' / 'destination material IOR.
  113557. */
  113558. indexOfRefraction: number;
  113559. /**
  113560. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113561. */
  113562. invertRefractionY: boolean;
  113563. /**
  113564. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113565. * Materials half opaque for instance using refraction could benefit from this control.
  113566. */
  113567. linkRefractionWithTransparency: boolean;
  113568. /**
  113569. * If true, the light map contains occlusion information instead of lighting info.
  113570. */
  113571. useLightmapAsShadowmap: boolean;
  113572. /**
  113573. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  113574. */
  113575. useAlphaFromAlbedoTexture: boolean;
  113576. /**
  113577. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113578. */
  113579. forceAlphaTest: boolean;
  113580. /**
  113581. * Defines the alpha limits in alpha test mode.
  113582. */
  113583. alphaCutOff: number;
  113584. /**
  113585. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  113586. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  113587. */
  113588. useSpecularOverAlpha: boolean;
  113589. /**
  113590. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  113591. */
  113592. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  113593. /**
  113594. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  113595. */
  113596. useRoughnessFromMetallicTextureAlpha: boolean;
  113597. /**
  113598. * Specifies if the metallic texture contains the roughness information in its green channel.
  113599. */
  113600. useRoughnessFromMetallicTextureGreen: boolean;
  113601. /**
  113602. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113603. */
  113604. useMetallnessFromMetallicTextureBlue: boolean;
  113605. /**
  113606. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113607. */
  113608. useAmbientOcclusionFromMetallicTextureRed: boolean;
  113609. /**
  113610. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113611. */
  113612. useAmbientInGrayScale: boolean;
  113613. /**
  113614. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113615. * The material will try to infer what glossiness each pixel should be.
  113616. */
  113617. useAutoMicroSurfaceFromReflectivityMap: boolean;
  113618. /**
  113619. * BJS is using an harcoded light falloff based on a manually sets up range.
  113620. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113621. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113622. */
  113623. /**
  113624. * BJS is using an harcoded light falloff based on a manually sets up range.
  113625. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113626. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113627. */
  113628. usePhysicalLightFalloff: boolean;
  113629. /**
  113630. * In order to support the falloff compatibility with gltf, a special mode has been added
  113631. * to reproduce the gltf light falloff.
  113632. */
  113633. /**
  113634. * In order to support the falloff compatibility with gltf, a special mode has been added
  113635. * to reproduce the gltf light falloff.
  113636. */
  113637. useGLTFLightFalloff: boolean;
  113638. /**
  113639. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113640. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113641. */
  113642. useRadianceOverAlpha: boolean;
  113643. /**
  113644. * Allows using an object space normal map (instead of tangent space).
  113645. */
  113646. useObjectSpaceNormalMap: boolean;
  113647. /**
  113648. * Allows using the bump map in parallax mode.
  113649. */
  113650. useParallax: boolean;
  113651. /**
  113652. * Allows using the bump map in parallax occlusion mode.
  113653. */
  113654. useParallaxOcclusion: boolean;
  113655. /**
  113656. * Controls the scale bias of the parallax mode.
  113657. */
  113658. parallaxScaleBias: number;
  113659. /**
  113660. * If sets to true, disables all the lights affecting the material.
  113661. */
  113662. disableLighting: boolean;
  113663. /**
  113664. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113665. */
  113666. forceIrradianceInFragment: boolean;
  113667. /**
  113668. * Number of Simultaneous lights allowed on the material.
  113669. */
  113670. maxSimultaneousLights: number;
  113671. /**
  113672. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  113673. */
  113674. invertNormalMapX: boolean;
  113675. /**
  113676. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  113677. */
  113678. invertNormalMapY: boolean;
  113679. /**
  113680. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113681. */
  113682. twoSidedLighting: boolean;
  113683. /**
  113684. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113685. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113686. */
  113687. useAlphaFresnel: boolean;
  113688. /**
  113689. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113690. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113691. */
  113692. useLinearAlphaFresnel: boolean;
  113693. /**
  113694. * Let user defines the brdf lookup texture used for IBL.
  113695. * A default 8bit version is embedded but you could point at :
  113696. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  113697. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  113698. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  113699. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  113700. */
  113701. environmentBRDFTexture: Nullable<BaseTexture>;
  113702. /**
  113703. * Force normal to face away from face.
  113704. */
  113705. forceNormalForward: boolean;
  113706. /**
  113707. * Enables specular anti aliasing in the PBR shader.
  113708. * It will both interacts on the Geometry for analytical and IBL lighting.
  113709. * It also prefilter the roughness map based on the bump values.
  113710. */
  113711. enableSpecularAntiAliasing: boolean;
  113712. /**
  113713. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  113714. * makes the reflect vector face the model (under horizon).
  113715. */
  113716. useHorizonOcclusion: boolean;
  113717. /**
  113718. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  113719. * too much the area relying on ambient texture to define their ambient occlusion.
  113720. */
  113721. useRadianceOcclusion: boolean;
  113722. /**
  113723. * If set to true, no lighting calculations will be applied.
  113724. */
  113725. unlit: boolean;
  113726. /**
  113727. * Gets the image processing configuration used either in this material.
  113728. */
  113729. /**
  113730. * Sets the Default image processing configuration used either in the this material.
  113731. *
  113732. * If sets to null, the scene one is in use.
  113733. */
  113734. imageProcessingConfiguration: ImageProcessingConfiguration;
  113735. /**
  113736. * Gets wether the color curves effect is enabled.
  113737. */
  113738. /**
  113739. * Sets wether the color curves effect is enabled.
  113740. */
  113741. cameraColorCurvesEnabled: boolean;
  113742. /**
  113743. * Gets wether the color grading effect is enabled.
  113744. */
  113745. /**
  113746. * Gets wether the color grading effect is enabled.
  113747. */
  113748. cameraColorGradingEnabled: boolean;
  113749. /**
  113750. * Gets wether tonemapping is enabled or not.
  113751. */
  113752. /**
  113753. * Sets wether tonemapping is enabled or not
  113754. */
  113755. cameraToneMappingEnabled: boolean;
  113756. /**
  113757. * The camera exposure used on this material.
  113758. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113759. * This corresponds to a photographic exposure.
  113760. */
  113761. /**
  113762. * The camera exposure used on this material.
  113763. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113764. * This corresponds to a photographic exposure.
  113765. */
  113766. cameraExposure: number;
  113767. /**
  113768. * Gets The camera contrast used on this material.
  113769. */
  113770. /**
  113771. * Sets The camera contrast used on this material.
  113772. */
  113773. cameraContrast: number;
  113774. /**
  113775. * Gets the Color Grading 2D Lookup Texture.
  113776. */
  113777. /**
  113778. * Sets the Color Grading 2D Lookup Texture.
  113779. */
  113780. cameraColorGradingTexture: Nullable<BaseTexture>;
  113781. /**
  113782. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113783. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113784. * 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;
  113785. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113786. */
  113787. /**
  113788. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113789. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113790. * 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;
  113791. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113792. */
  113793. cameraColorCurves: Nullable<ColorCurves>;
  113794. /**
  113795. * Instantiates a new PBRMaterial instance.
  113796. *
  113797. * @param name The material name
  113798. * @param scene The scene the material will be use in.
  113799. */
  113800. constructor(name: string, scene: Scene);
  113801. /**
  113802. * Returns the name of this material class.
  113803. */
  113804. getClassName(): string;
  113805. /**
  113806. * Makes a duplicate of the current material.
  113807. * @param name - name to use for the new material.
  113808. */
  113809. clone(name: string): PBRMaterial;
  113810. /**
  113811. * Serializes this PBR Material.
  113812. * @returns - An object with the serialized material.
  113813. */
  113814. serialize(): any;
  113815. /**
  113816. * Parses a PBR Material from a serialized object.
  113817. * @param source - Serialized object.
  113818. * @param scene - BJS scene instance.
  113819. * @param rootUrl - url for the scene object
  113820. * @returns - PBRMaterial
  113821. */
  113822. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  113823. }
  113824. }
  113825. declare module BABYLON {
  113826. /**
  113827. * Direct draw surface info
  113828. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  113829. */
  113830. export interface DDSInfo {
  113831. /**
  113832. * Width of the texture
  113833. */
  113834. width: number;
  113835. /**
  113836. * Width of the texture
  113837. */
  113838. height: number;
  113839. /**
  113840. * Number of Mipmaps for the texture
  113841. * @see https://en.wikipedia.org/wiki/Mipmap
  113842. */
  113843. mipmapCount: number;
  113844. /**
  113845. * If the textures format is a known fourCC format
  113846. * @see https://www.fourcc.org/
  113847. */
  113848. isFourCC: boolean;
  113849. /**
  113850. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  113851. */
  113852. isRGB: boolean;
  113853. /**
  113854. * If the texture is a lumincance format
  113855. */
  113856. isLuminance: boolean;
  113857. /**
  113858. * If this is a cube texture
  113859. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  113860. */
  113861. isCube: boolean;
  113862. /**
  113863. * If the texture is a compressed format eg. FOURCC_DXT1
  113864. */
  113865. isCompressed: boolean;
  113866. /**
  113867. * The dxgiFormat of the texture
  113868. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  113869. */
  113870. dxgiFormat: number;
  113871. /**
  113872. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  113873. */
  113874. textureType: number;
  113875. /**
  113876. * Sphericle polynomial created for the dds texture
  113877. */
  113878. sphericalPolynomial?: SphericalPolynomial;
  113879. }
  113880. /**
  113881. * Class used to provide DDS decompression tools
  113882. */
  113883. export class DDSTools {
  113884. /**
  113885. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  113886. */
  113887. static StoreLODInAlphaChannel: boolean;
  113888. /**
  113889. * Gets DDS information from an array buffer
  113890. * @param arrayBuffer defines the array buffer to read data from
  113891. * @returns the DDS information
  113892. */
  113893. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  113894. private static _FloatView;
  113895. private static _Int32View;
  113896. private static _ToHalfFloat;
  113897. private static _FromHalfFloat;
  113898. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  113899. private static _GetHalfFloatRGBAArrayBuffer;
  113900. private static _GetFloatRGBAArrayBuffer;
  113901. private static _GetFloatAsUIntRGBAArrayBuffer;
  113902. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  113903. private static _GetRGBAArrayBuffer;
  113904. private static _ExtractLongWordOrder;
  113905. private static _GetRGBArrayBuffer;
  113906. private static _GetLuminanceArrayBuffer;
  113907. /**
  113908. * Uploads DDS Levels to a Babylon Texture
  113909. * @hidden
  113910. */
  113911. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  113912. }
  113913. interface Engine {
  113914. /**
  113915. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  113916. * @param rootUrl defines the url where the file to load is located
  113917. * @param scene defines the current scene
  113918. * @param lodScale defines scale to apply to the mip map selection
  113919. * @param lodOffset defines offset to apply to the mip map selection
  113920. * @param onLoad defines an optional callback raised when the texture is loaded
  113921. * @param onError defines an optional callback raised if there is an issue to load the texture
  113922. * @param format defines the format of the data
  113923. * @param forcedExtension defines the extension to use to pick the right loader
  113924. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  113925. * @returns the cube texture as an InternalTexture
  113926. */
  113927. 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;
  113928. }
  113929. }
  113930. declare module BABYLON {
  113931. /**
  113932. * Implementation of the DDS Texture Loader.
  113933. * @hidden
  113934. */
  113935. export class _DDSTextureLoader implements IInternalTextureLoader {
  113936. /**
  113937. * Defines wether the loader supports cascade loading the different faces.
  113938. */
  113939. readonly supportCascades: boolean;
  113940. /**
  113941. * This returns if the loader support the current file information.
  113942. * @param extension defines the file extension of the file being loaded
  113943. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113944. * @param fallback defines the fallback internal texture if any
  113945. * @param isBase64 defines whether the texture is encoded as a base64
  113946. * @param isBuffer defines whether the texture data are stored as a buffer
  113947. * @returns true if the loader can load the specified file
  113948. */
  113949. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113950. /**
  113951. * Transform the url before loading if required.
  113952. * @param rootUrl the url of the texture
  113953. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113954. * @returns the transformed texture
  113955. */
  113956. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113957. /**
  113958. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113959. * @param rootUrl the url of the texture
  113960. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113961. * @returns the fallback texture
  113962. */
  113963. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113964. /**
  113965. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113966. * @param data contains the texture data
  113967. * @param texture defines the BabylonJS internal texture
  113968. * @param createPolynomials will be true if polynomials have been requested
  113969. * @param onLoad defines the callback to trigger once the texture is ready
  113970. * @param onError defines the callback to trigger in case of error
  113971. */
  113972. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113973. /**
  113974. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113975. * @param data contains the texture data
  113976. * @param texture defines the BabylonJS internal texture
  113977. * @param callback defines the method to call once ready to upload
  113978. */
  113979. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113980. }
  113981. }
  113982. declare module BABYLON {
  113983. /**
  113984. * Implementation of the ENV Texture Loader.
  113985. * @hidden
  113986. */
  113987. export class _ENVTextureLoader implements IInternalTextureLoader {
  113988. /**
  113989. * Defines wether the loader supports cascade loading the different faces.
  113990. */
  113991. readonly supportCascades: boolean;
  113992. /**
  113993. * This returns if the loader support the current file information.
  113994. * @param extension defines the file extension of the file being loaded
  113995. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113996. * @param fallback defines the fallback internal texture if any
  113997. * @param isBase64 defines whether the texture is encoded as a base64
  113998. * @param isBuffer defines whether the texture data are stored as a buffer
  113999. * @returns true if the loader can load the specified file
  114000. */
  114001. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114002. /**
  114003. * Transform the url before loading if required.
  114004. * @param rootUrl the url of the texture
  114005. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114006. * @returns the transformed texture
  114007. */
  114008. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114009. /**
  114010. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114011. * @param rootUrl the url of the texture
  114012. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114013. * @returns the fallback texture
  114014. */
  114015. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114016. /**
  114017. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114018. * @param data contains the texture data
  114019. * @param texture defines the BabylonJS internal texture
  114020. * @param createPolynomials will be true if polynomials have been requested
  114021. * @param onLoad defines the callback to trigger once the texture is ready
  114022. * @param onError defines the callback to trigger in case of error
  114023. */
  114024. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114025. /**
  114026. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114027. * @param data contains the texture data
  114028. * @param texture defines the BabylonJS internal texture
  114029. * @param callback defines the method to call once ready to upload
  114030. */
  114031. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114032. }
  114033. }
  114034. declare module BABYLON {
  114035. /**
  114036. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  114037. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  114038. */
  114039. export class KhronosTextureContainer {
  114040. /** contents of the KTX container file */
  114041. arrayBuffer: any;
  114042. private static HEADER_LEN;
  114043. private static COMPRESSED_2D;
  114044. private static COMPRESSED_3D;
  114045. private static TEX_2D;
  114046. private static TEX_3D;
  114047. /**
  114048. * Gets the openGL type
  114049. */
  114050. glType: number;
  114051. /**
  114052. * Gets the openGL type size
  114053. */
  114054. glTypeSize: number;
  114055. /**
  114056. * Gets the openGL format
  114057. */
  114058. glFormat: number;
  114059. /**
  114060. * Gets the openGL internal format
  114061. */
  114062. glInternalFormat: number;
  114063. /**
  114064. * Gets the base internal format
  114065. */
  114066. glBaseInternalFormat: number;
  114067. /**
  114068. * Gets image width in pixel
  114069. */
  114070. pixelWidth: number;
  114071. /**
  114072. * Gets image height in pixel
  114073. */
  114074. pixelHeight: number;
  114075. /**
  114076. * Gets image depth in pixels
  114077. */
  114078. pixelDepth: number;
  114079. /**
  114080. * Gets the number of array elements
  114081. */
  114082. numberOfArrayElements: number;
  114083. /**
  114084. * Gets the number of faces
  114085. */
  114086. numberOfFaces: number;
  114087. /**
  114088. * Gets the number of mipmap levels
  114089. */
  114090. numberOfMipmapLevels: number;
  114091. /**
  114092. * Gets the bytes of key value data
  114093. */
  114094. bytesOfKeyValueData: number;
  114095. /**
  114096. * Gets the load type
  114097. */
  114098. loadType: number;
  114099. /**
  114100. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  114101. */
  114102. isInvalid: boolean;
  114103. /**
  114104. * Creates a new KhronosTextureContainer
  114105. * @param arrayBuffer contents of the KTX container file
  114106. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  114107. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  114108. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  114109. */
  114110. constructor(
  114111. /** contents of the KTX container file */
  114112. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  114113. /**
  114114. * Uploads KTX content to a Babylon Texture.
  114115. * It is assumed that the texture has already been created & is currently bound
  114116. * @hidden
  114117. */
  114118. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  114119. private _upload2DCompressedLevels;
  114120. }
  114121. }
  114122. declare module BABYLON {
  114123. /**
  114124. * Implementation of the KTX Texture Loader.
  114125. * @hidden
  114126. */
  114127. export class _KTXTextureLoader implements IInternalTextureLoader {
  114128. /**
  114129. * Defines wether the loader supports cascade loading the different faces.
  114130. */
  114131. readonly supportCascades: boolean;
  114132. /**
  114133. * This returns if the loader support the current file information.
  114134. * @param extension defines the file extension of the file being loaded
  114135. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114136. * @param fallback defines the fallback internal texture if any
  114137. * @param isBase64 defines whether the texture is encoded as a base64
  114138. * @param isBuffer defines whether the texture data are stored as a buffer
  114139. * @returns true if the loader can load the specified file
  114140. */
  114141. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114142. /**
  114143. * Transform the url before loading if required.
  114144. * @param rootUrl the url of the texture
  114145. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114146. * @returns the transformed texture
  114147. */
  114148. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114149. /**
  114150. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114151. * @param rootUrl the url of the texture
  114152. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114153. * @returns the fallback texture
  114154. */
  114155. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114156. /**
  114157. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114158. * @param data contains the texture data
  114159. * @param texture defines the BabylonJS internal texture
  114160. * @param createPolynomials will be true if polynomials have been requested
  114161. * @param onLoad defines the callback to trigger once the texture is ready
  114162. * @param onError defines the callback to trigger in case of error
  114163. */
  114164. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114165. /**
  114166. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114167. * @param data contains the texture data
  114168. * @param texture defines the BabylonJS internal texture
  114169. * @param callback defines the method to call once ready to upload
  114170. */
  114171. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  114172. }
  114173. }
  114174. declare module BABYLON {
  114175. /**
  114176. * Options for the default xr helper
  114177. */
  114178. export class WebXRDefaultExperienceOptions {
  114179. /**
  114180. * Floor meshes that should be used for teleporting
  114181. */
  114182. floorMeshes: Array<AbstractMesh>;
  114183. }
  114184. /**
  114185. * Default experience which provides a similar setup to the previous webVRExperience
  114186. */
  114187. export class WebXRDefaultExperience {
  114188. /**
  114189. * Base experience
  114190. */
  114191. baseExperience: WebXRExperienceHelper;
  114192. /**
  114193. * Input experience extension
  114194. */
  114195. input: WebXRInput;
  114196. /**
  114197. * Loads the controller models
  114198. */
  114199. controllerModelLoader: WebXRControllerModelLoader;
  114200. /**
  114201. * Enables laser pointer and selection
  114202. */
  114203. pointerSelection: WebXRControllerPointerSelection;
  114204. /**
  114205. * Enables teleportation
  114206. */
  114207. teleportation: WebXRControllerTeleportation;
  114208. /**
  114209. * Enables ui for enetering/exiting xr
  114210. */
  114211. enterExitUI: WebXREnterExitUI;
  114212. /**
  114213. * Default output canvas xr should render to
  114214. */
  114215. outputCanvas: WebXRManagedOutputCanvas;
  114216. /**
  114217. * Creates the default xr experience
  114218. * @param scene scene
  114219. * @param options options for basic configuration
  114220. * @returns resulting WebXRDefaultExperience
  114221. */
  114222. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114223. private constructor();
  114224. /**
  114225. * DIsposes of the experience helper
  114226. */
  114227. dispose(): void;
  114228. }
  114229. }
  114230. declare module BABYLON {
  114231. /** @hidden */
  114232. export var _forceSceneHelpersToBundle: boolean;
  114233. interface Scene {
  114234. /**
  114235. * Creates a default light for the scene.
  114236. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  114237. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  114238. */
  114239. createDefaultLight(replace?: boolean): void;
  114240. /**
  114241. * Creates a default camera for the scene.
  114242. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  114243. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  114244. * @param replace has default false, when true replaces the active camera in the scene
  114245. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  114246. */
  114247. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  114248. /**
  114249. * Creates a default camera and a default light.
  114250. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  114251. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  114252. * @param replace has the default false, when true replaces the active camera/light in the scene
  114253. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  114254. */
  114255. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  114256. /**
  114257. * Creates a new sky box
  114258. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  114259. * @param environmentTexture defines the texture to use as environment texture
  114260. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  114261. * @param scale defines the overall scale of the skybox
  114262. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  114263. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  114264. * @returns a new mesh holding the sky box
  114265. */
  114266. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  114267. /**
  114268. * Creates a new environment
  114269. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  114270. * @param options defines the options you can use to configure the environment
  114271. * @returns the new EnvironmentHelper
  114272. */
  114273. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  114274. /**
  114275. * Creates a new VREXperienceHelper
  114276. * @see http://doc.babylonjs.com/how_to/webvr_helper
  114277. * @param webVROptions defines the options used to create the new VREXperienceHelper
  114278. * @returns a new VREXperienceHelper
  114279. */
  114280. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  114281. /**
  114282. * Creates a new WebXRDefaultExperience
  114283. * @see http://doc.babylonjs.com/how_to/webxr
  114284. * @param options experience options
  114285. * @returns a promise for a new WebXRDefaultExperience
  114286. */
  114287. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114288. }
  114289. }
  114290. declare module BABYLON {
  114291. /**
  114292. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  114293. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  114294. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  114295. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  114296. */
  114297. export class VideoDome extends TransformNode {
  114298. /**
  114299. * Define the video source as a Monoscopic panoramic 360 video.
  114300. */
  114301. static readonly MODE_MONOSCOPIC: number;
  114302. /**
  114303. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114304. */
  114305. static readonly MODE_TOPBOTTOM: number;
  114306. /**
  114307. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114308. */
  114309. static readonly MODE_SIDEBYSIDE: number;
  114310. private _halfDome;
  114311. private _useDirectMapping;
  114312. /**
  114313. * The video texture being displayed on the sphere
  114314. */
  114315. protected _videoTexture: VideoTexture;
  114316. /**
  114317. * Gets the video texture being displayed on the sphere
  114318. */
  114319. readonly videoTexture: VideoTexture;
  114320. /**
  114321. * The skybox material
  114322. */
  114323. protected _material: BackgroundMaterial;
  114324. /**
  114325. * The surface used for the skybox
  114326. */
  114327. protected _mesh: Mesh;
  114328. /**
  114329. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  114330. */
  114331. private _halfDomeMask;
  114332. /**
  114333. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114334. * Also see the options.resolution property.
  114335. */
  114336. fovMultiplier: number;
  114337. private _videoMode;
  114338. /**
  114339. * Gets or set the current video mode for the video. It can be:
  114340. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  114341. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114342. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114343. */
  114344. videoMode: number;
  114345. /**
  114346. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  114347. *
  114348. */
  114349. /**
  114350. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  114351. */
  114352. halfDome: boolean;
  114353. /**
  114354. * Oberserver used in Stereoscopic VR Mode.
  114355. */
  114356. private _onBeforeCameraRenderObserver;
  114357. /**
  114358. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  114359. * @param name Element's name, child elements will append suffixes for their own names.
  114360. * @param urlsOrVideo defines the url(s) or the video element to use
  114361. * @param options An object containing optional or exposed sub element properties
  114362. */
  114363. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  114364. resolution?: number;
  114365. clickToPlay?: boolean;
  114366. autoPlay?: boolean;
  114367. loop?: boolean;
  114368. size?: number;
  114369. poster?: string;
  114370. faceForward?: boolean;
  114371. useDirectMapping?: boolean;
  114372. halfDomeMode?: boolean;
  114373. }, scene: Scene);
  114374. private _changeVideoMode;
  114375. /**
  114376. * Releases resources associated with this node.
  114377. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114378. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114379. */
  114380. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114381. }
  114382. }
  114383. declare module BABYLON {
  114384. /**
  114385. * This class can be used to get instrumentation data from a Babylon engine
  114386. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114387. */
  114388. export class EngineInstrumentation implements IDisposable {
  114389. /**
  114390. * Define the instrumented engine.
  114391. */
  114392. engine: Engine;
  114393. private _captureGPUFrameTime;
  114394. private _gpuFrameTimeToken;
  114395. private _gpuFrameTime;
  114396. private _captureShaderCompilationTime;
  114397. private _shaderCompilationTime;
  114398. private _onBeginFrameObserver;
  114399. private _onEndFrameObserver;
  114400. private _onBeforeShaderCompilationObserver;
  114401. private _onAfterShaderCompilationObserver;
  114402. /**
  114403. * Gets the perf counter used for GPU frame time
  114404. */
  114405. readonly gpuFrameTimeCounter: PerfCounter;
  114406. /**
  114407. * Gets the GPU frame time capture status
  114408. */
  114409. /**
  114410. * Enable or disable the GPU frame time capture
  114411. */
  114412. captureGPUFrameTime: boolean;
  114413. /**
  114414. * Gets the perf counter used for shader compilation time
  114415. */
  114416. readonly shaderCompilationTimeCounter: PerfCounter;
  114417. /**
  114418. * Gets the shader compilation time capture status
  114419. */
  114420. /**
  114421. * Enable or disable the shader compilation time capture
  114422. */
  114423. captureShaderCompilationTime: boolean;
  114424. /**
  114425. * Instantiates a new engine instrumentation.
  114426. * This class can be used to get instrumentation data from a Babylon engine
  114427. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114428. * @param engine Defines the engine to instrument
  114429. */
  114430. constructor(
  114431. /**
  114432. * Define the instrumented engine.
  114433. */
  114434. engine: Engine);
  114435. /**
  114436. * Dispose and release associated resources.
  114437. */
  114438. dispose(): void;
  114439. }
  114440. }
  114441. declare module BABYLON {
  114442. /**
  114443. * This class can be used to get instrumentation data from a Babylon engine
  114444. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114445. */
  114446. export class SceneInstrumentation implements IDisposable {
  114447. /**
  114448. * Defines the scene to instrument
  114449. */
  114450. scene: Scene;
  114451. private _captureActiveMeshesEvaluationTime;
  114452. private _activeMeshesEvaluationTime;
  114453. private _captureRenderTargetsRenderTime;
  114454. private _renderTargetsRenderTime;
  114455. private _captureFrameTime;
  114456. private _frameTime;
  114457. private _captureRenderTime;
  114458. private _renderTime;
  114459. private _captureInterFrameTime;
  114460. private _interFrameTime;
  114461. private _captureParticlesRenderTime;
  114462. private _particlesRenderTime;
  114463. private _captureSpritesRenderTime;
  114464. private _spritesRenderTime;
  114465. private _capturePhysicsTime;
  114466. private _physicsTime;
  114467. private _captureAnimationsTime;
  114468. private _animationsTime;
  114469. private _captureCameraRenderTime;
  114470. private _cameraRenderTime;
  114471. private _onBeforeActiveMeshesEvaluationObserver;
  114472. private _onAfterActiveMeshesEvaluationObserver;
  114473. private _onBeforeRenderTargetsRenderObserver;
  114474. private _onAfterRenderTargetsRenderObserver;
  114475. private _onAfterRenderObserver;
  114476. private _onBeforeDrawPhaseObserver;
  114477. private _onAfterDrawPhaseObserver;
  114478. private _onBeforeAnimationsObserver;
  114479. private _onBeforeParticlesRenderingObserver;
  114480. private _onAfterParticlesRenderingObserver;
  114481. private _onBeforeSpritesRenderingObserver;
  114482. private _onAfterSpritesRenderingObserver;
  114483. private _onBeforePhysicsObserver;
  114484. private _onAfterPhysicsObserver;
  114485. private _onAfterAnimationsObserver;
  114486. private _onBeforeCameraRenderObserver;
  114487. private _onAfterCameraRenderObserver;
  114488. /**
  114489. * Gets the perf counter used for active meshes evaluation time
  114490. */
  114491. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  114492. /**
  114493. * Gets the active meshes evaluation time capture status
  114494. */
  114495. /**
  114496. * Enable or disable the active meshes evaluation time capture
  114497. */
  114498. captureActiveMeshesEvaluationTime: boolean;
  114499. /**
  114500. * Gets the perf counter used for render targets render time
  114501. */
  114502. readonly renderTargetsRenderTimeCounter: PerfCounter;
  114503. /**
  114504. * Gets the render targets render time capture status
  114505. */
  114506. /**
  114507. * Enable or disable the render targets render time capture
  114508. */
  114509. captureRenderTargetsRenderTime: boolean;
  114510. /**
  114511. * Gets the perf counter used for particles render time
  114512. */
  114513. readonly particlesRenderTimeCounter: PerfCounter;
  114514. /**
  114515. * Gets the particles render time capture status
  114516. */
  114517. /**
  114518. * Enable or disable the particles render time capture
  114519. */
  114520. captureParticlesRenderTime: boolean;
  114521. /**
  114522. * Gets the perf counter used for sprites render time
  114523. */
  114524. readonly spritesRenderTimeCounter: PerfCounter;
  114525. /**
  114526. * Gets the sprites render time capture status
  114527. */
  114528. /**
  114529. * Enable or disable the sprites render time capture
  114530. */
  114531. captureSpritesRenderTime: boolean;
  114532. /**
  114533. * Gets the perf counter used for physics time
  114534. */
  114535. readonly physicsTimeCounter: PerfCounter;
  114536. /**
  114537. * Gets the physics time capture status
  114538. */
  114539. /**
  114540. * Enable or disable the physics time capture
  114541. */
  114542. capturePhysicsTime: boolean;
  114543. /**
  114544. * Gets the perf counter used for animations time
  114545. */
  114546. readonly animationsTimeCounter: PerfCounter;
  114547. /**
  114548. * Gets the animations time capture status
  114549. */
  114550. /**
  114551. * Enable or disable the animations time capture
  114552. */
  114553. captureAnimationsTime: boolean;
  114554. /**
  114555. * Gets the perf counter used for frame time capture
  114556. */
  114557. readonly frameTimeCounter: PerfCounter;
  114558. /**
  114559. * Gets the frame time capture status
  114560. */
  114561. /**
  114562. * Enable or disable the frame time capture
  114563. */
  114564. captureFrameTime: boolean;
  114565. /**
  114566. * Gets the perf counter used for inter-frames time capture
  114567. */
  114568. readonly interFrameTimeCounter: PerfCounter;
  114569. /**
  114570. * Gets the inter-frames time capture status
  114571. */
  114572. /**
  114573. * Enable or disable the inter-frames time capture
  114574. */
  114575. captureInterFrameTime: boolean;
  114576. /**
  114577. * Gets the perf counter used for render time capture
  114578. */
  114579. readonly renderTimeCounter: PerfCounter;
  114580. /**
  114581. * Gets the render time capture status
  114582. */
  114583. /**
  114584. * Enable or disable the render time capture
  114585. */
  114586. captureRenderTime: boolean;
  114587. /**
  114588. * Gets the perf counter used for camera render time capture
  114589. */
  114590. readonly cameraRenderTimeCounter: PerfCounter;
  114591. /**
  114592. * Gets the camera render time capture status
  114593. */
  114594. /**
  114595. * Enable or disable the camera render time capture
  114596. */
  114597. captureCameraRenderTime: boolean;
  114598. /**
  114599. * Gets the perf counter used for draw calls
  114600. */
  114601. readonly drawCallsCounter: PerfCounter;
  114602. /**
  114603. * Instantiates a new scene instrumentation.
  114604. * This class can be used to get instrumentation data from a Babylon engine
  114605. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114606. * @param scene Defines the scene to instrument
  114607. */
  114608. constructor(
  114609. /**
  114610. * Defines the scene to instrument
  114611. */
  114612. scene: Scene);
  114613. /**
  114614. * Dispose and release associated resources.
  114615. */
  114616. dispose(): void;
  114617. }
  114618. }
  114619. declare module BABYLON {
  114620. /** @hidden */
  114621. export var glowMapGenerationPixelShader: {
  114622. name: string;
  114623. shader: string;
  114624. };
  114625. }
  114626. declare module BABYLON {
  114627. /** @hidden */
  114628. export var glowMapGenerationVertexShader: {
  114629. name: string;
  114630. shader: string;
  114631. };
  114632. }
  114633. declare module BABYLON {
  114634. /**
  114635. * Effect layer options. This helps customizing the behaviour
  114636. * of the effect layer.
  114637. */
  114638. export interface IEffectLayerOptions {
  114639. /**
  114640. * Multiplication factor apply to the canvas size to compute the render target size
  114641. * used to generated the objects (the smaller the faster).
  114642. */
  114643. mainTextureRatio: number;
  114644. /**
  114645. * Enforces a fixed size texture to ensure effect stability across devices.
  114646. */
  114647. mainTextureFixedSize?: number;
  114648. /**
  114649. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  114650. */
  114651. alphaBlendingMode: number;
  114652. /**
  114653. * The camera attached to the layer.
  114654. */
  114655. camera: Nullable<Camera>;
  114656. /**
  114657. * The rendering group to draw the layer in.
  114658. */
  114659. renderingGroupId: number;
  114660. }
  114661. /**
  114662. * The effect layer Helps adding post process effect blended with the main pass.
  114663. *
  114664. * This can be for instance use to generate glow or higlight effects on the scene.
  114665. *
  114666. * The effect layer class can not be used directly and is intented to inherited from to be
  114667. * customized per effects.
  114668. */
  114669. export abstract class EffectLayer {
  114670. private _vertexBuffers;
  114671. private _indexBuffer;
  114672. private _cachedDefines;
  114673. private _effectLayerMapGenerationEffect;
  114674. private _effectLayerOptions;
  114675. private _mergeEffect;
  114676. protected _scene: Scene;
  114677. protected _engine: Engine;
  114678. protected _maxSize: number;
  114679. protected _mainTextureDesiredSize: ISize;
  114680. protected _mainTexture: RenderTargetTexture;
  114681. protected _shouldRender: boolean;
  114682. protected _postProcesses: PostProcess[];
  114683. protected _textures: BaseTexture[];
  114684. protected _emissiveTextureAndColor: {
  114685. texture: Nullable<BaseTexture>;
  114686. color: Color4;
  114687. };
  114688. /**
  114689. * The name of the layer
  114690. */
  114691. name: string;
  114692. /**
  114693. * The clear color of the texture used to generate the glow map.
  114694. */
  114695. neutralColor: Color4;
  114696. /**
  114697. * Specifies wether the highlight layer is enabled or not.
  114698. */
  114699. isEnabled: boolean;
  114700. /**
  114701. * Gets the camera attached to the layer.
  114702. */
  114703. readonly camera: Nullable<Camera>;
  114704. /**
  114705. * Gets the rendering group id the layer should render in.
  114706. */
  114707. renderingGroupId: number;
  114708. /**
  114709. * An event triggered when the effect layer has been disposed.
  114710. */
  114711. onDisposeObservable: Observable<EffectLayer>;
  114712. /**
  114713. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  114714. */
  114715. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  114716. /**
  114717. * An event triggered when the generated texture is being merged in the scene.
  114718. */
  114719. onBeforeComposeObservable: Observable<EffectLayer>;
  114720. /**
  114721. * An event triggered when the generated texture has been merged in the scene.
  114722. */
  114723. onAfterComposeObservable: Observable<EffectLayer>;
  114724. /**
  114725. * An event triggered when the efffect layer changes its size.
  114726. */
  114727. onSizeChangedObservable: Observable<EffectLayer>;
  114728. /** @hidden */
  114729. static _SceneComponentInitialization: (scene: Scene) => void;
  114730. /**
  114731. * Instantiates a new effect Layer and references it in the scene.
  114732. * @param name The name of the layer
  114733. * @param scene The scene to use the layer in
  114734. */
  114735. constructor(
  114736. /** The Friendly of the effect in the scene */
  114737. name: string, scene: Scene);
  114738. /**
  114739. * Get the effect name of the layer.
  114740. * @return The effect name
  114741. */
  114742. abstract getEffectName(): string;
  114743. /**
  114744. * Checks for the readiness of the element composing the layer.
  114745. * @param subMesh the mesh to check for
  114746. * @param useInstances specify wether or not to use instances to render the mesh
  114747. * @return true if ready otherwise, false
  114748. */
  114749. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114750. /**
  114751. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  114752. * @returns true if the effect requires stencil during the main canvas render pass.
  114753. */
  114754. abstract needStencil(): boolean;
  114755. /**
  114756. * Create the merge effect. This is the shader use to blit the information back
  114757. * to the main canvas at the end of the scene rendering.
  114758. * @returns The effect containing the shader used to merge the effect on the main canvas
  114759. */
  114760. protected abstract _createMergeEffect(): Effect;
  114761. /**
  114762. * Creates the render target textures and post processes used in the effect layer.
  114763. */
  114764. protected abstract _createTextureAndPostProcesses(): void;
  114765. /**
  114766. * Implementation specific of rendering the generating effect on the main canvas.
  114767. * @param effect The effect used to render through
  114768. */
  114769. protected abstract _internalRender(effect: Effect): void;
  114770. /**
  114771. * Sets the required values for both the emissive texture and and the main color.
  114772. */
  114773. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114774. /**
  114775. * Free any resources and references associated to a mesh.
  114776. * Internal use
  114777. * @param mesh The mesh to free.
  114778. */
  114779. abstract _disposeMesh(mesh: Mesh): void;
  114780. /**
  114781. * Serializes this layer (Glow or Highlight for example)
  114782. * @returns a serialized layer object
  114783. */
  114784. abstract serialize?(): any;
  114785. /**
  114786. * Initializes the effect layer with the required options.
  114787. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  114788. */
  114789. protected _init(options: Partial<IEffectLayerOptions>): void;
  114790. /**
  114791. * Generates the index buffer of the full screen quad blending to the main canvas.
  114792. */
  114793. private _generateIndexBuffer;
  114794. /**
  114795. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  114796. */
  114797. private _generateVertexBuffer;
  114798. /**
  114799. * Sets the main texture desired size which is the closest power of two
  114800. * of the engine canvas size.
  114801. */
  114802. private _setMainTextureSize;
  114803. /**
  114804. * Creates the main texture for the effect layer.
  114805. */
  114806. protected _createMainTexture(): void;
  114807. /**
  114808. * Adds specific effects defines.
  114809. * @param defines The defines to add specifics to.
  114810. */
  114811. protected _addCustomEffectDefines(defines: string[]): void;
  114812. /**
  114813. * Checks for the readiness of the element composing the layer.
  114814. * @param subMesh the mesh to check for
  114815. * @param useInstances specify wether or not to use instances to render the mesh
  114816. * @param emissiveTexture the associated emissive texture used to generate the glow
  114817. * @return true if ready otherwise, false
  114818. */
  114819. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  114820. /**
  114821. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  114822. */
  114823. render(): void;
  114824. /**
  114825. * Determine if a given mesh will be used in the current effect.
  114826. * @param mesh mesh to test
  114827. * @returns true if the mesh will be used
  114828. */
  114829. hasMesh(mesh: AbstractMesh): boolean;
  114830. /**
  114831. * Returns true if the layer contains information to display, otherwise false.
  114832. * @returns true if the glow layer should be rendered
  114833. */
  114834. shouldRender(): boolean;
  114835. /**
  114836. * Returns true if the mesh should render, otherwise false.
  114837. * @param mesh The mesh to render
  114838. * @returns true if it should render otherwise false
  114839. */
  114840. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  114841. /**
  114842. * Returns true if the mesh can be rendered, otherwise false.
  114843. * @param mesh The mesh to render
  114844. * @param material The material used on the mesh
  114845. * @returns true if it can be rendered otherwise false
  114846. */
  114847. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  114848. /**
  114849. * Returns true if the mesh should render, otherwise false.
  114850. * @param mesh The mesh to render
  114851. * @returns true if it should render otherwise false
  114852. */
  114853. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  114854. /**
  114855. * Renders the submesh passed in parameter to the generation map.
  114856. */
  114857. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  114858. /**
  114859. * Rebuild the required buffers.
  114860. * @hidden Internal use only.
  114861. */
  114862. _rebuild(): void;
  114863. /**
  114864. * Dispose only the render target textures and post process.
  114865. */
  114866. private _disposeTextureAndPostProcesses;
  114867. /**
  114868. * Dispose the highlight layer and free resources.
  114869. */
  114870. dispose(): void;
  114871. /**
  114872. * Gets the class name of the effect layer
  114873. * @returns the string with the class name of the effect layer
  114874. */
  114875. getClassName(): string;
  114876. /**
  114877. * Creates an effect layer from parsed effect layer data
  114878. * @param parsedEffectLayer defines effect layer data
  114879. * @param scene defines the current scene
  114880. * @param rootUrl defines the root URL containing the effect layer information
  114881. * @returns a parsed effect Layer
  114882. */
  114883. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  114884. }
  114885. }
  114886. declare module BABYLON {
  114887. interface AbstractScene {
  114888. /**
  114889. * The list of effect layers (highlights/glow) added to the scene
  114890. * @see http://doc.babylonjs.com/how_to/highlight_layer
  114891. * @see http://doc.babylonjs.com/how_to/glow_layer
  114892. */
  114893. effectLayers: Array<EffectLayer>;
  114894. /**
  114895. * Removes the given effect layer from this scene.
  114896. * @param toRemove defines the effect layer to remove
  114897. * @returns the index of the removed effect layer
  114898. */
  114899. removeEffectLayer(toRemove: EffectLayer): number;
  114900. /**
  114901. * Adds the given effect layer to this scene
  114902. * @param newEffectLayer defines the effect layer to add
  114903. */
  114904. addEffectLayer(newEffectLayer: EffectLayer): void;
  114905. }
  114906. /**
  114907. * Defines the layer scene component responsible to manage any effect layers
  114908. * in a given scene.
  114909. */
  114910. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  114911. /**
  114912. * The component name helpfull to identify the component in the list of scene components.
  114913. */
  114914. readonly name: string;
  114915. /**
  114916. * The scene the component belongs to.
  114917. */
  114918. scene: Scene;
  114919. private _engine;
  114920. private _renderEffects;
  114921. private _needStencil;
  114922. private _previousStencilState;
  114923. /**
  114924. * Creates a new instance of the component for the given scene
  114925. * @param scene Defines the scene to register the component in
  114926. */
  114927. constructor(scene: Scene);
  114928. /**
  114929. * Registers the component in a given scene
  114930. */
  114931. register(): void;
  114932. /**
  114933. * Rebuilds the elements related to this component in case of
  114934. * context lost for instance.
  114935. */
  114936. rebuild(): void;
  114937. /**
  114938. * Serializes the component data to the specified json object
  114939. * @param serializationObject The object to serialize to
  114940. */
  114941. serialize(serializationObject: any): void;
  114942. /**
  114943. * Adds all the elements from the container to the scene
  114944. * @param container the container holding the elements
  114945. */
  114946. addFromContainer(container: AbstractScene): void;
  114947. /**
  114948. * Removes all the elements in the container from the scene
  114949. * @param container contains the elements to remove
  114950. * @param dispose if the removed element should be disposed (default: false)
  114951. */
  114952. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114953. /**
  114954. * Disposes the component and the associated ressources.
  114955. */
  114956. dispose(): void;
  114957. private _isReadyForMesh;
  114958. private _renderMainTexture;
  114959. private _setStencil;
  114960. private _setStencilBack;
  114961. private _draw;
  114962. private _drawCamera;
  114963. private _drawRenderingGroup;
  114964. }
  114965. }
  114966. declare module BABYLON {
  114967. /** @hidden */
  114968. export var glowMapMergePixelShader: {
  114969. name: string;
  114970. shader: string;
  114971. };
  114972. }
  114973. declare module BABYLON {
  114974. /** @hidden */
  114975. export var glowMapMergeVertexShader: {
  114976. name: string;
  114977. shader: string;
  114978. };
  114979. }
  114980. declare module BABYLON {
  114981. interface AbstractScene {
  114982. /**
  114983. * Return a the first highlight layer of the scene with a given name.
  114984. * @param name The name of the highlight layer to look for.
  114985. * @return The highlight layer if found otherwise null.
  114986. */
  114987. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  114988. }
  114989. /**
  114990. * Glow layer options. This helps customizing the behaviour
  114991. * of the glow layer.
  114992. */
  114993. export interface IGlowLayerOptions {
  114994. /**
  114995. * Multiplication factor apply to the canvas size to compute the render target size
  114996. * used to generated the glowing objects (the smaller the faster).
  114997. */
  114998. mainTextureRatio: number;
  114999. /**
  115000. * Enforces a fixed size texture to ensure resize independant blur.
  115001. */
  115002. mainTextureFixedSize?: number;
  115003. /**
  115004. * How big is the kernel of the blur texture.
  115005. */
  115006. blurKernelSize: number;
  115007. /**
  115008. * The camera attached to the layer.
  115009. */
  115010. camera: Nullable<Camera>;
  115011. /**
  115012. * Enable MSAA by chosing the number of samples.
  115013. */
  115014. mainTextureSamples?: number;
  115015. /**
  115016. * The rendering group to draw the layer in.
  115017. */
  115018. renderingGroupId: number;
  115019. }
  115020. /**
  115021. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  115022. *
  115023. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  115024. * glowy meshes to your scene.
  115025. *
  115026. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  115027. */
  115028. export class GlowLayer extends EffectLayer {
  115029. /**
  115030. * Effect Name of the layer.
  115031. */
  115032. static readonly EffectName: string;
  115033. /**
  115034. * The default blur kernel size used for the glow.
  115035. */
  115036. static DefaultBlurKernelSize: number;
  115037. /**
  115038. * The default texture size ratio used for the glow.
  115039. */
  115040. static DefaultTextureRatio: number;
  115041. /**
  115042. * Sets the kernel size of the blur.
  115043. */
  115044. /**
  115045. * Gets the kernel size of the blur.
  115046. */
  115047. blurKernelSize: number;
  115048. /**
  115049. * Sets the glow intensity.
  115050. */
  115051. /**
  115052. * Gets the glow intensity.
  115053. */
  115054. intensity: number;
  115055. private _options;
  115056. private _intensity;
  115057. private _horizontalBlurPostprocess1;
  115058. private _verticalBlurPostprocess1;
  115059. private _horizontalBlurPostprocess2;
  115060. private _verticalBlurPostprocess2;
  115061. private _blurTexture1;
  115062. private _blurTexture2;
  115063. private _postProcesses1;
  115064. private _postProcesses2;
  115065. private _includedOnlyMeshes;
  115066. private _excludedMeshes;
  115067. /**
  115068. * Callback used to let the user override the color selection on a per mesh basis
  115069. */
  115070. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  115071. /**
  115072. * Callback used to let the user override the texture selection on a per mesh basis
  115073. */
  115074. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  115075. /**
  115076. * Instantiates a new glow Layer and references it to the scene.
  115077. * @param name The name of the layer
  115078. * @param scene The scene to use the layer in
  115079. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  115080. */
  115081. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  115082. /**
  115083. * Get the effect name of the layer.
  115084. * @return The effect name
  115085. */
  115086. getEffectName(): string;
  115087. /**
  115088. * Create the merge effect. This is the shader use to blit the information back
  115089. * to the main canvas at the end of the scene rendering.
  115090. */
  115091. protected _createMergeEffect(): Effect;
  115092. /**
  115093. * Creates the render target textures and post processes used in the glow layer.
  115094. */
  115095. protected _createTextureAndPostProcesses(): void;
  115096. /**
  115097. * Checks for the readiness of the element composing the layer.
  115098. * @param subMesh the mesh to check for
  115099. * @param useInstances specify wether or not to use instances to render the mesh
  115100. * @param emissiveTexture the associated emissive texture used to generate the glow
  115101. * @return true if ready otherwise, false
  115102. */
  115103. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115104. /**
  115105. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115106. */
  115107. needStencil(): boolean;
  115108. /**
  115109. * Returns true if the mesh can be rendered, otherwise false.
  115110. * @param mesh The mesh to render
  115111. * @param material The material used on the mesh
  115112. * @returns true if it can be rendered otherwise false
  115113. */
  115114. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  115115. /**
  115116. * Implementation specific of rendering the generating effect on the main canvas.
  115117. * @param effect The effect used to render through
  115118. */
  115119. protected _internalRender(effect: Effect): void;
  115120. /**
  115121. * Sets the required values for both the emissive texture and and the main color.
  115122. */
  115123. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115124. /**
  115125. * Returns true if the mesh should render, otherwise false.
  115126. * @param mesh The mesh to render
  115127. * @returns true if it should render otherwise false
  115128. */
  115129. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115130. /**
  115131. * Adds specific effects defines.
  115132. * @param defines The defines to add specifics to.
  115133. */
  115134. protected _addCustomEffectDefines(defines: string[]): void;
  115135. /**
  115136. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  115137. * @param mesh The mesh to exclude from the glow layer
  115138. */
  115139. addExcludedMesh(mesh: Mesh): void;
  115140. /**
  115141. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  115142. * @param mesh The mesh to remove
  115143. */
  115144. removeExcludedMesh(mesh: Mesh): void;
  115145. /**
  115146. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  115147. * @param mesh The mesh to include in the glow layer
  115148. */
  115149. addIncludedOnlyMesh(mesh: Mesh): void;
  115150. /**
  115151. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  115152. * @param mesh The mesh to remove
  115153. */
  115154. removeIncludedOnlyMesh(mesh: Mesh): void;
  115155. /**
  115156. * Determine if a given mesh will be used in the glow layer
  115157. * @param mesh The mesh to test
  115158. * @returns true if the mesh will be highlighted by the current glow layer
  115159. */
  115160. hasMesh(mesh: AbstractMesh): boolean;
  115161. /**
  115162. * Free any resources and references associated to a mesh.
  115163. * Internal use
  115164. * @param mesh The mesh to free.
  115165. * @hidden
  115166. */
  115167. _disposeMesh(mesh: Mesh): void;
  115168. /**
  115169. * Gets the class name of the effect layer
  115170. * @returns the string with the class name of the effect layer
  115171. */
  115172. getClassName(): string;
  115173. /**
  115174. * Serializes this glow layer
  115175. * @returns a serialized glow layer object
  115176. */
  115177. serialize(): any;
  115178. /**
  115179. * Creates a Glow Layer from parsed glow layer data
  115180. * @param parsedGlowLayer defines glow layer data
  115181. * @param scene defines the current scene
  115182. * @param rootUrl defines the root URL containing the glow layer information
  115183. * @returns a parsed Glow Layer
  115184. */
  115185. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  115186. }
  115187. }
  115188. declare module BABYLON {
  115189. /** @hidden */
  115190. export var glowBlurPostProcessPixelShader: {
  115191. name: string;
  115192. shader: string;
  115193. };
  115194. }
  115195. declare module BABYLON {
  115196. interface AbstractScene {
  115197. /**
  115198. * Return a the first highlight layer of the scene with a given name.
  115199. * @param name The name of the highlight layer to look for.
  115200. * @return The highlight layer if found otherwise null.
  115201. */
  115202. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  115203. }
  115204. /**
  115205. * Highlight layer options. This helps customizing the behaviour
  115206. * of the highlight layer.
  115207. */
  115208. export interface IHighlightLayerOptions {
  115209. /**
  115210. * Multiplication factor apply to the canvas size to compute the render target size
  115211. * used to generated the glowing objects (the smaller the faster).
  115212. */
  115213. mainTextureRatio: number;
  115214. /**
  115215. * Enforces a fixed size texture to ensure resize independant blur.
  115216. */
  115217. mainTextureFixedSize?: number;
  115218. /**
  115219. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  115220. * of the picture to blur (the smaller the faster).
  115221. */
  115222. blurTextureSizeRatio: number;
  115223. /**
  115224. * How big in texel of the blur texture is the vertical blur.
  115225. */
  115226. blurVerticalSize: number;
  115227. /**
  115228. * How big in texel of the blur texture is the horizontal blur.
  115229. */
  115230. blurHorizontalSize: number;
  115231. /**
  115232. * Alpha blending mode used to apply the blur. Default is combine.
  115233. */
  115234. alphaBlendingMode: number;
  115235. /**
  115236. * The camera attached to the layer.
  115237. */
  115238. camera: Nullable<Camera>;
  115239. /**
  115240. * Should we display highlight as a solid stroke?
  115241. */
  115242. isStroke?: boolean;
  115243. /**
  115244. * The rendering group to draw the layer in.
  115245. */
  115246. renderingGroupId: number;
  115247. }
  115248. /**
  115249. * The highlight layer Helps adding a glow effect around a mesh.
  115250. *
  115251. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  115252. * glowy meshes to your scene.
  115253. *
  115254. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  115255. */
  115256. export class HighlightLayer extends EffectLayer {
  115257. name: string;
  115258. /**
  115259. * Effect Name of the highlight layer.
  115260. */
  115261. static readonly EffectName: string;
  115262. /**
  115263. * The neutral color used during the preparation of the glow effect.
  115264. * This is black by default as the blend operation is a blend operation.
  115265. */
  115266. static NeutralColor: Color4;
  115267. /**
  115268. * Stencil value used for glowing meshes.
  115269. */
  115270. static GlowingMeshStencilReference: number;
  115271. /**
  115272. * Stencil value used for the other meshes in the scene.
  115273. */
  115274. static NormalMeshStencilReference: number;
  115275. /**
  115276. * Specifies whether or not the inner glow is ACTIVE in the layer.
  115277. */
  115278. innerGlow: boolean;
  115279. /**
  115280. * Specifies whether or not the outer glow is ACTIVE in the layer.
  115281. */
  115282. outerGlow: boolean;
  115283. /**
  115284. * Specifies the horizontal size of the blur.
  115285. */
  115286. /**
  115287. * Gets the horizontal size of the blur.
  115288. */
  115289. blurHorizontalSize: number;
  115290. /**
  115291. * Specifies the vertical size of the blur.
  115292. */
  115293. /**
  115294. * Gets the vertical size of the blur.
  115295. */
  115296. blurVerticalSize: number;
  115297. /**
  115298. * An event triggered when the highlight layer is being blurred.
  115299. */
  115300. onBeforeBlurObservable: Observable<HighlightLayer>;
  115301. /**
  115302. * An event triggered when the highlight layer has been blurred.
  115303. */
  115304. onAfterBlurObservable: Observable<HighlightLayer>;
  115305. private _instanceGlowingMeshStencilReference;
  115306. private _options;
  115307. private _downSamplePostprocess;
  115308. private _horizontalBlurPostprocess;
  115309. private _verticalBlurPostprocess;
  115310. private _blurTexture;
  115311. private _meshes;
  115312. private _excludedMeshes;
  115313. /**
  115314. * Instantiates a new highlight Layer and references it to the scene..
  115315. * @param name The name of the layer
  115316. * @param scene The scene to use the layer in
  115317. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  115318. */
  115319. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  115320. /**
  115321. * Get the effect name of the layer.
  115322. * @return The effect name
  115323. */
  115324. getEffectName(): string;
  115325. /**
  115326. * Create the merge effect. This is the shader use to blit the information back
  115327. * to the main canvas at the end of the scene rendering.
  115328. */
  115329. protected _createMergeEffect(): Effect;
  115330. /**
  115331. * Creates the render target textures and post processes used in the highlight layer.
  115332. */
  115333. protected _createTextureAndPostProcesses(): void;
  115334. /**
  115335. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115336. */
  115337. needStencil(): boolean;
  115338. /**
  115339. * Checks for the readiness of the element composing the layer.
  115340. * @param subMesh the mesh to check for
  115341. * @param useInstances specify wether or not to use instances to render the mesh
  115342. * @param emissiveTexture the associated emissive texture used to generate the glow
  115343. * @return true if ready otherwise, false
  115344. */
  115345. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115346. /**
  115347. * Implementation specific of rendering the generating effect on the main canvas.
  115348. * @param effect The effect used to render through
  115349. */
  115350. protected _internalRender(effect: Effect): void;
  115351. /**
  115352. * Returns true if the layer contains information to display, otherwise false.
  115353. */
  115354. shouldRender(): boolean;
  115355. /**
  115356. * Returns true if the mesh should render, otherwise false.
  115357. * @param mesh The mesh to render
  115358. * @returns true if it should render otherwise false
  115359. */
  115360. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115361. /**
  115362. * Sets the required values for both the emissive texture and and the main color.
  115363. */
  115364. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115365. /**
  115366. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  115367. * @param mesh The mesh to exclude from the highlight layer
  115368. */
  115369. addExcludedMesh(mesh: Mesh): void;
  115370. /**
  115371. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  115372. * @param mesh The mesh to highlight
  115373. */
  115374. removeExcludedMesh(mesh: Mesh): void;
  115375. /**
  115376. * Determine if a given mesh will be highlighted by the current HighlightLayer
  115377. * @param mesh mesh to test
  115378. * @returns true if the mesh will be highlighted by the current HighlightLayer
  115379. */
  115380. hasMesh(mesh: AbstractMesh): boolean;
  115381. /**
  115382. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  115383. * @param mesh The mesh to highlight
  115384. * @param color The color of the highlight
  115385. * @param glowEmissiveOnly Extract the glow from the emissive texture
  115386. */
  115387. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  115388. /**
  115389. * Remove a mesh from the highlight layer in order to make it stop glowing.
  115390. * @param mesh The mesh to highlight
  115391. */
  115392. removeMesh(mesh: Mesh): void;
  115393. /**
  115394. * Force the stencil to the normal expected value for none glowing parts
  115395. */
  115396. private _defaultStencilReference;
  115397. /**
  115398. * Free any resources and references associated to a mesh.
  115399. * Internal use
  115400. * @param mesh The mesh to free.
  115401. * @hidden
  115402. */
  115403. _disposeMesh(mesh: Mesh): void;
  115404. /**
  115405. * Dispose the highlight layer and free resources.
  115406. */
  115407. dispose(): void;
  115408. /**
  115409. * Gets the class name of the effect layer
  115410. * @returns the string with the class name of the effect layer
  115411. */
  115412. getClassName(): string;
  115413. /**
  115414. * Serializes this Highlight layer
  115415. * @returns a serialized Highlight layer object
  115416. */
  115417. serialize(): any;
  115418. /**
  115419. * Creates a Highlight layer from parsed Highlight layer data
  115420. * @param parsedHightlightLayer defines the Highlight layer data
  115421. * @param scene defines the current scene
  115422. * @param rootUrl defines the root URL containing the Highlight layer information
  115423. * @returns a parsed Highlight layer
  115424. */
  115425. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  115426. }
  115427. }
  115428. declare module BABYLON {
  115429. interface AbstractScene {
  115430. /**
  115431. * The list of layers (background and foreground) of the scene
  115432. */
  115433. layers: Array<Layer>;
  115434. }
  115435. /**
  115436. * Defines the layer scene component responsible to manage any layers
  115437. * in a given scene.
  115438. */
  115439. export class LayerSceneComponent implements ISceneComponent {
  115440. /**
  115441. * The component name helpfull to identify the component in the list of scene components.
  115442. */
  115443. readonly name: string;
  115444. /**
  115445. * The scene the component belongs to.
  115446. */
  115447. scene: Scene;
  115448. private _engine;
  115449. /**
  115450. * Creates a new instance of the component for the given scene
  115451. * @param scene Defines the scene to register the component in
  115452. */
  115453. constructor(scene: Scene);
  115454. /**
  115455. * Registers the component in a given scene
  115456. */
  115457. register(): void;
  115458. /**
  115459. * Rebuilds the elements related to this component in case of
  115460. * context lost for instance.
  115461. */
  115462. rebuild(): void;
  115463. /**
  115464. * Disposes the component and the associated ressources.
  115465. */
  115466. dispose(): void;
  115467. private _draw;
  115468. private _drawCameraPredicate;
  115469. private _drawCameraBackground;
  115470. private _drawCameraForeground;
  115471. private _drawRenderTargetPredicate;
  115472. private _drawRenderTargetBackground;
  115473. private _drawRenderTargetForeground;
  115474. /**
  115475. * Adds all the elements from the container to the scene
  115476. * @param container the container holding the elements
  115477. */
  115478. addFromContainer(container: AbstractScene): void;
  115479. /**
  115480. * Removes all the elements in the container from the scene
  115481. * @param container contains the elements to remove
  115482. * @param dispose if the removed element should be disposed (default: false)
  115483. */
  115484. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115485. }
  115486. }
  115487. declare module BABYLON {
  115488. /** @hidden */
  115489. export var layerPixelShader: {
  115490. name: string;
  115491. shader: string;
  115492. };
  115493. }
  115494. declare module BABYLON {
  115495. /** @hidden */
  115496. export var layerVertexShader: {
  115497. name: string;
  115498. shader: string;
  115499. };
  115500. }
  115501. declare module BABYLON {
  115502. /**
  115503. * This represents a full screen 2d layer.
  115504. * This can be useful to display a picture in the background of your scene for instance.
  115505. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115506. */
  115507. export class Layer {
  115508. /**
  115509. * Define the name of the layer.
  115510. */
  115511. name: string;
  115512. /**
  115513. * Define the texture the layer should display.
  115514. */
  115515. texture: Nullable<Texture>;
  115516. /**
  115517. * Is the layer in background or foreground.
  115518. */
  115519. isBackground: boolean;
  115520. /**
  115521. * Define the color of the layer (instead of texture).
  115522. */
  115523. color: Color4;
  115524. /**
  115525. * Define the scale of the layer in order to zoom in out of the texture.
  115526. */
  115527. scale: Vector2;
  115528. /**
  115529. * Define an offset for the layer in order to shift the texture.
  115530. */
  115531. offset: Vector2;
  115532. /**
  115533. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  115534. */
  115535. alphaBlendingMode: number;
  115536. /**
  115537. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  115538. * Alpha test will not mix with the background color in case of transparency.
  115539. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  115540. */
  115541. alphaTest: boolean;
  115542. /**
  115543. * Define a mask to restrict the layer to only some of the scene cameras.
  115544. */
  115545. layerMask: number;
  115546. /**
  115547. * Define the list of render target the layer is visible into.
  115548. */
  115549. renderTargetTextures: RenderTargetTexture[];
  115550. /**
  115551. * Define if the layer is only used in renderTarget or if it also
  115552. * renders in the main frame buffer of the canvas.
  115553. */
  115554. renderOnlyInRenderTargetTextures: boolean;
  115555. private _scene;
  115556. private _vertexBuffers;
  115557. private _indexBuffer;
  115558. private _effect;
  115559. private _alphaTestEffect;
  115560. /**
  115561. * An event triggered when the layer is disposed.
  115562. */
  115563. onDisposeObservable: Observable<Layer>;
  115564. private _onDisposeObserver;
  115565. /**
  115566. * Back compatibility with callback before the onDisposeObservable existed.
  115567. * The set callback will be triggered when the layer has been disposed.
  115568. */
  115569. onDispose: () => void;
  115570. /**
  115571. * An event triggered before rendering the scene
  115572. */
  115573. onBeforeRenderObservable: Observable<Layer>;
  115574. private _onBeforeRenderObserver;
  115575. /**
  115576. * Back compatibility with callback before the onBeforeRenderObservable existed.
  115577. * The set callback will be triggered just before rendering the layer.
  115578. */
  115579. onBeforeRender: () => void;
  115580. /**
  115581. * An event triggered after rendering the scene
  115582. */
  115583. onAfterRenderObservable: Observable<Layer>;
  115584. private _onAfterRenderObserver;
  115585. /**
  115586. * Back compatibility with callback before the onAfterRenderObservable existed.
  115587. * The set callback will be triggered just after rendering the layer.
  115588. */
  115589. onAfterRender: () => void;
  115590. /**
  115591. * Instantiates a new layer.
  115592. * This represents a full screen 2d layer.
  115593. * This can be useful to display a picture in the background of your scene for instance.
  115594. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115595. * @param name Define the name of the layer in the scene
  115596. * @param imgUrl Define the url of the texture to display in the layer
  115597. * @param scene Define the scene the layer belongs to
  115598. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  115599. * @param color Defines a color for the layer
  115600. */
  115601. constructor(
  115602. /**
  115603. * Define the name of the layer.
  115604. */
  115605. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  115606. private _createIndexBuffer;
  115607. /** @hidden */
  115608. _rebuild(): void;
  115609. /**
  115610. * Renders the layer in the scene.
  115611. */
  115612. render(): void;
  115613. /**
  115614. * Disposes and releases the associated ressources.
  115615. */
  115616. dispose(): void;
  115617. }
  115618. }
  115619. declare module BABYLON {
  115620. /** @hidden */
  115621. export var lensFlarePixelShader: {
  115622. name: string;
  115623. shader: string;
  115624. };
  115625. }
  115626. declare module BABYLON {
  115627. /** @hidden */
  115628. export var lensFlareVertexShader: {
  115629. name: string;
  115630. shader: string;
  115631. };
  115632. }
  115633. declare module BABYLON {
  115634. /**
  115635. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115636. * It is usually composed of several `lensFlare`.
  115637. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115638. */
  115639. export class LensFlareSystem {
  115640. /**
  115641. * Define the name of the lens flare system
  115642. */
  115643. name: string;
  115644. /**
  115645. * List of lens flares used in this system.
  115646. */
  115647. lensFlares: LensFlare[];
  115648. /**
  115649. * Define a limit from the border the lens flare can be visible.
  115650. */
  115651. borderLimit: number;
  115652. /**
  115653. * Define a viewport border we do not want to see the lens flare in.
  115654. */
  115655. viewportBorder: number;
  115656. /**
  115657. * Define a predicate which could limit the list of meshes able to occlude the effect.
  115658. */
  115659. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  115660. /**
  115661. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  115662. */
  115663. layerMask: number;
  115664. /**
  115665. * Define the id of the lens flare system in the scene.
  115666. * (equal to name by default)
  115667. */
  115668. id: string;
  115669. private _scene;
  115670. private _emitter;
  115671. private _vertexBuffers;
  115672. private _indexBuffer;
  115673. private _effect;
  115674. private _positionX;
  115675. private _positionY;
  115676. private _isEnabled;
  115677. /** @hidden */
  115678. static _SceneComponentInitialization: (scene: Scene) => void;
  115679. /**
  115680. * Instantiates a lens flare system.
  115681. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115682. * It is usually composed of several `lensFlare`.
  115683. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115684. * @param name Define the name of the lens flare system in the scene
  115685. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  115686. * @param scene Define the scene the lens flare system belongs to
  115687. */
  115688. constructor(
  115689. /**
  115690. * Define the name of the lens flare system
  115691. */
  115692. name: string, emitter: any, scene: Scene);
  115693. /**
  115694. * Define if the lens flare system is enabled.
  115695. */
  115696. isEnabled: boolean;
  115697. /**
  115698. * Get the scene the effects belongs to.
  115699. * @returns the scene holding the lens flare system
  115700. */
  115701. getScene(): Scene;
  115702. /**
  115703. * Get the emitter of the lens flare system.
  115704. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115705. * @returns the emitter of the lens flare system
  115706. */
  115707. getEmitter(): any;
  115708. /**
  115709. * Set the emitter of the lens flare system.
  115710. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115711. * @param newEmitter Define the new emitter of the system
  115712. */
  115713. setEmitter(newEmitter: any): void;
  115714. /**
  115715. * Get the lens flare system emitter position.
  115716. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  115717. * @returns the position
  115718. */
  115719. getEmitterPosition(): Vector3;
  115720. /**
  115721. * @hidden
  115722. */
  115723. computeEffectivePosition(globalViewport: Viewport): boolean;
  115724. /** @hidden */
  115725. _isVisible(): boolean;
  115726. /**
  115727. * @hidden
  115728. */
  115729. render(): boolean;
  115730. /**
  115731. * Dispose and release the lens flare with its associated resources.
  115732. */
  115733. dispose(): void;
  115734. /**
  115735. * Parse a lens flare system from a JSON repressentation
  115736. * @param parsedLensFlareSystem Define the JSON to parse
  115737. * @param scene Define the scene the parsed system should be instantiated in
  115738. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  115739. * @returns the parsed system
  115740. */
  115741. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  115742. /**
  115743. * Serialize the current Lens Flare System into a JSON representation.
  115744. * @returns the serialized JSON
  115745. */
  115746. serialize(): any;
  115747. }
  115748. }
  115749. declare module BABYLON {
  115750. /**
  115751. * This represents one of the lens effect in a `lensFlareSystem`.
  115752. * It controls one of the indiviual texture used in the effect.
  115753. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115754. */
  115755. export class LensFlare {
  115756. /**
  115757. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115758. */
  115759. size: number;
  115760. /**
  115761. * 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.
  115762. */
  115763. position: number;
  115764. /**
  115765. * Define the lens color.
  115766. */
  115767. color: Color3;
  115768. /**
  115769. * Define the lens texture.
  115770. */
  115771. texture: Nullable<Texture>;
  115772. /**
  115773. * Define the alpha mode to render this particular lens.
  115774. */
  115775. alphaMode: number;
  115776. private _system;
  115777. /**
  115778. * Creates a new Lens Flare.
  115779. * This represents one of the lens effect in a `lensFlareSystem`.
  115780. * It controls one of the indiviual texture used in the effect.
  115781. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115782. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  115783. * @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.
  115784. * @param color Define the lens color
  115785. * @param imgUrl Define the lens texture url
  115786. * @param system Define the `lensFlareSystem` this flare is part of
  115787. * @returns The newly created Lens Flare
  115788. */
  115789. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  115790. /**
  115791. * Instantiates a new Lens Flare.
  115792. * This represents one of the lens effect in a `lensFlareSystem`.
  115793. * It controls one of the indiviual texture used in the effect.
  115794. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115795. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  115796. * @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.
  115797. * @param color Define the lens color
  115798. * @param imgUrl Define the lens texture url
  115799. * @param system Define the `lensFlareSystem` this flare is part of
  115800. */
  115801. constructor(
  115802. /**
  115803. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115804. */
  115805. size: number,
  115806. /**
  115807. * 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.
  115808. */
  115809. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  115810. /**
  115811. * Dispose and release the lens flare with its associated resources.
  115812. */
  115813. dispose(): void;
  115814. }
  115815. }
  115816. declare module BABYLON {
  115817. interface AbstractScene {
  115818. /**
  115819. * The list of lens flare system added to the scene
  115820. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115821. */
  115822. lensFlareSystems: Array<LensFlareSystem>;
  115823. /**
  115824. * Removes the given lens flare system from this scene.
  115825. * @param toRemove The lens flare system to remove
  115826. * @returns The index of the removed lens flare system
  115827. */
  115828. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  115829. /**
  115830. * Adds the given lens flare system to this scene
  115831. * @param newLensFlareSystem The lens flare system to add
  115832. */
  115833. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  115834. /**
  115835. * Gets a lens flare system using its name
  115836. * @param name defines the name to look for
  115837. * @returns the lens flare system or null if not found
  115838. */
  115839. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  115840. /**
  115841. * Gets a lens flare system using its id
  115842. * @param id defines the id to look for
  115843. * @returns the lens flare system or null if not found
  115844. */
  115845. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  115846. }
  115847. /**
  115848. * Defines the lens flare scene component responsible to manage any lens flares
  115849. * in a given scene.
  115850. */
  115851. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  115852. /**
  115853. * The component name helpfull to identify the component in the list of scene components.
  115854. */
  115855. readonly name: string;
  115856. /**
  115857. * The scene the component belongs to.
  115858. */
  115859. scene: Scene;
  115860. /**
  115861. * Creates a new instance of the component for the given scene
  115862. * @param scene Defines the scene to register the component in
  115863. */
  115864. constructor(scene: Scene);
  115865. /**
  115866. * Registers the component in a given scene
  115867. */
  115868. register(): void;
  115869. /**
  115870. * Rebuilds the elements related to this component in case of
  115871. * context lost for instance.
  115872. */
  115873. rebuild(): void;
  115874. /**
  115875. * Adds all the elements from the container to the scene
  115876. * @param container the container holding the elements
  115877. */
  115878. addFromContainer(container: AbstractScene): void;
  115879. /**
  115880. * Removes all the elements in the container from the scene
  115881. * @param container contains the elements to remove
  115882. * @param dispose if the removed element should be disposed (default: false)
  115883. */
  115884. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115885. /**
  115886. * Serializes the component data to the specified json object
  115887. * @param serializationObject The object to serialize to
  115888. */
  115889. serialize(serializationObject: any): void;
  115890. /**
  115891. * Disposes the component and the associated ressources.
  115892. */
  115893. dispose(): void;
  115894. private _draw;
  115895. }
  115896. }
  115897. declare module BABYLON {
  115898. /**
  115899. * Defines the shadow generator component responsible to manage any shadow generators
  115900. * in a given scene.
  115901. */
  115902. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  115903. /**
  115904. * The component name helpfull to identify the component in the list of scene components.
  115905. */
  115906. readonly name: string;
  115907. /**
  115908. * The scene the component belongs to.
  115909. */
  115910. scene: Scene;
  115911. /**
  115912. * Creates a new instance of the component for the given scene
  115913. * @param scene Defines the scene to register the component in
  115914. */
  115915. constructor(scene: Scene);
  115916. /**
  115917. * Registers the component in a given scene
  115918. */
  115919. register(): void;
  115920. /**
  115921. * Rebuilds the elements related to this component in case of
  115922. * context lost for instance.
  115923. */
  115924. rebuild(): void;
  115925. /**
  115926. * Serializes the component data to the specified json object
  115927. * @param serializationObject The object to serialize to
  115928. */
  115929. serialize(serializationObject: any): void;
  115930. /**
  115931. * Adds all the elements from the container to the scene
  115932. * @param container the container holding the elements
  115933. */
  115934. addFromContainer(container: AbstractScene): void;
  115935. /**
  115936. * Removes all the elements in the container from the scene
  115937. * @param container contains the elements to remove
  115938. * @param dispose if the removed element should be disposed (default: false)
  115939. */
  115940. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115941. /**
  115942. * Rebuilds the elements related to this component in case of
  115943. * context lost for instance.
  115944. */
  115945. dispose(): void;
  115946. private _gatherRenderTargets;
  115947. }
  115948. }
  115949. declare module BABYLON {
  115950. /**
  115951. * A point light is a light defined by an unique point in world space.
  115952. * The light is emitted in every direction from this point.
  115953. * A good example of a point light is a standard light bulb.
  115954. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115955. */
  115956. export class PointLight extends ShadowLight {
  115957. private _shadowAngle;
  115958. /**
  115959. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115960. * This specifies what angle the shadow will use to be created.
  115961. *
  115962. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  115963. */
  115964. /**
  115965. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115966. * This specifies what angle the shadow will use to be created.
  115967. *
  115968. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  115969. */
  115970. shadowAngle: number;
  115971. /**
  115972. * Gets the direction if it has been set.
  115973. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115974. */
  115975. /**
  115976. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115977. */
  115978. direction: Vector3;
  115979. /**
  115980. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  115981. * A PointLight emits the light in every direction.
  115982. * It can cast shadows.
  115983. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  115984. * ```javascript
  115985. * var pointLight = new PointLight("pl", camera.position, scene);
  115986. * ```
  115987. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115988. * @param name The light friendly name
  115989. * @param position The position of the point light in the scene
  115990. * @param scene The scene the lights belongs to
  115991. */
  115992. constructor(name: string, position: Vector3, scene: Scene);
  115993. /**
  115994. * Returns the string "PointLight"
  115995. * @returns the class name
  115996. */
  115997. getClassName(): string;
  115998. /**
  115999. * Returns the integer 0.
  116000. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  116001. */
  116002. getTypeID(): number;
  116003. /**
  116004. * Specifies wether or not the shadowmap should be a cube texture.
  116005. * @returns true if the shadowmap needs to be a cube texture.
  116006. */
  116007. needCube(): boolean;
  116008. /**
  116009. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  116010. * @param faceIndex The index of the face we are computed the direction to generate shadow
  116011. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  116012. */
  116013. getShadowDirection(faceIndex?: number): Vector3;
  116014. /**
  116015. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  116016. * - fov = PI / 2
  116017. * - aspect ratio : 1.0
  116018. * - z-near and far equal to the active camera minZ and maxZ.
  116019. * Returns the PointLight.
  116020. */
  116021. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  116022. protected _buildUniformLayout(): void;
  116023. /**
  116024. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  116025. * @param effect The effect to update
  116026. * @param lightIndex The index of the light in the effect to update
  116027. * @returns The point light
  116028. */
  116029. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  116030. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  116031. /**
  116032. * Prepares the list of defines specific to the light type.
  116033. * @param defines the list of defines
  116034. * @param lightIndex defines the index of the light for the effect
  116035. */
  116036. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  116037. }
  116038. }
  116039. declare module BABYLON {
  116040. /**
  116041. * Header information of HDR texture files.
  116042. */
  116043. export interface HDRInfo {
  116044. /**
  116045. * The height of the texture in pixels.
  116046. */
  116047. height: number;
  116048. /**
  116049. * The width of the texture in pixels.
  116050. */
  116051. width: number;
  116052. /**
  116053. * The index of the beginning of the data in the binary file.
  116054. */
  116055. dataPosition: number;
  116056. }
  116057. /**
  116058. * This groups tools to convert HDR texture to native colors array.
  116059. */
  116060. export class HDRTools {
  116061. private static Ldexp;
  116062. private static Rgbe2float;
  116063. private static readStringLine;
  116064. /**
  116065. * Reads header information from an RGBE texture stored in a native array.
  116066. * More information on this format are available here:
  116067. * https://en.wikipedia.org/wiki/RGBE_image_format
  116068. *
  116069. * @param uint8array The binary file stored in native array.
  116070. * @return The header information.
  116071. */
  116072. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  116073. /**
  116074. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  116075. * This RGBE texture needs to store the information as a panorama.
  116076. *
  116077. * More information on this format are available here:
  116078. * https://en.wikipedia.org/wiki/RGBE_image_format
  116079. *
  116080. * @param buffer The binary file stored in an array buffer.
  116081. * @param size The expected size of the extracted cubemap.
  116082. * @return The Cube Map information.
  116083. */
  116084. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  116085. /**
  116086. * Returns the pixels data extracted from an RGBE texture.
  116087. * This pixels will be stored left to right up to down in the R G B order in one array.
  116088. *
  116089. * More information on this format are available here:
  116090. * https://en.wikipedia.org/wiki/RGBE_image_format
  116091. *
  116092. * @param uint8array The binary file stored in an array buffer.
  116093. * @param hdrInfo The header information of the file.
  116094. * @return The pixels data in RGB right to left up to down order.
  116095. */
  116096. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  116097. private static RGBE_ReadPixels_RLE;
  116098. }
  116099. }
  116100. declare module BABYLON {
  116101. /**
  116102. * This represents a texture coming from an HDR input.
  116103. *
  116104. * The only supported format is currently panorama picture stored in RGBE format.
  116105. * Example of such files can be found on HDRLib: http://hdrlib.com/
  116106. */
  116107. export class HDRCubeTexture extends BaseTexture {
  116108. private static _facesMapping;
  116109. private _generateHarmonics;
  116110. private _noMipmap;
  116111. private _textureMatrix;
  116112. private _size;
  116113. private _onLoad;
  116114. private _onError;
  116115. /**
  116116. * The texture URL.
  116117. */
  116118. url: string;
  116119. /**
  116120. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  116121. */
  116122. coordinatesMode: number;
  116123. protected _isBlocking: boolean;
  116124. /**
  116125. * Sets wether or not the texture is blocking during loading.
  116126. */
  116127. /**
  116128. * Gets wether or not the texture is blocking during loading.
  116129. */
  116130. isBlocking: boolean;
  116131. protected _rotationY: number;
  116132. /**
  116133. * Sets texture matrix rotation angle around Y axis in radians.
  116134. */
  116135. /**
  116136. * Gets texture matrix rotation angle around Y axis radians.
  116137. */
  116138. rotationY: number;
  116139. /**
  116140. * Gets or sets the center of the bounding box associated with the cube texture
  116141. * It must define where the camera used to render the texture was set
  116142. */
  116143. boundingBoxPosition: Vector3;
  116144. private _boundingBoxSize;
  116145. /**
  116146. * Gets or sets the size of the bounding box associated with the cube texture
  116147. * When defined, the cubemap will switch to local mode
  116148. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  116149. * @example https://www.babylonjs-playground.com/#RNASML
  116150. */
  116151. boundingBoxSize: Vector3;
  116152. /**
  116153. * Instantiates an HDRTexture from the following parameters.
  116154. *
  116155. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  116156. * @param scene The scene the texture will be used in
  116157. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  116158. * @param noMipmap Forces to not generate the mipmap if true
  116159. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  116160. * @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)
  116161. * @param reserved Reserved flag for internal use.
  116162. */
  116163. 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>);
  116164. /**
  116165. * Get the current class name of the texture useful for serialization or dynamic coding.
  116166. * @returns "HDRCubeTexture"
  116167. */
  116168. getClassName(): string;
  116169. /**
  116170. * Occurs when the file is raw .hdr file.
  116171. */
  116172. private loadTexture;
  116173. clone(): HDRCubeTexture;
  116174. delayLoad(): void;
  116175. /**
  116176. * Get the texture reflection matrix used to rotate/transform the reflection.
  116177. * @returns the reflection matrix
  116178. */
  116179. getReflectionTextureMatrix(): Matrix;
  116180. /**
  116181. * Set the texture reflection matrix used to rotate/transform the reflection.
  116182. * @param value Define the reflection matrix to set
  116183. */
  116184. setReflectionTextureMatrix(value: Matrix): void;
  116185. /**
  116186. * Parses a JSON representation of an HDR Texture in order to create the texture
  116187. * @param parsedTexture Define the JSON representation
  116188. * @param scene Define the scene the texture should be created in
  116189. * @param rootUrl Define the root url in case we need to load relative dependencies
  116190. * @returns the newly created texture after parsing
  116191. */
  116192. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  116193. serialize(): any;
  116194. }
  116195. }
  116196. declare module BABYLON {
  116197. /**
  116198. * Class used to control physics engine
  116199. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116200. */
  116201. export class PhysicsEngine implements IPhysicsEngine {
  116202. private _physicsPlugin;
  116203. /**
  116204. * Global value used to control the smallest number supported by the simulation
  116205. */
  116206. static Epsilon: number;
  116207. private _impostors;
  116208. private _joints;
  116209. /**
  116210. * Gets the gravity vector used by the simulation
  116211. */
  116212. gravity: Vector3;
  116213. /**
  116214. * Factory used to create the default physics plugin.
  116215. * @returns The default physics plugin
  116216. */
  116217. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  116218. /**
  116219. * Creates a new Physics Engine
  116220. * @param gravity defines the gravity vector used by the simulation
  116221. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  116222. */
  116223. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  116224. /**
  116225. * Sets the gravity vector used by the simulation
  116226. * @param gravity defines the gravity vector to use
  116227. */
  116228. setGravity(gravity: Vector3): void;
  116229. /**
  116230. * Set the time step of the physics engine.
  116231. * Default is 1/60.
  116232. * To slow it down, enter 1/600 for example.
  116233. * To speed it up, 1/30
  116234. * @param newTimeStep defines the new timestep to apply to this world.
  116235. */
  116236. setTimeStep(newTimeStep?: number): void;
  116237. /**
  116238. * Get the time step of the physics engine.
  116239. * @returns the current time step
  116240. */
  116241. getTimeStep(): number;
  116242. /**
  116243. * Release all resources
  116244. */
  116245. dispose(): void;
  116246. /**
  116247. * Gets the name of the current physics plugin
  116248. * @returns the name of the plugin
  116249. */
  116250. getPhysicsPluginName(): string;
  116251. /**
  116252. * Adding a new impostor for the impostor tracking.
  116253. * This will be done by the impostor itself.
  116254. * @param impostor the impostor to add
  116255. */
  116256. addImpostor(impostor: PhysicsImpostor): void;
  116257. /**
  116258. * Remove an impostor from the engine.
  116259. * This impostor and its mesh will not longer be updated by the physics engine.
  116260. * @param impostor the impostor to remove
  116261. */
  116262. removeImpostor(impostor: PhysicsImpostor): void;
  116263. /**
  116264. * Add a joint to the physics engine
  116265. * @param mainImpostor defines the main impostor to which the joint is added.
  116266. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  116267. * @param joint defines the joint that will connect both impostors.
  116268. */
  116269. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116270. /**
  116271. * Removes a joint from the simulation
  116272. * @param mainImpostor defines the impostor used with the joint
  116273. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  116274. * @param joint defines the joint to remove
  116275. */
  116276. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116277. /**
  116278. * Called by the scene. No need to call it.
  116279. * @param delta defines the timespam between frames
  116280. */
  116281. _step(delta: number): void;
  116282. /**
  116283. * Gets the current plugin used to run the simulation
  116284. * @returns current plugin
  116285. */
  116286. getPhysicsPlugin(): IPhysicsEnginePlugin;
  116287. /**
  116288. * Gets the list of physic impostors
  116289. * @returns an array of PhysicsImpostor
  116290. */
  116291. getImpostors(): Array<PhysicsImpostor>;
  116292. /**
  116293. * Gets the impostor for a physics enabled object
  116294. * @param object defines the object impersonated by the impostor
  116295. * @returns the PhysicsImpostor or null if not found
  116296. */
  116297. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  116298. /**
  116299. * Gets the impostor for a physics body object
  116300. * @param body defines physics body used by the impostor
  116301. * @returns the PhysicsImpostor or null if not found
  116302. */
  116303. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  116304. /**
  116305. * Does a raycast in the physics world
  116306. * @param from when should the ray start?
  116307. * @param to when should the ray end?
  116308. * @returns PhysicsRaycastResult
  116309. */
  116310. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116311. }
  116312. }
  116313. declare module BABYLON {
  116314. /** @hidden */
  116315. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  116316. private _useDeltaForWorldStep;
  116317. world: any;
  116318. name: string;
  116319. private _physicsMaterials;
  116320. private _fixedTimeStep;
  116321. private _cannonRaycastResult;
  116322. private _raycastResult;
  116323. private _physicsBodysToRemoveAfterStep;
  116324. BJSCANNON: any;
  116325. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  116326. setGravity(gravity: Vector3): void;
  116327. setTimeStep(timeStep: number): void;
  116328. getTimeStep(): number;
  116329. executeStep(delta: number): void;
  116330. private _removeMarkedPhysicsBodiesFromWorld;
  116331. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116332. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116333. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116334. private _processChildMeshes;
  116335. removePhysicsBody(impostor: PhysicsImpostor): void;
  116336. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116337. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116338. private _addMaterial;
  116339. private _checkWithEpsilon;
  116340. private _createShape;
  116341. private _createHeightmap;
  116342. private _minus90X;
  116343. private _plus90X;
  116344. private _tmpPosition;
  116345. private _tmpDeltaPosition;
  116346. private _tmpUnityRotation;
  116347. private _updatePhysicsBodyTransformation;
  116348. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116349. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116350. isSupported(): boolean;
  116351. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116352. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116353. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116354. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116355. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116356. getBodyMass(impostor: PhysicsImpostor): number;
  116357. getBodyFriction(impostor: PhysicsImpostor): number;
  116358. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116359. getBodyRestitution(impostor: PhysicsImpostor): number;
  116360. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116361. sleepBody(impostor: PhysicsImpostor): void;
  116362. wakeUpBody(impostor: PhysicsImpostor): void;
  116363. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  116364. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116365. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116366. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116367. getRadius(impostor: PhysicsImpostor): number;
  116368. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116369. dispose(): void;
  116370. private _extendNamespace;
  116371. /**
  116372. * Does a raycast in the physics world
  116373. * @param from when should the ray start?
  116374. * @param to when should the ray end?
  116375. * @returns PhysicsRaycastResult
  116376. */
  116377. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116378. }
  116379. }
  116380. declare module BABYLON {
  116381. /** @hidden */
  116382. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  116383. world: any;
  116384. name: string;
  116385. BJSOIMO: any;
  116386. private _raycastResult;
  116387. constructor(iterations?: number, oimoInjection?: any);
  116388. setGravity(gravity: Vector3): void;
  116389. setTimeStep(timeStep: number): void;
  116390. getTimeStep(): number;
  116391. private _tmpImpostorsArray;
  116392. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116393. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116394. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116395. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116396. private _tmpPositionVector;
  116397. removePhysicsBody(impostor: PhysicsImpostor): void;
  116398. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116399. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116400. isSupported(): boolean;
  116401. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116402. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116403. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116404. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116405. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116406. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116407. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116408. getBodyMass(impostor: PhysicsImpostor): number;
  116409. getBodyFriction(impostor: PhysicsImpostor): number;
  116410. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116411. getBodyRestitution(impostor: PhysicsImpostor): number;
  116412. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116413. sleepBody(impostor: PhysicsImpostor): void;
  116414. wakeUpBody(impostor: PhysicsImpostor): void;
  116415. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116416. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  116417. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  116418. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116419. getRadius(impostor: PhysicsImpostor): number;
  116420. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116421. dispose(): void;
  116422. /**
  116423. * Does a raycast in the physics world
  116424. * @param from when should the ray start?
  116425. * @param to when should the ray end?
  116426. * @returns PhysicsRaycastResult
  116427. */
  116428. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116429. }
  116430. }
  116431. declare module BABYLON {
  116432. /**
  116433. * Class containing static functions to help procedurally build meshes
  116434. */
  116435. export class RibbonBuilder {
  116436. /**
  116437. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116438. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  116439. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  116440. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  116441. * * 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
  116442. * * 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
  116443. * * 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
  116444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116445. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116446. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116447. * * 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
  116448. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  116449. * * 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
  116450. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  116451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116452. * @param name defines the name of the mesh
  116453. * @param options defines the options used to create the mesh
  116454. * @param scene defines the hosting scene
  116455. * @returns the ribbon mesh
  116456. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  116457. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116458. */
  116459. static CreateRibbon(name: string, options: {
  116460. pathArray: Vector3[][];
  116461. closeArray?: boolean;
  116462. closePath?: boolean;
  116463. offset?: number;
  116464. updatable?: boolean;
  116465. sideOrientation?: number;
  116466. frontUVs?: Vector4;
  116467. backUVs?: Vector4;
  116468. instance?: Mesh;
  116469. invertUV?: boolean;
  116470. uvs?: Vector2[];
  116471. colors?: Color4[];
  116472. }, scene?: Nullable<Scene>): Mesh;
  116473. }
  116474. }
  116475. declare module BABYLON {
  116476. /**
  116477. * Class containing static functions to help procedurally build meshes
  116478. */
  116479. export class ShapeBuilder {
  116480. /**
  116481. * 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.
  116482. * * 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.
  116483. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116484. * * 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.
  116485. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116486. * * 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
  116487. * * 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
  116488. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116490. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116491. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116493. * @param name defines the name of the mesh
  116494. * @param options defines the options used to create the mesh
  116495. * @param scene defines the hosting scene
  116496. * @returns the extruded shape mesh
  116497. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116498. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116499. */
  116500. static ExtrudeShape(name: string, options: {
  116501. shape: Vector3[];
  116502. path: Vector3[];
  116503. scale?: number;
  116504. rotation?: number;
  116505. cap?: number;
  116506. updatable?: boolean;
  116507. sideOrientation?: number;
  116508. frontUVs?: Vector4;
  116509. backUVs?: Vector4;
  116510. instance?: Mesh;
  116511. invertUV?: boolean;
  116512. }, scene?: Nullable<Scene>): Mesh;
  116513. /**
  116514. * Creates an custom extruded shape mesh.
  116515. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116516. * * 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.
  116517. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116518. * * 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
  116519. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116520. * * 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
  116521. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116522. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116523. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  116524. * * 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
  116525. * * 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
  116526. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  116527. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116528. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116529. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116531. * @param name defines the name of the mesh
  116532. * @param options defines the options used to create the mesh
  116533. * @param scene defines the hosting scene
  116534. * @returns the custom extruded shape mesh
  116535. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116536. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116537. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116538. */
  116539. static ExtrudeShapeCustom(name: string, options: {
  116540. shape: Vector3[];
  116541. path: Vector3[];
  116542. scaleFunction?: any;
  116543. rotationFunction?: any;
  116544. ribbonCloseArray?: boolean;
  116545. ribbonClosePath?: boolean;
  116546. cap?: number;
  116547. updatable?: boolean;
  116548. sideOrientation?: number;
  116549. frontUVs?: Vector4;
  116550. backUVs?: Vector4;
  116551. instance?: Mesh;
  116552. invertUV?: boolean;
  116553. }, scene?: Nullable<Scene>): Mesh;
  116554. private static _ExtrudeShapeGeneric;
  116555. }
  116556. }
  116557. declare module BABYLON {
  116558. /**
  116559. * AmmoJS Physics plugin
  116560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116561. * @see https://github.com/kripken/ammo.js/
  116562. */
  116563. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  116564. private _useDeltaForWorldStep;
  116565. /**
  116566. * Reference to the Ammo library
  116567. */
  116568. bjsAMMO: any;
  116569. /**
  116570. * Created ammoJS world which physics bodies are added to
  116571. */
  116572. world: any;
  116573. /**
  116574. * Name of the plugin
  116575. */
  116576. name: string;
  116577. private _timeStep;
  116578. private _fixedTimeStep;
  116579. private _maxSteps;
  116580. private _tmpQuaternion;
  116581. private _tmpAmmoTransform;
  116582. private _tmpAmmoQuaternion;
  116583. private _tmpAmmoConcreteContactResultCallback;
  116584. private _collisionConfiguration;
  116585. private _dispatcher;
  116586. private _overlappingPairCache;
  116587. private _solver;
  116588. private _softBodySolver;
  116589. private _tmpAmmoVectorA;
  116590. private _tmpAmmoVectorB;
  116591. private _tmpAmmoVectorC;
  116592. private _tmpAmmoVectorD;
  116593. private _tmpContactCallbackResult;
  116594. private _tmpAmmoVectorRCA;
  116595. private _tmpAmmoVectorRCB;
  116596. private _raycastResult;
  116597. private static readonly DISABLE_COLLISION_FLAG;
  116598. private static readonly KINEMATIC_FLAG;
  116599. private static readonly DISABLE_DEACTIVATION_FLAG;
  116600. /**
  116601. * Initializes the ammoJS plugin
  116602. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  116603. * @param ammoInjection can be used to inject your own ammo reference
  116604. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  116605. */
  116606. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  116607. /**
  116608. * Sets the gravity of the physics world (m/(s^2))
  116609. * @param gravity Gravity to set
  116610. */
  116611. setGravity(gravity: Vector3): void;
  116612. /**
  116613. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  116614. * @param timeStep timestep to use in seconds
  116615. */
  116616. setTimeStep(timeStep: number): void;
  116617. /**
  116618. * 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)
  116619. * @param fixedTimeStep fixedTimeStep to use in seconds
  116620. */
  116621. setFixedTimeStep(fixedTimeStep: number): void;
  116622. /**
  116623. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  116624. * @param maxSteps the maximum number of steps by the physics engine per frame
  116625. */
  116626. setMaxSteps(maxSteps: number): void;
  116627. /**
  116628. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  116629. * @returns the current timestep in seconds
  116630. */
  116631. getTimeStep(): number;
  116632. private _isImpostorInContact;
  116633. private _isImpostorPairInContact;
  116634. private _stepSimulation;
  116635. /**
  116636. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  116637. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  116638. * After the step the babylon meshes are set to the position of the physics imposters
  116639. * @param delta amount of time to step forward
  116640. * @param impostors array of imposters to update before/after the step
  116641. */
  116642. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116643. /**
  116644. * Update babylon mesh to match physics world object
  116645. * @param impostor imposter to match
  116646. */
  116647. private _afterSoftStep;
  116648. /**
  116649. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116650. * @param impostor imposter to match
  116651. */
  116652. private _ropeStep;
  116653. /**
  116654. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116655. * @param impostor imposter to match
  116656. */
  116657. private _softbodyOrClothStep;
  116658. private _tmpVector;
  116659. private _tmpMatrix;
  116660. /**
  116661. * Applies an impulse on the imposter
  116662. * @param impostor imposter to apply impulse to
  116663. * @param force amount of force to be applied to the imposter
  116664. * @param contactPoint the location to apply the impulse on the imposter
  116665. */
  116666. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116667. /**
  116668. * Applies a force on the imposter
  116669. * @param impostor imposter to apply force
  116670. * @param force amount of force to be applied to the imposter
  116671. * @param contactPoint the location to apply the force on the imposter
  116672. */
  116673. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116674. /**
  116675. * Creates a physics body using the plugin
  116676. * @param impostor the imposter to create the physics body on
  116677. */
  116678. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116679. /**
  116680. * Removes the physics body from the imposter and disposes of the body's memory
  116681. * @param impostor imposter to remove the physics body from
  116682. */
  116683. removePhysicsBody(impostor: PhysicsImpostor): void;
  116684. /**
  116685. * Generates a joint
  116686. * @param impostorJoint the imposter joint to create the joint with
  116687. */
  116688. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116689. /**
  116690. * Removes a joint
  116691. * @param impostorJoint the imposter joint to remove the joint from
  116692. */
  116693. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116694. private _addMeshVerts;
  116695. /**
  116696. * Initialise the soft body vertices to match its object's (mesh) vertices
  116697. * Softbody vertices (nodes) are in world space and to match this
  116698. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  116699. * @param impostor to create the softbody for
  116700. */
  116701. private _softVertexData;
  116702. /**
  116703. * Create an impostor's soft body
  116704. * @param impostor to create the softbody for
  116705. */
  116706. private _createSoftbody;
  116707. /**
  116708. * Create cloth for an impostor
  116709. * @param impostor to create the softbody for
  116710. */
  116711. private _createCloth;
  116712. /**
  116713. * Create rope for an impostor
  116714. * @param impostor to create the softbody for
  116715. */
  116716. private _createRope;
  116717. private _addHullVerts;
  116718. private _createShape;
  116719. /**
  116720. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  116721. * @param impostor imposter containing the physics body and babylon object
  116722. */
  116723. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116724. /**
  116725. * Sets the babylon object's position/rotation from the physics body's position/rotation
  116726. * @param impostor imposter containing the physics body and babylon object
  116727. * @param newPosition new position
  116728. * @param newRotation new rotation
  116729. */
  116730. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116731. /**
  116732. * If this plugin is supported
  116733. * @returns true if its supported
  116734. */
  116735. isSupported(): boolean;
  116736. /**
  116737. * Sets the linear velocity of the physics body
  116738. * @param impostor imposter to set the velocity on
  116739. * @param velocity velocity to set
  116740. */
  116741. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116742. /**
  116743. * Sets the angular velocity of the physics body
  116744. * @param impostor imposter to set the velocity on
  116745. * @param velocity velocity to set
  116746. */
  116747. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116748. /**
  116749. * gets the linear velocity
  116750. * @param impostor imposter to get linear velocity from
  116751. * @returns linear velocity
  116752. */
  116753. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116754. /**
  116755. * gets the angular velocity
  116756. * @param impostor imposter to get angular velocity from
  116757. * @returns angular velocity
  116758. */
  116759. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116760. /**
  116761. * Sets the mass of physics body
  116762. * @param impostor imposter to set the mass on
  116763. * @param mass mass to set
  116764. */
  116765. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116766. /**
  116767. * Gets the mass of the physics body
  116768. * @param impostor imposter to get the mass from
  116769. * @returns mass
  116770. */
  116771. getBodyMass(impostor: PhysicsImpostor): number;
  116772. /**
  116773. * Gets friction of the impostor
  116774. * @param impostor impostor to get friction from
  116775. * @returns friction value
  116776. */
  116777. getBodyFriction(impostor: PhysicsImpostor): number;
  116778. /**
  116779. * Sets friction of the impostor
  116780. * @param impostor impostor to set friction on
  116781. * @param friction friction value
  116782. */
  116783. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116784. /**
  116785. * Gets restitution of the impostor
  116786. * @param impostor impostor to get restitution from
  116787. * @returns restitution value
  116788. */
  116789. getBodyRestitution(impostor: PhysicsImpostor): number;
  116790. /**
  116791. * Sets resitution of the impostor
  116792. * @param impostor impostor to set resitution on
  116793. * @param restitution resitution value
  116794. */
  116795. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116796. /**
  116797. * Gets pressure inside the impostor
  116798. * @param impostor impostor to get pressure from
  116799. * @returns pressure value
  116800. */
  116801. getBodyPressure(impostor: PhysicsImpostor): number;
  116802. /**
  116803. * Sets pressure inside a soft body impostor
  116804. * Cloth and rope must remain 0 pressure
  116805. * @param impostor impostor to set pressure on
  116806. * @param pressure pressure value
  116807. */
  116808. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  116809. /**
  116810. * Gets stiffness of the impostor
  116811. * @param impostor impostor to get stiffness from
  116812. * @returns pressure value
  116813. */
  116814. getBodyStiffness(impostor: PhysicsImpostor): number;
  116815. /**
  116816. * Sets stiffness of the impostor
  116817. * @param impostor impostor to set stiffness on
  116818. * @param stiffness stiffness value from 0 to 1
  116819. */
  116820. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  116821. /**
  116822. * Gets velocityIterations of the impostor
  116823. * @param impostor impostor to get velocity iterations from
  116824. * @returns velocityIterations value
  116825. */
  116826. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  116827. /**
  116828. * Sets velocityIterations of the impostor
  116829. * @param impostor impostor to set velocity iterations on
  116830. * @param velocityIterations velocityIterations value
  116831. */
  116832. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  116833. /**
  116834. * Gets positionIterations of the impostor
  116835. * @param impostor impostor to get position iterations from
  116836. * @returns positionIterations value
  116837. */
  116838. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  116839. /**
  116840. * Sets positionIterations of the impostor
  116841. * @param impostor impostor to set position on
  116842. * @param positionIterations positionIterations value
  116843. */
  116844. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  116845. /**
  116846. * Append an anchor to a cloth object
  116847. * @param impostor is the cloth impostor to add anchor to
  116848. * @param otherImpostor is the rigid impostor to anchor to
  116849. * @param width ratio across width from 0 to 1
  116850. * @param height ratio up height from 0 to 1
  116851. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  116852. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116853. */
  116854. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116855. /**
  116856. * Append an hook to a rope object
  116857. * @param impostor is the rope impostor to add hook to
  116858. * @param otherImpostor is the rigid impostor to hook to
  116859. * @param length ratio along the rope from 0 to 1
  116860. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  116861. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116862. */
  116863. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116864. /**
  116865. * Sleeps the physics body and stops it from being active
  116866. * @param impostor impostor to sleep
  116867. */
  116868. sleepBody(impostor: PhysicsImpostor): void;
  116869. /**
  116870. * Activates the physics body
  116871. * @param impostor impostor to activate
  116872. */
  116873. wakeUpBody(impostor: PhysicsImpostor): void;
  116874. /**
  116875. * Updates the distance parameters of the joint
  116876. * @param joint joint to update
  116877. * @param maxDistance maximum distance of the joint
  116878. * @param minDistance minimum distance of the joint
  116879. */
  116880. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116881. /**
  116882. * Sets a motor on the joint
  116883. * @param joint joint to set motor on
  116884. * @param speed speed of the motor
  116885. * @param maxForce maximum force of the motor
  116886. * @param motorIndex index of the motor
  116887. */
  116888. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116889. /**
  116890. * Sets the motors limit
  116891. * @param joint joint to set limit on
  116892. * @param upperLimit upper limit
  116893. * @param lowerLimit lower limit
  116894. */
  116895. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116896. /**
  116897. * Syncs the position and rotation of a mesh with the impostor
  116898. * @param mesh mesh to sync
  116899. * @param impostor impostor to update the mesh with
  116900. */
  116901. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116902. /**
  116903. * Gets the radius of the impostor
  116904. * @param impostor impostor to get radius from
  116905. * @returns the radius
  116906. */
  116907. getRadius(impostor: PhysicsImpostor): number;
  116908. /**
  116909. * Gets the box size of the impostor
  116910. * @param impostor impostor to get box size from
  116911. * @param result the resulting box size
  116912. */
  116913. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116914. /**
  116915. * Disposes of the impostor
  116916. */
  116917. dispose(): void;
  116918. /**
  116919. * Does a raycast in the physics world
  116920. * @param from when should the ray start?
  116921. * @param to when should the ray end?
  116922. * @returns PhysicsRaycastResult
  116923. */
  116924. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116925. }
  116926. }
  116927. declare module BABYLON {
  116928. interface AbstractScene {
  116929. /**
  116930. * The list of reflection probes added to the scene
  116931. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116932. */
  116933. reflectionProbes: Array<ReflectionProbe>;
  116934. /**
  116935. * Removes the given reflection probe from this scene.
  116936. * @param toRemove The reflection probe to remove
  116937. * @returns The index of the removed reflection probe
  116938. */
  116939. removeReflectionProbe(toRemove: ReflectionProbe): number;
  116940. /**
  116941. * Adds the given reflection probe to this scene.
  116942. * @param newReflectionProbe The reflection probe to add
  116943. */
  116944. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  116945. }
  116946. /**
  116947. * Class used to generate realtime reflection / refraction cube textures
  116948. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116949. */
  116950. export class ReflectionProbe {
  116951. /** defines the name of the probe */
  116952. name: string;
  116953. private _scene;
  116954. private _renderTargetTexture;
  116955. private _projectionMatrix;
  116956. private _viewMatrix;
  116957. private _target;
  116958. private _add;
  116959. private _attachedMesh;
  116960. private _invertYAxis;
  116961. /** Gets or sets probe position (center of the cube map) */
  116962. position: Vector3;
  116963. /**
  116964. * Creates a new reflection probe
  116965. * @param name defines the name of the probe
  116966. * @param size defines the texture resolution (for each face)
  116967. * @param scene defines the hosting scene
  116968. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  116969. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  116970. */
  116971. constructor(
  116972. /** defines the name of the probe */
  116973. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  116974. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  116975. samples: number;
  116976. /** Gets or sets the refresh rate to use (on every frame by default) */
  116977. refreshRate: number;
  116978. /**
  116979. * Gets the hosting scene
  116980. * @returns a Scene
  116981. */
  116982. getScene(): Scene;
  116983. /** Gets the internal CubeTexture used to render to */
  116984. readonly cubeTexture: RenderTargetTexture;
  116985. /** Gets the list of meshes to render */
  116986. readonly renderList: Nullable<AbstractMesh[]>;
  116987. /**
  116988. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  116989. * @param mesh defines the mesh to attach to
  116990. */
  116991. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  116992. /**
  116993. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  116994. * @param renderingGroupId The rendering group id corresponding to its index
  116995. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  116996. */
  116997. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  116998. /**
  116999. * Clean all associated resources
  117000. */
  117001. dispose(): void;
  117002. /**
  117003. * Converts the reflection probe information to a readable string for debug purpose.
  117004. * @param fullDetails Supports for multiple levels of logging within scene loading
  117005. * @returns the human readable reflection probe info
  117006. */
  117007. toString(fullDetails?: boolean): string;
  117008. /**
  117009. * Get the class name of the relfection probe.
  117010. * @returns "ReflectionProbe"
  117011. */
  117012. getClassName(): string;
  117013. /**
  117014. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  117015. * @returns The JSON representation of the texture
  117016. */
  117017. serialize(): any;
  117018. /**
  117019. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  117020. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  117021. * @param scene Define the scene the parsed reflection probe should be instantiated in
  117022. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  117023. * @returns The parsed reflection probe if successful
  117024. */
  117025. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  117026. }
  117027. }
  117028. declare module BABYLON {
  117029. /** @hidden */
  117030. export var _BabylonLoaderRegistered: boolean;
  117031. }
  117032. declare module BABYLON {
  117033. /**
  117034. * The Physically based simple base material of BJS.
  117035. *
  117036. * This enables better naming and convention enforcements on top of the pbrMaterial.
  117037. * It is used as the base class for both the specGloss and metalRough conventions.
  117038. */
  117039. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  117040. /**
  117041. * Number of Simultaneous lights allowed on the material.
  117042. */
  117043. maxSimultaneousLights: number;
  117044. /**
  117045. * If sets to true, disables all the lights affecting the material.
  117046. */
  117047. disableLighting: boolean;
  117048. /**
  117049. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  117050. */
  117051. environmentTexture: BaseTexture;
  117052. /**
  117053. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  117054. */
  117055. invertNormalMapX: boolean;
  117056. /**
  117057. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  117058. */
  117059. invertNormalMapY: boolean;
  117060. /**
  117061. * Normal map used in the model.
  117062. */
  117063. normalTexture: BaseTexture;
  117064. /**
  117065. * Emissivie color used to self-illuminate the model.
  117066. */
  117067. emissiveColor: Color3;
  117068. /**
  117069. * Emissivie texture used to self-illuminate the model.
  117070. */
  117071. emissiveTexture: BaseTexture;
  117072. /**
  117073. * Occlusion Channel Strenght.
  117074. */
  117075. occlusionStrength: number;
  117076. /**
  117077. * Occlusion Texture of the material (adding extra occlusion effects).
  117078. */
  117079. occlusionTexture: BaseTexture;
  117080. /**
  117081. * Defines the alpha limits in alpha test mode.
  117082. */
  117083. alphaCutOff: number;
  117084. /**
  117085. * Gets the current double sided mode.
  117086. */
  117087. /**
  117088. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  117089. */
  117090. doubleSided: boolean;
  117091. /**
  117092. * Stores the pre-calculated light information of a mesh in a texture.
  117093. */
  117094. lightmapTexture: BaseTexture;
  117095. /**
  117096. * If true, the light map contains occlusion information instead of lighting info.
  117097. */
  117098. useLightmapAsShadowmap: boolean;
  117099. /**
  117100. * Instantiates a new PBRMaterial instance.
  117101. *
  117102. * @param name The material name
  117103. * @param scene The scene the material will be use in.
  117104. */
  117105. constructor(name: string, scene: Scene);
  117106. getClassName(): string;
  117107. }
  117108. }
  117109. declare module BABYLON {
  117110. /**
  117111. * The PBR material of BJS following the metal roughness convention.
  117112. *
  117113. * This fits to the PBR convention in the GLTF definition:
  117114. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  117115. */
  117116. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  117117. /**
  117118. * The base color has two different interpretations depending on the value of metalness.
  117119. * When the material is a metal, the base color is the specific measured reflectance value
  117120. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  117121. * of the material.
  117122. */
  117123. baseColor: Color3;
  117124. /**
  117125. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  117126. * well as opacity information in the alpha channel.
  117127. */
  117128. baseTexture: BaseTexture;
  117129. /**
  117130. * Specifies the metallic scalar value of the material.
  117131. * Can also be used to scale the metalness values of the metallic texture.
  117132. */
  117133. metallic: number;
  117134. /**
  117135. * Specifies the roughness scalar value of the material.
  117136. * Can also be used to scale the roughness values of the metallic texture.
  117137. */
  117138. roughness: number;
  117139. /**
  117140. * Texture containing both the metallic value in the B channel and the
  117141. * roughness value in the G channel to keep better precision.
  117142. */
  117143. metallicRoughnessTexture: BaseTexture;
  117144. /**
  117145. * Instantiates a new PBRMetalRoughnessMaterial instance.
  117146. *
  117147. * @param name The material name
  117148. * @param scene The scene the material will be use in.
  117149. */
  117150. constructor(name: string, scene: Scene);
  117151. /**
  117152. * Return the currrent class name of the material.
  117153. */
  117154. getClassName(): string;
  117155. /**
  117156. * Makes a duplicate of the current material.
  117157. * @param name - name to use for the new material.
  117158. */
  117159. clone(name: string): PBRMetallicRoughnessMaterial;
  117160. /**
  117161. * Serialize the material to a parsable JSON object.
  117162. */
  117163. serialize(): any;
  117164. /**
  117165. * Parses a JSON object correponding to the serialize function.
  117166. */
  117167. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  117168. }
  117169. }
  117170. declare module BABYLON {
  117171. /**
  117172. * The PBR material of BJS following the specular glossiness convention.
  117173. *
  117174. * This fits to the PBR convention in the GLTF definition:
  117175. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  117176. */
  117177. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  117178. /**
  117179. * Specifies the diffuse color of the material.
  117180. */
  117181. diffuseColor: Color3;
  117182. /**
  117183. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  117184. * channel.
  117185. */
  117186. diffuseTexture: BaseTexture;
  117187. /**
  117188. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  117189. */
  117190. specularColor: Color3;
  117191. /**
  117192. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  117193. */
  117194. glossiness: number;
  117195. /**
  117196. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  117197. */
  117198. specularGlossinessTexture: BaseTexture;
  117199. /**
  117200. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  117201. *
  117202. * @param name The material name
  117203. * @param scene The scene the material will be use in.
  117204. */
  117205. constructor(name: string, scene: Scene);
  117206. /**
  117207. * Return the currrent class name of the material.
  117208. */
  117209. getClassName(): string;
  117210. /**
  117211. * Makes a duplicate of the current material.
  117212. * @param name - name to use for the new material.
  117213. */
  117214. clone(name: string): PBRSpecularGlossinessMaterial;
  117215. /**
  117216. * Serialize the material to a parsable JSON object.
  117217. */
  117218. serialize(): any;
  117219. /**
  117220. * Parses a JSON object correponding to the serialize function.
  117221. */
  117222. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  117223. }
  117224. }
  117225. declare module BABYLON {
  117226. /**
  117227. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  117228. * It can help converting any input color in a desired output one. This can then be used to create effects
  117229. * from sepia, black and white to sixties or futuristic rendering...
  117230. *
  117231. * The only supported format is currently 3dl.
  117232. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  117233. */
  117234. export class ColorGradingTexture extends BaseTexture {
  117235. /**
  117236. * The current texture matrix. (will always be identity in color grading texture)
  117237. */
  117238. private _textureMatrix;
  117239. /**
  117240. * The texture URL.
  117241. */
  117242. url: string;
  117243. /**
  117244. * Empty line regex stored for GC.
  117245. */
  117246. private static _noneEmptyLineRegex;
  117247. private _engine;
  117248. /**
  117249. * Instantiates a ColorGradingTexture from the following parameters.
  117250. *
  117251. * @param url The location of the color gradind data (currently only supporting 3dl)
  117252. * @param scene The scene the texture will be used in
  117253. */
  117254. constructor(url: string, scene: Scene);
  117255. /**
  117256. * Returns the texture matrix used in most of the material.
  117257. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  117258. */
  117259. getTextureMatrix(): Matrix;
  117260. /**
  117261. * Occurs when the file being loaded is a .3dl LUT file.
  117262. */
  117263. private load3dlTexture;
  117264. /**
  117265. * Starts the loading process of the texture.
  117266. */
  117267. private loadTexture;
  117268. /**
  117269. * Clones the color gradind texture.
  117270. */
  117271. clone(): ColorGradingTexture;
  117272. /**
  117273. * Called during delayed load for textures.
  117274. */
  117275. delayLoad(): void;
  117276. /**
  117277. * Parses a color grading texture serialized by Babylon.
  117278. * @param parsedTexture The texture information being parsedTexture
  117279. * @param scene The scene to load the texture in
  117280. * @param rootUrl The root url of the data assets to load
  117281. * @return A color gradind texture
  117282. */
  117283. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  117284. /**
  117285. * Serializes the LUT texture to json format.
  117286. */
  117287. serialize(): any;
  117288. }
  117289. }
  117290. declare module BABYLON {
  117291. /**
  117292. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  117293. */
  117294. export class EquiRectangularCubeTexture extends BaseTexture {
  117295. /** The six faces of the cube. */
  117296. private static _FacesMapping;
  117297. private _noMipmap;
  117298. private _onLoad;
  117299. private _onError;
  117300. /** The size of the cubemap. */
  117301. private _size;
  117302. /** The buffer of the image. */
  117303. private _buffer;
  117304. /** The width of the input image. */
  117305. private _width;
  117306. /** The height of the input image. */
  117307. private _height;
  117308. /** The URL to the image. */
  117309. url: string;
  117310. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  117311. coordinatesMode: number;
  117312. /**
  117313. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  117314. * @param url The location of the image
  117315. * @param scene The scene the texture will be used in
  117316. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117317. * @param noMipmap Forces to not generate the mipmap if true
  117318. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  117319. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  117320. * @param onLoad — defines a callback called when texture is loaded
  117321. * @param onError — defines a callback called if there is an error
  117322. */
  117323. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  117324. /**
  117325. * Load the image data, by putting the image on a canvas and extracting its buffer.
  117326. */
  117327. private loadImage;
  117328. /**
  117329. * Convert the image buffer into a cubemap and create a CubeTexture.
  117330. */
  117331. private loadTexture;
  117332. /**
  117333. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  117334. * @param buffer The ArrayBuffer that should be converted.
  117335. * @returns The buffer as Float32Array.
  117336. */
  117337. private getFloat32ArrayFromArrayBuffer;
  117338. /**
  117339. * Get the current class name of the texture useful for serialization or dynamic coding.
  117340. * @returns "EquiRectangularCubeTexture"
  117341. */
  117342. getClassName(): string;
  117343. /**
  117344. * Create a clone of the current EquiRectangularCubeTexture and return it.
  117345. * @returns A clone of the current EquiRectangularCubeTexture.
  117346. */
  117347. clone(): EquiRectangularCubeTexture;
  117348. }
  117349. }
  117350. declare module BABYLON {
  117351. /**
  117352. * Based on jsTGALoader - Javascript loader for TGA file
  117353. * By Vincent Thibault
  117354. * @see http://blog.robrowser.com/javascript-tga-loader.html
  117355. */
  117356. export class TGATools {
  117357. private static _TYPE_INDEXED;
  117358. private static _TYPE_RGB;
  117359. private static _TYPE_GREY;
  117360. private static _TYPE_RLE_INDEXED;
  117361. private static _TYPE_RLE_RGB;
  117362. private static _TYPE_RLE_GREY;
  117363. private static _ORIGIN_MASK;
  117364. private static _ORIGIN_SHIFT;
  117365. private static _ORIGIN_BL;
  117366. private static _ORIGIN_BR;
  117367. private static _ORIGIN_UL;
  117368. private static _ORIGIN_UR;
  117369. /**
  117370. * Gets the header of a TGA file
  117371. * @param data defines the TGA data
  117372. * @returns the header
  117373. */
  117374. static GetTGAHeader(data: Uint8Array): any;
  117375. /**
  117376. * Uploads TGA content to a Babylon Texture
  117377. * @hidden
  117378. */
  117379. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  117380. /** @hidden */
  117381. 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;
  117382. /** @hidden */
  117383. 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;
  117384. /** @hidden */
  117385. 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;
  117386. /** @hidden */
  117387. 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;
  117388. /** @hidden */
  117389. 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;
  117390. /** @hidden */
  117391. 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;
  117392. }
  117393. }
  117394. declare module BABYLON {
  117395. /**
  117396. * Implementation of the TGA Texture Loader.
  117397. * @hidden
  117398. */
  117399. export class _TGATextureLoader implements IInternalTextureLoader {
  117400. /**
  117401. * Defines wether the loader supports cascade loading the different faces.
  117402. */
  117403. readonly supportCascades: boolean;
  117404. /**
  117405. * This returns if the loader support the current file information.
  117406. * @param extension defines the file extension of the file being loaded
  117407. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117408. * @param fallback defines the fallback internal texture if any
  117409. * @param isBase64 defines whether the texture is encoded as a base64
  117410. * @param isBuffer defines whether the texture data are stored as a buffer
  117411. * @returns true if the loader can load the specified file
  117412. */
  117413. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117414. /**
  117415. * Transform the url before loading if required.
  117416. * @param rootUrl the url of the texture
  117417. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117418. * @returns the transformed texture
  117419. */
  117420. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117421. /**
  117422. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117423. * @param rootUrl the url of the texture
  117424. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117425. * @returns the fallback texture
  117426. */
  117427. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117428. /**
  117429. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117430. * @param data contains the texture data
  117431. * @param texture defines the BabylonJS internal texture
  117432. * @param createPolynomials will be true if polynomials have been requested
  117433. * @param onLoad defines the callback to trigger once the texture is ready
  117434. * @param onError defines the callback to trigger in case of error
  117435. */
  117436. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117437. /**
  117438. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117439. * @param data contains the texture data
  117440. * @param texture defines the BabylonJS internal texture
  117441. * @param callback defines the method to call once ready to upload
  117442. */
  117443. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117444. }
  117445. }
  117446. declare module BABYLON {
  117447. /**
  117448. * Info about the .basis files
  117449. */
  117450. class BasisFileInfo {
  117451. /**
  117452. * If the file has alpha
  117453. */
  117454. hasAlpha: boolean;
  117455. /**
  117456. * Info about each image of the basis file
  117457. */
  117458. images: Array<{
  117459. levels: Array<{
  117460. width: number;
  117461. height: number;
  117462. transcodedPixels: ArrayBufferView;
  117463. }>;
  117464. }>;
  117465. }
  117466. /**
  117467. * Result of transcoding a basis file
  117468. */
  117469. class TranscodeResult {
  117470. /**
  117471. * Info about the .basis file
  117472. */
  117473. fileInfo: BasisFileInfo;
  117474. /**
  117475. * Format to use when loading the file
  117476. */
  117477. format: number;
  117478. }
  117479. /**
  117480. * Configuration options for the Basis transcoder
  117481. */
  117482. export class BasisTranscodeConfiguration {
  117483. /**
  117484. * Supported compression formats used to determine the supported output format of the transcoder
  117485. */
  117486. supportedCompressionFormats?: {
  117487. /**
  117488. * etc1 compression format
  117489. */
  117490. etc1?: boolean;
  117491. /**
  117492. * s3tc compression format
  117493. */
  117494. s3tc?: boolean;
  117495. /**
  117496. * pvrtc compression format
  117497. */
  117498. pvrtc?: boolean;
  117499. /**
  117500. * etc2 compression format
  117501. */
  117502. etc2?: boolean;
  117503. };
  117504. /**
  117505. * If mipmap levels should be loaded for transcoded images (Default: true)
  117506. */
  117507. loadMipmapLevels?: boolean;
  117508. /**
  117509. * Index of a single image to load (Default: all images)
  117510. */
  117511. loadSingleImage?: number;
  117512. }
  117513. /**
  117514. * Used to load .Basis files
  117515. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  117516. */
  117517. export class BasisTools {
  117518. private static _IgnoreSupportedFormats;
  117519. /**
  117520. * URL to use when loading the basis transcoder
  117521. */
  117522. static JSModuleURL: string;
  117523. /**
  117524. * URL to use when loading the wasm module for the transcoder
  117525. */
  117526. static WasmModuleURL: string;
  117527. /**
  117528. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  117529. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  117530. * @returns internal format corresponding to the Basis format
  117531. */
  117532. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  117533. private static _WorkerPromise;
  117534. private static _Worker;
  117535. private static _actionId;
  117536. private static _CreateWorkerAsync;
  117537. /**
  117538. * Transcodes a loaded image file to compressed pixel data
  117539. * @param imageData image data to transcode
  117540. * @param config configuration options for the transcoding
  117541. * @returns a promise resulting in the transcoded image
  117542. */
  117543. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  117544. /**
  117545. * Loads a texture from the transcode result
  117546. * @param texture texture load to
  117547. * @param transcodeResult the result of transcoding the basis file to load from
  117548. */
  117549. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  117550. }
  117551. }
  117552. declare module BABYLON {
  117553. /**
  117554. * Loader for .basis file format
  117555. */
  117556. export class _BasisTextureLoader implements IInternalTextureLoader {
  117557. /**
  117558. * Defines whether the loader supports cascade loading the different faces.
  117559. */
  117560. readonly supportCascades: boolean;
  117561. /**
  117562. * This returns if the loader support the current file information.
  117563. * @param extension defines the file extension of the file being loaded
  117564. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117565. * @param fallback defines the fallback internal texture if any
  117566. * @param isBase64 defines whether the texture is encoded as a base64
  117567. * @param isBuffer defines whether the texture data are stored as a buffer
  117568. * @returns true if the loader can load the specified file
  117569. */
  117570. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117571. /**
  117572. * Transform the url before loading if required.
  117573. * @param rootUrl the url of the texture
  117574. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117575. * @returns the transformed texture
  117576. */
  117577. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117578. /**
  117579. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117580. * @param rootUrl the url of the texture
  117581. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117582. * @returns the fallback texture
  117583. */
  117584. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117585. /**
  117586. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  117587. * @param data contains the texture data
  117588. * @param texture defines the BabylonJS internal texture
  117589. * @param createPolynomials will be true if polynomials have been requested
  117590. * @param onLoad defines the callback to trigger once the texture is ready
  117591. * @param onError defines the callback to trigger in case of error
  117592. */
  117593. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117594. /**
  117595. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117596. * @param data contains the texture data
  117597. * @param texture defines the BabylonJS internal texture
  117598. * @param callback defines the method to call once ready to upload
  117599. */
  117600. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117601. }
  117602. }
  117603. declare module BABYLON {
  117604. /**
  117605. * 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.
  117606. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117607. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117608. */
  117609. export class CustomProceduralTexture extends ProceduralTexture {
  117610. private _animate;
  117611. private _time;
  117612. private _config;
  117613. private _texturePath;
  117614. /**
  117615. * Instantiates a new Custom Procedural Texture.
  117616. * 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.
  117617. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117618. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117619. * @param name Define the name of the texture
  117620. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  117621. * @param size Define the size of the texture to create
  117622. * @param scene Define the scene the texture belongs to
  117623. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  117624. * @param generateMipMaps Define if the texture should creates mip maps or not
  117625. */
  117626. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117627. private _loadJson;
  117628. /**
  117629. * Is the texture ready to be used ? (rendered at least once)
  117630. * @returns true if ready, otherwise, false.
  117631. */
  117632. isReady(): boolean;
  117633. /**
  117634. * Render the texture to its associated render target.
  117635. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  117636. */
  117637. render(useCameraPostProcess?: boolean): void;
  117638. /**
  117639. * Update the list of dependant textures samplers in the shader.
  117640. */
  117641. updateTextures(): void;
  117642. /**
  117643. * Update the uniform values of the procedural texture in the shader.
  117644. */
  117645. updateShaderUniforms(): void;
  117646. /**
  117647. * Define if the texture animates or not.
  117648. */
  117649. animate: boolean;
  117650. }
  117651. }
  117652. declare module BABYLON {
  117653. /** @hidden */
  117654. export var noisePixelShader: {
  117655. name: string;
  117656. shader: string;
  117657. };
  117658. }
  117659. declare module BABYLON {
  117660. /**
  117661. * Class used to generate noise procedural textures
  117662. */
  117663. export class NoiseProceduralTexture extends ProceduralTexture {
  117664. private _time;
  117665. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  117666. brightness: number;
  117667. /** Defines the number of octaves to process */
  117668. octaves: number;
  117669. /** Defines the level of persistence (0.8 by default) */
  117670. persistence: number;
  117671. /** Gets or sets animation speed factor (default is 1) */
  117672. animationSpeedFactor: number;
  117673. /**
  117674. * Creates a new NoiseProceduralTexture
  117675. * @param name defines the name fo the texture
  117676. * @param size defines the size of the texture (default is 256)
  117677. * @param scene defines the hosting scene
  117678. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  117679. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  117680. */
  117681. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117682. private _updateShaderUniforms;
  117683. protected _getDefines(): string;
  117684. /** Generate the current state of the procedural texture */
  117685. render(useCameraPostProcess?: boolean): void;
  117686. /**
  117687. * Serializes this noise procedural texture
  117688. * @returns a serialized noise procedural texture object
  117689. */
  117690. serialize(): any;
  117691. /**
  117692. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  117693. * @param parsedTexture defines parsed texture data
  117694. * @param scene defines the current scene
  117695. * @param rootUrl defines the root URL containing noise procedural texture information
  117696. * @returns a parsed NoiseProceduralTexture
  117697. */
  117698. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  117699. }
  117700. }
  117701. declare module BABYLON {
  117702. /**
  117703. * Raw cube texture where the raw buffers are passed in
  117704. */
  117705. export class RawCubeTexture extends CubeTexture {
  117706. /**
  117707. * Creates a cube texture where the raw buffers are passed in.
  117708. * @param scene defines the scene the texture is attached to
  117709. * @param data defines the array of data to use to create each face
  117710. * @param size defines the size of the textures
  117711. * @param format defines the format of the data
  117712. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  117713. * @param generateMipMaps defines if the engine should generate the mip levels
  117714. * @param invertY defines if data must be stored with Y axis inverted
  117715. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  117716. * @param compression defines the compression used (null by default)
  117717. */
  117718. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  117719. /**
  117720. * Updates the raw cube texture.
  117721. * @param data defines the data to store
  117722. * @param format defines the data format
  117723. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  117724. * @param invertY defines if data must be stored with Y axis inverted
  117725. * @param compression defines the compression used (null by default)
  117726. * @param level defines which level of the texture to update
  117727. */
  117728. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  117729. /**
  117730. * Updates a raw cube texture with RGBD encoded data.
  117731. * @param data defines the array of data [mipmap][face] to use to create each face
  117732. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  117733. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  117734. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  117735. * @returns a promsie that resolves when the operation is complete
  117736. */
  117737. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  117738. /**
  117739. * Clones the raw cube texture.
  117740. * @return a new cube texture
  117741. */
  117742. clone(): CubeTexture;
  117743. /** @hidden */
  117744. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  117745. }
  117746. }
  117747. declare module BABYLON {
  117748. /**
  117749. * Class used to store 3D textures containing user data
  117750. */
  117751. export class RawTexture3D extends Texture {
  117752. /** Gets or sets the texture format to use */
  117753. format: number;
  117754. private _engine;
  117755. /**
  117756. * Create a new RawTexture3D
  117757. * @param data defines the data of the texture
  117758. * @param width defines the width of the texture
  117759. * @param height defines the height of the texture
  117760. * @param depth defines the depth of the texture
  117761. * @param format defines the texture format to use
  117762. * @param scene defines the hosting scene
  117763. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  117764. * @param invertY defines if texture must be stored with Y axis inverted
  117765. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  117766. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  117767. */
  117768. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  117769. /** Gets or sets the texture format to use */
  117770. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  117771. /**
  117772. * Update the texture with new data
  117773. * @param data defines the data to store in the texture
  117774. */
  117775. update(data: ArrayBufferView): void;
  117776. }
  117777. }
  117778. declare module BABYLON {
  117779. /**
  117780. * Creates a refraction texture used by refraction channel of the standard material.
  117781. * It is like a mirror but to see through a material.
  117782. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117783. */
  117784. export class RefractionTexture extends RenderTargetTexture {
  117785. /**
  117786. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  117787. * 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.
  117788. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117789. */
  117790. refractionPlane: Plane;
  117791. /**
  117792. * Define how deep under the surface we should see.
  117793. */
  117794. depth: number;
  117795. /**
  117796. * Creates a refraction texture used by refraction channel of the standard material.
  117797. * It is like a mirror but to see through a material.
  117798. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117799. * @param name Define the texture name
  117800. * @param size Define the size of the underlying texture
  117801. * @param scene Define the scene the refraction belongs to
  117802. * @param generateMipMaps Define if we need to generate mips level for the refraction
  117803. */
  117804. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  117805. /**
  117806. * Clone the refraction texture.
  117807. * @returns the cloned texture
  117808. */
  117809. clone(): RefractionTexture;
  117810. /**
  117811. * Serialize the texture to a JSON representation you could use in Parse later on
  117812. * @returns the serialized JSON representation
  117813. */
  117814. serialize(): any;
  117815. }
  117816. }
  117817. declare module BABYLON {
  117818. /**
  117819. * Defines the options related to the creation of an HtmlElementTexture
  117820. */
  117821. export interface IHtmlElementTextureOptions {
  117822. /**
  117823. * Defines wether mip maps should be created or not.
  117824. */
  117825. generateMipMaps?: boolean;
  117826. /**
  117827. * Defines the sampling mode of the texture.
  117828. */
  117829. samplingMode?: number;
  117830. /**
  117831. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  117832. */
  117833. engine: Nullable<Engine>;
  117834. /**
  117835. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  117836. */
  117837. scene: Nullable<Scene>;
  117838. }
  117839. /**
  117840. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  117841. * To be as efficient as possible depending on your constraints nothing aside the first upload
  117842. * is automatically managed.
  117843. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  117844. * in your application.
  117845. *
  117846. * As the update is not automatic, you need to call them manually.
  117847. */
  117848. export class HtmlElementTexture extends BaseTexture {
  117849. /**
  117850. * The texture URL.
  117851. */
  117852. element: HTMLVideoElement | HTMLCanvasElement;
  117853. private static readonly DefaultOptions;
  117854. private _textureMatrix;
  117855. private _engine;
  117856. private _isVideo;
  117857. private _generateMipMaps;
  117858. private _samplingMode;
  117859. /**
  117860. * Instantiates a HtmlElementTexture from the following parameters.
  117861. *
  117862. * @param name Defines the name of the texture
  117863. * @param element Defines the video or canvas the texture is filled with
  117864. * @param options Defines the other none mandatory texture creation options
  117865. */
  117866. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  117867. private _createInternalTexture;
  117868. /**
  117869. * Returns the texture matrix used in most of the material.
  117870. */
  117871. getTextureMatrix(): Matrix;
  117872. /**
  117873. * Updates the content of the texture.
  117874. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  117875. */
  117876. update(invertY?: Nullable<boolean>): void;
  117877. }
  117878. }
  117879. declare module BABYLON {
  117880. /**
  117881. * Enum used to define the target of a block
  117882. */
  117883. export enum NodeMaterialBlockTargets {
  117884. /** Vertex shader */
  117885. Vertex = 1,
  117886. /** Fragment shader */
  117887. Fragment = 2,
  117888. /** Neutral */
  117889. Neutral = 4,
  117890. /** Vertex and Fragment */
  117891. VertexAndFragment = 3
  117892. }
  117893. }
  117894. declare module BABYLON {
  117895. /**
  117896. * Defines the kind of connection point for node based material
  117897. */
  117898. export enum NodeMaterialBlockConnectionPointTypes {
  117899. /** Float */
  117900. Float = 1,
  117901. /** Int */
  117902. Int = 2,
  117903. /** Vector2 */
  117904. Vector2 = 4,
  117905. /** Vector3 */
  117906. Vector3 = 8,
  117907. /** Vector4 */
  117908. Vector4 = 16,
  117909. /** Color3 */
  117910. Color3 = 32,
  117911. /** Color4 */
  117912. Color4 = 64,
  117913. /** Matrix */
  117914. Matrix = 128,
  117915. /** Detect type based on connection */
  117916. AutoDetect = 1024,
  117917. /** Output type that will be defined by input type */
  117918. BasedOnInput = 2048
  117919. }
  117920. }
  117921. declare module BABYLON {
  117922. /**
  117923. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  117924. */
  117925. export enum NodeMaterialBlockConnectionPointMode {
  117926. /** Value is an uniform */
  117927. Uniform = 0,
  117928. /** Value is a mesh attribute */
  117929. Attribute = 1,
  117930. /** Value is a varying between vertex and fragment shaders */
  117931. Varying = 2,
  117932. /** Mode is undefined */
  117933. Undefined = 3
  117934. }
  117935. }
  117936. declare module BABYLON {
  117937. /**
  117938. * Enum used to define system values e.g. values automatically provided by the system
  117939. */
  117940. export enum NodeMaterialSystemValues {
  117941. /** World */
  117942. World = 1,
  117943. /** View */
  117944. View = 2,
  117945. /** Projection */
  117946. Projection = 3,
  117947. /** ViewProjection */
  117948. ViewProjection = 4,
  117949. /** WorldView */
  117950. WorldView = 5,
  117951. /** WorldViewProjection */
  117952. WorldViewProjection = 6,
  117953. /** CameraPosition */
  117954. CameraPosition = 7,
  117955. /** Fog Color */
  117956. FogColor = 8
  117957. }
  117958. }
  117959. declare module BABYLON {
  117960. /**
  117961. * Root class for all node material optimizers
  117962. */
  117963. export class NodeMaterialOptimizer {
  117964. /**
  117965. * Function used to optimize a NodeMaterial graph
  117966. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  117967. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  117968. */
  117969. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  117970. }
  117971. }
  117972. declare module BABYLON {
  117973. /**
  117974. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  117975. */
  117976. export class TransformBlock extends NodeMaterialBlock {
  117977. /**
  117978. * Defines the value to use to complement W value to transform it to a Vector4
  117979. */
  117980. complementW: number;
  117981. /**
  117982. * Defines the value to use to complement z value to transform it to a Vector4
  117983. */
  117984. complementZ: number;
  117985. /**
  117986. * Creates a new TransformBlock
  117987. * @param name defines the block name
  117988. */
  117989. constructor(name: string);
  117990. /**
  117991. * Gets the current class name
  117992. * @returns the class name
  117993. */
  117994. getClassName(): string;
  117995. /**
  117996. * Gets the vector input
  117997. */
  117998. readonly vector: NodeMaterialConnectionPoint;
  117999. /**
  118000. * Gets the output component
  118001. */
  118002. readonly output: NodeMaterialConnectionPoint;
  118003. /**
  118004. * Gets the matrix transform input
  118005. */
  118006. readonly transform: NodeMaterialConnectionPoint;
  118007. protected _buildBlock(state: NodeMaterialBuildState): this;
  118008. serialize(): any;
  118009. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118010. protected _dumpPropertiesCode(): string;
  118011. }
  118012. }
  118013. declare module BABYLON {
  118014. /**
  118015. * Block used to output the vertex position
  118016. */
  118017. export class VertexOutputBlock extends NodeMaterialBlock {
  118018. /**
  118019. * Creates a new VertexOutputBlock
  118020. * @param name defines the block name
  118021. */
  118022. constructor(name: string);
  118023. /**
  118024. * Gets the current class name
  118025. * @returns the class name
  118026. */
  118027. getClassName(): string;
  118028. /**
  118029. * Gets the vector input component
  118030. */
  118031. readonly vector: NodeMaterialConnectionPoint;
  118032. protected _buildBlock(state: NodeMaterialBuildState): this;
  118033. }
  118034. }
  118035. declare module BABYLON {
  118036. /**
  118037. * Block used to output the final color
  118038. */
  118039. export class FragmentOutputBlock extends NodeMaterialBlock {
  118040. /**
  118041. * Create a new FragmentOutputBlock
  118042. * @param name defines the block name
  118043. */
  118044. constructor(name: string);
  118045. /**
  118046. * Gets the current class name
  118047. * @returns the class name
  118048. */
  118049. getClassName(): string;
  118050. /**
  118051. * Gets the rgba input component
  118052. */
  118053. readonly rgba: NodeMaterialConnectionPoint;
  118054. /**
  118055. * Gets the rgb input component
  118056. */
  118057. readonly rgb: NodeMaterialConnectionPoint;
  118058. /**
  118059. * Gets the a input component
  118060. */
  118061. readonly a: NodeMaterialConnectionPoint;
  118062. protected _buildBlock(state: NodeMaterialBuildState): this;
  118063. }
  118064. }
  118065. declare module BABYLON {
  118066. /**
  118067. * Block used to read a reflection texture from a sampler
  118068. */
  118069. export class ReflectionTextureBlock extends NodeMaterialBlock {
  118070. private _define3DName;
  118071. private _defineCubicName;
  118072. private _defineExplicitName;
  118073. private _defineProjectionName;
  118074. private _defineLocalCubicName;
  118075. private _defineSphericalName;
  118076. private _definePlanarName;
  118077. private _defineEquirectangularName;
  118078. private _defineMirroredEquirectangularFixedName;
  118079. private _defineEquirectangularFixedName;
  118080. private _defineSkyboxName;
  118081. private _cubeSamplerName;
  118082. private _2DSamplerName;
  118083. private _positionUVWName;
  118084. private _directionWName;
  118085. private _reflectionCoordsName;
  118086. private _reflection2DCoordsName;
  118087. private _reflectionColorName;
  118088. private _reflectionMatrixName;
  118089. /**
  118090. * Gets or sets the texture associated with the node
  118091. */
  118092. texture: Nullable<BaseTexture>;
  118093. /**
  118094. * Create a new TextureBlock
  118095. * @param name defines the block name
  118096. */
  118097. constructor(name: string);
  118098. /**
  118099. * Gets the current class name
  118100. * @returns the class name
  118101. */
  118102. getClassName(): string;
  118103. /**
  118104. * Gets the world position input component
  118105. */
  118106. readonly position: NodeMaterialConnectionPoint;
  118107. /**
  118108. * Gets the world position input component
  118109. */
  118110. readonly worldPosition: NodeMaterialConnectionPoint;
  118111. /**
  118112. * Gets the world normal input component
  118113. */
  118114. readonly worldNormal: NodeMaterialConnectionPoint;
  118115. /**
  118116. * Gets the world input component
  118117. */
  118118. readonly world: NodeMaterialConnectionPoint;
  118119. /**
  118120. * Gets the camera (or eye) position component
  118121. */
  118122. readonly cameraPosition: NodeMaterialConnectionPoint;
  118123. /**
  118124. * Gets the view input component
  118125. */
  118126. readonly view: NodeMaterialConnectionPoint;
  118127. /**
  118128. * Gets the rgb output component
  118129. */
  118130. readonly rgb: NodeMaterialConnectionPoint;
  118131. /**
  118132. * Gets the r output component
  118133. */
  118134. readonly r: NodeMaterialConnectionPoint;
  118135. /**
  118136. * Gets the g output component
  118137. */
  118138. readonly g: NodeMaterialConnectionPoint;
  118139. /**
  118140. * Gets the b output component
  118141. */
  118142. readonly b: NodeMaterialConnectionPoint;
  118143. autoConfigure(material: NodeMaterial): void;
  118144. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118145. isReady(): boolean;
  118146. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118147. private _injectVertexCode;
  118148. private _writeOutput;
  118149. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118150. serialize(): any;
  118151. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118152. }
  118153. }
  118154. declare module BABYLON {
  118155. /**
  118156. * Interface used to configure the node material editor
  118157. */
  118158. export interface INodeMaterialEditorOptions {
  118159. /** Define the URl to load node editor script */
  118160. editorURL?: string;
  118161. }
  118162. /** @hidden */
  118163. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  118164. /** BONES */
  118165. NUM_BONE_INFLUENCERS: number;
  118166. BonesPerMesh: number;
  118167. BONETEXTURE: boolean;
  118168. /** MORPH TARGETS */
  118169. MORPHTARGETS: boolean;
  118170. MORPHTARGETS_NORMAL: boolean;
  118171. MORPHTARGETS_TANGENT: boolean;
  118172. MORPHTARGETS_UV: boolean;
  118173. NUM_MORPH_INFLUENCERS: number;
  118174. /** IMAGE PROCESSING */
  118175. IMAGEPROCESSING: boolean;
  118176. VIGNETTE: boolean;
  118177. VIGNETTEBLENDMODEMULTIPLY: boolean;
  118178. VIGNETTEBLENDMODEOPAQUE: boolean;
  118179. TONEMAPPING: boolean;
  118180. TONEMAPPING_ACES: boolean;
  118181. CONTRAST: boolean;
  118182. EXPOSURE: boolean;
  118183. COLORCURVES: boolean;
  118184. COLORGRADING: boolean;
  118185. COLORGRADING3D: boolean;
  118186. SAMPLER3DGREENDEPTH: boolean;
  118187. SAMPLER3DBGRMAP: boolean;
  118188. IMAGEPROCESSINGPOSTPROCESS: boolean;
  118189. /** MISC. */
  118190. BUMPDIRECTUV: number;
  118191. constructor();
  118192. setValue(name: string, value: boolean): void;
  118193. }
  118194. /**
  118195. * Class used to configure NodeMaterial
  118196. */
  118197. export interface INodeMaterialOptions {
  118198. /**
  118199. * Defines if blocks should emit comments
  118200. */
  118201. emitComments: boolean;
  118202. }
  118203. /**
  118204. * Class used to create a node based material built by assembling shader blocks
  118205. */
  118206. export class NodeMaterial extends PushMaterial {
  118207. private static _BuildIdGenerator;
  118208. private _options;
  118209. private _vertexCompilationState;
  118210. private _fragmentCompilationState;
  118211. private _sharedData;
  118212. private _buildId;
  118213. private _buildWasSuccessful;
  118214. private _cachedWorldViewMatrix;
  118215. private _cachedWorldViewProjectionMatrix;
  118216. private _optimizers;
  118217. private _animationFrame;
  118218. /** Define the URl to load node editor script */
  118219. static EditorURL: string;
  118220. private BJSNODEMATERIALEDITOR;
  118221. /** Get the inspector from bundle or global */
  118222. private _getGlobalNodeMaterialEditor;
  118223. /**
  118224. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  118225. */
  118226. ignoreAlpha: boolean;
  118227. /**
  118228. * Defines the maximum number of lights that can be used in the material
  118229. */
  118230. maxSimultaneousLights: number;
  118231. /**
  118232. * Observable raised when the material is built
  118233. */
  118234. onBuildObservable: Observable<NodeMaterial>;
  118235. /**
  118236. * Gets or sets the root nodes of the material vertex shader
  118237. */
  118238. _vertexOutputNodes: NodeMaterialBlock[];
  118239. /**
  118240. * Gets or sets the root nodes of the material fragment (pixel) shader
  118241. */
  118242. _fragmentOutputNodes: NodeMaterialBlock[];
  118243. /** Gets or sets options to control the node material overall behavior */
  118244. options: INodeMaterialOptions;
  118245. /**
  118246. * Default configuration related to image processing available in the standard Material.
  118247. */
  118248. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118249. /**
  118250. * Gets the image processing configuration used either in this material.
  118251. */
  118252. /**
  118253. * Sets the Default image processing configuration used either in the this material.
  118254. *
  118255. * If sets to null, the scene one is in use.
  118256. */
  118257. imageProcessingConfiguration: ImageProcessingConfiguration;
  118258. /**
  118259. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  118260. */
  118261. attachedBlocks: NodeMaterialBlock[];
  118262. /**
  118263. * Create a new node based material
  118264. * @param name defines the material name
  118265. * @param scene defines the hosting scene
  118266. * @param options defines creation option
  118267. */
  118268. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  118269. /**
  118270. * Gets the current class name of the material e.g. "NodeMaterial"
  118271. * @returns the class name
  118272. */
  118273. getClassName(): string;
  118274. /**
  118275. * Keep track of the image processing observer to allow dispose and replace.
  118276. */
  118277. private _imageProcessingObserver;
  118278. /**
  118279. * Attaches a new image processing configuration to the Standard Material.
  118280. * @param configuration
  118281. */
  118282. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  118283. /**
  118284. * Get a block by its name
  118285. * @param name defines the name of the block to retrieve
  118286. * @returns the required block or null if not found
  118287. */
  118288. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  118289. /**
  118290. * Get a block by its name
  118291. * @param predicate defines the predicate used to find the good candidate
  118292. * @returns the required block or null if not found
  118293. */
  118294. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  118295. /**
  118296. * Get an input block by its name
  118297. * @param predicate defines the predicate used to find the good candidate
  118298. * @returns the required input block or null if not found
  118299. */
  118300. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  118301. /**
  118302. * Gets the list of input blocks attached to this material
  118303. * @returns an array of InputBlocks
  118304. */
  118305. getInputBlocks(): InputBlock[];
  118306. /**
  118307. * Adds a new optimizer to the list of optimizers
  118308. * @param optimizer defines the optimizers to add
  118309. * @returns the current material
  118310. */
  118311. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  118312. /**
  118313. * Remove an optimizer from the list of optimizers
  118314. * @param optimizer defines the optimizers to remove
  118315. * @returns the current material
  118316. */
  118317. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  118318. /**
  118319. * Add a new block to the list of output nodes
  118320. * @param node defines the node to add
  118321. * @returns the current material
  118322. */
  118323. addOutputNode(node: NodeMaterialBlock): this;
  118324. /**
  118325. * Remove a block from the list of root nodes
  118326. * @param node defines the node to remove
  118327. * @returns the current material
  118328. */
  118329. removeOutputNode(node: NodeMaterialBlock): this;
  118330. private _addVertexOutputNode;
  118331. private _removeVertexOutputNode;
  118332. private _addFragmentOutputNode;
  118333. private _removeFragmentOutputNode;
  118334. /**
  118335. * Specifies if the material will require alpha blending
  118336. * @returns a boolean specifying if alpha blending is needed
  118337. */
  118338. needAlphaBlending(): boolean;
  118339. /**
  118340. * Specifies if this material should be rendered in alpha test mode
  118341. * @returns a boolean specifying if an alpha test is needed.
  118342. */
  118343. needAlphaTesting(): boolean;
  118344. private _initializeBlock;
  118345. private _resetDualBlocks;
  118346. /**
  118347. * Build the material and generates the inner effect
  118348. * @param verbose defines if the build should log activity
  118349. */
  118350. build(verbose?: boolean): void;
  118351. /**
  118352. * Runs an otpimization phase to try to improve the shader code
  118353. */
  118354. optimize(): void;
  118355. private _prepareDefinesForAttributes;
  118356. /**
  118357. * Get if the submesh is ready to be used and all its information available.
  118358. * Child classes can use it to update shaders
  118359. * @param mesh defines the mesh to check
  118360. * @param subMesh defines which submesh to check
  118361. * @param useInstances specifies that instances should be used
  118362. * @returns a boolean indicating that the submesh is ready or not
  118363. */
  118364. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  118365. /**
  118366. * Get a string representing the shaders built by the current node graph
  118367. */
  118368. readonly compiledShaders: string;
  118369. /**
  118370. * Binds the world matrix to the material
  118371. * @param world defines the world transformation matrix
  118372. */
  118373. bindOnlyWorldMatrix(world: Matrix): void;
  118374. /**
  118375. * Binds the submesh to this material by preparing the effect and shader to draw
  118376. * @param world defines the world transformation matrix
  118377. * @param mesh defines the mesh containing the submesh
  118378. * @param subMesh defines the submesh to bind the material to
  118379. */
  118380. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118381. /**
  118382. * Gets the active textures from the material
  118383. * @returns an array of textures
  118384. */
  118385. getActiveTextures(): BaseTexture[];
  118386. /**
  118387. * Gets the list of texture blocks
  118388. * @returns an array of texture blocks
  118389. */
  118390. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  118391. /**
  118392. * Specifies if the material uses a texture
  118393. * @param texture defines the texture to check against the material
  118394. * @returns a boolean specifying if the material uses the texture
  118395. */
  118396. hasTexture(texture: BaseTexture): boolean;
  118397. /**
  118398. * Disposes the material
  118399. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  118400. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  118401. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  118402. */
  118403. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  118404. /** Creates the node editor window. */
  118405. private _createNodeEditor;
  118406. /**
  118407. * Launch the node material editor
  118408. * @param config Define the configuration of the editor
  118409. * @return a promise fulfilled when the node editor is visible
  118410. */
  118411. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  118412. /**
  118413. * Clear the current material
  118414. */
  118415. clear(): void;
  118416. /**
  118417. * Clear the current material and set it to a default state
  118418. */
  118419. setToDefault(): void;
  118420. /**
  118421. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  118422. * @param url defines the url to load from
  118423. * @returns a promise that will fullfil when the material is fully loaded
  118424. */
  118425. loadAsync(url: string): Promise<unknown>;
  118426. private _gatherBlocks;
  118427. /**
  118428. * Generate a string containing the code declaration required to create an equivalent of this material
  118429. * @returns a string
  118430. */
  118431. generateCode(): string;
  118432. /**
  118433. * Serializes this material in a JSON representation
  118434. * @returns the serialized material object
  118435. */
  118436. serialize(): any;
  118437. private _restoreConnections;
  118438. /**
  118439. * Clear the current graph and load a new one from a serialization object
  118440. * @param source defines the JSON representation of the material
  118441. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118442. */
  118443. loadFromSerialization(source: any, rootUrl?: string): void;
  118444. /**
  118445. * Creates a node material from parsed material data
  118446. * @param source defines the JSON representation of the material
  118447. * @param scene defines the hosting scene
  118448. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118449. * @returns a new node material
  118450. */
  118451. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  118452. /**
  118453. * Creates a new node material set to default basic configuration
  118454. * @param name defines the name of the material
  118455. * @param scene defines the hosting scene
  118456. * @returns a new NodeMaterial
  118457. */
  118458. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  118459. }
  118460. }
  118461. declare module BABYLON {
  118462. /**
  118463. * Block used to read a texture from a sampler
  118464. */
  118465. export class TextureBlock extends NodeMaterialBlock {
  118466. private _defineName;
  118467. private _samplerName;
  118468. private _transformedUVName;
  118469. private _textureTransformName;
  118470. private _textureInfoName;
  118471. private _mainUVName;
  118472. private _mainUVDefineName;
  118473. /**
  118474. * Gets or sets the texture associated with the node
  118475. */
  118476. texture: Nullable<Texture>;
  118477. /**
  118478. * Create a new TextureBlock
  118479. * @param name defines the block name
  118480. */
  118481. constructor(name: string);
  118482. /**
  118483. * Gets the current class name
  118484. * @returns the class name
  118485. */
  118486. getClassName(): string;
  118487. /**
  118488. * Gets the uv input component
  118489. */
  118490. readonly uv: NodeMaterialConnectionPoint;
  118491. /**
  118492. * Gets the rgba output component
  118493. */
  118494. readonly rgba: NodeMaterialConnectionPoint;
  118495. /**
  118496. * Gets the rgb output component
  118497. */
  118498. readonly rgb: NodeMaterialConnectionPoint;
  118499. /**
  118500. * Gets the r output component
  118501. */
  118502. readonly r: NodeMaterialConnectionPoint;
  118503. /**
  118504. * Gets the g output component
  118505. */
  118506. readonly g: NodeMaterialConnectionPoint;
  118507. /**
  118508. * Gets the b output component
  118509. */
  118510. readonly b: NodeMaterialConnectionPoint;
  118511. /**
  118512. * Gets the a output component
  118513. */
  118514. readonly a: NodeMaterialConnectionPoint;
  118515. readonly target: NodeMaterialBlockTargets;
  118516. autoConfigure(material: NodeMaterial): void;
  118517. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118518. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118519. isReady(): boolean;
  118520. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118521. private readonly _isMixed;
  118522. private _injectVertexCode;
  118523. private _writeOutput;
  118524. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118525. protected _dumpPropertiesCode(): string;
  118526. serialize(): any;
  118527. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118528. }
  118529. }
  118530. declare module BABYLON {
  118531. /**
  118532. * Class used to store shared data between 2 NodeMaterialBuildState
  118533. */
  118534. export class NodeMaterialBuildStateSharedData {
  118535. /**
  118536. * Gets the list of emitted varyings
  118537. */
  118538. temps: string[];
  118539. /**
  118540. * Gets the list of emitted varyings
  118541. */
  118542. varyings: string[];
  118543. /**
  118544. * Gets the varying declaration string
  118545. */
  118546. varyingDeclaration: string;
  118547. /**
  118548. * Input blocks
  118549. */
  118550. inputBlocks: InputBlock[];
  118551. /**
  118552. * Input blocks
  118553. */
  118554. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  118555. /**
  118556. * Bindable blocks (Blocks that need to set data to the effect)
  118557. */
  118558. bindableBlocks: NodeMaterialBlock[];
  118559. /**
  118560. * List of blocks that can provide a compilation fallback
  118561. */
  118562. blocksWithFallbacks: NodeMaterialBlock[];
  118563. /**
  118564. * List of blocks that can provide a define update
  118565. */
  118566. blocksWithDefines: NodeMaterialBlock[];
  118567. /**
  118568. * List of blocks that can provide a repeatable content
  118569. */
  118570. repeatableContentBlocks: NodeMaterialBlock[];
  118571. /**
  118572. * List of blocks that can provide a dynamic list of uniforms
  118573. */
  118574. dynamicUniformBlocks: NodeMaterialBlock[];
  118575. /**
  118576. * List of blocks that can block the isReady function for the material
  118577. */
  118578. blockingBlocks: NodeMaterialBlock[];
  118579. /**
  118580. * Gets the list of animated inputs
  118581. */
  118582. animatedInputs: InputBlock[];
  118583. /**
  118584. * Build Id used to avoid multiple recompilations
  118585. */
  118586. buildId: number;
  118587. /** List of emitted variables */
  118588. variableNames: {
  118589. [key: string]: number;
  118590. };
  118591. /** List of emitted defines */
  118592. defineNames: {
  118593. [key: string]: number;
  118594. };
  118595. /** Should emit comments? */
  118596. emitComments: boolean;
  118597. /** Emit build activity */
  118598. verbose: boolean;
  118599. /** Gets or sets the hosting scene */
  118600. scene: Scene;
  118601. /**
  118602. * Gets the compilation hints emitted at compilation time
  118603. */
  118604. hints: {
  118605. needWorldViewMatrix: boolean;
  118606. needWorldViewProjectionMatrix: boolean;
  118607. needAlphaBlending: boolean;
  118608. needAlphaTesting: boolean;
  118609. };
  118610. /**
  118611. * List of compilation checks
  118612. */
  118613. checks: {
  118614. emitVertex: boolean;
  118615. emitFragment: boolean;
  118616. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  118617. };
  118618. /** Creates a new shared data */
  118619. constructor();
  118620. /**
  118621. * Emits console errors and exceptions if there is a failing check
  118622. */
  118623. emitErrors(): void;
  118624. }
  118625. }
  118626. declare module BABYLON {
  118627. /**
  118628. * Class used to store node based material build state
  118629. */
  118630. export class NodeMaterialBuildState {
  118631. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  118632. supportUniformBuffers: boolean;
  118633. /**
  118634. * Gets the list of emitted attributes
  118635. */
  118636. attributes: string[];
  118637. /**
  118638. * Gets the list of emitted uniforms
  118639. */
  118640. uniforms: string[];
  118641. /**
  118642. * Gets the list of emitted constants
  118643. */
  118644. constants: string[];
  118645. /**
  118646. * Gets the list of emitted uniform buffers
  118647. */
  118648. uniformBuffers: string[];
  118649. /**
  118650. * Gets the list of emitted samplers
  118651. */
  118652. samplers: string[];
  118653. /**
  118654. * Gets the list of emitted functions
  118655. */
  118656. functions: {
  118657. [key: string]: string;
  118658. };
  118659. /**
  118660. * Gets the list of emitted extensions
  118661. */
  118662. extensions: {
  118663. [key: string]: string;
  118664. };
  118665. /**
  118666. * Gets the target of the compilation state
  118667. */
  118668. target: NodeMaterialBlockTargets;
  118669. /**
  118670. * Gets the list of emitted counters
  118671. */
  118672. counters: {
  118673. [key: string]: number;
  118674. };
  118675. /**
  118676. * Shared data between multiple NodeMaterialBuildState instances
  118677. */
  118678. sharedData: NodeMaterialBuildStateSharedData;
  118679. /** @hidden */
  118680. _vertexState: NodeMaterialBuildState;
  118681. /** @hidden */
  118682. _attributeDeclaration: string;
  118683. /** @hidden */
  118684. _uniformDeclaration: string;
  118685. /** @hidden */
  118686. _constantDeclaration: string;
  118687. /** @hidden */
  118688. _samplerDeclaration: string;
  118689. /** @hidden */
  118690. _varyingTransfer: string;
  118691. private _repeatableContentAnchorIndex;
  118692. /** @hidden */
  118693. _builtCompilationString: string;
  118694. /**
  118695. * Gets the emitted compilation strings
  118696. */
  118697. compilationString: string;
  118698. /**
  118699. * Finalize the compilation strings
  118700. * @param state defines the current compilation state
  118701. */
  118702. finalize(state: NodeMaterialBuildState): void;
  118703. /** @hidden */
  118704. readonly _repeatableContentAnchor: string;
  118705. /** @hidden */
  118706. _getFreeVariableName(prefix: string): string;
  118707. /** @hidden */
  118708. _getFreeDefineName(prefix: string): string;
  118709. /** @hidden */
  118710. _excludeVariableName(name: string): void;
  118711. /** @hidden */
  118712. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  118713. /** @hidden */
  118714. _emitExtension(name: string, extension: string): void;
  118715. /** @hidden */
  118716. _emitFunction(name: string, code: string, comments: string): void;
  118717. /** @hidden */
  118718. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  118719. replaceStrings?: {
  118720. search: RegExp;
  118721. replace: string;
  118722. }[];
  118723. repeatKey?: string;
  118724. }): string;
  118725. /** @hidden */
  118726. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  118727. repeatKey?: string;
  118728. removeAttributes?: boolean;
  118729. removeUniforms?: boolean;
  118730. removeVaryings?: boolean;
  118731. removeIfDef?: boolean;
  118732. replaceStrings?: {
  118733. search: RegExp;
  118734. replace: string;
  118735. }[];
  118736. }, storeKey?: string): void;
  118737. /** @hidden */
  118738. _registerTempVariable(name: string): boolean;
  118739. /** @hidden */
  118740. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  118741. /** @hidden */
  118742. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  118743. }
  118744. }
  118745. declare module BABYLON {
  118746. /**
  118747. * Defines a block that can be used inside a node based material
  118748. */
  118749. export class NodeMaterialBlock {
  118750. private _buildId;
  118751. private _buildTarget;
  118752. private _target;
  118753. private _isFinalMerger;
  118754. private _isInput;
  118755. /** @hidden */
  118756. _codeVariableName: string;
  118757. /** @hidden */
  118758. _inputs: NodeMaterialConnectionPoint[];
  118759. /** @hidden */
  118760. _outputs: NodeMaterialConnectionPoint[];
  118761. /** @hidden */
  118762. _preparationId: number;
  118763. /**
  118764. * Gets or sets the name of the block
  118765. */
  118766. name: string;
  118767. /**
  118768. * Gets or sets the unique id of the node
  118769. */
  118770. uniqueId: number;
  118771. /**
  118772. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  118773. */
  118774. readonly isFinalMerger: boolean;
  118775. /**
  118776. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  118777. */
  118778. readonly isInput: boolean;
  118779. /**
  118780. * Gets or sets the build Id
  118781. */
  118782. buildId: number;
  118783. /**
  118784. * Gets or sets the target of the block
  118785. */
  118786. target: NodeMaterialBlockTargets;
  118787. /**
  118788. * Gets the list of input points
  118789. */
  118790. readonly inputs: NodeMaterialConnectionPoint[];
  118791. /** Gets the list of output points */
  118792. readonly outputs: NodeMaterialConnectionPoint[];
  118793. /**
  118794. * Find an input by its name
  118795. * @param name defines the name of the input to look for
  118796. * @returns the input or null if not found
  118797. */
  118798. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118799. /**
  118800. * Find an output by its name
  118801. * @param name defines the name of the outputto look for
  118802. * @returns the output or null if not found
  118803. */
  118804. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118805. /**
  118806. * Creates a new NodeMaterialBlock
  118807. * @param name defines the block name
  118808. * @param target defines the target of that block (Vertex by default)
  118809. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  118810. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  118811. */
  118812. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  118813. /**
  118814. * Initialize the block and prepare the context for build
  118815. * @param state defines the state that will be used for the build
  118816. */
  118817. initialize(state: NodeMaterialBuildState): void;
  118818. /**
  118819. * Bind data to effect. Will only be called for blocks with isBindable === true
  118820. * @param effect defines the effect to bind data to
  118821. * @param nodeMaterial defines the hosting NodeMaterial
  118822. * @param mesh defines the mesh that will be rendered
  118823. */
  118824. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118825. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  118826. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  118827. protected _writeFloat(value: number): string;
  118828. /**
  118829. * Gets the current class name e.g. "NodeMaterialBlock"
  118830. * @returns the class name
  118831. */
  118832. getClassName(): string;
  118833. /**
  118834. * Register a new input. Must be called inside a block constructor
  118835. * @param name defines the connection point name
  118836. * @param type defines the connection point type
  118837. * @param isOptional defines a boolean indicating that this input can be omitted
  118838. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118839. * @returns the current block
  118840. */
  118841. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  118842. /**
  118843. * Register a new output. Must be called inside a block constructor
  118844. * @param name defines the connection point name
  118845. * @param type defines the connection point type
  118846. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118847. * @returns the current block
  118848. */
  118849. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  118850. /**
  118851. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  118852. * @param forOutput defines an optional connection point to check compatibility with
  118853. * @returns the first available input or null
  118854. */
  118855. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  118856. /**
  118857. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  118858. * @param forBlock defines an optional block to check compatibility with
  118859. * @returns the first available input or null
  118860. */
  118861. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  118862. /**
  118863. * Gets the sibling of the given output
  118864. * @param current defines the current output
  118865. * @returns the next output in the list or null
  118866. */
  118867. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  118868. /**
  118869. * Connect current block with another block
  118870. * @param other defines the block to connect with
  118871. * @param options define the various options to help pick the right connections
  118872. * @returns the current block
  118873. */
  118874. connectTo(other: NodeMaterialBlock, options?: {
  118875. input?: string;
  118876. output?: string;
  118877. outputSwizzle?: string;
  118878. }): this | undefined;
  118879. protected _buildBlock(state: NodeMaterialBuildState): void;
  118880. /**
  118881. * Add uniforms, samplers and uniform buffers at compilation time
  118882. * @param state defines the state to update
  118883. * @param nodeMaterial defines the node material requesting the update
  118884. * @param defines defines the material defines to update
  118885. */
  118886. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118887. /**
  118888. * Add potential fallbacks if shader compilation fails
  118889. * @param mesh defines the mesh to be rendered
  118890. * @param fallbacks defines the current prioritized list of fallbacks
  118891. */
  118892. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  118893. /**
  118894. * Initialize defines for shader compilation
  118895. * @param mesh defines the mesh to be rendered
  118896. * @param nodeMaterial defines the node material requesting the update
  118897. * @param defines defines the material defines to update
  118898. * @param useInstances specifies that instances should be used
  118899. */
  118900. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118901. /**
  118902. * Update defines for shader compilation
  118903. * @param mesh defines the mesh to be rendered
  118904. * @param nodeMaterial defines the node material requesting the update
  118905. * @param defines defines the material defines to update
  118906. * @param useInstances specifies that instances should be used
  118907. */
  118908. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118909. /**
  118910. * Lets the block try to connect some inputs automatically
  118911. * @param material defines the hosting NodeMaterial
  118912. */
  118913. autoConfigure(material: NodeMaterial): void;
  118914. /**
  118915. * Function called when a block is declared as repeatable content generator
  118916. * @param vertexShaderState defines the current compilation state for the vertex shader
  118917. * @param fragmentShaderState defines the current compilation state for the fragment shader
  118918. * @param mesh defines the mesh to be rendered
  118919. * @param defines defines the material defines to update
  118920. */
  118921. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  118922. /**
  118923. * Checks if the block is ready
  118924. * @param mesh defines the mesh to be rendered
  118925. * @param nodeMaterial defines the node material requesting the update
  118926. * @param defines defines the material defines to update
  118927. * @param useInstances specifies that instances should be used
  118928. * @returns true if the block is ready
  118929. */
  118930. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  118931. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  118932. private _processBuild;
  118933. /**
  118934. * Compile the current node and generate the shader code
  118935. * @param state defines the current compilation state (uniforms, samplers, current string)
  118936. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  118937. * @returns true if already built
  118938. */
  118939. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  118940. protected _inputRename(name: string): string;
  118941. protected _outputRename(name: string): string;
  118942. protected _dumpPropertiesCode(): string;
  118943. /** @hidden */
  118944. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  118945. /**
  118946. * Clone the current block to a new identical block
  118947. * @param scene defines the hosting scene
  118948. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118949. * @returns a copy of the current block
  118950. */
  118951. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  118952. /**
  118953. * Serializes this block in a JSON representation
  118954. * @returns the serialized block object
  118955. */
  118956. serialize(): any;
  118957. /** @hidden */
  118958. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118959. }
  118960. }
  118961. declare module BABYLON {
  118962. /**
  118963. * Enum defining the type of animations supported by InputBlock
  118964. */
  118965. export enum AnimatedInputBlockTypes {
  118966. /** No animation */
  118967. None = 0,
  118968. /** Time based animation. Will only work for floats */
  118969. Time = 1
  118970. }
  118971. }
  118972. declare module BABYLON {
  118973. /**
  118974. * Block used to expose an input value
  118975. */
  118976. export class InputBlock extends NodeMaterialBlock {
  118977. private _mode;
  118978. private _associatedVariableName;
  118979. private _storedValue;
  118980. private _valueCallback;
  118981. private _type;
  118982. private _animationType;
  118983. /** Gets or set a value used to limit the range of float values */
  118984. min: number;
  118985. /** Gets or set a value used to limit the range of float values */
  118986. max: number;
  118987. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  118988. matrixMode: number;
  118989. /** @hidden */
  118990. _systemValue: Nullable<NodeMaterialSystemValues>;
  118991. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  118992. visibleInInspector: boolean;
  118993. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  118994. isConstant: boolean;
  118995. /**
  118996. * Gets or sets the connection point type (default is float)
  118997. */
  118998. readonly type: NodeMaterialBlockConnectionPointTypes;
  118999. /**
  119000. * Creates a new InputBlock
  119001. * @param name defines the block name
  119002. * @param target defines the target of that block (Vertex by default)
  119003. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  119004. */
  119005. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  119006. /**
  119007. * Gets the output component
  119008. */
  119009. readonly output: NodeMaterialConnectionPoint;
  119010. /**
  119011. * Set the source of this connection point to a vertex attribute
  119012. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  119013. * @returns the current connection point
  119014. */
  119015. setAsAttribute(attributeName?: string): InputBlock;
  119016. /**
  119017. * Set the source of this connection point to a system value
  119018. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  119019. * @returns the current connection point
  119020. */
  119021. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  119022. /**
  119023. * Gets or sets the value of that point.
  119024. * Please note that this value will be ignored if valueCallback is defined
  119025. */
  119026. value: any;
  119027. /**
  119028. * Gets or sets a callback used to get the value of that point.
  119029. * Please note that setting this value will force the connection point to ignore the value property
  119030. */
  119031. valueCallback: () => any;
  119032. /**
  119033. * Gets or sets the associated variable name in the shader
  119034. */
  119035. associatedVariableName: string;
  119036. /** Gets or sets the type of animation applied to the input */
  119037. animationType: AnimatedInputBlockTypes;
  119038. /**
  119039. * Gets a boolean indicating that this connection point not defined yet
  119040. */
  119041. readonly isUndefined: boolean;
  119042. /**
  119043. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  119044. * In this case the connection point name must be the name of the uniform to use.
  119045. * Can only be set on inputs
  119046. */
  119047. isUniform: boolean;
  119048. /**
  119049. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  119050. * In this case the connection point name must be the name of the attribute to use
  119051. * Can only be set on inputs
  119052. */
  119053. isAttribute: boolean;
  119054. /**
  119055. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  119056. * Can only be set on exit points
  119057. */
  119058. isVarying: boolean;
  119059. /**
  119060. * Gets a boolean indicating that the current connection point is a system value
  119061. */
  119062. readonly isSystemValue: boolean;
  119063. /**
  119064. * Gets or sets the current well known value or null if not defined as a system value
  119065. */
  119066. systemValue: Nullable<NodeMaterialSystemValues>;
  119067. /**
  119068. * Gets the current class name
  119069. * @returns the class name
  119070. */
  119071. getClassName(): string;
  119072. /**
  119073. * Animate the input if animationType !== None
  119074. * @param scene defines the rendering scene
  119075. */
  119076. animate(scene: Scene): void;
  119077. private _emitDefine;
  119078. initialize(state: NodeMaterialBuildState): void;
  119079. /**
  119080. * Set the input block to its default value (based on its type)
  119081. */
  119082. setDefaultValue(): void;
  119083. private _emitConstant;
  119084. private _emit;
  119085. /** @hidden */
  119086. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  119087. /** @hidden */
  119088. _transmit(effect: Effect, scene: Scene): void;
  119089. protected _buildBlock(state: NodeMaterialBuildState): void;
  119090. protected _dumpPropertiesCode(): string;
  119091. serialize(): any;
  119092. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119093. }
  119094. }
  119095. declare module BABYLON {
  119096. /**
  119097. * Defines a connection point for a block
  119098. */
  119099. export class NodeMaterialConnectionPoint {
  119100. /** @hidden */
  119101. _ownerBlock: NodeMaterialBlock;
  119102. /** @hidden */
  119103. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  119104. private _endpoints;
  119105. private _associatedVariableName;
  119106. /** @hidden */
  119107. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  119108. /** @hidden */
  119109. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  119110. private _type;
  119111. /** @hidden */
  119112. _enforceAssociatedVariableName: boolean;
  119113. /**
  119114. * Gets or sets the additional types supported by this connection point
  119115. */
  119116. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  119117. /**
  119118. * Gets or sets the additional types excluded by this connection point
  119119. */
  119120. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  119121. /**
  119122. * Gets or sets the associated variable name in the shader
  119123. */
  119124. associatedVariableName: string;
  119125. /**
  119126. * Gets or sets the connection point type (default is float)
  119127. */
  119128. type: NodeMaterialBlockConnectionPointTypes;
  119129. /**
  119130. * Gets or sets the connection point name
  119131. */
  119132. name: string;
  119133. /**
  119134. * Gets or sets a boolean indicating that this connection point can be omitted
  119135. */
  119136. isOptional: boolean;
  119137. /**
  119138. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  119139. */
  119140. define: string;
  119141. /** Gets or sets the target of that connection point */
  119142. target: NodeMaterialBlockTargets;
  119143. /**
  119144. * Gets a boolean indicating that the current point is connected
  119145. */
  119146. readonly isConnected: boolean;
  119147. /**
  119148. * Gets a boolean indicating that the current point is connected to an input block
  119149. */
  119150. readonly isConnectedToInputBlock: boolean;
  119151. /**
  119152. * Gets a the connected input block (if any)
  119153. */
  119154. readonly connectInputBlock: Nullable<InputBlock>;
  119155. /** Get the other side of the connection (if any) */
  119156. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  119157. /** Get the block that owns this connection point */
  119158. readonly ownerBlock: NodeMaterialBlock;
  119159. /** Get the block connected on the other side of this connection (if any) */
  119160. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  119161. /** Get the block connected on the endpoints of this connection (if any) */
  119162. readonly connectedBlocks: Array<NodeMaterialBlock>;
  119163. /** Gets the list of connected endpoints */
  119164. readonly endpoints: NodeMaterialConnectionPoint[];
  119165. /** Gets a boolean indicating if that output point is connected to at least one input */
  119166. readonly hasEndpoints: boolean;
  119167. /**
  119168. * Creates a new connection point
  119169. * @param name defines the connection point name
  119170. * @param ownerBlock defines the block hosting this connection point
  119171. */
  119172. constructor(name: string, ownerBlock: NodeMaterialBlock);
  119173. /**
  119174. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  119175. * @returns the class name
  119176. */
  119177. getClassName(): string;
  119178. /**
  119179. * Gets an boolean indicating if the current point can be connected to another point
  119180. * @param connectionPoint defines the other connection point
  119181. * @returns true if the connection is possible
  119182. */
  119183. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  119184. /**
  119185. * Connect this point to another connection point
  119186. * @param connectionPoint defines the other connection point
  119187. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  119188. * @returns the current connection point
  119189. */
  119190. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  119191. /**
  119192. * Disconnect this point from one of his endpoint
  119193. * @param endpoint defines the other connection point
  119194. * @returns the current connection point
  119195. */
  119196. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  119197. /**
  119198. * Serializes this point in a JSON representation
  119199. * @returns the serialized point object
  119200. */
  119201. serialize(): any;
  119202. }
  119203. }
  119204. declare module BABYLON {
  119205. /**
  119206. * Block used to add support for vertex skinning (bones)
  119207. */
  119208. export class BonesBlock extends NodeMaterialBlock {
  119209. /**
  119210. * Creates a new BonesBlock
  119211. * @param name defines the block name
  119212. */
  119213. constructor(name: string);
  119214. /**
  119215. * Initialize the block and prepare the context for build
  119216. * @param state defines the state that will be used for the build
  119217. */
  119218. initialize(state: NodeMaterialBuildState): void;
  119219. /**
  119220. * Gets the current class name
  119221. * @returns the class name
  119222. */
  119223. getClassName(): string;
  119224. /**
  119225. * Gets the matrix indices input component
  119226. */
  119227. readonly matricesIndices: NodeMaterialConnectionPoint;
  119228. /**
  119229. * Gets the matrix weights input component
  119230. */
  119231. readonly matricesWeights: NodeMaterialConnectionPoint;
  119232. /**
  119233. * Gets the extra matrix indices input component
  119234. */
  119235. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  119236. /**
  119237. * Gets the extra matrix weights input component
  119238. */
  119239. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  119240. /**
  119241. * Gets the world input component
  119242. */
  119243. readonly world: NodeMaterialConnectionPoint;
  119244. /**
  119245. * Gets the output component
  119246. */
  119247. readonly output: NodeMaterialConnectionPoint;
  119248. autoConfigure(material: NodeMaterial): void;
  119249. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  119250. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119251. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119252. protected _buildBlock(state: NodeMaterialBuildState): this;
  119253. }
  119254. }
  119255. declare module BABYLON {
  119256. /**
  119257. * Block used to add support for instances
  119258. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  119259. */
  119260. export class InstancesBlock extends NodeMaterialBlock {
  119261. /**
  119262. * Creates a new InstancesBlock
  119263. * @param name defines the block name
  119264. */
  119265. constructor(name: string);
  119266. /**
  119267. * Gets the current class name
  119268. * @returns the class name
  119269. */
  119270. getClassName(): string;
  119271. /**
  119272. * Gets the first world row input component
  119273. */
  119274. readonly world0: NodeMaterialConnectionPoint;
  119275. /**
  119276. * Gets the second world row input component
  119277. */
  119278. readonly world1: NodeMaterialConnectionPoint;
  119279. /**
  119280. * Gets the third world row input component
  119281. */
  119282. readonly world2: NodeMaterialConnectionPoint;
  119283. /**
  119284. * Gets the forth world row input component
  119285. */
  119286. readonly world3: NodeMaterialConnectionPoint;
  119287. /**
  119288. * Gets the world input component
  119289. */
  119290. readonly world: NodeMaterialConnectionPoint;
  119291. /**
  119292. * Gets the output component
  119293. */
  119294. readonly output: NodeMaterialConnectionPoint;
  119295. autoConfigure(material: NodeMaterial): void;
  119296. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119297. protected _buildBlock(state: NodeMaterialBuildState): this;
  119298. }
  119299. }
  119300. declare module BABYLON {
  119301. /**
  119302. * Block used to add morph targets support to vertex shader
  119303. */
  119304. export class MorphTargetsBlock extends NodeMaterialBlock {
  119305. private _repeatableContentAnchor;
  119306. private _repeatebleContentGenerated;
  119307. /**
  119308. * Create a new MorphTargetsBlock
  119309. * @param name defines the block name
  119310. */
  119311. constructor(name: string);
  119312. /**
  119313. * Gets the current class name
  119314. * @returns the class name
  119315. */
  119316. getClassName(): string;
  119317. /**
  119318. * Gets the position input component
  119319. */
  119320. readonly position: NodeMaterialConnectionPoint;
  119321. /**
  119322. * Gets the normal input component
  119323. */
  119324. readonly normal: NodeMaterialConnectionPoint;
  119325. /**
  119326. * Gets the tangent input component
  119327. */
  119328. readonly tangent: NodeMaterialConnectionPoint;
  119329. /**
  119330. * Gets the tangent input component
  119331. */
  119332. readonly uv: NodeMaterialConnectionPoint;
  119333. /**
  119334. * Gets the position output component
  119335. */
  119336. readonly positionOutput: NodeMaterialConnectionPoint;
  119337. /**
  119338. * Gets the normal output component
  119339. */
  119340. readonly normalOutput: NodeMaterialConnectionPoint;
  119341. /**
  119342. * Gets the tangent output component
  119343. */
  119344. readonly tangentOutput: NodeMaterialConnectionPoint;
  119345. /**
  119346. * Gets the tangent output component
  119347. */
  119348. readonly uvOutput: NodeMaterialConnectionPoint;
  119349. initialize(state: NodeMaterialBuildState): void;
  119350. autoConfigure(material: NodeMaterial): void;
  119351. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119352. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119353. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  119354. protected _buildBlock(state: NodeMaterialBuildState): this;
  119355. }
  119356. }
  119357. declare module BABYLON {
  119358. /**
  119359. * Block used to get data information from a light
  119360. */
  119361. export class LightInformationBlock extends NodeMaterialBlock {
  119362. private _lightDataUniformName;
  119363. private _lightColorUniformName;
  119364. private _lightTypeDefineName;
  119365. /**
  119366. * Gets or sets the light associated with this block
  119367. */
  119368. light: Nullable<Light>;
  119369. /**
  119370. * Creates a new LightInformationBlock
  119371. * @param name defines the block name
  119372. */
  119373. constructor(name: string);
  119374. /**
  119375. * Gets the current class name
  119376. * @returns the class name
  119377. */
  119378. getClassName(): string;
  119379. /**
  119380. * Gets the world position input component
  119381. */
  119382. readonly worldPosition: NodeMaterialConnectionPoint;
  119383. /**
  119384. * Gets the direction output component
  119385. */
  119386. readonly direction: NodeMaterialConnectionPoint;
  119387. /**
  119388. * Gets the direction output component
  119389. */
  119390. readonly color: NodeMaterialConnectionPoint;
  119391. /**
  119392. * Gets the direction output component
  119393. */
  119394. readonly intensity: NodeMaterialConnectionPoint;
  119395. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119396. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119397. protected _buildBlock(state: NodeMaterialBuildState): this;
  119398. serialize(): any;
  119399. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119400. }
  119401. }
  119402. declare module BABYLON {
  119403. /**
  119404. * Block used to add image processing support to fragment shader
  119405. */
  119406. export class ImageProcessingBlock extends NodeMaterialBlock {
  119407. /**
  119408. * Create a new ImageProcessingBlock
  119409. * @param name defines the block name
  119410. */
  119411. constructor(name: string);
  119412. /**
  119413. * Gets the current class name
  119414. * @returns the class name
  119415. */
  119416. getClassName(): string;
  119417. /**
  119418. * Gets the color input component
  119419. */
  119420. readonly color: NodeMaterialConnectionPoint;
  119421. /**
  119422. * Gets the output component
  119423. */
  119424. readonly output: NodeMaterialConnectionPoint;
  119425. /**
  119426. * Initialize the block and prepare the context for build
  119427. * @param state defines the state that will be used for the build
  119428. */
  119429. initialize(state: NodeMaterialBuildState): void;
  119430. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  119431. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119432. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119433. protected _buildBlock(state: NodeMaterialBuildState): this;
  119434. }
  119435. }
  119436. declare module BABYLON {
  119437. /**
  119438. * Block used to pertub normals based on a normal map
  119439. */
  119440. export class PerturbNormalBlock extends NodeMaterialBlock {
  119441. private _tangentSpaceParameterName;
  119442. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  119443. invertX: boolean;
  119444. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  119445. invertY: boolean;
  119446. /**
  119447. * Create a new PerturbNormalBlock
  119448. * @param name defines the block name
  119449. */
  119450. constructor(name: string);
  119451. /**
  119452. * Gets the current class name
  119453. * @returns the class name
  119454. */
  119455. getClassName(): string;
  119456. /**
  119457. * Gets the world position input component
  119458. */
  119459. readonly worldPosition: NodeMaterialConnectionPoint;
  119460. /**
  119461. * Gets the world normal input component
  119462. */
  119463. readonly worldNormal: NodeMaterialConnectionPoint;
  119464. /**
  119465. * Gets the uv input component
  119466. */
  119467. readonly uv: NodeMaterialConnectionPoint;
  119468. /**
  119469. * Gets the normal map color input component
  119470. */
  119471. readonly normalMapColor: NodeMaterialConnectionPoint;
  119472. /**
  119473. * Gets the strength input component
  119474. */
  119475. readonly strength: NodeMaterialConnectionPoint;
  119476. /**
  119477. * Gets the output component
  119478. */
  119479. readonly output: NodeMaterialConnectionPoint;
  119480. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119481. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119482. autoConfigure(material: NodeMaterial): void;
  119483. protected _buildBlock(state: NodeMaterialBuildState): this;
  119484. protected _dumpPropertiesCode(): string;
  119485. serialize(): any;
  119486. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119487. }
  119488. }
  119489. declare module BABYLON {
  119490. /**
  119491. * Block used to discard a pixel if a value is smaller than a cutoff
  119492. */
  119493. export class DiscardBlock extends NodeMaterialBlock {
  119494. /**
  119495. * Create a new DiscardBlock
  119496. * @param name defines the block name
  119497. */
  119498. constructor(name: string);
  119499. /**
  119500. * Gets the current class name
  119501. * @returns the class name
  119502. */
  119503. getClassName(): string;
  119504. /**
  119505. * Gets the color input component
  119506. */
  119507. readonly value: NodeMaterialConnectionPoint;
  119508. /**
  119509. * Gets the cutoff input component
  119510. */
  119511. readonly cutoff: NodeMaterialConnectionPoint;
  119512. protected _buildBlock(state: NodeMaterialBuildState): this;
  119513. }
  119514. }
  119515. declare module BABYLON {
  119516. /**
  119517. * Block used to add support for scene fog
  119518. */
  119519. export class FogBlock extends NodeMaterialBlock {
  119520. private _fogDistanceName;
  119521. private _fogParameters;
  119522. /**
  119523. * Create a new FogBlock
  119524. * @param name defines the block name
  119525. */
  119526. constructor(name: string);
  119527. /**
  119528. * Gets the current class name
  119529. * @returns the class name
  119530. */
  119531. getClassName(): string;
  119532. /**
  119533. * Gets the world position input component
  119534. */
  119535. readonly worldPosition: NodeMaterialConnectionPoint;
  119536. /**
  119537. * Gets the view input component
  119538. */
  119539. readonly view: NodeMaterialConnectionPoint;
  119540. /**
  119541. * Gets the color input component
  119542. */
  119543. readonly input: NodeMaterialConnectionPoint;
  119544. /**
  119545. * Gets the fog color input component
  119546. */
  119547. readonly fogColor: NodeMaterialConnectionPoint;
  119548. /**
  119549. * Gets the output component
  119550. */
  119551. readonly output: NodeMaterialConnectionPoint;
  119552. autoConfigure(material: NodeMaterial): void;
  119553. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119554. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119555. protected _buildBlock(state: NodeMaterialBuildState): this;
  119556. }
  119557. }
  119558. declare module BABYLON {
  119559. /**
  119560. * Block used to add light in the fragment shader
  119561. */
  119562. export class LightBlock extends NodeMaterialBlock {
  119563. private _lightId;
  119564. /**
  119565. * Gets or sets the light associated with this block
  119566. */
  119567. light: Nullable<Light>;
  119568. /**
  119569. * Create a new LightBlock
  119570. * @param name defines the block name
  119571. */
  119572. constructor(name: string);
  119573. /**
  119574. * Gets the current class name
  119575. * @returns the class name
  119576. */
  119577. getClassName(): string;
  119578. /**
  119579. * Gets the world position input component
  119580. */
  119581. readonly worldPosition: NodeMaterialConnectionPoint;
  119582. /**
  119583. * Gets the world normal input component
  119584. */
  119585. readonly worldNormal: NodeMaterialConnectionPoint;
  119586. /**
  119587. * Gets the camera (or eye) position component
  119588. */
  119589. readonly cameraPosition: NodeMaterialConnectionPoint;
  119590. /**
  119591. * Gets the glossiness component
  119592. */
  119593. readonly glossiness: NodeMaterialConnectionPoint;
  119594. /**
  119595. * Gets the diffuse output component
  119596. */
  119597. readonly diffuseOutput: NodeMaterialConnectionPoint;
  119598. /**
  119599. * Gets the specular output component
  119600. */
  119601. readonly specularOutput: NodeMaterialConnectionPoint;
  119602. autoConfigure(material: NodeMaterial): void;
  119603. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119604. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119605. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119606. private _injectVertexCode;
  119607. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119608. serialize(): any;
  119609. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119610. }
  119611. }
  119612. declare module BABYLON {
  119613. /**
  119614. * Block used to multiply 2 values
  119615. */
  119616. export class MultiplyBlock extends NodeMaterialBlock {
  119617. /**
  119618. * Creates a new MultiplyBlock
  119619. * @param name defines the block name
  119620. */
  119621. constructor(name: string);
  119622. /**
  119623. * Gets the current class name
  119624. * @returns the class name
  119625. */
  119626. getClassName(): string;
  119627. /**
  119628. * Gets the left operand input component
  119629. */
  119630. readonly left: NodeMaterialConnectionPoint;
  119631. /**
  119632. * Gets the right operand input component
  119633. */
  119634. readonly right: NodeMaterialConnectionPoint;
  119635. /**
  119636. * Gets the output component
  119637. */
  119638. readonly output: NodeMaterialConnectionPoint;
  119639. protected _buildBlock(state: NodeMaterialBuildState): this;
  119640. }
  119641. }
  119642. declare module BABYLON {
  119643. /**
  119644. * Block used to add 2 vectors
  119645. */
  119646. export class AddBlock extends NodeMaterialBlock {
  119647. /**
  119648. * Creates a new AddBlock
  119649. * @param name defines the block name
  119650. */
  119651. constructor(name: string);
  119652. /**
  119653. * Gets the current class name
  119654. * @returns the class name
  119655. */
  119656. getClassName(): string;
  119657. /**
  119658. * Gets the left operand input component
  119659. */
  119660. readonly left: NodeMaterialConnectionPoint;
  119661. /**
  119662. * Gets the right operand input component
  119663. */
  119664. readonly right: NodeMaterialConnectionPoint;
  119665. /**
  119666. * Gets the output component
  119667. */
  119668. readonly output: NodeMaterialConnectionPoint;
  119669. protected _buildBlock(state: NodeMaterialBuildState): this;
  119670. }
  119671. }
  119672. declare module BABYLON {
  119673. /**
  119674. * Block used to scale a vector by a float
  119675. */
  119676. export class ScaleBlock extends NodeMaterialBlock {
  119677. /**
  119678. * Creates a new ScaleBlock
  119679. * @param name defines the block name
  119680. */
  119681. constructor(name: string);
  119682. /**
  119683. * Gets the current class name
  119684. * @returns the class name
  119685. */
  119686. getClassName(): string;
  119687. /**
  119688. * Gets the input component
  119689. */
  119690. readonly input: NodeMaterialConnectionPoint;
  119691. /**
  119692. * Gets the factor input component
  119693. */
  119694. readonly factor: NodeMaterialConnectionPoint;
  119695. /**
  119696. * Gets the output component
  119697. */
  119698. readonly output: NodeMaterialConnectionPoint;
  119699. protected _buildBlock(state: NodeMaterialBuildState): this;
  119700. }
  119701. }
  119702. declare module BABYLON {
  119703. /**
  119704. * Block used to clamp a float
  119705. */
  119706. export class ClampBlock extends NodeMaterialBlock {
  119707. /** Gets or sets the minimum range */
  119708. minimum: number;
  119709. /** Gets or sets the maximum range */
  119710. maximum: number;
  119711. /**
  119712. * Creates a new ClampBlock
  119713. * @param name defines the block name
  119714. */
  119715. constructor(name: string);
  119716. /**
  119717. * Gets the current class name
  119718. * @returns the class name
  119719. */
  119720. getClassName(): string;
  119721. /**
  119722. * Gets the value input component
  119723. */
  119724. readonly value: NodeMaterialConnectionPoint;
  119725. /**
  119726. * Gets the output component
  119727. */
  119728. readonly output: NodeMaterialConnectionPoint;
  119729. protected _buildBlock(state: NodeMaterialBuildState): this;
  119730. protected _dumpPropertiesCode(): string;
  119731. serialize(): any;
  119732. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119733. }
  119734. }
  119735. declare module BABYLON {
  119736. /**
  119737. * Block used to apply a cross product between 2 vectors
  119738. */
  119739. export class CrossBlock extends NodeMaterialBlock {
  119740. /**
  119741. * Creates a new CrossBlock
  119742. * @param name defines the block name
  119743. */
  119744. constructor(name: string);
  119745. /**
  119746. * Gets the current class name
  119747. * @returns the class name
  119748. */
  119749. getClassName(): string;
  119750. /**
  119751. * Gets the left operand input component
  119752. */
  119753. readonly left: NodeMaterialConnectionPoint;
  119754. /**
  119755. * Gets the right operand input component
  119756. */
  119757. readonly right: NodeMaterialConnectionPoint;
  119758. /**
  119759. * Gets the output component
  119760. */
  119761. readonly output: NodeMaterialConnectionPoint;
  119762. protected _buildBlock(state: NodeMaterialBuildState): this;
  119763. }
  119764. }
  119765. declare module BABYLON {
  119766. /**
  119767. * Block used to apply a dot product between 2 vectors
  119768. */
  119769. export class DotBlock extends NodeMaterialBlock {
  119770. /**
  119771. * Creates a new DotBlock
  119772. * @param name defines the block name
  119773. */
  119774. constructor(name: string);
  119775. /**
  119776. * Gets the current class name
  119777. * @returns the class name
  119778. */
  119779. getClassName(): string;
  119780. /**
  119781. * Gets the left operand input component
  119782. */
  119783. readonly left: NodeMaterialConnectionPoint;
  119784. /**
  119785. * Gets the right operand input component
  119786. */
  119787. readonly right: NodeMaterialConnectionPoint;
  119788. /**
  119789. * Gets the output component
  119790. */
  119791. readonly output: NodeMaterialConnectionPoint;
  119792. protected _buildBlock(state: NodeMaterialBuildState): this;
  119793. }
  119794. }
  119795. declare module BABYLON {
  119796. /**
  119797. * Block used to remap a float from a range to a new one
  119798. */
  119799. export class RemapBlock extends NodeMaterialBlock {
  119800. /**
  119801. * Gets or sets the source range
  119802. */
  119803. sourceRange: Vector2;
  119804. /**
  119805. * Gets or sets the target range
  119806. */
  119807. targetRange: Vector2;
  119808. /**
  119809. * Creates a new RemapBlock
  119810. * @param name defines the block name
  119811. */
  119812. constructor(name: string);
  119813. /**
  119814. * Gets the current class name
  119815. * @returns the class name
  119816. */
  119817. getClassName(): string;
  119818. /**
  119819. * Gets the input component
  119820. */
  119821. readonly input: NodeMaterialConnectionPoint;
  119822. /**
  119823. * Gets the source min input component
  119824. */
  119825. readonly sourceMin: NodeMaterialConnectionPoint;
  119826. /**
  119827. * Gets the source max input component
  119828. */
  119829. readonly sourceMax: NodeMaterialConnectionPoint;
  119830. /**
  119831. * Gets the target min input component
  119832. */
  119833. readonly targetMin: NodeMaterialConnectionPoint;
  119834. /**
  119835. * Gets the target max input component
  119836. */
  119837. readonly targetMax: NodeMaterialConnectionPoint;
  119838. /**
  119839. * Gets the output component
  119840. */
  119841. readonly output: NodeMaterialConnectionPoint;
  119842. protected _buildBlock(state: NodeMaterialBuildState): this;
  119843. protected _dumpPropertiesCode(): string;
  119844. serialize(): any;
  119845. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119846. }
  119847. }
  119848. declare module BABYLON {
  119849. /**
  119850. * Block used to normalize a vector
  119851. */
  119852. export class NormalizeBlock extends NodeMaterialBlock {
  119853. /**
  119854. * Creates a new NormalizeBlock
  119855. * @param name defines the block name
  119856. */
  119857. constructor(name: string);
  119858. /**
  119859. * Gets the current class name
  119860. * @returns the class name
  119861. */
  119862. getClassName(): string;
  119863. /**
  119864. * Gets the input component
  119865. */
  119866. readonly input: NodeMaterialConnectionPoint;
  119867. /**
  119868. * Gets the output component
  119869. */
  119870. readonly output: NodeMaterialConnectionPoint;
  119871. protected _buildBlock(state: NodeMaterialBuildState): this;
  119872. }
  119873. }
  119874. declare module BABYLON {
  119875. /**
  119876. * Operations supported by the Trigonometry block
  119877. */
  119878. export enum TrigonometryBlockOperations {
  119879. /** Cos */
  119880. Cos = 0,
  119881. /** Sin */
  119882. Sin = 1,
  119883. /** Abs */
  119884. Abs = 2,
  119885. /** Exp */
  119886. Exp = 3,
  119887. /** Exp2 */
  119888. Exp2 = 4,
  119889. /** Round */
  119890. Round = 5,
  119891. /** Floor */
  119892. Floor = 6,
  119893. /** Ceiling */
  119894. Ceiling = 7,
  119895. /** Square root */
  119896. Sqrt = 8
  119897. }
  119898. /**
  119899. * Block used to apply trigonometry operation to floats
  119900. */
  119901. export class TrigonometryBlock extends NodeMaterialBlock {
  119902. /**
  119903. * Gets or sets the operation applied by the block
  119904. */
  119905. operation: TrigonometryBlockOperations;
  119906. /**
  119907. * Creates a new TrigonometryBlock
  119908. * @param name defines the block name
  119909. */
  119910. constructor(name: string);
  119911. /**
  119912. * Gets the current class name
  119913. * @returns the class name
  119914. */
  119915. getClassName(): string;
  119916. /**
  119917. * Gets the input component
  119918. */
  119919. readonly input: NodeMaterialConnectionPoint;
  119920. /**
  119921. * Gets the output component
  119922. */
  119923. readonly output: NodeMaterialConnectionPoint;
  119924. protected _buildBlock(state: NodeMaterialBuildState): this;
  119925. serialize(): any;
  119926. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119927. }
  119928. }
  119929. declare module BABYLON {
  119930. /**
  119931. * Block used to create a Color3/4 out of individual inputs (one for each component)
  119932. */
  119933. export class ColorMergerBlock extends NodeMaterialBlock {
  119934. /**
  119935. * Create a new ColorMergerBlock
  119936. * @param name defines the block name
  119937. */
  119938. constructor(name: string);
  119939. /**
  119940. * Gets the current class name
  119941. * @returns the class name
  119942. */
  119943. getClassName(): string;
  119944. /**
  119945. * Gets the r component (input)
  119946. */
  119947. readonly r: NodeMaterialConnectionPoint;
  119948. /**
  119949. * Gets the g component (input)
  119950. */
  119951. readonly g: NodeMaterialConnectionPoint;
  119952. /**
  119953. * Gets the b component (input)
  119954. */
  119955. readonly b: NodeMaterialConnectionPoint;
  119956. /**
  119957. * Gets the a component (input)
  119958. */
  119959. readonly a: NodeMaterialConnectionPoint;
  119960. /**
  119961. * Gets the rgba component (output)
  119962. */
  119963. readonly rgba: NodeMaterialConnectionPoint;
  119964. /**
  119965. * Gets the rgb component (output)
  119966. */
  119967. readonly rgb: NodeMaterialConnectionPoint;
  119968. protected _buildBlock(state: NodeMaterialBuildState): this;
  119969. }
  119970. }
  119971. declare module BABYLON {
  119972. /**
  119973. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  119974. */
  119975. export class VectorMergerBlock extends NodeMaterialBlock {
  119976. /**
  119977. * Create a new VectorMergerBlock
  119978. * @param name defines the block name
  119979. */
  119980. constructor(name: string);
  119981. /**
  119982. * Gets the current class name
  119983. * @returns the class name
  119984. */
  119985. getClassName(): string;
  119986. /**
  119987. * Gets the x component (input)
  119988. */
  119989. readonly x: NodeMaterialConnectionPoint;
  119990. /**
  119991. * Gets the y component (input)
  119992. */
  119993. readonly y: NodeMaterialConnectionPoint;
  119994. /**
  119995. * Gets the z component (input)
  119996. */
  119997. readonly z: NodeMaterialConnectionPoint;
  119998. /**
  119999. * Gets the w component (input)
  120000. */
  120001. readonly w: NodeMaterialConnectionPoint;
  120002. /**
  120003. * Gets the xyzw component (output)
  120004. */
  120005. readonly xyzw: NodeMaterialConnectionPoint;
  120006. /**
  120007. * Gets the xyz component (output)
  120008. */
  120009. readonly xyz: NodeMaterialConnectionPoint;
  120010. /**
  120011. * Gets the xy component (output)
  120012. */
  120013. readonly xy: NodeMaterialConnectionPoint;
  120014. protected _buildBlock(state: NodeMaterialBuildState): this;
  120015. }
  120016. }
  120017. declare module BABYLON {
  120018. /**
  120019. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  120020. */
  120021. export class ColorSplitterBlock extends NodeMaterialBlock {
  120022. /**
  120023. * Create a new ColorSplitterBlock
  120024. * @param name defines the block name
  120025. */
  120026. constructor(name: string);
  120027. /**
  120028. * Gets the current class name
  120029. * @returns the class name
  120030. */
  120031. getClassName(): string;
  120032. /**
  120033. * Gets the rgba component (input)
  120034. */
  120035. readonly rgba: NodeMaterialConnectionPoint;
  120036. /**
  120037. * Gets the rgb component (input)
  120038. */
  120039. readonly rgbIn: NodeMaterialConnectionPoint;
  120040. /**
  120041. * Gets the rgb component (output)
  120042. */
  120043. readonly rgbOut: NodeMaterialConnectionPoint;
  120044. /**
  120045. * Gets the r component (output)
  120046. */
  120047. readonly r: NodeMaterialConnectionPoint;
  120048. /**
  120049. * Gets the g component (output)
  120050. */
  120051. readonly g: NodeMaterialConnectionPoint;
  120052. /**
  120053. * Gets the b component (output)
  120054. */
  120055. readonly b: NodeMaterialConnectionPoint;
  120056. /**
  120057. * Gets the a component (output)
  120058. */
  120059. readonly a: NodeMaterialConnectionPoint;
  120060. protected _inputRename(name: string): string;
  120061. protected _outputRename(name: string): string;
  120062. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120063. }
  120064. }
  120065. declare module BABYLON {
  120066. /**
  120067. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  120068. */
  120069. export class VectorSplitterBlock extends NodeMaterialBlock {
  120070. /**
  120071. * Create a new VectorSplitterBlock
  120072. * @param name defines the block name
  120073. */
  120074. constructor(name: string);
  120075. /**
  120076. * Gets the current class name
  120077. * @returns the class name
  120078. */
  120079. getClassName(): string;
  120080. /**
  120081. * Gets the xyzw component (input)
  120082. */
  120083. readonly xyzw: NodeMaterialConnectionPoint;
  120084. /**
  120085. * Gets the xyz component (input)
  120086. */
  120087. readonly xyzIn: NodeMaterialConnectionPoint;
  120088. /**
  120089. * Gets the xy component (input)
  120090. */
  120091. readonly xyIn: NodeMaterialConnectionPoint;
  120092. /**
  120093. * Gets the xyz component (output)
  120094. */
  120095. readonly xyzOut: NodeMaterialConnectionPoint;
  120096. /**
  120097. * Gets the xy component (output)
  120098. */
  120099. readonly xyOut: NodeMaterialConnectionPoint;
  120100. /**
  120101. * Gets the x component (output)
  120102. */
  120103. readonly x: NodeMaterialConnectionPoint;
  120104. /**
  120105. * Gets the y component (output)
  120106. */
  120107. readonly y: NodeMaterialConnectionPoint;
  120108. /**
  120109. * Gets the z component (output)
  120110. */
  120111. readonly z: NodeMaterialConnectionPoint;
  120112. /**
  120113. * Gets the w component (output)
  120114. */
  120115. readonly w: NodeMaterialConnectionPoint;
  120116. protected _inputRename(name: string): string;
  120117. protected _outputRename(name: string): string;
  120118. protected _buildBlock(state: NodeMaterialBuildState): this;
  120119. }
  120120. }
  120121. declare module BABYLON {
  120122. /**
  120123. * Block used to lerp 2 values
  120124. */
  120125. export class LerpBlock extends NodeMaterialBlock {
  120126. /**
  120127. * Creates a new LerpBlock
  120128. * @param name defines the block name
  120129. */
  120130. constructor(name: string);
  120131. /**
  120132. * Gets the current class name
  120133. * @returns the class name
  120134. */
  120135. getClassName(): string;
  120136. /**
  120137. * Gets the left operand input component
  120138. */
  120139. readonly left: NodeMaterialConnectionPoint;
  120140. /**
  120141. * Gets the right operand input component
  120142. */
  120143. readonly right: NodeMaterialConnectionPoint;
  120144. /**
  120145. * Gets the gradient operand input component
  120146. */
  120147. readonly gradient: NodeMaterialConnectionPoint;
  120148. /**
  120149. * Gets the output component
  120150. */
  120151. readonly output: NodeMaterialConnectionPoint;
  120152. protected _buildBlock(state: NodeMaterialBuildState): this;
  120153. }
  120154. }
  120155. declare module BABYLON {
  120156. /**
  120157. * Block used to divide 2 vectors
  120158. */
  120159. export class DivideBlock extends NodeMaterialBlock {
  120160. /**
  120161. * Creates a new DivideBlock
  120162. * @param name defines the block name
  120163. */
  120164. constructor(name: string);
  120165. /**
  120166. * Gets the current class name
  120167. * @returns the class name
  120168. */
  120169. getClassName(): string;
  120170. /**
  120171. * Gets the left operand input component
  120172. */
  120173. readonly left: NodeMaterialConnectionPoint;
  120174. /**
  120175. * Gets the right operand input component
  120176. */
  120177. readonly right: NodeMaterialConnectionPoint;
  120178. /**
  120179. * Gets the output component
  120180. */
  120181. readonly output: NodeMaterialConnectionPoint;
  120182. protected _buildBlock(state: NodeMaterialBuildState): this;
  120183. }
  120184. }
  120185. declare module BABYLON {
  120186. /**
  120187. * Block used to subtract 2 vectors
  120188. */
  120189. export class SubtractBlock extends NodeMaterialBlock {
  120190. /**
  120191. * Creates a new SubtractBlock
  120192. * @param name defines the block name
  120193. */
  120194. constructor(name: string);
  120195. /**
  120196. * Gets the current class name
  120197. * @returns the class name
  120198. */
  120199. getClassName(): string;
  120200. /**
  120201. * Gets the left operand input component
  120202. */
  120203. readonly left: NodeMaterialConnectionPoint;
  120204. /**
  120205. * Gets the right operand input component
  120206. */
  120207. readonly right: NodeMaterialConnectionPoint;
  120208. /**
  120209. * Gets the output component
  120210. */
  120211. readonly output: NodeMaterialConnectionPoint;
  120212. protected _buildBlock(state: NodeMaterialBuildState): this;
  120213. }
  120214. }
  120215. declare module BABYLON {
  120216. /**
  120217. * Block used to step a value
  120218. */
  120219. export class StepBlock extends NodeMaterialBlock {
  120220. /**
  120221. * Creates a new AddBlock
  120222. * @param name defines the block name
  120223. */
  120224. constructor(name: string);
  120225. /**
  120226. * Gets the current class name
  120227. * @returns the class name
  120228. */
  120229. getClassName(): string;
  120230. /**
  120231. * Gets the value operand input component
  120232. */
  120233. readonly value: NodeMaterialConnectionPoint;
  120234. /**
  120235. * Gets the edge operand input component
  120236. */
  120237. readonly edge: NodeMaterialConnectionPoint;
  120238. /**
  120239. * Gets the output component
  120240. */
  120241. readonly output: NodeMaterialConnectionPoint;
  120242. protected _buildBlock(state: NodeMaterialBuildState): this;
  120243. }
  120244. }
  120245. declare module BABYLON {
  120246. /**
  120247. * Block used to get the opposite (1 - x) of a value
  120248. */
  120249. export class OneMinusBlock extends NodeMaterialBlock {
  120250. /**
  120251. * Creates a new OneMinusBlock
  120252. * @param name defines the block name
  120253. */
  120254. constructor(name: string);
  120255. /**
  120256. * Gets the current class name
  120257. * @returns the class name
  120258. */
  120259. getClassName(): string;
  120260. /**
  120261. * Gets the input component
  120262. */
  120263. readonly input: NodeMaterialConnectionPoint;
  120264. /**
  120265. * Gets the output component
  120266. */
  120267. readonly output: NodeMaterialConnectionPoint;
  120268. protected _buildBlock(state: NodeMaterialBuildState): this;
  120269. }
  120270. }
  120271. declare module BABYLON {
  120272. /**
  120273. * Block used to get the view direction
  120274. */
  120275. export class ViewDirectionBlock extends NodeMaterialBlock {
  120276. /**
  120277. * Creates a new ViewDirectionBlock
  120278. * @param name defines the block name
  120279. */
  120280. constructor(name: string);
  120281. /**
  120282. * Gets the current class name
  120283. * @returns the class name
  120284. */
  120285. getClassName(): string;
  120286. /**
  120287. * Gets the world position component
  120288. */
  120289. readonly worldPosition: NodeMaterialConnectionPoint;
  120290. /**
  120291. * Gets the camera position component
  120292. */
  120293. readonly cameraPosition: NodeMaterialConnectionPoint;
  120294. /**
  120295. * Gets the output component
  120296. */
  120297. readonly output: NodeMaterialConnectionPoint;
  120298. autoConfigure(material: NodeMaterial): void;
  120299. protected _buildBlock(state: NodeMaterialBuildState): this;
  120300. }
  120301. }
  120302. declare module BABYLON {
  120303. /**
  120304. * Block used to compute fresnel value
  120305. */
  120306. export class FresnelBlock extends NodeMaterialBlock {
  120307. /**
  120308. * Create a new FresnelBlock
  120309. * @param name defines the block name
  120310. */
  120311. constructor(name: string);
  120312. /**
  120313. * Gets the current class name
  120314. * @returns the class name
  120315. */
  120316. getClassName(): string;
  120317. /**
  120318. * Gets the world normal input component
  120319. */
  120320. readonly worldNormal: NodeMaterialConnectionPoint;
  120321. /**
  120322. * Gets the view direction input component
  120323. */
  120324. readonly viewDirection: NodeMaterialConnectionPoint;
  120325. /**
  120326. * Gets the bias input component
  120327. */
  120328. readonly bias: NodeMaterialConnectionPoint;
  120329. /**
  120330. * Gets the camera (or eye) position component
  120331. */
  120332. readonly power: NodeMaterialConnectionPoint;
  120333. /**
  120334. * Gets the fresnel output component
  120335. */
  120336. readonly fresnel: NodeMaterialConnectionPoint;
  120337. autoConfigure(material: NodeMaterial): void;
  120338. protected _buildBlock(state: NodeMaterialBuildState): this;
  120339. }
  120340. }
  120341. declare module BABYLON {
  120342. /**
  120343. * Block used to get the max of 2 values
  120344. */
  120345. export class MaxBlock extends NodeMaterialBlock {
  120346. /**
  120347. * Creates a new MaxBlock
  120348. * @param name defines the block name
  120349. */
  120350. constructor(name: string);
  120351. /**
  120352. * Gets the current class name
  120353. * @returns the class name
  120354. */
  120355. getClassName(): string;
  120356. /**
  120357. * Gets the left operand input component
  120358. */
  120359. readonly left: NodeMaterialConnectionPoint;
  120360. /**
  120361. * Gets the right operand input component
  120362. */
  120363. readonly right: NodeMaterialConnectionPoint;
  120364. /**
  120365. * Gets the output component
  120366. */
  120367. readonly output: NodeMaterialConnectionPoint;
  120368. protected _buildBlock(state: NodeMaterialBuildState): this;
  120369. }
  120370. }
  120371. declare module BABYLON {
  120372. /**
  120373. * Block used to get the min of 2 values
  120374. */
  120375. export class MinBlock extends NodeMaterialBlock {
  120376. /**
  120377. * Creates a new MinBlock
  120378. * @param name defines the block name
  120379. */
  120380. constructor(name: string);
  120381. /**
  120382. * Gets the current class name
  120383. * @returns the class name
  120384. */
  120385. getClassName(): string;
  120386. /**
  120387. * Gets the left operand input component
  120388. */
  120389. readonly left: NodeMaterialConnectionPoint;
  120390. /**
  120391. * Gets the right operand input component
  120392. */
  120393. readonly right: NodeMaterialConnectionPoint;
  120394. /**
  120395. * Gets the output component
  120396. */
  120397. readonly output: NodeMaterialConnectionPoint;
  120398. protected _buildBlock(state: NodeMaterialBuildState): this;
  120399. }
  120400. }
  120401. declare module BABYLON {
  120402. /**
  120403. * Block used to get the distance between 2 values
  120404. */
  120405. export class DistanceBlock extends NodeMaterialBlock {
  120406. /**
  120407. * Creates a new DistanceBlock
  120408. * @param name defines the block name
  120409. */
  120410. constructor(name: string);
  120411. /**
  120412. * Gets the current class name
  120413. * @returns the class name
  120414. */
  120415. getClassName(): string;
  120416. /**
  120417. * Gets the left operand input component
  120418. */
  120419. readonly left: NodeMaterialConnectionPoint;
  120420. /**
  120421. * Gets the right operand input component
  120422. */
  120423. readonly right: NodeMaterialConnectionPoint;
  120424. /**
  120425. * Gets the output component
  120426. */
  120427. readonly output: NodeMaterialConnectionPoint;
  120428. protected _buildBlock(state: NodeMaterialBuildState): this;
  120429. }
  120430. }
  120431. declare module BABYLON {
  120432. /**
  120433. * Block used to get the length of a vector
  120434. */
  120435. export class LengthBlock extends NodeMaterialBlock {
  120436. /**
  120437. * Creates a new LengthBlock
  120438. * @param name defines the block name
  120439. */
  120440. constructor(name: string);
  120441. /**
  120442. * Gets the current class name
  120443. * @returns the class name
  120444. */
  120445. getClassName(): string;
  120446. /**
  120447. * Gets the value input component
  120448. */
  120449. readonly value: NodeMaterialConnectionPoint;
  120450. /**
  120451. * Gets the output component
  120452. */
  120453. readonly output: NodeMaterialConnectionPoint;
  120454. protected _buildBlock(state: NodeMaterialBuildState): this;
  120455. }
  120456. }
  120457. declare module BABYLON {
  120458. /**
  120459. * Block used to get negative version of a value (i.e. x * -1)
  120460. */
  120461. export class NegateBlock extends NodeMaterialBlock {
  120462. /**
  120463. * Creates a new NegateBlock
  120464. * @param name defines the block name
  120465. */
  120466. constructor(name: string);
  120467. /**
  120468. * Gets the current class name
  120469. * @returns the class name
  120470. */
  120471. getClassName(): string;
  120472. /**
  120473. * Gets the value input component
  120474. */
  120475. readonly value: NodeMaterialConnectionPoint;
  120476. /**
  120477. * Gets the output component
  120478. */
  120479. readonly output: NodeMaterialConnectionPoint;
  120480. protected _buildBlock(state: NodeMaterialBuildState): this;
  120481. }
  120482. }
  120483. declare module BABYLON {
  120484. /**
  120485. * Block used to get the value of the first parameter raised to the power of the second
  120486. */
  120487. export class PowBlock extends NodeMaterialBlock {
  120488. /**
  120489. * Creates a new PowBlock
  120490. * @param name defines the block name
  120491. */
  120492. constructor(name: string);
  120493. /**
  120494. * Gets the current class name
  120495. * @returns the class name
  120496. */
  120497. getClassName(): string;
  120498. /**
  120499. * Gets the value operand input component
  120500. */
  120501. readonly value: NodeMaterialConnectionPoint;
  120502. /**
  120503. * Gets the power operand input component
  120504. */
  120505. readonly power: NodeMaterialConnectionPoint;
  120506. /**
  120507. * Gets the output component
  120508. */
  120509. readonly output: NodeMaterialConnectionPoint;
  120510. protected _buildBlock(state: NodeMaterialBuildState): this;
  120511. }
  120512. }
  120513. declare module BABYLON {
  120514. /**
  120515. * Block used to get a random number
  120516. */
  120517. export class RandomNumberBlock extends NodeMaterialBlock {
  120518. /**
  120519. * Creates a new RandomNumberBlock
  120520. * @param name defines the block name
  120521. */
  120522. constructor(name: string);
  120523. /**
  120524. * Gets the current class name
  120525. * @returns the class name
  120526. */
  120527. getClassName(): string;
  120528. /**
  120529. * Gets the seed input component
  120530. */
  120531. readonly seed: NodeMaterialConnectionPoint;
  120532. /**
  120533. * Gets the output component
  120534. */
  120535. readonly output: NodeMaterialConnectionPoint;
  120536. protected _buildBlock(state: NodeMaterialBuildState): this;
  120537. }
  120538. }
  120539. declare module BABYLON {
  120540. /**
  120541. * Effect Render Options
  120542. */
  120543. export interface IEffectRendererOptions {
  120544. /**
  120545. * Defines the vertices positions.
  120546. */
  120547. positions?: number[];
  120548. /**
  120549. * Defines the indices.
  120550. */
  120551. indices?: number[];
  120552. }
  120553. /**
  120554. * Helper class to render one or more effects
  120555. */
  120556. export class EffectRenderer {
  120557. private engine;
  120558. private static _DefaultOptions;
  120559. private _vertexBuffers;
  120560. private _indexBuffer;
  120561. private _ringBufferIndex;
  120562. private _ringScreenBuffer;
  120563. private _fullscreenViewport;
  120564. private _getNextFrameBuffer;
  120565. /**
  120566. * Creates an effect renderer
  120567. * @param engine the engine to use for rendering
  120568. * @param options defines the options of the effect renderer
  120569. */
  120570. constructor(engine: Engine, options?: IEffectRendererOptions);
  120571. /**
  120572. * Sets the current viewport in normalized coordinates 0-1
  120573. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  120574. */
  120575. setViewport(viewport?: Viewport): void;
  120576. /**
  120577. * Binds the embedded attributes buffer to the effect.
  120578. * @param effect Defines the effect to bind the attributes for
  120579. */
  120580. bindBuffers(effect: Effect): void;
  120581. /**
  120582. * Sets the current effect wrapper to use during draw.
  120583. * The effect needs to be ready before calling this api.
  120584. * This also sets the default full screen position attribute.
  120585. * @param effectWrapper Defines the effect to draw with
  120586. */
  120587. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  120588. /**
  120589. * Draws a full screen quad.
  120590. */
  120591. draw(): void;
  120592. /**
  120593. * renders one or more effects to a specified texture
  120594. * @param effectWrappers list of effects to renderer
  120595. * @param outputTexture texture to draw to, if null it will render to the screen
  120596. */
  120597. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  120598. /**
  120599. * Disposes of the effect renderer
  120600. */
  120601. dispose(): void;
  120602. }
  120603. /**
  120604. * Options to create an EffectWrapper
  120605. */
  120606. interface EffectWrapperCreationOptions {
  120607. /**
  120608. * Engine to use to create the effect
  120609. */
  120610. engine: Engine;
  120611. /**
  120612. * Fragment shader for the effect
  120613. */
  120614. fragmentShader: string;
  120615. /**
  120616. * Vertex shader for the effect
  120617. */
  120618. vertexShader?: string;
  120619. /**
  120620. * Attributes to use in the shader
  120621. */
  120622. attributeNames?: Array<string>;
  120623. /**
  120624. * Uniforms to use in the shader
  120625. */
  120626. uniformNames?: Array<string>;
  120627. /**
  120628. * Texture sampler names to use in the shader
  120629. */
  120630. samplerNames?: Array<string>;
  120631. /**
  120632. * The friendly name of the effect displayed in Spector.
  120633. */
  120634. name?: string;
  120635. }
  120636. /**
  120637. * Wraps an effect to be used for rendering
  120638. */
  120639. export class EffectWrapper {
  120640. /**
  120641. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  120642. */
  120643. onApplyObservable: Observable<{}>;
  120644. /**
  120645. * The underlying effect
  120646. */
  120647. effect: Effect;
  120648. /**
  120649. * Creates an effect to be renderer
  120650. * @param creationOptions options to create the effect
  120651. */
  120652. constructor(creationOptions: EffectWrapperCreationOptions);
  120653. /**
  120654. * Disposes of the effect wrapper
  120655. */
  120656. dispose(): void;
  120657. }
  120658. }
  120659. declare module BABYLON {
  120660. /**
  120661. * Helper class to push actions to a pool of workers.
  120662. */
  120663. export class WorkerPool implements IDisposable {
  120664. private _workerInfos;
  120665. private _pendingActions;
  120666. /**
  120667. * Constructor
  120668. * @param workers Array of workers to use for actions
  120669. */
  120670. constructor(workers: Array<Worker>);
  120671. /**
  120672. * Terminates all workers and clears any pending actions.
  120673. */
  120674. dispose(): void;
  120675. /**
  120676. * Pushes an action to the worker pool. If all the workers are active, the action will be
  120677. * pended until a worker has completed its action.
  120678. * @param action The action to perform. Call onComplete when the action is complete.
  120679. */
  120680. push(action: (worker: Worker, onComplete: () => void) => void): void;
  120681. private _execute;
  120682. }
  120683. }
  120684. declare module BABYLON {
  120685. /**
  120686. * Configuration for Draco compression
  120687. */
  120688. export interface IDracoCompressionConfiguration {
  120689. /**
  120690. * Configuration for the decoder.
  120691. */
  120692. decoder: {
  120693. /**
  120694. * The url to the WebAssembly module.
  120695. */
  120696. wasmUrl?: string;
  120697. /**
  120698. * The url to the WebAssembly binary.
  120699. */
  120700. wasmBinaryUrl?: string;
  120701. /**
  120702. * The url to the fallback JavaScript module.
  120703. */
  120704. fallbackUrl?: string;
  120705. };
  120706. }
  120707. /**
  120708. * Draco compression (https://google.github.io/draco/)
  120709. *
  120710. * This class wraps the Draco module.
  120711. *
  120712. * **Encoder**
  120713. *
  120714. * The encoder is not currently implemented.
  120715. *
  120716. * **Decoder**
  120717. *
  120718. * 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.
  120719. *
  120720. * To update the configuration, use the following code:
  120721. * ```javascript
  120722. * DracoCompression.Configuration = {
  120723. * decoder: {
  120724. * wasmUrl: "<url to the WebAssembly library>",
  120725. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  120726. * fallbackUrl: "<url to the fallback JavaScript library>",
  120727. * }
  120728. * };
  120729. * ```
  120730. *
  120731. * 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.
  120732. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  120733. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  120734. *
  120735. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  120736. * ```javascript
  120737. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  120738. * ```
  120739. *
  120740. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  120741. */
  120742. export class DracoCompression implements IDisposable {
  120743. private _workerPoolPromise?;
  120744. private _decoderModulePromise?;
  120745. /**
  120746. * The configuration. Defaults to the following urls:
  120747. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  120748. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  120749. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  120750. */
  120751. static Configuration: IDracoCompressionConfiguration;
  120752. /**
  120753. * Returns true if the decoder configuration is available.
  120754. */
  120755. static readonly DecoderAvailable: boolean;
  120756. /**
  120757. * Default number of workers to create when creating the draco compression object.
  120758. */
  120759. static DefaultNumWorkers: number;
  120760. private static GetDefaultNumWorkers;
  120761. private static _Default;
  120762. /**
  120763. * Default instance for the draco compression object.
  120764. */
  120765. static readonly Default: DracoCompression;
  120766. /**
  120767. * Constructor
  120768. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  120769. */
  120770. constructor(numWorkers?: number);
  120771. /**
  120772. * Stop all async operations and release resources.
  120773. */
  120774. dispose(): void;
  120775. /**
  120776. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  120777. * @returns a promise that resolves when ready
  120778. */
  120779. whenReadyAsync(): Promise<void>;
  120780. /**
  120781. * Decode Draco compressed mesh data to vertex data.
  120782. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  120783. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  120784. * @returns A promise that resolves with the decoded vertex data
  120785. */
  120786. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  120787. [kind: string]: number;
  120788. }): Promise<VertexData>;
  120789. }
  120790. }
  120791. declare module BABYLON {
  120792. /**
  120793. * Class for building Constructive Solid Geometry
  120794. */
  120795. export class CSG {
  120796. private polygons;
  120797. /**
  120798. * The world matrix
  120799. */
  120800. matrix: Matrix;
  120801. /**
  120802. * Stores the position
  120803. */
  120804. position: Vector3;
  120805. /**
  120806. * Stores the rotation
  120807. */
  120808. rotation: Vector3;
  120809. /**
  120810. * Stores the rotation quaternion
  120811. */
  120812. rotationQuaternion: Nullable<Quaternion>;
  120813. /**
  120814. * Stores the scaling vector
  120815. */
  120816. scaling: Vector3;
  120817. /**
  120818. * Convert the Mesh to CSG
  120819. * @param mesh The Mesh to convert to CSG
  120820. * @returns A new CSG from the Mesh
  120821. */
  120822. static FromMesh(mesh: Mesh): CSG;
  120823. /**
  120824. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  120825. * @param polygons Polygons used to construct a CSG solid
  120826. */
  120827. private static FromPolygons;
  120828. /**
  120829. * Clones, or makes a deep copy, of the CSG
  120830. * @returns A new CSG
  120831. */
  120832. clone(): CSG;
  120833. /**
  120834. * Unions this CSG with another CSG
  120835. * @param csg The CSG to union against this CSG
  120836. * @returns The unioned CSG
  120837. */
  120838. union(csg: CSG): CSG;
  120839. /**
  120840. * Unions this CSG with another CSG in place
  120841. * @param csg The CSG to union against this CSG
  120842. */
  120843. unionInPlace(csg: CSG): void;
  120844. /**
  120845. * Subtracts this CSG with another CSG
  120846. * @param csg The CSG to subtract against this CSG
  120847. * @returns A new CSG
  120848. */
  120849. subtract(csg: CSG): CSG;
  120850. /**
  120851. * Subtracts this CSG with another CSG in place
  120852. * @param csg The CSG to subtact against this CSG
  120853. */
  120854. subtractInPlace(csg: CSG): void;
  120855. /**
  120856. * Intersect this CSG with another CSG
  120857. * @param csg The CSG to intersect against this CSG
  120858. * @returns A new CSG
  120859. */
  120860. intersect(csg: CSG): CSG;
  120861. /**
  120862. * Intersects this CSG with another CSG in place
  120863. * @param csg The CSG to intersect against this CSG
  120864. */
  120865. intersectInPlace(csg: CSG): void;
  120866. /**
  120867. * Return a new CSG solid with solid and empty space switched. This solid is
  120868. * not modified.
  120869. * @returns A new CSG solid with solid and empty space switched
  120870. */
  120871. inverse(): CSG;
  120872. /**
  120873. * Inverses the CSG in place
  120874. */
  120875. inverseInPlace(): void;
  120876. /**
  120877. * This is used to keep meshes transformations so they can be restored
  120878. * when we build back a Babylon Mesh
  120879. * NB : All CSG operations are performed in world coordinates
  120880. * @param csg The CSG to copy the transform attributes from
  120881. * @returns This CSG
  120882. */
  120883. copyTransformAttributes(csg: CSG): CSG;
  120884. /**
  120885. * Build Raw mesh from CSG
  120886. * Coordinates here are in world space
  120887. * @param name The name of the mesh geometry
  120888. * @param scene The Scene
  120889. * @param keepSubMeshes Specifies if the submeshes should be kept
  120890. * @returns A new Mesh
  120891. */
  120892. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120893. /**
  120894. * Build Mesh from CSG taking material and transforms into account
  120895. * @param name The name of the Mesh
  120896. * @param material The material of the Mesh
  120897. * @param scene The Scene
  120898. * @param keepSubMeshes Specifies if submeshes should be kept
  120899. * @returns The new Mesh
  120900. */
  120901. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120902. }
  120903. }
  120904. declare module BABYLON {
  120905. /**
  120906. * Class used to create a trail following a mesh
  120907. */
  120908. export class TrailMesh extends Mesh {
  120909. private _generator;
  120910. private _autoStart;
  120911. private _running;
  120912. private _diameter;
  120913. private _length;
  120914. private _sectionPolygonPointsCount;
  120915. private _sectionVectors;
  120916. private _sectionNormalVectors;
  120917. private _beforeRenderObserver;
  120918. /**
  120919. * @constructor
  120920. * @param name The value used by scene.getMeshByName() to do a lookup.
  120921. * @param generator The mesh to generate a trail.
  120922. * @param scene The scene to add this mesh to.
  120923. * @param diameter Diameter of trailing mesh. Default is 1.
  120924. * @param length Length of trailing mesh. Default is 60.
  120925. * @param autoStart Automatically start trailing mesh. Default true.
  120926. */
  120927. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  120928. /**
  120929. * "TrailMesh"
  120930. * @returns "TrailMesh"
  120931. */
  120932. getClassName(): string;
  120933. private _createMesh;
  120934. /**
  120935. * Start trailing mesh.
  120936. */
  120937. start(): void;
  120938. /**
  120939. * Stop trailing mesh.
  120940. */
  120941. stop(): void;
  120942. /**
  120943. * Update trailing mesh geometry.
  120944. */
  120945. update(): void;
  120946. /**
  120947. * Returns a new TrailMesh object.
  120948. * @param name is a string, the name given to the new mesh
  120949. * @param newGenerator use new generator object for cloned trail mesh
  120950. * @returns a new mesh
  120951. */
  120952. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  120953. /**
  120954. * Serializes this trail mesh
  120955. * @param serializationObject object to write serialization to
  120956. */
  120957. serialize(serializationObject: any): void;
  120958. /**
  120959. * Parses a serialized trail mesh
  120960. * @param parsedMesh the serialized mesh
  120961. * @param scene the scene to create the trail mesh in
  120962. * @returns the created trail mesh
  120963. */
  120964. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  120965. }
  120966. }
  120967. declare module BABYLON {
  120968. /**
  120969. * Class containing static functions to help procedurally build meshes
  120970. */
  120971. export class TiledBoxBuilder {
  120972. /**
  120973. * Creates a box mesh
  120974. * 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)
  120975. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120977. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120979. * @param name defines the name of the mesh
  120980. * @param options defines the options used to create the mesh
  120981. * @param scene defines the hosting scene
  120982. * @returns the box mesh
  120983. */
  120984. static CreateTiledBox(name: string, options: {
  120985. pattern?: number;
  120986. width?: number;
  120987. height?: number;
  120988. depth?: number;
  120989. tileSize?: number;
  120990. tileWidth?: number;
  120991. tileHeight?: number;
  120992. alignHorizontal?: number;
  120993. alignVertical?: number;
  120994. faceUV?: Vector4[];
  120995. faceColors?: Color4[];
  120996. sideOrientation?: number;
  120997. updatable?: boolean;
  120998. }, scene?: Nullable<Scene>): Mesh;
  120999. }
  121000. }
  121001. declare module BABYLON {
  121002. /**
  121003. * Class containing static functions to help procedurally build meshes
  121004. */
  121005. export class TorusKnotBuilder {
  121006. /**
  121007. * Creates a torus knot mesh
  121008. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  121009. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  121010. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  121011. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  121012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121013. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121015. * @param name defines the name of the mesh
  121016. * @param options defines the options used to create the mesh
  121017. * @param scene defines the hosting scene
  121018. * @returns the torus knot mesh
  121019. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  121020. */
  121021. static CreateTorusKnot(name: string, options: {
  121022. radius?: number;
  121023. tube?: number;
  121024. radialSegments?: number;
  121025. tubularSegments?: number;
  121026. p?: number;
  121027. q?: number;
  121028. updatable?: boolean;
  121029. sideOrientation?: number;
  121030. frontUVs?: Vector4;
  121031. backUVs?: Vector4;
  121032. }, scene: any): Mesh;
  121033. }
  121034. }
  121035. declare module BABYLON {
  121036. /**
  121037. * Polygon
  121038. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  121039. */
  121040. export class Polygon {
  121041. /**
  121042. * Creates a rectangle
  121043. * @param xmin bottom X coord
  121044. * @param ymin bottom Y coord
  121045. * @param xmax top X coord
  121046. * @param ymax top Y coord
  121047. * @returns points that make the resulting rectation
  121048. */
  121049. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  121050. /**
  121051. * Creates a circle
  121052. * @param radius radius of circle
  121053. * @param cx scale in x
  121054. * @param cy scale in y
  121055. * @param numberOfSides number of sides that make up the circle
  121056. * @returns points that make the resulting circle
  121057. */
  121058. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  121059. /**
  121060. * Creates a polygon from input string
  121061. * @param input Input polygon data
  121062. * @returns the parsed points
  121063. */
  121064. static Parse(input: string): Vector2[];
  121065. /**
  121066. * Starts building a polygon from x and y coordinates
  121067. * @param x x coordinate
  121068. * @param y y coordinate
  121069. * @returns the started path2
  121070. */
  121071. static StartingAt(x: number, y: number): Path2;
  121072. }
  121073. /**
  121074. * Builds a polygon
  121075. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  121076. */
  121077. export class PolygonMeshBuilder {
  121078. private _points;
  121079. private _outlinepoints;
  121080. private _holes;
  121081. private _name;
  121082. private _scene;
  121083. private _epoints;
  121084. private _eholes;
  121085. private _addToepoint;
  121086. /**
  121087. * Babylon reference to the earcut plugin.
  121088. */
  121089. bjsEarcut: any;
  121090. /**
  121091. * Creates a PolygonMeshBuilder
  121092. * @param name name of the builder
  121093. * @param contours Path of the polygon
  121094. * @param scene scene to add to when creating the mesh
  121095. * @param earcutInjection can be used to inject your own earcut reference
  121096. */
  121097. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  121098. /**
  121099. * Adds a whole within the polygon
  121100. * @param hole Array of points defining the hole
  121101. * @returns this
  121102. */
  121103. addHole(hole: Vector2[]): PolygonMeshBuilder;
  121104. /**
  121105. * Creates the polygon
  121106. * @param updatable If the mesh should be updatable
  121107. * @param depth The depth of the mesh created
  121108. * @returns the created mesh
  121109. */
  121110. build(updatable?: boolean, depth?: number): Mesh;
  121111. /**
  121112. * Creates the polygon
  121113. * @param depth The depth of the mesh created
  121114. * @returns the created VertexData
  121115. */
  121116. buildVertexData(depth?: number): VertexData;
  121117. /**
  121118. * Adds a side to the polygon
  121119. * @param positions points that make the polygon
  121120. * @param normals normals of the polygon
  121121. * @param uvs uvs of the polygon
  121122. * @param indices indices of the polygon
  121123. * @param bounds bounds of the polygon
  121124. * @param points points of the polygon
  121125. * @param depth depth of the polygon
  121126. * @param flip flip of the polygon
  121127. */
  121128. private addSide;
  121129. }
  121130. }
  121131. declare module BABYLON {
  121132. /**
  121133. * Class containing static functions to help procedurally build meshes
  121134. */
  121135. export class PolygonBuilder {
  121136. /**
  121137. * Creates a polygon mesh
  121138. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  121139. * * 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
  121140. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121142. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  121143. * * Remember you can only change the shape positions, not their number when updating a polygon
  121144. * @param name defines the name of the mesh
  121145. * @param options defines the options used to create the mesh
  121146. * @param scene defines the hosting scene
  121147. * @param earcutInjection can be used to inject your own earcut reference
  121148. * @returns the polygon mesh
  121149. */
  121150. static CreatePolygon(name: string, options: {
  121151. shape: Vector3[];
  121152. holes?: Vector3[][];
  121153. depth?: number;
  121154. faceUV?: Vector4[];
  121155. faceColors?: Color4[];
  121156. updatable?: boolean;
  121157. sideOrientation?: number;
  121158. frontUVs?: Vector4;
  121159. backUVs?: Vector4;
  121160. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121161. /**
  121162. * Creates an extruded polygon mesh, with depth in the Y direction.
  121163. * * 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)
  121164. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121165. * @param name defines the name of the mesh
  121166. * @param options defines the options used to create the mesh
  121167. * @param scene defines the hosting scene
  121168. * @param earcutInjection can be used to inject your own earcut reference
  121169. * @returns the polygon mesh
  121170. */
  121171. static ExtrudePolygon(name: string, options: {
  121172. shape: Vector3[];
  121173. holes?: Vector3[][];
  121174. depth?: number;
  121175. faceUV?: Vector4[];
  121176. faceColors?: Color4[];
  121177. updatable?: boolean;
  121178. sideOrientation?: number;
  121179. frontUVs?: Vector4;
  121180. backUVs?: Vector4;
  121181. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121182. }
  121183. }
  121184. declare module BABYLON {
  121185. /**
  121186. * Class containing static functions to help procedurally build meshes
  121187. */
  121188. export class LatheBuilder {
  121189. /**
  121190. * Creates lathe mesh.
  121191. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121192. * * 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
  121193. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121194. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121195. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121196. * * 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
  121197. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121198. * * 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
  121199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121200. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121201. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121203. * @param name defines the name of the mesh
  121204. * @param options defines the options used to create the mesh
  121205. * @param scene defines the hosting scene
  121206. * @returns the lathe mesh
  121207. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121208. */
  121209. static CreateLathe(name: string, options: {
  121210. shape: Vector3[];
  121211. radius?: number;
  121212. tessellation?: number;
  121213. clip?: number;
  121214. arc?: number;
  121215. closed?: boolean;
  121216. updatable?: boolean;
  121217. sideOrientation?: number;
  121218. frontUVs?: Vector4;
  121219. backUVs?: Vector4;
  121220. cap?: number;
  121221. invertUV?: boolean;
  121222. }, scene?: Nullable<Scene>): Mesh;
  121223. }
  121224. }
  121225. declare module BABYLON {
  121226. /**
  121227. * Class containing static functions to help procedurally build meshes
  121228. */
  121229. export class TiledPlaneBuilder {
  121230. /**
  121231. * Creates a tiled plane mesh
  121232. * * The parameter `pattern` will, depending on value, do nothing or
  121233. * * * flip (reflect about central vertical) alternate tiles across and up
  121234. * * * flip every tile on alternate rows
  121235. * * * rotate (180 degs) alternate tiles across and up
  121236. * * * rotate every tile on alternate rows
  121237. * * * flip and rotate alternate tiles across and up
  121238. * * * flip and rotate every tile on alternate rows
  121239. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  121240. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  121241. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121242. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121243. * * 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)
  121244. * * 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)
  121245. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  121246. * @param name defines the name of the mesh
  121247. * @param options defines the options used to create the mesh
  121248. * @param scene defines the hosting scene
  121249. * @returns the box mesh
  121250. */
  121251. static CreateTiledPlane(name: string, options: {
  121252. pattern?: number;
  121253. tileSize?: number;
  121254. tileWidth?: number;
  121255. tileHeight?: number;
  121256. size?: number;
  121257. width?: number;
  121258. height?: number;
  121259. alignHorizontal?: number;
  121260. alignVertical?: number;
  121261. sideOrientation?: number;
  121262. frontUVs?: Vector4;
  121263. backUVs?: Vector4;
  121264. updatable?: boolean;
  121265. }, scene?: Nullable<Scene>): Mesh;
  121266. }
  121267. }
  121268. declare module BABYLON {
  121269. /**
  121270. * Class containing static functions to help procedurally build meshes
  121271. */
  121272. export class TubeBuilder {
  121273. /**
  121274. * Creates a tube mesh.
  121275. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121276. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  121277. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  121278. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  121279. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  121280. * * 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)
  121281. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  121282. * * 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
  121283. * * 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
  121284. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121285. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121286. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121288. * @param name defines the name of the mesh
  121289. * @param options defines the options used to create the mesh
  121290. * @param scene defines the hosting scene
  121291. * @returns the tube mesh
  121292. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121293. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  121294. */
  121295. static CreateTube(name: string, options: {
  121296. path: Vector3[];
  121297. radius?: number;
  121298. tessellation?: number;
  121299. radiusFunction?: {
  121300. (i: number, distance: number): number;
  121301. };
  121302. cap?: number;
  121303. arc?: number;
  121304. updatable?: boolean;
  121305. sideOrientation?: number;
  121306. frontUVs?: Vector4;
  121307. backUVs?: Vector4;
  121308. instance?: Mesh;
  121309. invertUV?: boolean;
  121310. }, scene?: Nullable<Scene>): Mesh;
  121311. }
  121312. }
  121313. declare module BABYLON {
  121314. /**
  121315. * Class containing static functions to help procedurally build meshes
  121316. */
  121317. export class IcoSphereBuilder {
  121318. /**
  121319. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121320. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121321. * * 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`)
  121322. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121323. * * 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
  121324. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121325. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121327. * @param name defines the name of the mesh
  121328. * @param options defines the options used to create the mesh
  121329. * @param scene defines the hosting scene
  121330. * @returns the icosahedron mesh
  121331. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121332. */
  121333. static CreateIcoSphere(name: string, options: {
  121334. radius?: number;
  121335. radiusX?: number;
  121336. radiusY?: number;
  121337. radiusZ?: number;
  121338. flat?: boolean;
  121339. subdivisions?: number;
  121340. sideOrientation?: number;
  121341. frontUVs?: Vector4;
  121342. backUVs?: Vector4;
  121343. updatable?: boolean;
  121344. }, scene?: Nullable<Scene>): Mesh;
  121345. }
  121346. }
  121347. declare module BABYLON {
  121348. /**
  121349. * Class containing static functions to help procedurally build meshes
  121350. */
  121351. export class DecalBuilder {
  121352. /**
  121353. * Creates a decal mesh.
  121354. * 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
  121355. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  121356. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  121357. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  121358. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  121359. * @param name defines the name of the mesh
  121360. * @param sourceMesh defines the mesh where the decal must be applied
  121361. * @param options defines the options used to create the mesh
  121362. * @param scene defines the hosting scene
  121363. * @returns the decal mesh
  121364. * @see https://doc.babylonjs.com/how_to/decals
  121365. */
  121366. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  121367. position?: Vector3;
  121368. normal?: Vector3;
  121369. size?: Vector3;
  121370. angle?: number;
  121371. }): Mesh;
  121372. }
  121373. }
  121374. declare module BABYLON {
  121375. /**
  121376. * Class containing static functions to help procedurally build meshes
  121377. */
  121378. export class MeshBuilder {
  121379. /**
  121380. * Creates a box mesh
  121381. * * The parameter `size` sets the size (float) of each box side (default 1)
  121382. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  121383. * * 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)
  121384. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121385. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121386. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121388. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  121389. * @param name defines the name of the mesh
  121390. * @param options defines the options used to create the mesh
  121391. * @param scene defines the hosting scene
  121392. * @returns the box mesh
  121393. */
  121394. static CreateBox(name: string, options: {
  121395. size?: number;
  121396. width?: number;
  121397. height?: number;
  121398. depth?: number;
  121399. faceUV?: Vector4[];
  121400. faceColors?: Color4[];
  121401. sideOrientation?: number;
  121402. frontUVs?: Vector4;
  121403. backUVs?: Vector4;
  121404. updatable?: boolean;
  121405. }, scene?: Nullable<Scene>): Mesh;
  121406. /**
  121407. * Creates a tiled box mesh
  121408. * * faceTiles sets the pattern, tile size and number of tiles for a face
  121409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121410. * @param name defines the name of the mesh
  121411. * @param options defines the options used to create the mesh
  121412. * @param scene defines the hosting scene
  121413. * @returns the tiled box mesh
  121414. */
  121415. static CreateTiledBox(name: string, options: {
  121416. pattern?: number;
  121417. size?: number;
  121418. width?: number;
  121419. height?: number;
  121420. depth: number;
  121421. tileSize?: number;
  121422. tileWidth?: number;
  121423. tileHeight?: number;
  121424. faceUV?: Vector4[];
  121425. faceColors?: Color4[];
  121426. alignHorizontal?: number;
  121427. alignVertical?: number;
  121428. sideOrientation?: number;
  121429. updatable?: boolean;
  121430. }, scene?: Nullable<Scene>): Mesh;
  121431. /**
  121432. * Creates a sphere mesh
  121433. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  121434. * * 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`)
  121435. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  121436. * * 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
  121437. * * 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)
  121438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121439. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121441. * @param name defines the name of the mesh
  121442. * @param options defines the options used to create the mesh
  121443. * @param scene defines the hosting scene
  121444. * @returns the sphere mesh
  121445. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  121446. */
  121447. static CreateSphere(name: string, options: {
  121448. segments?: number;
  121449. diameter?: number;
  121450. diameterX?: number;
  121451. diameterY?: number;
  121452. diameterZ?: number;
  121453. arc?: number;
  121454. slice?: number;
  121455. sideOrientation?: number;
  121456. frontUVs?: Vector4;
  121457. backUVs?: Vector4;
  121458. updatable?: boolean;
  121459. }, scene?: Nullable<Scene>): Mesh;
  121460. /**
  121461. * Creates a plane polygonal mesh. By default, this is a disc
  121462. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  121463. * * 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
  121464. * * 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
  121465. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121466. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121468. * @param name defines the name of the mesh
  121469. * @param options defines the options used to create the mesh
  121470. * @param scene defines the hosting scene
  121471. * @returns the plane polygonal mesh
  121472. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  121473. */
  121474. static CreateDisc(name: string, options: {
  121475. radius?: number;
  121476. tessellation?: number;
  121477. arc?: number;
  121478. updatable?: boolean;
  121479. sideOrientation?: number;
  121480. frontUVs?: Vector4;
  121481. backUVs?: Vector4;
  121482. }, scene?: Nullable<Scene>): Mesh;
  121483. /**
  121484. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121485. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121486. * * 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`)
  121487. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121488. * * 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
  121489. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121490. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121492. * @param name defines the name of the mesh
  121493. * @param options defines the options used to create the mesh
  121494. * @param scene defines the hosting scene
  121495. * @returns the icosahedron mesh
  121496. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121497. */
  121498. static CreateIcoSphere(name: string, options: {
  121499. radius?: number;
  121500. radiusX?: number;
  121501. radiusY?: number;
  121502. radiusZ?: number;
  121503. flat?: boolean;
  121504. subdivisions?: number;
  121505. sideOrientation?: number;
  121506. frontUVs?: Vector4;
  121507. backUVs?: Vector4;
  121508. updatable?: boolean;
  121509. }, scene?: Nullable<Scene>): Mesh;
  121510. /**
  121511. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121512. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  121513. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  121514. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  121515. * * 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
  121516. * * 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
  121517. * * 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
  121518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121519. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121520. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121521. * * 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
  121522. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  121523. * * 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
  121524. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  121525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121526. * @param name defines the name of the mesh
  121527. * @param options defines the options used to create the mesh
  121528. * @param scene defines the hosting scene
  121529. * @returns the ribbon mesh
  121530. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  121531. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121532. */
  121533. static CreateRibbon(name: string, options: {
  121534. pathArray: Vector3[][];
  121535. closeArray?: boolean;
  121536. closePath?: boolean;
  121537. offset?: number;
  121538. updatable?: boolean;
  121539. sideOrientation?: number;
  121540. frontUVs?: Vector4;
  121541. backUVs?: Vector4;
  121542. instance?: Mesh;
  121543. invertUV?: boolean;
  121544. uvs?: Vector2[];
  121545. colors?: Color4[];
  121546. }, scene?: Nullable<Scene>): Mesh;
  121547. /**
  121548. * Creates a cylinder or a cone mesh
  121549. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  121550. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  121551. * * 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.
  121552. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  121553. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  121554. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  121555. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  121556. * * 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).
  121557. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  121558. * * 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).
  121559. * * 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
  121560. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  121561. * * 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
  121562. * * 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.
  121563. * * If `enclose` is false, a ring surface is one element.
  121564. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  121565. * * 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
  121566. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121567. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121569. * @param name defines the name of the mesh
  121570. * @param options defines the options used to create the mesh
  121571. * @param scene defines the hosting scene
  121572. * @returns the cylinder mesh
  121573. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  121574. */
  121575. static CreateCylinder(name: string, options: {
  121576. height?: number;
  121577. diameterTop?: number;
  121578. diameterBottom?: number;
  121579. diameter?: number;
  121580. tessellation?: number;
  121581. subdivisions?: number;
  121582. arc?: number;
  121583. faceColors?: Color4[];
  121584. faceUV?: Vector4[];
  121585. updatable?: boolean;
  121586. hasRings?: boolean;
  121587. enclose?: boolean;
  121588. cap?: number;
  121589. sideOrientation?: number;
  121590. frontUVs?: Vector4;
  121591. backUVs?: Vector4;
  121592. }, scene?: Nullable<Scene>): Mesh;
  121593. /**
  121594. * Creates a torus mesh
  121595. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  121596. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  121597. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  121598. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121599. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121601. * @param name defines the name of the mesh
  121602. * @param options defines the options used to create the mesh
  121603. * @param scene defines the hosting scene
  121604. * @returns the torus mesh
  121605. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  121606. */
  121607. static CreateTorus(name: string, options: {
  121608. diameter?: number;
  121609. thickness?: number;
  121610. tessellation?: number;
  121611. updatable?: boolean;
  121612. sideOrientation?: number;
  121613. frontUVs?: Vector4;
  121614. backUVs?: Vector4;
  121615. }, scene?: Nullable<Scene>): Mesh;
  121616. /**
  121617. * Creates a torus knot mesh
  121618. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  121619. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  121620. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  121621. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  121622. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121623. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121625. * @param name defines the name of the mesh
  121626. * @param options defines the options used to create the mesh
  121627. * @param scene defines the hosting scene
  121628. * @returns the torus knot mesh
  121629. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  121630. */
  121631. static CreateTorusKnot(name: string, options: {
  121632. radius?: number;
  121633. tube?: number;
  121634. radialSegments?: number;
  121635. tubularSegments?: number;
  121636. p?: number;
  121637. q?: number;
  121638. updatable?: boolean;
  121639. sideOrientation?: number;
  121640. frontUVs?: Vector4;
  121641. backUVs?: Vector4;
  121642. }, scene?: Nullable<Scene>): Mesh;
  121643. /**
  121644. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  121645. * * 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
  121646. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  121647. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  121648. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  121649. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  121650. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121651. * * 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
  121652. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  121653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121654. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  121655. * @param name defines the name of the new line system
  121656. * @param options defines the options used to create the line system
  121657. * @param scene defines the hosting scene
  121658. * @returns a new line system mesh
  121659. */
  121660. static CreateLineSystem(name: string, options: {
  121661. lines: Vector3[][];
  121662. updatable?: boolean;
  121663. instance?: Nullable<LinesMesh>;
  121664. colors?: Nullable<Color4[][]>;
  121665. useVertexAlpha?: boolean;
  121666. }, scene: Nullable<Scene>): LinesMesh;
  121667. /**
  121668. * Creates a line mesh
  121669. * 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
  121670. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121671. * * The parameter `points` is an array successive Vector3
  121672. * * 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
  121673. * * The optional parameter `colors` is an array of successive Color4, one per line point
  121674. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  121675. * * When updating an instance, remember that only point positions can change, not the number of points
  121676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121677. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  121678. * @param name defines the name of the new line system
  121679. * @param options defines the options used to create the line system
  121680. * @param scene defines the hosting scene
  121681. * @returns a new line mesh
  121682. */
  121683. static CreateLines(name: string, options: {
  121684. points: Vector3[];
  121685. updatable?: boolean;
  121686. instance?: Nullable<LinesMesh>;
  121687. colors?: Color4[];
  121688. useVertexAlpha?: boolean;
  121689. }, scene?: Nullable<Scene>): LinesMesh;
  121690. /**
  121691. * Creates a dashed line mesh
  121692. * * 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
  121693. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121694. * * The parameter `points` is an array successive Vector3
  121695. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  121696. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  121697. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  121698. * * 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
  121699. * * When updating an instance, remember that only point positions can change, not the number of points
  121700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121701. * @param name defines the name of the mesh
  121702. * @param options defines the options used to create the mesh
  121703. * @param scene defines the hosting scene
  121704. * @returns the dashed line mesh
  121705. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  121706. */
  121707. static CreateDashedLines(name: string, options: {
  121708. points: Vector3[];
  121709. dashSize?: number;
  121710. gapSize?: number;
  121711. dashNb?: number;
  121712. updatable?: boolean;
  121713. instance?: LinesMesh;
  121714. }, scene?: Nullable<Scene>): LinesMesh;
  121715. /**
  121716. * 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.
  121717. * * 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.
  121718. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121719. * * 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.
  121720. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  121721. * * 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
  121722. * * 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
  121723. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  121724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121725. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121726. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  121727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121728. * @param name defines the name of the mesh
  121729. * @param options defines the options used to create the mesh
  121730. * @param scene defines the hosting scene
  121731. * @returns the extruded shape mesh
  121732. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121733. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121734. */
  121735. static ExtrudeShape(name: string, options: {
  121736. shape: Vector3[];
  121737. path: Vector3[];
  121738. scale?: number;
  121739. rotation?: number;
  121740. cap?: number;
  121741. updatable?: boolean;
  121742. sideOrientation?: number;
  121743. frontUVs?: Vector4;
  121744. backUVs?: Vector4;
  121745. instance?: Mesh;
  121746. invertUV?: boolean;
  121747. }, scene?: Nullable<Scene>): Mesh;
  121748. /**
  121749. * Creates an custom extruded shape mesh.
  121750. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  121751. * * 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.
  121752. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121753. * * 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
  121754. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  121755. * * 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
  121756. * * It must returns a float value that will be the scale value applied to the shape on each path point
  121757. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  121758. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  121759. * * 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
  121760. * * 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
  121761. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  121762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121763. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121764. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121766. * @param name defines the name of the mesh
  121767. * @param options defines the options used to create the mesh
  121768. * @param scene defines the hosting scene
  121769. * @returns the custom extruded shape mesh
  121770. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  121771. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121772. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121773. */
  121774. static ExtrudeShapeCustom(name: string, options: {
  121775. shape: Vector3[];
  121776. path: Vector3[];
  121777. scaleFunction?: any;
  121778. rotationFunction?: any;
  121779. ribbonCloseArray?: boolean;
  121780. ribbonClosePath?: boolean;
  121781. cap?: number;
  121782. updatable?: boolean;
  121783. sideOrientation?: number;
  121784. frontUVs?: Vector4;
  121785. backUVs?: Vector4;
  121786. instance?: Mesh;
  121787. invertUV?: boolean;
  121788. }, scene?: Nullable<Scene>): Mesh;
  121789. /**
  121790. * Creates lathe mesh.
  121791. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121792. * * 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
  121793. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121794. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121795. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121796. * * 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
  121797. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121798. * * 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
  121799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121800. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121801. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121802. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121803. * @param name defines the name of the mesh
  121804. * @param options defines the options used to create the mesh
  121805. * @param scene defines the hosting scene
  121806. * @returns the lathe mesh
  121807. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121808. */
  121809. static CreateLathe(name: string, options: {
  121810. shape: Vector3[];
  121811. radius?: number;
  121812. tessellation?: number;
  121813. clip?: number;
  121814. arc?: number;
  121815. closed?: boolean;
  121816. updatable?: boolean;
  121817. sideOrientation?: number;
  121818. frontUVs?: Vector4;
  121819. backUVs?: Vector4;
  121820. cap?: number;
  121821. invertUV?: boolean;
  121822. }, scene?: Nullable<Scene>): Mesh;
  121823. /**
  121824. * Creates a tiled plane mesh
  121825. * * You can set a limited pattern arrangement with the tiles
  121826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121827. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121829. * @param name defines the name of the mesh
  121830. * @param options defines the options used to create the mesh
  121831. * @param scene defines the hosting scene
  121832. * @returns the plane mesh
  121833. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121834. */
  121835. static CreateTiledPlane(name: string, options: {
  121836. pattern?: number;
  121837. tileSize?: number;
  121838. tileWidth?: number;
  121839. tileHeight?: number;
  121840. size?: number;
  121841. width?: number;
  121842. height?: number;
  121843. alignHorizontal?: number;
  121844. alignVertical?: number;
  121845. sideOrientation?: number;
  121846. frontUVs?: Vector4;
  121847. backUVs?: Vector4;
  121848. updatable?: boolean;
  121849. }, scene?: Nullable<Scene>): Mesh;
  121850. /**
  121851. * Creates a plane mesh
  121852. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  121853. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  121854. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  121855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121856. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121858. * @param name defines the name of the mesh
  121859. * @param options defines the options used to create the mesh
  121860. * @param scene defines the hosting scene
  121861. * @returns the plane mesh
  121862. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121863. */
  121864. static CreatePlane(name: string, options: {
  121865. size?: number;
  121866. width?: number;
  121867. height?: number;
  121868. sideOrientation?: number;
  121869. frontUVs?: Vector4;
  121870. backUVs?: Vector4;
  121871. updatable?: boolean;
  121872. sourcePlane?: Plane;
  121873. }, scene?: Nullable<Scene>): Mesh;
  121874. /**
  121875. * Creates a ground mesh
  121876. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  121877. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  121878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121879. * @param name defines the name of the mesh
  121880. * @param options defines the options used to create the mesh
  121881. * @param scene defines the hosting scene
  121882. * @returns the ground mesh
  121883. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  121884. */
  121885. static CreateGround(name: string, options: {
  121886. width?: number;
  121887. height?: number;
  121888. subdivisions?: number;
  121889. subdivisionsX?: number;
  121890. subdivisionsY?: number;
  121891. updatable?: boolean;
  121892. }, scene?: Nullable<Scene>): Mesh;
  121893. /**
  121894. * Creates a tiled ground mesh
  121895. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  121896. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  121897. * * 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
  121898. * * 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
  121899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121900. * @param name defines the name of the mesh
  121901. * @param options defines the options used to create the mesh
  121902. * @param scene defines the hosting scene
  121903. * @returns the tiled ground mesh
  121904. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  121905. */
  121906. static CreateTiledGround(name: string, options: {
  121907. xmin: number;
  121908. zmin: number;
  121909. xmax: number;
  121910. zmax: number;
  121911. subdivisions?: {
  121912. w: number;
  121913. h: number;
  121914. };
  121915. precision?: {
  121916. w: number;
  121917. h: number;
  121918. };
  121919. updatable?: boolean;
  121920. }, scene?: Nullable<Scene>): Mesh;
  121921. /**
  121922. * Creates a ground mesh from a height map
  121923. * * The parameter `url` sets the URL of the height map image resource.
  121924. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  121925. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  121926. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  121927. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  121928. * * 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.
  121929. * * 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).
  121930. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  121931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121932. * @param name defines the name of the mesh
  121933. * @param url defines the url to the height map
  121934. * @param options defines the options used to create the mesh
  121935. * @param scene defines the hosting scene
  121936. * @returns the ground mesh
  121937. * @see https://doc.babylonjs.com/babylon101/height_map
  121938. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  121939. */
  121940. static CreateGroundFromHeightMap(name: string, url: string, options: {
  121941. width?: number;
  121942. height?: number;
  121943. subdivisions?: number;
  121944. minHeight?: number;
  121945. maxHeight?: number;
  121946. colorFilter?: Color3;
  121947. alphaFilter?: number;
  121948. updatable?: boolean;
  121949. onReady?: (mesh: GroundMesh) => void;
  121950. }, scene?: Nullable<Scene>): GroundMesh;
  121951. /**
  121952. * Creates a polygon mesh
  121953. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  121954. * * 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
  121955. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121957. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  121958. * * Remember you can only change the shape positions, not their number when updating a polygon
  121959. * @param name defines the name of the mesh
  121960. * @param options defines the options used to create the mesh
  121961. * @param scene defines the hosting scene
  121962. * @param earcutInjection can be used to inject your own earcut reference
  121963. * @returns the polygon mesh
  121964. */
  121965. static CreatePolygon(name: string, options: {
  121966. shape: Vector3[];
  121967. holes?: Vector3[][];
  121968. depth?: number;
  121969. faceUV?: Vector4[];
  121970. faceColors?: Color4[];
  121971. updatable?: boolean;
  121972. sideOrientation?: number;
  121973. frontUVs?: Vector4;
  121974. backUVs?: Vector4;
  121975. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121976. /**
  121977. * Creates an extruded polygon mesh, with depth in the Y direction.
  121978. * * 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)
  121979. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121980. * @param name defines the name of the mesh
  121981. * @param options defines the options used to create the mesh
  121982. * @param scene defines the hosting scene
  121983. * @param earcutInjection can be used to inject your own earcut reference
  121984. * @returns the polygon mesh
  121985. */
  121986. static ExtrudePolygon(name: string, options: {
  121987. shape: Vector3[];
  121988. holes?: Vector3[][];
  121989. depth?: number;
  121990. faceUV?: Vector4[];
  121991. faceColors?: Color4[];
  121992. updatable?: boolean;
  121993. sideOrientation?: number;
  121994. frontUVs?: Vector4;
  121995. backUVs?: Vector4;
  121996. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121997. /**
  121998. * Creates a tube mesh.
  121999. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  122000. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  122001. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  122002. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  122003. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  122004. * * 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)
  122005. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  122006. * * 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
  122007. * * 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
  122008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122009. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122010. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122012. * @param name defines the name of the mesh
  122013. * @param options defines the options used to create the mesh
  122014. * @param scene defines the hosting scene
  122015. * @returns the tube mesh
  122016. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122017. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  122018. */
  122019. static CreateTube(name: string, options: {
  122020. path: Vector3[];
  122021. radius?: number;
  122022. tessellation?: number;
  122023. radiusFunction?: {
  122024. (i: number, distance: number): number;
  122025. };
  122026. cap?: number;
  122027. arc?: number;
  122028. updatable?: boolean;
  122029. sideOrientation?: number;
  122030. frontUVs?: Vector4;
  122031. backUVs?: Vector4;
  122032. instance?: Mesh;
  122033. invertUV?: boolean;
  122034. }, scene?: Nullable<Scene>): Mesh;
  122035. /**
  122036. * Creates a polyhedron mesh
  122037. * * 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
  122038. * * The parameter `size` (positive float, default 1) sets the polygon size
  122039. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  122040. * * 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`
  122041. * * 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
  122042. * * 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)`)
  122043. * * 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
  122044. * * 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
  122045. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122046. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122048. * @param name defines the name of the mesh
  122049. * @param options defines the options used to create the mesh
  122050. * @param scene defines the hosting scene
  122051. * @returns the polyhedron mesh
  122052. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  122053. */
  122054. static CreatePolyhedron(name: string, options: {
  122055. type?: number;
  122056. size?: number;
  122057. sizeX?: number;
  122058. sizeY?: number;
  122059. sizeZ?: number;
  122060. custom?: any;
  122061. faceUV?: Vector4[];
  122062. faceColors?: Color4[];
  122063. flat?: boolean;
  122064. updatable?: boolean;
  122065. sideOrientation?: number;
  122066. frontUVs?: Vector4;
  122067. backUVs?: Vector4;
  122068. }, scene?: Nullable<Scene>): Mesh;
  122069. /**
  122070. * Creates a decal mesh.
  122071. * 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
  122072. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  122073. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  122074. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  122075. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  122076. * @param name defines the name of the mesh
  122077. * @param sourceMesh defines the mesh where the decal must be applied
  122078. * @param options defines the options used to create the mesh
  122079. * @param scene defines the hosting scene
  122080. * @returns the decal mesh
  122081. * @see https://doc.babylonjs.com/how_to/decals
  122082. */
  122083. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  122084. position?: Vector3;
  122085. normal?: Vector3;
  122086. size?: Vector3;
  122087. angle?: number;
  122088. }): Mesh;
  122089. }
  122090. }
  122091. declare module BABYLON {
  122092. /**
  122093. * A simplifier interface for future simplification implementations
  122094. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122095. */
  122096. export interface ISimplifier {
  122097. /**
  122098. * Simplification of a given mesh according to the given settings.
  122099. * Since this requires computation, it is assumed that the function runs async.
  122100. * @param settings The settings of the simplification, including quality and distance
  122101. * @param successCallback A callback that will be called after the mesh was simplified.
  122102. * @param errorCallback in case of an error, this callback will be called. optional.
  122103. */
  122104. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  122105. }
  122106. /**
  122107. * Expected simplification settings.
  122108. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  122109. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122110. */
  122111. export interface ISimplificationSettings {
  122112. /**
  122113. * Gets or sets the expected quality
  122114. */
  122115. quality: number;
  122116. /**
  122117. * Gets or sets the distance when this optimized version should be used
  122118. */
  122119. distance: number;
  122120. /**
  122121. * Gets an already optimized mesh
  122122. */
  122123. optimizeMesh?: boolean;
  122124. }
  122125. /**
  122126. * Class used to specify simplification options
  122127. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122128. */
  122129. export class SimplificationSettings implements ISimplificationSettings {
  122130. /** expected quality */
  122131. quality: number;
  122132. /** distance when this optimized version should be used */
  122133. distance: number;
  122134. /** already optimized mesh */
  122135. optimizeMesh?: boolean | undefined;
  122136. /**
  122137. * Creates a SimplificationSettings
  122138. * @param quality expected quality
  122139. * @param distance distance when this optimized version should be used
  122140. * @param optimizeMesh already optimized mesh
  122141. */
  122142. constructor(
  122143. /** expected quality */
  122144. quality: number,
  122145. /** distance when this optimized version should be used */
  122146. distance: number,
  122147. /** already optimized mesh */
  122148. optimizeMesh?: boolean | undefined);
  122149. }
  122150. /**
  122151. * Interface used to define a simplification task
  122152. */
  122153. export interface ISimplificationTask {
  122154. /**
  122155. * Array of settings
  122156. */
  122157. settings: Array<ISimplificationSettings>;
  122158. /**
  122159. * Simplification type
  122160. */
  122161. simplificationType: SimplificationType;
  122162. /**
  122163. * Mesh to simplify
  122164. */
  122165. mesh: Mesh;
  122166. /**
  122167. * Callback called on success
  122168. */
  122169. successCallback?: () => void;
  122170. /**
  122171. * Defines if parallel processing can be used
  122172. */
  122173. parallelProcessing: boolean;
  122174. }
  122175. /**
  122176. * Queue used to order the simplification tasks
  122177. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122178. */
  122179. export class SimplificationQueue {
  122180. private _simplificationArray;
  122181. /**
  122182. * Gets a boolean indicating that the process is still running
  122183. */
  122184. running: boolean;
  122185. /**
  122186. * Creates a new queue
  122187. */
  122188. constructor();
  122189. /**
  122190. * Adds a new simplification task
  122191. * @param task defines a task to add
  122192. */
  122193. addTask(task: ISimplificationTask): void;
  122194. /**
  122195. * Execute next task
  122196. */
  122197. executeNext(): void;
  122198. /**
  122199. * Execute a simplification task
  122200. * @param task defines the task to run
  122201. */
  122202. runSimplification(task: ISimplificationTask): void;
  122203. private getSimplifier;
  122204. }
  122205. /**
  122206. * The implemented types of simplification
  122207. * At the moment only Quadratic Error Decimation is implemented
  122208. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122209. */
  122210. export enum SimplificationType {
  122211. /** Quadratic error decimation */
  122212. QUADRATIC = 0
  122213. }
  122214. }
  122215. declare module BABYLON {
  122216. interface Scene {
  122217. /** @hidden (Backing field) */
  122218. _simplificationQueue: SimplificationQueue;
  122219. /**
  122220. * Gets or sets the simplification queue attached to the scene
  122221. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122222. */
  122223. simplificationQueue: SimplificationQueue;
  122224. }
  122225. interface Mesh {
  122226. /**
  122227. * Simplify the mesh according to the given array of settings.
  122228. * Function will return immediately and will simplify async
  122229. * @param settings a collection of simplification settings
  122230. * @param parallelProcessing should all levels calculate parallel or one after the other
  122231. * @param simplificationType the type of simplification to run
  122232. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  122233. * @returns the current mesh
  122234. */
  122235. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  122236. }
  122237. /**
  122238. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  122239. * created in a scene
  122240. */
  122241. export class SimplicationQueueSceneComponent implements ISceneComponent {
  122242. /**
  122243. * The component name helpfull to identify the component in the list of scene components.
  122244. */
  122245. readonly name: string;
  122246. /**
  122247. * The scene the component belongs to.
  122248. */
  122249. scene: Scene;
  122250. /**
  122251. * Creates a new instance of the component for the given scene
  122252. * @param scene Defines the scene to register the component in
  122253. */
  122254. constructor(scene: Scene);
  122255. /**
  122256. * Registers the component in a given scene
  122257. */
  122258. register(): void;
  122259. /**
  122260. * Rebuilds the elements related to this component in case of
  122261. * context lost for instance.
  122262. */
  122263. rebuild(): void;
  122264. /**
  122265. * Disposes the component and the associated ressources
  122266. */
  122267. dispose(): void;
  122268. private _beforeCameraUpdate;
  122269. }
  122270. }
  122271. declare module BABYLON {
  122272. /**
  122273. * Navigation plugin interface to add navigation constrained by a navigation mesh
  122274. */
  122275. export interface INavigationEnginePlugin {
  122276. /**
  122277. * plugin name
  122278. */
  122279. name: string;
  122280. /**
  122281. * Creates a navigation mesh
  122282. * @param meshes array of all the geometry used to compute the navigatio mesh
  122283. * @param parameters bunch of parameters used to filter geometry
  122284. */
  122285. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122286. /**
  122287. * Create a navigation mesh debug mesh
  122288. * @param scene is where the mesh will be added
  122289. * @returns debug display mesh
  122290. */
  122291. createDebugNavMesh(scene: Scene): Mesh;
  122292. /**
  122293. * Get a navigation mesh constrained position, closest to the parameter position
  122294. * @param position world position
  122295. * @returns the closest point to position constrained by the navigation mesh
  122296. */
  122297. getClosestPoint(position: Vector3): Vector3;
  122298. /**
  122299. * Get a navigation mesh constrained position, within a particular radius
  122300. * @param position world position
  122301. * @param maxRadius the maximum distance to the constrained world position
  122302. * @returns the closest point to position constrained by the navigation mesh
  122303. */
  122304. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122305. /**
  122306. * Compute the final position from a segment made of destination-position
  122307. * @param position world position
  122308. * @param destination world position
  122309. * @returns the resulting point along the navmesh
  122310. */
  122311. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122312. /**
  122313. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122314. * @param start world position
  122315. * @param end world position
  122316. * @returns array containing world position composing the path
  122317. */
  122318. computePath(start: Vector3, end: Vector3): Vector3[];
  122319. /**
  122320. * If this plugin is supported
  122321. * @returns true if plugin is supported
  122322. */
  122323. isSupported(): boolean;
  122324. /**
  122325. * Create a new Crowd so you can add agents
  122326. * @param maxAgents the maximum agent count in the crowd
  122327. * @param maxAgentRadius the maximum radius an agent can have
  122328. * @param scene to attach the crowd to
  122329. * @returns the crowd you can add agents to
  122330. */
  122331. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122332. /**
  122333. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122334. * The queries will try to find a solution within those bounds
  122335. * default is (1,1,1)
  122336. * @param extent x,y,z value that define the extent around the queries point of reference
  122337. */
  122338. setDefaultQueryExtent(extent: Vector3): void;
  122339. /**
  122340. * Get the Bounding box extent specified by setDefaultQueryExtent
  122341. * @returns the box extent values
  122342. */
  122343. getDefaultQueryExtent(): Vector3;
  122344. /**
  122345. * Release all resources
  122346. */
  122347. dispose(): void;
  122348. }
  122349. /**
  122350. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  122351. */
  122352. export interface ICrowd {
  122353. /**
  122354. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122355. * You can attach anything to that node. The node position is updated in the scene update tick.
  122356. * @param pos world position that will be constrained by the navigation mesh
  122357. * @param parameters agent parameters
  122358. * @param transform hooked to the agent that will be update by the scene
  122359. * @returns agent index
  122360. */
  122361. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122362. /**
  122363. * Returns the agent position in world space
  122364. * @param index agent index returned by addAgent
  122365. * @returns world space position
  122366. */
  122367. getAgentPosition(index: number): Vector3;
  122368. /**
  122369. * Gets the agent velocity in world space
  122370. * @param index agent index returned by addAgent
  122371. * @returns world space velocity
  122372. */
  122373. getAgentVelocity(index: number): Vector3;
  122374. /**
  122375. * remove a particular agent previously created
  122376. * @param index agent index returned by addAgent
  122377. */
  122378. removeAgent(index: number): void;
  122379. /**
  122380. * get the list of all agents attached to this crowd
  122381. * @returns list of agent indices
  122382. */
  122383. getAgents(): number[];
  122384. /**
  122385. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  122386. * @param deltaTime in seconds
  122387. */
  122388. update(deltaTime: number): void;
  122389. /**
  122390. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122391. * @param index agent index returned by addAgent
  122392. * @param destination targeted world position
  122393. */
  122394. agentGoto(index: number, destination: Vector3): void;
  122395. /**
  122396. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122397. * The queries will try to find a solution within those bounds
  122398. * default is (1,1,1)
  122399. * @param extent x,y,z value that define the extent around the queries point of reference
  122400. */
  122401. setDefaultQueryExtent(extent: Vector3): void;
  122402. /**
  122403. * Get the Bounding box extent specified by setDefaultQueryExtent
  122404. * @returns the box extent values
  122405. */
  122406. getDefaultQueryExtent(): Vector3;
  122407. /**
  122408. * Release all resources
  122409. */
  122410. dispose(): void;
  122411. }
  122412. /**
  122413. * Configures an agent
  122414. */
  122415. export interface IAgentParameters {
  122416. /**
  122417. * Agent radius. [Limit: >= 0]
  122418. */
  122419. radius: number;
  122420. /**
  122421. * Agent height. [Limit: > 0]
  122422. */
  122423. height: number;
  122424. /**
  122425. * Maximum allowed acceleration. [Limit: >= 0]
  122426. */
  122427. maxAcceleration: number;
  122428. /**
  122429. * Maximum allowed speed. [Limit: >= 0]
  122430. */
  122431. maxSpeed: number;
  122432. /**
  122433. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  122434. */
  122435. collisionQueryRange: number;
  122436. /**
  122437. * The path visibility optimization range. [Limit: > 0]
  122438. */
  122439. pathOptimizationRange: number;
  122440. /**
  122441. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  122442. */
  122443. separationWeight: number;
  122444. }
  122445. /**
  122446. * Configures the navigation mesh creation
  122447. */
  122448. export interface INavMeshParameters {
  122449. /**
  122450. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  122451. */
  122452. cs: number;
  122453. /**
  122454. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  122455. */
  122456. ch: number;
  122457. /**
  122458. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  122459. */
  122460. walkableSlopeAngle: number;
  122461. /**
  122462. * Minimum floor to 'ceiling' height that will still allow the floor area to
  122463. * be considered walkable. [Limit: >= 3] [Units: vx]
  122464. */
  122465. walkableHeight: number;
  122466. /**
  122467. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  122468. */
  122469. walkableClimb: number;
  122470. /**
  122471. * The distance to erode/shrink the walkable area of the heightfield away from
  122472. * obstructions. [Limit: >=0] [Units: vx]
  122473. */
  122474. walkableRadius: number;
  122475. /**
  122476. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  122477. */
  122478. maxEdgeLen: number;
  122479. /**
  122480. * The maximum distance a simplfied contour's border edges should deviate
  122481. * the original raw contour. [Limit: >=0] [Units: vx]
  122482. */
  122483. maxSimplificationError: number;
  122484. /**
  122485. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  122486. */
  122487. minRegionArea: number;
  122488. /**
  122489. * Any regions with a span count smaller than this value will, if possible,
  122490. * be merged with larger regions. [Limit: >=0] [Units: vx]
  122491. */
  122492. mergeRegionArea: number;
  122493. /**
  122494. * The maximum number of vertices allowed for polygons generated during the
  122495. * contour to polygon conversion process. [Limit: >= 3]
  122496. */
  122497. maxVertsPerPoly: number;
  122498. /**
  122499. * Sets the sampling distance to use when generating the detail mesh.
  122500. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  122501. */
  122502. detailSampleDist: number;
  122503. /**
  122504. * The maximum distance the detail mesh surface should deviate from heightfield
  122505. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  122506. */
  122507. detailSampleMaxError: number;
  122508. }
  122509. }
  122510. declare module BABYLON {
  122511. /**
  122512. * RecastJS navigation plugin
  122513. */
  122514. export class RecastJSPlugin implements INavigationEnginePlugin {
  122515. /**
  122516. * Reference to the Recast library
  122517. */
  122518. bjsRECAST: any;
  122519. /**
  122520. * plugin name
  122521. */
  122522. name: string;
  122523. /**
  122524. * the first navmesh created. We might extend this to support multiple navmeshes
  122525. */
  122526. navMesh: any;
  122527. /**
  122528. * Initializes the recastJS plugin
  122529. * @param recastInjection can be used to inject your own recast reference
  122530. */
  122531. constructor(recastInjection?: any);
  122532. /**
  122533. * Creates a navigation mesh
  122534. * @param meshes array of all the geometry used to compute the navigatio mesh
  122535. * @param parameters bunch of parameters used to filter geometry
  122536. */
  122537. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122538. /**
  122539. * Create a navigation mesh debug mesh
  122540. * @param scene is where the mesh will be added
  122541. * @returns debug display mesh
  122542. */
  122543. createDebugNavMesh(scene: Scene): Mesh;
  122544. /**
  122545. * Get a navigation mesh constrained position, closest to the parameter position
  122546. * @param position world position
  122547. * @returns the closest point to position constrained by the navigation mesh
  122548. */
  122549. getClosestPoint(position: Vector3): Vector3;
  122550. /**
  122551. * Get a navigation mesh constrained position, within a particular radius
  122552. * @param position world position
  122553. * @param maxRadius the maximum distance to the constrained world position
  122554. * @returns the closest point to position constrained by the navigation mesh
  122555. */
  122556. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122557. /**
  122558. * Compute the final position from a segment made of destination-position
  122559. * @param position world position
  122560. * @param destination world position
  122561. * @returns the resulting point along the navmesh
  122562. */
  122563. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122564. /**
  122565. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122566. * @param start world position
  122567. * @param end world position
  122568. * @returns array containing world position composing the path
  122569. */
  122570. computePath(start: Vector3, end: Vector3): Vector3[];
  122571. /**
  122572. * Create a new Crowd so you can add agents
  122573. * @param maxAgents the maximum agent count in the crowd
  122574. * @param maxAgentRadius the maximum radius an agent can have
  122575. * @param scene to attach the crowd to
  122576. * @returns the crowd you can add agents to
  122577. */
  122578. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122579. /**
  122580. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122581. * The queries will try to find a solution within those bounds
  122582. * default is (1,1,1)
  122583. * @param extent x,y,z value that define the extent around the queries point of reference
  122584. */
  122585. setDefaultQueryExtent(extent: Vector3): void;
  122586. /**
  122587. * Get the Bounding box extent specified by setDefaultQueryExtent
  122588. * @returns the box extent values
  122589. */
  122590. getDefaultQueryExtent(): Vector3;
  122591. /**
  122592. * Disposes
  122593. */
  122594. dispose(): void;
  122595. /**
  122596. * If this plugin is supported
  122597. * @returns true if plugin is supported
  122598. */
  122599. isSupported(): boolean;
  122600. }
  122601. /**
  122602. * Recast detour crowd implementation
  122603. */
  122604. export class RecastJSCrowd implements ICrowd {
  122605. /**
  122606. * Recast/detour plugin
  122607. */
  122608. bjsRECASTPlugin: RecastJSPlugin;
  122609. /**
  122610. * Link to the detour crowd
  122611. */
  122612. recastCrowd: any;
  122613. /**
  122614. * One transform per agent
  122615. */
  122616. transforms: TransformNode[];
  122617. /**
  122618. * All agents created
  122619. */
  122620. agents: number[];
  122621. /**
  122622. * Link to the scene is kept to unregister the crowd from the scene
  122623. */
  122624. private _scene;
  122625. /**
  122626. * Observer for crowd updates
  122627. */
  122628. private _onBeforeAnimationsObserver;
  122629. /**
  122630. * Constructor
  122631. * @param plugin recastJS plugin
  122632. * @param maxAgents the maximum agent count in the crowd
  122633. * @param maxAgentRadius the maximum radius an agent can have
  122634. * @param scene to attach the crowd to
  122635. * @returns the crowd you can add agents to
  122636. */
  122637. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  122638. /**
  122639. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122640. * You can attach anything to that node. The node position is updated in the scene update tick.
  122641. * @param pos world position that will be constrained by the navigation mesh
  122642. * @param parameters agent parameters
  122643. * @param transform hooked to the agent that will be update by the scene
  122644. * @returns agent index
  122645. */
  122646. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122647. /**
  122648. * Returns the agent position in world space
  122649. * @param index agent index returned by addAgent
  122650. * @returns world space position
  122651. */
  122652. getAgentPosition(index: number): Vector3;
  122653. /**
  122654. * Returns the agent velocity in world space
  122655. * @param index agent index returned by addAgent
  122656. * @returns world space velocity
  122657. */
  122658. getAgentVelocity(index: number): Vector3;
  122659. /**
  122660. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122661. * @param index agent index returned by addAgent
  122662. * @param destination targeted world position
  122663. */
  122664. agentGoto(index: number, destination: Vector3): void;
  122665. /**
  122666. * remove a particular agent previously created
  122667. * @param index agent index returned by addAgent
  122668. */
  122669. removeAgent(index: number): void;
  122670. /**
  122671. * get the list of all agents attached to this crowd
  122672. * @returns list of agent indices
  122673. */
  122674. getAgents(): number[];
  122675. /**
  122676. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  122677. * @param deltaTime in seconds
  122678. */
  122679. update(deltaTime: number): void;
  122680. /**
  122681. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122682. * The queries will try to find a solution within those bounds
  122683. * default is (1,1,1)
  122684. * @param extent x,y,z value that define the extent around the queries point of reference
  122685. */
  122686. setDefaultQueryExtent(extent: Vector3): void;
  122687. /**
  122688. * Get the Bounding box extent specified by setDefaultQueryExtent
  122689. * @returns the box extent values
  122690. */
  122691. getDefaultQueryExtent(): Vector3;
  122692. /**
  122693. * Release all resources
  122694. */
  122695. dispose(): void;
  122696. }
  122697. }
  122698. declare module BABYLON {
  122699. /**
  122700. * Class used to enable access to IndexedDB
  122701. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  122702. */
  122703. export class Database implements IOfflineProvider {
  122704. private _callbackManifestChecked;
  122705. private _currentSceneUrl;
  122706. private _db;
  122707. private _enableSceneOffline;
  122708. private _enableTexturesOffline;
  122709. private _manifestVersionFound;
  122710. private _mustUpdateRessources;
  122711. private _hasReachedQuota;
  122712. private _isSupported;
  122713. private _idbFactory;
  122714. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  122715. private static IsUASupportingBlobStorage;
  122716. /**
  122717. * Gets a boolean indicating if Database storate is enabled (off by default)
  122718. */
  122719. static IDBStorageEnabled: boolean;
  122720. /**
  122721. * Gets a boolean indicating if scene must be saved in the database
  122722. */
  122723. readonly enableSceneOffline: boolean;
  122724. /**
  122725. * Gets a boolean indicating if textures must be saved in the database
  122726. */
  122727. readonly enableTexturesOffline: boolean;
  122728. /**
  122729. * Creates a new Database
  122730. * @param urlToScene defines the url to load the scene
  122731. * @param callbackManifestChecked defines the callback to use when manifest is checked
  122732. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  122733. */
  122734. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  122735. private static _ParseURL;
  122736. private static _ReturnFullUrlLocation;
  122737. private _checkManifestFile;
  122738. /**
  122739. * Open the database and make it available
  122740. * @param successCallback defines the callback to call on success
  122741. * @param errorCallback defines the callback to call on error
  122742. */
  122743. open(successCallback: () => void, errorCallback: () => void): void;
  122744. /**
  122745. * Loads an image from the database
  122746. * @param url defines the url to load from
  122747. * @param image defines the target DOM image
  122748. */
  122749. loadImage(url: string, image: HTMLImageElement): void;
  122750. private _loadImageFromDBAsync;
  122751. private _saveImageIntoDBAsync;
  122752. private _checkVersionFromDB;
  122753. private _loadVersionFromDBAsync;
  122754. private _saveVersionIntoDBAsync;
  122755. /**
  122756. * Loads a file from database
  122757. * @param url defines the URL to load from
  122758. * @param sceneLoaded defines a callback to call on success
  122759. * @param progressCallBack defines a callback to call when progress changed
  122760. * @param errorCallback defines a callback to call on error
  122761. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  122762. */
  122763. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  122764. private _loadFileAsync;
  122765. private _saveFileAsync;
  122766. /**
  122767. * Validates if xhr data is correct
  122768. * @param xhr defines the request to validate
  122769. * @param dataType defines the expected data type
  122770. * @returns true if data is correct
  122771. */
  122772. private static _ValidateXHRData;
  122773. }
  122774. }
  122775. declare module BABYLON {
  122776. /** @hidden */
  122777. export var gpuUpdateParticlesPixelShader: {
  122778. name: string;
  122779. shader: string;
  122780. };
  122781. }
  122782. declare module BABYLON {
  122783. /** @hidden */
  122784. export var gpuUpdateParticlesVertexShader: {
  122785. name: string;
  122786. shader: string;
  122787. };
  122788. }
  122789. declare module BABYLON {
  122790. /** @hidden */
  122791. export var clipPlaneFragmentDeclaration2: {
  122792. name: string;
  122793. shader: string;
  122794. };
  122795. }
  122796. declare module BABYLON {
  122797. /** @hidden */
  122798. export var gpuRenderParticlesPixelShader: {
  122799. name: string;
  122800. shader: string;
  122801. };
  122802. }
  122803. declare module BABYLON {
  122804. /** @hidden */
  122805. export var clipPlaneVertexDeclaration2: {
  122806. name: string;
  122807. shader: string;
  122808. };
  122809. }
  122810. declare module BABYLON {
  122811. /** @hidden */
  122812. export var gpuRenderParticlesVertexShader: {
  122813. name: string;
  122814. shader: string;
  122815. };
  122816. }
  122817. declare module BABYLON {
  122818. /**
  122819. * This represents a GPU particle system in Babylon
  122820. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  122821. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  122822. */
  122823. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  122824. /**
  122825. * The layer mask we are rendering the particles through.
  122826. */
  122827. layerMask: number;
  122828. private _capacity;
  122829. private _activeCount;
  122830. private _currentActiveCount;
  122831. private _accumulatedCount;
  122832. private _renderEffect;
  122833. private _updateEffect;
  122834. private _buffer0;
  122835. private _buffer1;
  122836. private _spriteBuffer;
  122837. private _updateVAO;
  122838. private _renderVAO;
  122839. private _targetIndex;
  122840. private _sourceBuffer;
  122841. private _targetBuffer;
  122842. private _engine;
  122843. private _currentRenderId;
  122844. private _started;
  122845. private _stopped;
  122846. private _timeDelta;
  122847. private _randomTexture;
  122848. private _randomTexture2;
  122849. private _attributesStrideSize;
  122850. private _updateEffectOptions;
  122851. private _randomTextureSize;
  122852. private _actualFrame;
  122853. private readonly _rawTextureWidth;
  122854. /**
  122855. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  122856. */
  122857. static readonly IsSupported: boolean;
  122858. /**
  122859. * An event triggered when the system is disposed.
  122860. */
  122861. onDisposeObservable: Observable<GPUParticleSystem>;
  122862. /**
  122863. * Gets the maximum number of particles active at the same time.
  122864. * @returns The max number of active particles.
  122865. */
  122866. getCapacity(): number;
  122867. /**
  122868. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  122869. * to override the particles.
  122870. */
  122871. forceDepthWrite: boolean;
  122872. /**
  122873. * Gets or set the number of active particles
  122874. */
  122875. activeParticleCount: number;
  122876. private _preWarmDone;
  122877. /**
  122878. * Is this system ready to be used/rendered
  122879. * @return true if the system is ready
  122880. */
  122881. isReady(): boolean;
  122882. /**
  122883. * Gets if the system has been started. (Note: this will still be true after stop is called)
  122884. * @returns True if it has been started, otherwise false.
  122885. */
  122886. isStarted(): boolean;
  122887. /**
  122888. * Starts the particle system and begins to emit
  122889. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  122890. */
  122891. start(delay?: number): void;
  122892. /**
  122893. * Stops the particle system.
  122894. */
  122895. stop(): void;
  122896. /**
  122897. * Remove all active particles
  122898. */
  122899. reset(): void;
  122900. /**
  122901. * Returns the string "GPUParticleSystem"
  122902. * @returns a string containing the class name
  122903. */
  122904. getClassName(): string;
  122905. private _colorGradientsTexture;
  122906. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  122907. /**
  122908. * Adds a new color gradient
  122909. * @param gradient defines the gradient to use (between 0 and 1)
  122910. * @param color1 defines the color to affect to the specified gradient
  122911. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  122912. * @returns the current particle system
  122913. */
  122914. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  122915. /**
  122916. * Remove a specific color gradient
  122917. * @param gradient defines the gradient to remove
  122918. * @returns the current particle system
  122919. */
  122920. removeColorGradient(gradient: number): GPUParticleSystem;
  122921. private _angularSpeedGradientsTexture;
  122922. private _sizeGradientsTexture;
  122923. private _velocityGradientsTexture;
  122924. private _limitVelocityGradientsTexture;
  122925. private _dragGradientsTexture;
  122926. private _addFactorGradient;
  122927. /**
  122928. * Adds a new size gradient
  122929. * @param gradient defines the gradient to use (between 0 and 1)
  122930. * @param factor defines the size factor to affect to the specified gradient
  122931. * @returns the current particle system
  122932. */
  122933. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  122934. /**
  122935. * Remove a specific size gradient
  122936. * @param gradient defines the gradient to remove
  122937. * @returns the current particle system
  122938. */
  122939. removeSizeGradient(gradient: number): GPUParticleSystem;
  122940. /**
  122941. * Adds a new angular speed gradient
  122942. * @param gradient defines the gradient to use (between 0 and 1)
  122943. * @param factor defines the angular speed to affect to the specified gradient
  122944. * @returns the current particle system
  122945. */
  122946. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  122947. /**
  122948. * Remove a specific angular speed gradient
  122949. * @param gradient defines the gradient to remove
  122950. * @returns the current particle system
  122951. */
  122952. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  122953. /**
  122954. * Adds a new velocity gradient
  122955. * @param gradient defines the gradient to use (between 0 and 1)
  122956. * @param factor defines the velocity to affect to the specified gradient
  122957. * @returns the current particle system
  122958. */
  122959. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  122960. /**
  122961. * Remove a specific velocity gradient
  122962. * @param gradient defines the gradient to remove
  122963. * @returns the current particle system
  122964. */
  122965. removeVelocityGradient(gradient: number): GPUParticleSystem;
  122966. /**
  122967. * Adds a new limit velocity gradient
  122968. * @param gradient defines the gradient to use (between 0 and 1)
  122969. * @param factor defines the limit velocity value to affect to the specified gradient
  122970. * @returns the current particle system
  122971. */
  122972. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  122973. /**
  122974. * Remove a specific limit velocity gradient
  122975. * @param gradient defines the gradient to remove
  122976. * @returns the current particle system
  122977. */
  122978. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  122979. /**
  122980. * Adds a new drag gradient
  122981. * @param gradient defines the gradient to use (between 0 and 1)
  122982. * @param factor defines the drag value to affect to the specified gradient
  122983. * @returns the current particle system
  122984. */
  122985. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  122986. /**
  122987. * Remove a specific drag gradient
  122988. * @param gradient defines the gradient to remove
  122989. * @returns the current particle system
  122990. */
  122991. removeDragGradient(gradient: number): GPUParticleSystem;
  122992. /**
  122993. * Not supported by GPUParticleSystem
  122994. * @param gradient defines the gradient to use (between 0 and 1)
  122995. * @param factor defines the emit rate value to affect to the specified gradient
  122996. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122997. * @returns the current particle system
  122998. */
  122999. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  123000. /**
  123001. * Not supported by GPUParticleSystem
  123002. * @param gradient defines the gradient to remove
  123003. * @returns the current particle system
  123004. */
  123005. removeEmitRateGradient(gradient: number): IParticleSystem;
  123006. /**
  123007. * Not supported by GPUParticleSystem
  123008. * @param gradient defines the gradient to use (between 0 and 1)
  123009. * @param factor defines the start size value to affect to the specified gradient
  123010. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  123011. * @returns the current particle system
  123012. */
  123013. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  123014. /**
  123015. * Not supported by GPUParticleSystem
  123016. * @param gradient defines the gradient to remove
  123017. * @returns the current particle system
  123018. */
  123019. removeStartSizeGradient(gradient: number): IParticleSystem;
  123020. /**
  123021. * Not supported by GPUParticleSystem
  123022. * @param gradient defines the gradient to use (between 0 and 1)
  123023. * @param min defines the color remap minimal range
  123024. * @param max defines the color remap maximal range
  123025. * @returns the current particle system
  123026. */
  123027. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  123028. /**
  123029. * Not supported by GPUParticleSystem
  123030. * @param gradient defines the gradient to remove
  123031. * @returns the current particle system
  123032. */
  123033. removeColorRemapGradient(): IParticleSystem;
  123034. /**
  123035. * Not supported by GPUParticleSystem
  123036. * @param gradient defines the gradient to use (between 0 and 1)
  123037. * @param min defines the alpha remap minimal range
  123038. * @param max defines the alpha remap maximal range
  123039. * @returns the current particle system
  123040. */
  123041. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  123042. /**
  123043. * Not supported by GPUParticleSystem
  123044. * @param gradient defines the gradient to remove
  123045. * @returns the current particle system
  123046. */
  123047. removeAlphaRemapGradient(): IParticleSystem;
  123048. /**
  123049. * Not supported by GPUParticleSystem
  123050. * @param gradient defines the gradient to use (between 0 and 1)
  123051. * @param color defines the color to affect to the specified gradient
  123052. * @returns the current particle system
  123053. */
  123054. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  123055. /**
  123056. * Not supported by GPUParticleSystem
  123057. * @param gradient defines the gradient to remove
  123058. * @returns the current particle system
  123059. */
  123060. removeRampGradient(): IParticleSystem;
  123061. /**
  123062. * Not supported by GPUParticleSystem
  123063. * @returns the list of ramp gradients
  123064. */
  123065. getRampGradients(): Nullable<Array<Color3Gradient>>;
  123066. /**
  123067. * Not supported by GPUParticleSystem
  123068. * Gets or sets a boolean indicating that ramp gradients must be used
  123069. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  123070. */
  123071. useRampGradients: boolean;
  123072. /**
  123073. * Not supported by GPUParticleSystem
  123074. * @param gradient defines the gradient to use (between 0 and 1)
  123075. * @param factor defines the life time factor to affect to the specified gradient
  123076. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  123077. * @returns the current particle system
  123078. */
  123079. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  123080. /**
  123081. * Not supported by GPUParticleSystem
  123082. * @param gradient defines the gradient to remove
  123083. * @returns the current particle system
  123084. */
  123085. removeLifeTimeGradient(gradient: number): IParticleSystem;
  123086. /**
  123087. * Instantiates a GPU particle system.
  123088. * 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.
  123089. * @param name The name of the particle system
  123090. * @param options The options used to create the system
  123091. * @param scene The scene the particle system belongs to
  123092. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  123093. */
  123094. constructor(name: string, options: Partial<{
  123095. capacity: number;
  123096. randomTextureSize: number;
  123097. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  123098. protected _reset(): void;
  123099. private _createUpdateVAO;
  123100. private _createRenderVAO;
  123101. private _initialize;
  123102. /** @hidden */
  123103. _recreateUpdateEffect(): void;
  123104. /** @hidden */
  123105. _recreateRenderEffect(): void;
  123106. /**
  123107. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  123108. * @param preWarm defines if we are in the pre-warmimg phase
  123109. */
  123110. animate(preWarm?: boolean): void;
  123111. private _createFactorGradientTexture;
  123112. private _createSizeGradientTexture;
  123113. private _createAngularSpeedGradientTexture;
  123114. private _createVelocityGradientTexture;
  123115. private _createLimitVelocityGradientTexture;
  123116. private _createDragGradientTexture;
  123117. private _createColorGradientTexture;
  123118. /**
  123119. * Renders the particle system in its current state
  123120. * @param preWarm defines if the system should only update the particles but not render them
  123121. * @returns the current number of particles
  123122. */
  123123. render(preWarm?: boolean): number;
  123124. /**
  123125. * Rebuilds the particle system
  123126. */
  123127. rebuild(): void;
  123128. private _releaseBuffers;
  123129. private _releaseVAOs;
  123130. /**
  123131. * Disposes the particle system and free the associated resources
  123132. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  123133. */
  123134. dispose(disposeTexture?: boolean): void;
  123135. /**
  123136. * Clones the particle system.
  123137. * @param name The name of the cloned object
  123138. * @param newEmitter The new emitter to use
  123139. * @returns the cloned particle system
  123140. */
  123141. clone(name: string, newEmitter: any): GPUParticleSystem;
  123142. /**
  123143. * Serializes the particle system to a JSON object.
  123144. * @returns the JSON object
  123145. */
  123146. serialize(): any;
  123147. /**
  123148. * Parses a JSON object to create a GPU particle system.
  123149. * @param parsedParticleSystem The JSON object to parse
  123150. * @param scene The scene to create the particle system in
  123151. * @param rootUrl The root url to use to load external dependencies like texture
  123152. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  123153. * @returns the parsed GPU particle system
  123154. */
  123155. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  123156. }
  123157. }
  123158. declare module BABYLON {
  123159. /**
  123160. * Represents a set of particle systems working together to create a specific effect
  123161. */
  123162. export class ParticleSystemSet implements IDisposable {
  123163. private _emitterCreationOptions;
  123164. private _emitterNode;
  123165. /**
  123166. * Gets the particle system list
  123167. */
  123168. systems: IParticleSystem[];
  123169. /**
  123170. * Gets the emitter node used with this set
  123171. */
  123172. readonly emitterNode: Nullable<TransformNode>;
  123173. /**
  123174. * Creates a new emitter mesh as a sphere
  123175. * @param options defines the options used to create the sphere
  123176. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  123177. * @param scene defines the hosting scene
  123178. */
  123179. setEmitterAsSphere(options: {
  123180. diameter: number;
  123181. segments: number;
  123182. color: Color3;
  123183. }, renderingGroupId: number, scene: Scene): void;
  123184. /**
  123185. * Starts all particle systems of the set
  123186. * @param emitter defines an optional mesh to use as emitter for the particle systems
  123187. */
  123188. start(emitter?: AbstractMesh): void;
  123189. /**
  123190. * Release all associated resources
  123191. */
  123192. dispose(): void;
  123193. /**
  123194. * Serialize the set into a JSON compatible object
  123195. * @returns a JSON compatible representation of the set
  123196. */
  123197. serialize(): any;
  123198. /**
  123199. * Parse a new ParticleSystemSet from a serialized source
  123200. * @param data defines a JSON compatible representation of the set
  123201. * @param scene defines the hosting scene
  123202. * @param gpu defines if we want GPU particles or CPU particles
  123203. * @returns a new ParticleSystemSet
  123204. */
  123205. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  123206. }
  123207. }
  123208. declare module BABYLON {
  123209. /**
  123210. * This class is made for on one-liner static method to help creating particle system set.
  123211. */
  123212. export class ParticleHelper {
  123213. /**
  123214. * Gets or sets base Assets URL
  123215. */
  123216. static BaseAssetsUrl: string;
  123217. /**
  123218. * Create a default particle system that you can tweak
  123219. * @param emitter defines the emitter to use
  123220. * @param capacity defines the system capacity (default is 500 particles)
  123221. * @param scene defines the hosting scene
  123222. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  123223. * @returns the new Particle system
  123224. */
  123225. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  123226. /**
  123227. * This is the main static method (one-liner) of this helper to create different particle systems
  123228. * @param type This string represents the type to the particle system to create
  123229. * @param scene The scene where the particle system should live
  123230. * @param gpu If the system will use gpu
  123231. * @returns the ParticleSystemSet created
  123232. */
  123233. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  123234. /**
  123235. * Static function used to export a particle system to a ParticleSystemSet variable.
  123236. * Please note that the emitter shape is not exported
  123237. * @param systems defines the particle systems to export
  123238. * @returns the created particle system set
  123239. */
  123240. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  123241. }
  123242. }
  123243. declare module BABYLON {
  123244. interface Engine {
  123245. /**
  123246. * Create an effect to use with particle systems.
  123247. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  123248. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  123249. * @param uniformsNames defines a list of attribute names
  123250. * @param samplers defines an array of string used to represent textures
  123251. * @param defines defines the string containing the defines to use to compile the shaders
  123252. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  123253. * @param onCompiled defines a function to call when the effect creation is successful
  123254. * @param onError defines a function to call when the effect creation has failed
  123255. * @returns the new Effect
  123256. */
  123257. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  123258. }
  123259. interface Mesh {
  123260. /**
  123261. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  123262. * @returns an array of IParticleSystem
  123263. */
  123264. getEmittedParticleSystems(): IParticleSystem[];
  123265. /**
  123266. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  123267. * @returns an array of IParticleSystem
  123268. */
  123269. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  123270. }
  123271. /**
  123272. * @hidden
  123273. */
  123274. export var _IDoNeedToBeInTheBuild: number;
  123275. }
  123276. declare module BABYLON {
  123277. interface Scene {
  123278. /** @hidden (Backing field) */
  123279. _physicsEngine: Nullable<IPhysicsEngine>;
  123280. /**
  123281. * Gets the current physics engine
  123282. * @returns a IPhysicsEngine or null if none attached
  123283. */
  123284. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  123285. /**
  123286. * Enables physics to the current scene
  123287. * @param gravity defines the scene's gravity for the physics engine
  123288. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  123289. * @return a boolean indicating if the physics engine was initialized
  123290. */
  123291. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  123292. /**
  123293. * Disables and disposes the physics engine associated with the scene
  123294. */
  123295. disablePhysicsEngine(): void;
  123296. /**
  123297. * Gets a boolean indicating if there is an active physics engine
  123298. * @returns a boolean indicating if there is an active physics engine
  123299. */
  123300. isPhysicsEnabled(): boolean;
  123301. /**
  123302. * Deletes a physics compound impostor
  123303. * @param compound defines the compound to delete
  123304. */
  123305. deleteCompoundImpostor(compound: any): void;
  123306. /**
  123307. * An event triggered when physic simulation is about to be run
  123308. */
  123309. onBeforePhysicsObservable: Observable<Scene>;
  123310. /**
  123311. * An event triggered when physic simulation has been done
  123312. */
  123313. onAfterPhysicsObservable: Observable<Scene>;
  123314. }
  123315. interface AbstractMesh {
  123316. /** @hidden */
  123317. _physicsImpostor: Nullable<PhysicsImpostor>;
  123318. /**
  123319. * Gets or sets impostor used for physic simulation
  123320. * @see http://doc.babylonjs.com/features/physics_engine
  123321. */
  123322. physicsImpostor: Nullable<PhysicsImpostor>;
  123323. /**
  123324. * Gets the current physics impostor
  123325. * @see http://doc.babylonjs.com/features/physics_engine
  123326. * @returns a physics impostor or null
  123327. */
  123328. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  123329. /** Apply a physic impulse to the mesh
  123330. * @param force defines the force to apply
  123331. * @param contactPoint defines where to apply the force
  123332. * @returns the current mesh
  123333. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  123334. */
  123335. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  123336. /**
  123337. * Creates a physic joint between two meshes
  123338. * @param otherMesh defines the other mesh to use
  123339. * @param pivot1 defines the pivot to use on this mesh
  123340. * @param pivot2 defines the pivot to use on the other mesh
  123341. * @param options defines additional options (can be plugin dependent)
  123342. * @returns the current mesh
  123343. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  123344. */
  123345. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  123346. /** @hidden */
  123347. _disposePhysicsObserver: Nullable<Observer<Node>>;
  123348. }
  123349. /**
  123350. * Defines the physics engine scene component responsible to manage a physics engine
  123351. */
  123352. export class PhysicsEngineSceneComponent implements ISceneComponent {
  123353. /**
  123354. * The component name helpful to identify the component in the list of scene components.
  123355. */
  123356. readonly name: string;
  123357. /**
  123358. * The scene the component belongs to.
  123359. */
  123360. scene: Scene;
  123361. /**
  123362. * Creates a new instance of the component for the given scene
  123363. * @param scene Defines the scene to register the component in
  123364. */
  123365. constructor(scene: Scene);
  123366. /**
  123367. * Registers the component in a given scene
  123368. */
  123369. register(): void;
  123370. /**
  123371. * Rebuilds the elements related to this component in case of
  123372. * context lost for instance.
  123373. */
  123374. rebuild(): void;
  123375. /**
  123376. * Disposes the component and the associated ressources
  123377. */
  123378. dispose(): void;
  123379. }
  123380. }
  123381. declare module BABYLON {
  123382. /**
  123383. * A helper for physics simulations
  123384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123385. */
  123386. export class PhysicsHelper {
  123387. private _scene;
  123388. private _physicsEngine;
  123389. /**
  123390. * Initializes the Physics helper
  123391. * @param scene Babylon.js scene
  123392. */
  123393. constructor(scene: Scene);
  123394. /**
  123395. * Applies a radial explosion impulse
  123396. * @param origin the origin of the explosion
  123397. * @param radiusOrEventOptions the radius or the options of radial explosion
  123398. * @param strength the explosion strength
  123399. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123400. * @returns A physics radial explosion event, or null
  123401. */
  123402. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  123403. /**
  123404. * Applies a radial explosion force
  123405. * @param origin the origin of the explosion
  123406. * @param radiusOrEventOptions the radius or the options of radial explosion
  123407. * @param strength the explosion strength
  123408. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123409. * @returns A physics radial explosion event, or null
  123410. */
  123411. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  123412. /**
  123413. * Creates a gravitational field
  123414. * @param origin the origin of the explosion
  123415. * @param radiusOrEventOptions the radius or the options of radial explosion
  123416. * @param strength the explosion strength
  123417. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123418. * @returns A physics gravitational field event, or null
  123419. */
  123420. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  123421. /**
  123422. * Creates a physics updraft event
  123423. * @param origin the origin of the updraft
  123424. * @param radiusOrEventOptions the radius or the options of the updraft
  123425. * @param strength the strength of the updraft
  123426. * @param height the height of the updraft
  123427. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  123428. * @returns A physics updraft event, or null
  123429. */
  123430. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  123431. /**
  123432. * Creates a physics vortex event
  123433. * @param origin the of the vortex
  123434. * @param radiusOrEventOptions the radius or the options of the vortex
  123435. * @param strength the strength of the vortex
  123436. * @param height the height of the vortex
  123437. * @returns a Physics vortex event, or null
  123438. * A physics vortex event or null
  123439. */
  123440. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  123441. }
  123442. /**
  123443. * Represents a physics radial explosion event
  123444. */
  123445. class PhysicsRadialExplosionEvent {
  123446. private _scene;
  123447. private _options;
  123448. private _sphere;
  123449. private _dataFetched;
  123450. /**
  123451. * Initializes a radial explosioin event
  123452. * @param _scene BabylonJS scene
  123453. * @param _options The options for the vortex event
  123454. */
  123455. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  123456. /**
  123457. * Returns the data related to the radial explosion event (sphere).
  123458. * @returns The radial explosion event data
  123459. */
  123460. getData(): PhysicsRadialExplosionEventData;
  123461. /**
  123462. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  123463. * @param impostor A physics imposter
  123464. * @param origin the origin of the explosion
  123465. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  123466. */
  123467. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  123468. /**
  123469. * Triggers affecterd impostors callbacks
  123470. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  123471. */
  123472. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  123473. /**
  123474. * Disposes the sphere.
  123475. * @param force Specifies if the sphere should be disposed by force
  123476. */
  123477. dispose(force?: boolean): void;
  123478. /*** Helpers ***/
  123479. private _prepareSphere;
  123480. private _intersectsWithSphere;
  123481. }
  123482. /**
  123483. * Represents a gravitational field event
  123484. */
  123485. class PhysicsGravitationalFieldEvent {
  123486. private _physicsHelper;
  123487. private _scene;
  123488. private _origin;
  123489. private _options;
  123490. private _tickCallback;
  123491. private _sphere;
  123492. private _dataFetched;
  123493. /**
  123494. * Initializes the physics gravitational field event
  123495. * @param _physicsHelper A physics helper
  123496. * @param _scene BabylonJS scene
  123497. * @param _origin The origin position of the gravitational field event
  123498. * @param _options The options for the vortex event
  123499. */
  123500. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  123501. /**
  123502. * Returns the data related to the gravitational field event (sphere).
  123503. * @returns A gravitational field event
  123504. */
  123505. getData(): PhysicsGravitationalFieldEventData;
  123506. /**
  123507. * Enables the gravitational field.
  123508. */
  123509. enable(): void;
  123510. /**
  123511. * Disables the gravitational field.
  123512. */
  123513. disable(): void;
  123514. /**
  123515. * Disposes the sphere.
  123516. * @param force The force to dispose from the gravitational field event
  123517. */
  123518. dispose(force?: boolean): void;
  123519. private _tick;
  123520. }
  123521. /**
  123522. * Represents a physics updraft event
  123523. */
  123524. class PhysicsUpdraftEvent {
  123525. private _scene;
  123526. private _origin;
  123527. private _options;
  123528. private _physicsEngine;
  123529. private _originTop;
  123530. private _originDirection;
  123531. private _tickCallback;
  123532. private _cylinder;
  123533. private _cylinderPosition;
  123534. private _dataFetched;
  123535. /**
  123536. * Initializes the physics updraft event
  123537. * @param _scene BabylonJS scene
  123538. * @param _origin The origin position of the updraft
  123539. * @param _options The options for the updraft event
  123540. */
  123541. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  123542. /**
  123543. * Returns the data related to the updraft event (cylinder).
  123544. * @returns A physics updraft event
  123545. */
  123546. getData(): PhysicsUpdraftEventData;
  123547. /**
  123548. * Enables the updraft.
  123549. */
  123550. enable(): void;
  123551. /**
  123552. * Disables the updraft.
  123553. */
  123554. disable(): void;
  123555. /**
  123556. * Disposes the cylinder.
  123557. * @param force Specifies if the updraft should be disposed by force
  123558. */
  123559. dispose(force?: boolean): void;
  123560. private getImpostorHitData;
  123561. private _tick;
  123562. /*** Helpers ***/
  123563. private _prepareCylinder;
  123564. private _intersectsWithCylinder;
  123565. }
  123566. /**
  123567. * Represents a physics vortex event
  123568. */
  123569. class PhysicsVortexEvent {
  123570. private _scene;
  123571. private _origin;
  123572. private _options;
  123573. private _physicsEngine;
  123574. private _originTop;
  123575. private _tickCallback;
  123576. private _cylinder;
  123577. private _cylinderPosition;
  123578. private _dataFetched;
  123579. /**
  123580. * Initializes the physics vortex event
  123581. * @param _scene The BabylonJS scene
  123582. * @param _origin The origin position of the vortex
  123583. * @param _options The options for the vortex event
  123584. */
  123585. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  123586. /**
  123587. * Returns the data related to the vortex event (cylinder).
  123588. * @returns The physics vortex event data
  123589. */
  123590. getData(): PhysicsVortexEventData;
  123591. /**
  123592. * Enables the vortex.
  123593. */
  123594. enable(): void;
  123595. /**
  123596. * Disables the cortex.
  123597. */
  123598. disable(): void;
  123599. /**
  123600. * Disposes the sphere.
  123601. * @param force
  123602. */
  123603. dispose(force?: boolean): void;
  123604. private getImpostorHitData;
  123605. private _tick;
  123606. /*** Helpers ***/
  123607. private _prepareCylinder;
  123608. private _intersectsWithCylinder;
  123609. }
  123610. /**
  123611. * Options fot the radial explosion event
  123612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123613. */
  123614. export class PhysicsRadialExplosionEventOptions {
  123615. /**
  123616. * The radius of the sphere for the radial explosion.
  123617. */
  123618. radius: number;
  123619. /**
  123620. * The strenth of the explosion.
  123621. */
  123622. strength: number;
  123623. /**
  123624. * The strenght of the force in correspondence to the distance of the affected object
  123625. */
  123626. falloff: PhysicsRadialImpulseFalloff;
  123627. /**
  123628. * Sphere options for the radial explosion.
  123629. */
  123630. sphere: {
  123631. segments: number;
  123632. diameter: number;
  123633. };
  123634. /**
  123635. * Sphere options for the radial explosion.
  123636. */
  123637. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  123638. }
  123639. /**
  123640. * Options fot the updraft event
  123641. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123642. */
  123643. export class PhysicsUpdraftEventOptions {
  123644. /**
  123645. * The radius of the cylinder for the vortex
  123646. */
  123647. radius: number;
  123648. /**
  123649. * The strenth of the updraft.
  123650. */
  123651. strength: number;
  123652. /**
  123653. * The height of the cylinder for the updraft.
  123654. */
  123655. height: number;
  123656. /**
  123657. * The mode for the the updraft.
  123658. */
  123659. updraftMode: PhysicsUpdraftMode;
  123660. }
  123661. /**
  123662. * Options fot the vortex event
  123663. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123664. */
  123665. export class PhysicsVortexEventOptions {
  123666. /**
  123667. * The radius of the cylinder for the vortex
  123668. */
  123669. radius: number;
  123670. /**
  123671. * The strenth of the vortex.
  123672. */
  123673. strength: number;
  123674. /**
  123675. * The height of the cylinder for the vortex.
  123676. */
  123677. height: number;
  123678. /**
  123679. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  123680. */
  123681. centripetalForceThreshold: number;
  123682. /**
  123683. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  123684. */
  123685. centripetalForceMultiplier: number;
  123686. /**
  123687. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  123688. */
  123689. centrifugalForceMultiplier: number;
  123690. /**
  123691. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  123692. */
  123693. updraftForceMultiplier: number;
  123694. }
  123695. /**
  123696. * The strenght of the force in correspondence to the distance of the affected object
  123697. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123698. */
  123699. export enum PhysicsRadialImpulseFalloff {
  123700. /** Defines that impulse is constant in strength across it's whole radius */
  123701. Constant = 0,
  123702. /** Defines that impulse gets weaker if it's further from the origin */
  123703. Linear = 1
  123704. }
  123705. /**
  123706. * The strength of the force in correspondence to the distance of the affected object
  123707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123708. */
  123709. export enum PhysicsUpdraftMode {
  123710. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  123711. Center = 0,
  123712. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  123713. Perpendicular = 1
  123714. }
  123715. /**
  123716. * Interface for a physics hit data
  123717. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123718. */
  123719. export interface PhysicsHitData {
  123720. /**
  123721. * The force applied at the contact point
  123722. */
  123723. force: Vector3;
  123724. /**
  123725. * The contact point
  123726. */
  123727. contactPoint: Vector3;
  123728. /**
  123729. * The distance from the origin to the contact point
  123730. */
  123731. distanceFromOrigin: number;
  123732. }
  123733. /**
  123734. * Interface for radial explosion event data
  123735. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123736. */
  123737. export interface PhysicsRadialExplosionEventData {
  123738. /**
  123739. * A sphere used for the radial explosion event
  123740. */
  123741. sphere: Mesh;
  123742. }
  123743. /**
  123744. * Interface for gravitational field event data
  123745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123746. */
  123747. export interface PhysicsGravitationalFieldEventData {
  123748. /**
  123749. * A sphere mesh used for the gravitational field event
  123750. */
  123751. sphere: Mesh;
  123752. }
  123753. /**
  123754. * Interface for updraft event data
  123755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123756. */
  123757. export interface PhysicsUpdraftEventData {
  123758. /**
  123759. * A cylinder used for the updraft event
  123760. */
  123761. cylinder: Mesh;
  123762. }
  123763. /**
  123764. * Interface for vortex event data
  123765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123766. */
  123767. export interface PhysicsVortexEventData {
  123768. /**
  123769. * A cylinder used for the vortex event
  123770. */
  123771. cylinder: Mesh;
  123772. }
  123773. /**
  123774. * Interface for an affected physics impostor
  123775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123776. */
  123777. export interface PhysicsAffectedImpostorWithData {
  123778. /**
  123779. * The impostor affected by the effect
  123780. */
  123781. impostor: PhysicsImpostor;
  123782. /**
  123783. * The data about the hit/horce from the explosion
  123784. */
  123785. hitData: PhysicsHitData;
  123786. }
  123787. }
  123788. declare module BABYLON {
  123789. /** @hidden */
  123790. export var blackAndWhitePixelShader: {
  123791. name: string;
  123792. shader: string;
  123793. };
  123794. }
  123795. declare module BABYLON {
  123796. /**
  123797. * Post process used to render in black and white
  123798. */
  123799. export class BlackAndWhitePostProcess extends PostProcess {
  123800. /**
  123801. * Linear about to convert he result to black and white (default: 1)
  123802. */
  123803. degree: number;
  123804. /**
  123805. * Creates a black and white post process
  123806. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  123807. * @param name The name of the effect.
  123808. * @param options The required width/height ratio to downsize to before computing the render pass.
  123809. * @param camera The camera to apply the render pass to.
  123810. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123811. * @param engine The engine which the post process will be applied. (default: current engine)
  123812. * @param reusable If the post process can be reused on the same frame. (default: false)
  123813. */
  123814. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123815. }
  123816. }
  123817. declare module BABYLON {
  123818. /**
  123819. * This represents a set of one or more post processes in Babylon.
  123820. * A post process can be used to apply a shader to a texture after it is rendered.
  123821. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123822. */
  123823. export class PostProcessRenderEffect {
  123824. private _postProcesses;
  123825. private _getPostProcesses;
  123826. private _singleInstance;
  123827. private _cameras;
  123828. private _indicesForCamera;
  123829. /**
  123830. * Name of the effect
  123831. * @hidden
  123832. */
  123833. _name: string;
  123834. /**
  123835. * Instantiates a post process render effect.
  123836. * A post process can be used to apply a shader to a texture after it is rendered.
  123837. * @param engine The engine the effect is tied to
  123838. * @param name The name of the effect
  123839. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  123840. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  123841. */
  123842. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  123843. /**
  123844. * Checks if all the post processes in the effect are supported.
  123845. */
  123846. readonly isSupported: boolean;
  123847. /**
  123848. * Updates the current state of the effect
  123849. * @hidden
  123850. */
  123851. _update(): void;
  123852. /**
  123853. * Attaches the effect on cameras
  123854. * @param cameras The camera to attach to.
  123855. * @hidden
  123856. */
  123857. _attachCameras(cameras: Camera): void;
  123858. /**
  123859. * Attaches the effect on cameras
  123860. * @param cameras The camera to attach to.
  123861. * @hidden
  123862. */
  123863. _attachCameras(cameras: Camera[]): void;
  123864. /**
  123865. * Detaches the effect on cameras
  123866. * @param cameras The camera to detatch from.
  123867. * @hidden
  123868. */
  123869. _detachCameras(cameras: Camera): void;
  123870. /**
  123871. * Detatches the effect on cameras
  123872. * @param cameras The camera to detatch from.
  123873. * @hidden
  123874. */
  123875. _detachCameras(cameras: Camera[]): void;
  123876. /**
  123877. * Enables the effect on given cameras
  123878. * @param cameras The camera to enable.
  123879. * @hidden
  123880. */
  123881. _enable(cameras: Camera): void;
  123882. /**
  123883. * Enables the effect on given cameras
  123884. * @param cameras The camera to enable.
  123885. * @hidden
  123886. */
  123887. _enable(cameras: Nullable<Camera[]>): void;
  123888. /**
  123889. * Disables the effect on the given cameras
  123890. * @param cameras The camera to disable.
  123891. * @hidden
  123892. */
  123893. _disable(cameras: Camera): void;
  123894. /**
  123895. * Disables the effect on the given cameras
  123896. * @param cameras The camera to disable.
  123897. * @hidden
  123898. */
  123899. _disable(cameras: Nullable<Camera[]>): void;
  123900. /**
  123901. * Gets a list of the post processes contained in the effect.
  123902. * @param camera The camera to get the post processes on.
  123903. * @returns The list of the post processes in the effect.
  123904. */
  123905. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  123906. }
  123907. }
  123908. declare module BABYLON {
  123909. /** @hidden */
  123910. export var extractHighlightsPixelShader: {
  123911. name: string;
  123912. shader: string;
  123913. };
  123914. }
  123915. declare module BABYLON {
  123916. /**
  123917. * 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.
  123918. */
  123919. export class ExtractHighlightsPostProcess extends PostProcess {
  123920. /**
  123921. * The luminance threshold, pixels below this value will be set to black.
  123922. */
  123923. threshold: number;
  123924. /** @hidden */
  123925. _exposure: number;
  123926. /**
  123927. * Post process which has the input texture to be used when performing highlight extraction
  123928. * @hidden
  123929. */
  123930. _inputPostProcess: Nullable<PostProcess>;
  123931. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123932. }
  123933. }
  123934. declare module BABYLON {
  123935. /** @hidden */
  123936. export var bloomMergePixelShader: {
  123937. name: string;
  123938. shader: string;
  123939. };
  123940. }
  123941. declare module BABYLON {
  123942. /**
  123943. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  123944. */
  123945. export class BloomMergePostProcess extends PostProcess {
  123946. /** Weight of the bloom to be added to the original input. */
  123947. weight: number;
  123948. /**
  123949. * Creates a new instance of @see BloomMergePostProcess
  123950. * @param name The name of the effect.
  123951. * @param originalFromInput Post process which's input will be used for the merge.
  123952. * @param blurred Blurred highlights post process which's output will be used.
  123953. * @param weight Weight of the bloom to be added to the original input.
  123954. * @param options The required width/height ratio to downsize to before computing the render pass.
  123955. * @param camera The camera to apply the render pass to.
  123956. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123957. * @param engine The engine which the post process will be applied. (default: current engine)
  123958. * @param reusable If the post process can be reused on the same frame. (default: false)
  123959. * @param textureType Type of textures used when performing the post process. (default: 0)
  123960. * @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)
  123961. */
  123962. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  123963. /** Weight of the bloom to be added to the original input. */
  123964. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123965. }
  123966. }
  123967. declare module BABYLON {
  123968. /**
  123969. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  123970. */
  123971. export class BloomEffect extends PostProcessRenderEffect {
  123972. private bloomScale;
  123973. /**
  123974. * @hidden Internal
  123975. */
  123976. _effects: Array<PostProcess>;
  123977. /**
  123978. * @hidden Internal
  123979. */
  123980. _downscale: ExtractHighlightsPostProcess;
  123981. private _blurX;
  123982. private _blurY;
  123983. private _merge;
  123984. /**
  123985. * The luminance threshold to find bright areas of the image to bloom.
  123986. */
  123987. threshold: number;
  123988. /**
  123989. * The strength of the bloom.
  123990. */
  123991. weight: number;
  123992. /**
  123993. * Specifies the size of the bloom blur kernel, relative to the final output size
  123994. */
  123995. kernel: number;
  123996. /**
  123997. * Creates a new instance of @see BloomEffect
  123998. * @param scene The scene the effect belongs to.
  123999. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  124000. * @param bloomKernel The size of the kernel to be used when applying the blur.
  124001. * @param bloomWeight The the strength of bloom.
  124002. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  124003. * @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)
  124004. */
  124005. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  124006. /**
  124007. * Disposes each of the internal effects for a given camera.
  124008. * @param camera The camera to dispose the effect on.
  124009. */
  124010. disposeEffects(camera: Camera): void;
  124011. /**
  124012. * @hidden Internal
  124013. */
  124014. _updateEffects(): void;
  124015. /**
  124016. * Internal
  124017. * @returns if all the contained post processes are ready.
  124018. * @hidden
  124019. */
  124020. _isReady(): boolean;
  124021. }
  124022. }
  124023. declare module BABYLON {
  124024. /** @hidden */
  124025. export var chromaticAberrationPixelShader: {
  124026. name: string;
  124027. shader: string;
  124028. };
  124029. }
  124030. declare module BABYLON {
  124031. /**
  124032. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  124033. */
  124034. export class ChromaticAberrationPostProcess extends PostProcess {
  124035. /**
  124036. * The amount of seperation of rgb channels (default: 30)
  124037. */
  124038. aberrationAmount: number;
  124039. /**
  124040. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  124041. */
  124042. radialIntensity: number;
  124043. /**
  124044. * 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))
  124045. */
  124046. direction: Vector2;
  124047. /**
  124048. * 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))
  124049. */
  124050. centerPosition: Vector2;
  124051. /**
  124052. * Creates a new instance ChromaticAberrationPostProcess
  124053. * @param name The name of the effect.
  124054. * @param screenWidth The width of the screen to apply the effect on.
  124055. * @param screenHeight The height of the screen to apply the effect on.
  124056. * @param options The required width/height ratio to downsize to before computing the render pass.
  124057. * @param camera The camera to apply the render pass to.
  124058. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124059. * @param engine The engine which the post process will be applied. (default: current engine)
  124060. * @param reusable If the post process can be reused on the same frame. (default: false)
  124061. * @param textureType Type of textures used when performing the post process. (default: 0)
  124062. * @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)
  124063. */
  124064. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124065. }
  124066. }
  124067. declare module BABYLON {
  124068. /** @hidden */
  124069. export var circleOfConfusionPixelShader: {
  124070. name: string;
  124071. shader: string;
  124072. };
  124073. }
  124074. declare module BABYLON {
  124075. /**
  124076. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  124077. */
  124078. export class CircleOfConfusionPostProcess extends PostProcess {
  124079. /**
  124080. * 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.
  124081. */
  124082. lensSize: number;
  124083. /**
  124084. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  124085. */
  124086. fStop: number;
  124087. /**
  124088. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  124089. */
  124090. focusDistance: number;
  124091. /**
  124092. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  124093. */
  124094. focalLength: number;
  124095. private _depthTexture;
  124096. /**
  124097. * Creates a new instance CircleOfConfusionPostProcess
  124098. * @param name The name of the effect.
  124099. * @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.
  124100. * @param options The required width/height ratio to downsize to before computing the render pass.
  124101. * @param camera The camera to apply the render pass to.
  124102. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124103. * @param engine The engine which the post process will be applied. (default: current engine)
  124104. * @param reusable If the post process can be reused on the same frame. (default: false)
  124105. * @param textureType Type of textures used when performing the post process. (default: 0)
  124106. * @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)
  124107. */
  124108. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124109. /**
  124110. * 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.
  124111. */
  124112. depthTexture: RenderTargetTexture;
  124113. }
  124114. }
  124115. declare module BABYLON {
  124116. /** @hidden */
  124117. export var colorCorrectionPixelShader: {
  124118. name: string;
  124119. shader: string;
  124120. };
  124121. }
  124122. declare module BABYLON {
  124123. /**
  124124. *
  124125. * This post-process allows the modification of rendered colors by using
  124126. * a 'look-up table' (LUT). This effect is also called Color Grading.
  124127. *
  124128. * The object needs to be provided an url to a texture containing the color
  124129. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  124130. * Use an image editing software to tweak the LUT to match your needs.
  124131. *
  124132. * For an example of a color LUT, see here:
  124133. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  124134. * For explanations on color grading, see here:
  124135. * @see http://udn.epicgames.com/Three/ColorGrading.html
  124136. *
  124137. */
  124138. export class ColorCorrectionPostProcess extends PostProcess {
  124139. private _colorTableTexture;
  124140. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124141. }
  124142. }
  124143. declare module BABYLON {
  124144. /** @hidden */
  124145. export var convolutionPixelShader: {
  124146. name: string;
  124147. shader: string;
  124148. };
  124149. }
  124150. declare module BABYLON {
  124151. /**
  124152. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  124153. * input texture to perform effects such as edge detection or sharpening
  124154. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124155. */
  124156. export class ConvolutionPostProcess extends PostProcess {
  124157. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  124158. kernel: number[];
  124159. /**
  124160. * Creates a new instance ConvolutionPostProcess
  124161. * @param name The name of the effect.
  124162. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  124163. * @param options The required width/height ratio to downsize to before computing the render pass.
  124164. * @param camera The camera to apply the render pass to.
  124165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124166. * @param engine The engine which the post process will be applied. (default: current engine)
  124167. * @param reusable If the post process can be reused on the same frame. (default: false)
  124168. * @param textureType Type of textures used when performing the post process. (default: 0)
  124169. */
  124170. constructor(name: string,
  124171. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  124172. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124173. /**
  124174. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124175. */
  124176. static EdgeDetect0Kernel: number[];
  124177. /**
  124178. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124179. */
  124180. static EdgeDetect1Kernel: number[];
  124181. /**
  124182. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124183. */
  124184. static EdgeDetect2Kernel: number[];
  124185. /**
  124186. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124187. */
  124188. static SharpenKernel: number[];
  124189. /**
  124190. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124191. */
  124192. static EmbossKernel: number[];
  124193. /**
  124194. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124195. */
  124196. static GaussianKernel: number[];
  124197. }
  124198. }
  124199. declare module BABYLON {
  124200. /**
  124201. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  124202. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  124203. * based on samples that have a large difference in distance than the center pixel.
  124204. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  124205. */
  124206. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  124207. direction: Vector2;
  124208. /**
  124209. * Creates a new instance CircleOfConfusionPostProcess
  124210. * @param name The name of the effect.
  124211. * @param scene The scene the effect belongs to.
  124212. * @param direction The direction the blur should be applied.
  124213. * @param kernel The size of the kernel used to blur.
  124214. * @param options The required width/height ratio to downsize to before computing the render pass.
  124215. * @param camera The camera to apply the render pass to.
  124216. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  124217. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  124218. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124219. * @param engine The engine which the post process will be applied. (default: current engine)
  124220. * @param reusable If the post process can be reused on the same frame. (default: false)
  124221. * @param textureType Type of textures used when performing the post process. (default: 0)
  124222. * @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)
  124223. */
  124224. 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);
  124225. }
  124226. }
  124227. declare module BABYLON {
  124228. /** @hidden */
  124229. export var depthOfFieldMergePixelShader: {
  124230. name: string;
  124231. shader: string;
  124232. };
  124233. }
  124234. declare module BABYLON {
  124235. /**
  124236. * Options to be set when merging outputs from the default pipeline.
  124237. */
  124238. export class DepthOfFieldMergePostProcessOptions {
  124239. /**
  124240. * The original image to merge on top of
  124241. */
  124242. originalFromInput: PostProcess;
  124243. /**
  124244. * Parameters to perform the merge of the depth of field effect
  124245. */
  124246. depthOfField?: {
  124247. circleOfConfusion: PostProcess;
  124248. blurSteps: Array<PostProcess>;
  124249. };
  124250. /**
  124251. * Parameters to perform the merge of bloom effect
  124252. */
  124253. bloom?: {
  124254. blurred: PostProcess;
  124255. weight: number;
  124256. };
  124257. }
  124258. /**
  124259. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  124260. */
  124261. export class DepthOfFieldMergePostProcess extends PostProcess {
  124262. private blurSteps;
  124263. /**
  124264. * Creates a new instance of DepthOfFieldMergePostProcess
  124265. * @param name The name of the effect.
  124266. * @param originalFromInput Post process which's input will be used for the merge.
  124267. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  124268. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  124269. * @param options The required width/height ratio to downsize to before computing the render pass.
  124270. * @param camera The camera to apply the render pass to.
  124271. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124272. * @param engine The engine which the post process will be applied. (default: current engine)
  124273. * @param reusable If the post process can be reused on the same frame. (default: false)
  124274. * @param textureType Type of textures used when performing the post process. (default: 0)
  124275. * @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)
  124276. */
  124277. 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);
  124278. /**
  124279. * Updates the effect with the current post process compile time values and recompiles the shader.
  124280. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  124281. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  124282. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  124283. * @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
  124284. * @param onCompiled Called when the shader has been compiled.
  124285. * @param onError Called if there is an error when compiling a shader.
  124286. */
  124287. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  124288. }
  124289. }
  124290. declare module BABYLON {
  124291. /**
  124292. * Specifies the level of max blur that should be applied when using the depth of field effect
  124293. */
  124294. export enum DepthOfFieldEffectBlurLevel {
  124295. /**
  124296. * Subtle blur
  124297. */
  124298. Low = 0,
  124299. /**
  124300. * Medium blur
  124301. */
  124302. Medium = 1,
  124303. /**
  124304. * Large blur
  124305. */
  124306. High = 2
  124307. }
  124308. /**
  124309. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  124310. */
  124311. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  124312. private _circleOfConfusion;
  124313. /**
  124314. * @hidden Internal, blurs from high to low
  124315. */
  124316. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  124317. private _depthOfFieldBlurY;
  124318. private _dofMerge;
  124319. /**
  124320. * @hidden Internal post processes in depth of field effect
  124321. */
  124322. _effects: Array<PostProcess>;
  124323. /**
  124324. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  124325. */
  124326. focalLength: number;
  124327. /**
  124328. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  124329. */
  124330. fStop: number;
  124331. /**
  124332. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  124333. */
  124334. focusDistance: number;
  124335. /**
  124336. * 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.
  124337. */
  124338. lensSize: number;
  124339. /**
  124340. * Creates a new instance DepthOfFieldEffect
  124341. * @param scene The scene the effect belongs to.
  124342. * @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.
  124343. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  124344. * @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)
  124345. */
  124346. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  124347. /**
  124348. * Get the current class name of the current effet
  124349. * @returns "DepthOfFieldEffect"
  124350. */
  124351. getClassName(): string;
  124352. /**
  124353. * 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.
  124354. */
  124355. depthTexture: RenderTargetTexture;
  124356. /**
  124357. * Disposes each of the internal effects for a given camera.
  124358. * @param camera The camera to dispose the effect on.
  124359. */
  124360. disposeEffects(camera: Camera): void;
  124361. /**
  124362. * @hidden Internal
  124363. */
  124364. _updateEffects(): void;
  124365. /**
  124366. * Internal
  124367. * @returns if all the contained post processes are ready.
  124368. * @hidden
  124369. */
  124370. _isReady(): boolean;
  124371. }
  124372. }
  124373. declare module BABYLON {
  124374. /** @hidden */
  124375. export var displayPassPixelShader: {
  124376. name: string;
  124377. shader: string;
  124378. };
  124379. }
  124380. declare module BABYLON {
  124381. /**
  124382. * DisplayPassPostProcess which produces an output the same as it's input
  124383. */
  124384. export class DisplayPassPostProcess extends PostProcess {
  124385. /**
  124386. * Creates the DisplayPassPostProcess
  124387. * @param name The name of the effect.
  124388. * @param options The required width/height ratio to downsize to before computing the render pass.
  124389. * @param camera The camera to apply the render pass to.
  124390. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124391. * @param engine The engine which the post process will be applied. (default: current engine)
  124392. * @param reusable If the post process can be reused on the same frame. (default: false)
  124393. */
  124394. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124395. }
  124396. }
  124397. declare module BABYLON {
  124398. /** @hidden */
  124399. export var filterPixelShader: {
  124400. name: string;
  124401. shader: string;
  124402. };
  124403. }
  124404. declare module BABYLON {
  124405. /**
  124406. * Applies a kernel filter to the image
  124407. */
  124408. export class FilterPostProcess extends PostProcess {
  124409. /** The matrix to be applied to the image */
  124410. kernelMatrix: Matrix;
  124411. /**
  124412. *
  124413. * @param name The name of the effect.
  124414. * @param kernelMatrix The matrix to be applied to the image
  124415. * @param options The required width/height ratio to downsize to before computing the render pass.
  124416. * @param camera The camera to apply the render pass to.
  124417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124418. * @param engine The engine which the post process will be applied. (default: current engine)
  124419. * @param reusable If the post process can be reused on the same frame. (default: false)
  124420. */
  124421. constructor(name: string,
  124422. /** The matrix to be applied to the image */
  124423. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124424. }
  124425. }
  124426. declare module BABYLON {
  124427. /** @hidden */
  124428. export var fxaaPixelShader: {
  124429. name: string;
  124430. shader: string;
  124431. };
  124432. }
  124433. declare module BABYLON {
  124434. /** @hidden */
  124435. export var fxaaVertexShader: {
  124436. name: string;
  124437. shader: string;
  124438. };
  124439. }
  124440. declare module BABYLON {
  124441. /**
  124442. * Fxaa post process
  124443. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  124444. */
  124445. export class FxaaPostProcess extends PostProcess {
  124446. /** @hidden */
  124447. texelWidth: number;
  124448. /** @hidden */
  124449. texelHeight: number;
  124450. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124451. private _getDefines;
  124452. }
  124453. }
  124454. declare module BABYLON {
  124455. /** @hidden */
  124456. export var grainPixelShader: {
  124457. name: string;
  124458. shader: string;
  124459. };
  124460. }
  124461. declare module BABYLON {
  124462. /**
  124463. * The GrainPostProcess adds noise to the image at mid luminance levels
  124464. */
  124465. export class GrainPostProcess extends PostProcess {
  124466. /**
  124467. * The intensity of the grain added (default: 30)
  124468. */
  124469. intensity: number;
  124470. /**
  124471. * If the grain should be randomized on every frame
  124472. */
  124473. animated: boolean;
  124474. /**
  124475. * Creates a new instance of @see GrainPostProcess
  124476. * @param name The name of the effect.
  124477. * @param options The required width/height ratio to downsize to before computing the render pass.
  124478. * @param camera The camera to apply the render pass to.
  124479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124480. * @param engine The engine which the post process will be applied. (default: current engine)
  124481. * @param reusable If the post process can be reused on the same frame. (default: false)
  124482. * @param textureType Type of textures used when performing the post process. (default: 0)
  124483. * @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)
  124484. */
  124485. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124486. }
  124487. }
  124488. declare module BABYLON {
  124489. /** @hidden */
  124490. export var highlightsPixelShader: {
  124491. name: string;
  124492. shader: string;
  124493. };
  124494. }
  124495. declare module BABYLON {
  124496. /**
  124497. * Extracts highlights from the image
  124498. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124499. */
  124500. export class HighlightsPostProcess extends PostProcess {
  124501. /**
  124502. * Extracts highlights from the image
  124503. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124504. * @param name The name of the effect.
  124505. * @param options The required width/height ratio to downsize to before computing the render pass.
  124506. * @param camera The camera to apply the render pass to.
  124507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124508. * @param engine The engine which the post process will be applied. (default: current engine)
  124509. * @param reusable If the post process can be reused on the same frame. (default: false)
  124510. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  124511. */
  124512. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124513. }
  124514. }
  124515. declare module BABYLON {
  124516. /** @hidden */
  124517. export var mrtFragmentDeclaration: {
  124518. name: string;
  124519. shader: string;
  124520. };
  124521. }
  124522. declare module BABYLON {
  124523. /** @hidden */
  124524. export var geometryPixelShader: {
  124525. name: string;
  124526. shader: string;
  124527. };
  124528. }
  124529. declare module BABYLON {
  124530. /** @hidden */
  124531. export var geometryVertexShader: {
  124532. name: string;
  124533. shader: string;
  124534. };
  124535. }
  124536. declare module BABYLON {
  124537. /** @hidden */
  124538. interface ISavedTransformationMatrix {
  124539. world: Matrix;
  124540. viewProjection: Matrix;
  124541. }
  124542. /**
  124543. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  124544. */
  124545. export class GeometryBufferRenderer {
  124546. /**
  124547. * Constant used to retrieve the position texture index in the G-Buffer textures array
  124548. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  124549. */
  124550. static readonly POSITION_TEXTURE_TYPE: number;
  124551. /**
  124552. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  124553. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  124554. */
  124555. static readonly VELOCITY_TEXTURE_TYPE: number;
  124556. /**
  124557. * Dictionary used to store the previous transformation matrices of each rendered mesh
  124558. * in order to compute objects velocities when enableVelocity is set to "true"
  124559. * @hidden
  124560. */
  124561. _previousTransformationMatrices: {
  124562. [index: number]: ISavedTransformationMatrix;
  124563. };
  124564. /**
  124565. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  124566. * in order to compute objects velocities when enableVelocity is set to "true"
  124567. * @hidden
  124568. */
  124569. _previousBonesTransformationMatrices: {
  124570. [index: number]: Float32Array;
  124571. };
  124572. /**
  124573. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  124574. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  124575. */
  124576. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  124577. private _scene;
  124578. private _multiRenderTarget;
  124579. private _ratio;
  124580. private _enablePosition;
  124581. private _enableVelocity;
  124582. private _positionIndex;
  124583. private _velocityIndex;
  124584. protected _effect: Effect;
  124585. protected _cachedDefines: string;
  124586. /**
  124587. * Set the render list (meshes to be rendered) used in the G buffer.
  124588. */
  124589. renderList: Mesh[];
  124590. /**
  124591. * Gets wether or not G buffer are supported by the running hardware.
  124592. * This requires draw buffer supports
  124593. */
  124594. readonly isSupported: boolean;
  124595. /**
  124596. * Returns the index of the given texture type in the G-Buffer textures array
  124597. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  124598. * @returns the index of the given texture type in the G-Buffer textures array
  124599. */
  124600. getTextureIndex(textureType: number): number;
  124601. /**
  124602. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  124603. */
  124604. /**
  124605. * Sets whether or not objects positions are enabled for the G buffer.
  124606. */
  124607. enablePosition: boolean;
  124608. /**
  124609. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  124610. */
  124611. /**
  124612. * Sets wether or not objects velocities are enabled for the G buffer.
  124613. */
  124614. enableVelocity: boolean;
  124615. /**
  124616. * Gets the scene associated with the buffer.
  124617. */
  124618. readonly scene: Scene;
  124619. /**
  124620. * Gets the ratio used by the buffer during its creation.
  124621. * How big is the buffer related to the main canvas.
  124622. */
  124623. readonly ratio: number;
  124624. /** @hidden */
  124625. static _SceneComponentInitialization: (scene: Scene) => void;
  124626. /**
  124627. * Creates a new G Buffer for the scene
  124628. * @param scene The scene the buffer belongs to
  124629. * @param ratio How big is the buffer related to the main canvas.
  124630. */
  124631. constructor(scene: Scene, ratio?: number);
  124632. /**
  124633. * Checks wether everything is ready to render a submesh to the G buffer.
  124634. * @param subMesh the submesh to check readiness for
  124635. * @param useInstances is the mesh drawn using instance or not
  124636. * @returns true if ready otherwise false
  124637. */
  124638. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124639. /**
  124640. * Gets the current underlying G Buffer.
  124641. * @returns the buffer
  124642. */
  124643. getGBuffer(): MultiRenderTarget;
  124644. /**
  124645. * Gets the number of samples used to render the buffer (anti aliasing).
  124646. */
  124647. /**
  124648. * Sets the number of samples used to render the buffer (anti aliasing).
  124649. */
  124650. samples: number;
  124651. /**
  124652. * Disposes the renderer and frees up associated resources.
  124653. */
  124654. dispose(): void;
  124655. protected _createRenderTargets(): void;
  124656. private _copyBonesTransformationMatrices;
  124657. }
  124658. }
  124659. declare module BABYLON {
  124660. interface Scene {
  124661. /** @hidden (Backing field) */
  124662. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124663. /**
  124664. * Gets or Sets the current geometry buffer associated to the scene.
  124665. */
  124666. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124667. /**
  124668. * Enables a GeometryBufferRender and associates it with the scene
  124669. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  124670. * @returns the GeometryBufferRenderer
  124671. */
  124672. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  124673. /**
  124674. * Disables the GeometryBufferRender associated with the scene
  124675. */
  124676. disableGeometryBufferRenderer(): void;
  124677. }
  124678. /**
  124679. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  124680. * in several rendering techniques.
  124681. */
  124682. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  124683. /**
  124684. * The component name helpful to identify the component in the list of scene components.
  124685. */
  124686. readonly name: string;
  124687. /**
  124688. * The scene the component belongs to.
  124689. */
  124690. scene: Scene;
  124691. /**
  124692. * Creates a new instance of the component for the given scene
  124693. * @param scene Defines the scene to register the component in
  124694. */
  124695. constructor(scene: Scene);
  124696. /**
  124697. * Registers the component in a given scene
  124698. */
  124699. register(): void;
  124700. /**
  124701. * Rebuilds the elements related to this component in case of
  124702. * context lost for instance.
  124703. */
  124704. rebuild(): void;
  124705. /**
  124706. * Disposes the component and the associated ressources
  124707. */
  124708. dispose(): void;
  124709. private _gatherRenderTargets;
  124710. }
  124711. }
  124712. declare module BABYLON {
  124713. /** @hidden */
  124714. export var motionBlurPixelShader: {
  124715. name: string;
  124716. shader: string;
  124717. };
  124718. }
  124719. declare module BABYLON {
  124720. /**
  124721. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  124722. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  124723. * As an example, all you have to do is to create the post-process:
  124724. * var mb = new BABYLON.MotionBlurPostProcess(
  124725. * 'mb', // The name of the effect.
  124726. * scene, // The scene containing the objects to blur according to their velocity.
  124727. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  124728. * camera // The camera to apply the render pass to.
  124729. * );
  124730. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  124731. */
  124732. export class MotionBlurPostProcess extends PostProcess {
  124733. /**
  124734. * Defines how much the image is blurred by the movement. Default value is equal to 1
  124735. */
  124736. motionStrength: number;
  124737. /**
  124738. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  124739. */
  124740. /**
  124741. * Sets the number of iterations to be used for motion blur quality
  124742. */
  124743. motionBlurSamples: number;
  124744. private _motionBlurSamples;
  124745. private _geometryBufferRenderer;
  124746. /**
  124747. * Creates a new instance MotionBlurPostProcess
  124748. * @param name The name of the effect.
  124749. * @param scene The scene containing the objects to blur according to their velocity.
  124750. * @param options The required width/height ratio to downsize to before computing the render pass.
  124751. * @param camera The camera to apply the render pass to.
  124752. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124753. * @param engine The engine which the post process will be applied. (default: current engine)
  124754. * @param reusable If the post process can be reused on the same frame. (default: false)
  124755. * @param textureType Type of textures used when performing the post process. (default: 0)
  124756. * @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)
  124757. */
  124758. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124759. /**
  124760. * Excludes the given skinned mesh from computing bones velocities.
  124761. * 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.
  124762. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  124763. */
  124764. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124765. /**
  124766. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  124767. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  124768. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  124769. */
  124770. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124771. /**
  124772. * Disposes the post process.
  124773. * @param camera The camera to dispose the post process on.
  124774. */
  124775. dispose(camera?: Camera): void;
  124776. }
  124777. }
  124778. declare module BABYLON {
  124779. /** @hidden */
  124780. export var refractionPixelShader: {
  124781. name: string;
  124782. shader: string;
  124783. };
  124784. }
  124785. declare module BABYLON {
  124786. /**
  124787. * Post process which applies a refractin texture
  124788. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124789. */
  124790. export class RefractionPostProcess extends PostProcess {
  124791. /** the base color of the refraction (used to taint the rendering) */
  124792. color: Color3;
  124793. /** simulated refraction depth */
  124794. depth: number;
  124795. /** the coefficient of the base color (0 to remove base color tainting) */
  124796. colorLevel: number;
  124797. private _refTexture;
  124798. private _ownRefractionTexture;
  124799. /**
  124800. * Gets or sets the refraction texture
  124801. * Please note that you are responsible for disposing the texture if you set it manually
  124802. */
  124803. refractionTexture: Texture;
  124804. /**
  124805. * Initializes the RefractionPostProcess
  124806. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124807. * @param name The name of the effect.
  124808. * @param refractionTextureUrl Url of the refraction texture to use
  124809. * @param color the base color of the refraction (used to taint the rendering)
  124810. * @param depth simulated refraction depth
  124811. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  124812. * @param camera The camera to apply the render pass to.
  124813. * @param options The required width/height ratio to downsize to before computing the render pass.
  124814. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124815. * @param engine The engine which the post process will be applied. (default: current engine)
  124816. * @param reusable If the post process can be reused on the same frame. (default: false)
  124817. */
  124818. constructor(name: string, refractionTextureUrl: string,
  124819. /** the base color of the refraction (used to taint the rendering) */
  124820. color: Color3,
  124821. /** simulated refraction depth */
  124822. depth: number,
  124823. /** the coefficient of the base color (0 to remove base color tainting) */
  124824. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124825. /**
  124826. * Disposes of the post process
  124827. * @param camera Camera to dispose post process on
  124828. */
  124829. dispose(camera: Camera): void;
  124830. }
  124831. }
  124832. declare module BABYLON {
  124833. /** @hidden */
  124834. export var sharpenPixelShader: {
  124835. name: string;
  124836. shader: string;
  124837. };
  124838. }
  124839. declare module BABYLON {
  124840. /**
  124841. * The SharpenPostProcess applies a sharpen kernel to every pixel
  124842. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124843. */
  124844. export class SharpenPostProcess extends PostProcess {
  124845. /**
  124846. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  124847. */
  124848. colorAmount: number;
  124849. /**
  124850. * How much sharpness should be applied (default: 0.3)
  124851. */
  124852. edgeAmount: number;
  124853. /**
  124854. * Creates a new instance ConvolutionPostProcess
  124855. * @param name The name of the effect.
  124856. * @param options The required width/height ratio to downsize to before computing the render pass.
  124857. * @param camera The camera to apply the render pass to.
  124858. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124859. * @param engine The engine which the post process will be applied. (default: current engine)
  124860. * @param reusable If the post process can be reused on the same frame. (default: false)
  124861. * @param textureType Type of textures used when performing the post process. (default: 0)
  124862. * @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)
  124863. */
  124864. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124865. }
  124866. }
  124867. declare module BABYLON {
  124868. /**
  124869. * PostProcessRenderPipeline
  124870. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124871. */
  124872. export class PostProcessRenderPipeline {
  124873. private engine;
  124874. private _renderEffects;
  124875. private _renderEffectsForIsolatedPass;
  124876. /**
  124877. * List of inspectable custom properties (used by the Inspector)
  124878. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  124879. */
  124880. inspectableCustomProperties: IInspectable[];
  124881. /**
  124882. * @hidden
  124883. */
  124884. protected _cameras: Camera[];
  124885. /** @hidden */
  124886. _name: string;
  124887. /**
  124888. * Gets pipeline name
  124889. */
  124890. readonly name: string;
  124891. /**
  124892. * Initializes a PostProcessRenderPipeline
  124893. * @param engine engine to add the pipeline to
  124894. * @param name name of the pipeline
  124895. */
  124896. constructor(engine: Engine, name: string);
  124897. /**
  124898. * Gets the class name
  124899. * @returns "PostProcessRenderPipeline"
  124900. */
  124901. getClassName(): string;
  124902. /**
  124903. * If all the render effects in the pipeline are supported
  124904. */
  124905. readonly isSupported: boolean;
  124906. /**
  124907. * Adds an effect to the pipeline
  124908. * @param renderEffect the effect to add
  124909. */
  124910. addEffect(renderEffect: PostProcessRenderEffect): void;
  124911. /** @hidden */
  124912. _rebuild(): void;
  124913. /** @hidden */
  124914. _enableEffect(renderEffectName: string, cameras: Camera): void;
  124915. /** @hidden */
  124916. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  124917. /** @hidden */
  124918. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124919. /** @hidden */
  124920. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124921. /** @hidden */
  124922. _attachCameras(cameras: Camera, unique: boolean): void;
  124923. /** @hidden */
  124924. _attachCameras(cameras: Camera[], unique: boolean): void;
  124925. /** @hidden */
  124926. _detachCameras(cameras: Camera): void;
  124927. /** @hidden */
  124928. _detachCameras(cameras: Nullable<Camera[]>): void;
  124929. /** @hidden */
  124930. _update(): void;
  124931. /** @hidden */
  124932. _reset(): void;
  124933. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  124934. /**
  124935. * Disposes of the pipeline
  124936. */
  124937. dispose(): void;
  124938. }
  124939. }
  124940. declare module BABYLON {
  124941. /**
  124942. * PostProcessRenderPipelineManager class
  124943. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124944. */
  124945. export class PostProcessRenderPipelineManager {
  124946. private _renderPipelines;
  124947. /**
  124948. * Initializes a PostProcessRenderPipelineManager
  124949. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124950. */
  124951. constructor();
  124952. /**
  124953. * Gets the list of supported render pipelines
  124954. */
  124955. readonly supportedPipelines: PostProcessRenderPipeline[];
  124956. /**
  124957. * Adds a pipeline to the manager
  124958. * @param renderPipeline The pipeline to add
  124959. */
  124960. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  124961. /**
  124962. * Attaches a camera to the pipeline
  124963. * @param renderPipelineName The name of the pipeline to attach to
  124964. * @param cameras the camera to attach
  124965. * @param unique if the camera can be attached multiple times to the pipeline
  124966. */
  124967. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  124968. /**
  124969. * Detaches a camera from the pipeline
  124970. * @param renderPipelineName The name of the pipeline to detach from
  124971. * @param cameras the camera to detach
  124972. */
  124973. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  124974. /**
  124975. * Enables an effect by name on a pipeline
  124976. * @param renderPipelineName the name of the pipeline to enable the effect in
  124977. * @param renderEffectName the name of the effect to enable
  124978. * @param cameras the cameras that the effect should be enabled on
  124979. */
  124980. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  124981. /**
  124982. * Disables an effect by name on a pipeline
  124983. * @param renderPipelineName the name of the pipeline to disable the effect in
  124984. * @param renderEffectName the name of the effect to disable
  124985. * @param cameras the cameras that the effect should be disabled on
  124986. */
  124987. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  124988. /**
  124989. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  124990. */
  124991. update(): void;
  124992. /** @hidden */
  124993. _rebuild(): void;
  124994. /**
  124995. * Disposes of the manager and pipelines
  124996. */
  124997. dispose(): void;
  124998. }
  124999. }
  125000. declare module BABYLON {
  125001. interface Scene {
  125002. /** @hidden (Backing field) */
  125003. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  125004. /**
  125005. * Gets the postprocess render pipeline manager
  125006. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125007. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  125008. */
  125009. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  125010. }
  125011. /**
  125012. * Defines the Render Pipeline scene component responsible to rendering pipelines
  125013. */
  125014. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  125015. /**
  125016. * The component name helpfull to identify the component in the list of scene components.
  125017. */
  125018. readonly name: string;
  125019. /**
  125020. * The scene the component belongs to.
  125021. */
  125022. scene: Scene;
  125023. /**
  125024. * Creates a new instance of the component for the given scene
  125025. * @param scene Defines the scene to register the component in
  125026. */
  125027. constructor(scene: Scene);
  125028. /**
  125029. * Registers the component in a given scene
  125030. */
  125031. register(): void;
  125032. /**
  125033. * Rebuilds the elements related to this component in case of
  125034. * context lost for instance.
  125035. */
  125036. rebuild(): void;
  125037. /**
  125038. * Disposes the component and the associated ressources
  125039. */
  125040. dispose(): void;
  125041. private _gatherRenderTargets;
  125042. }
  125043. }
  125044. declare module BABYLON {
  125045. /**
  125046. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  125047. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  125048. */
  125049. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  125050. private _scene;
  125051. private _camerasToBeAttached;
  125052. /**
  125053. * ID of the sharpen post process,
  125054. */
  125055. private readonly SharpenPostProcessId;
  125056. /**
  125057. * @ignore
  125058. * ID of the image processing post process;
  125059. */
  125060. readonly ImageProcessingPostProcessId: string;
  125061. /**
  125062. * @ignore
  125063. * ID of the Fast Approximate Anti-Aliasing post process;
  125064. */
  125065. readonly FxaaPostProcessId: string;
  125066. /**
  125067. * ID of the chromatic aberration post process,
  125068. */
  125069. private readonly ChromaticAberrationPostProcessId;
  125070. /**
  125071. * ID of the grain post process
  125072. */
  125073. private readonly GrainPostProcessId;
  125074. /**
  125075. * Sharpen post process which will apply a sharpen convolution to enhance edges
  125076. */
  125077. sharpen: SharpenPostProcess;
  125078. private _sharpenEffect;
  125079. private bloom;
  125080. /**
  125081. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  125082. */
  125083. depthOfField: DepthOfFieldEffect;
  125084. /**
  125085. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  125086. */
  125087. fxaa: FxaaPostProcess;
  125088. /**
  125089. * Image post processing pass used to perform operations such as tone mapping or color grading.
  125090. */
  125091. imageProcessing: ImageProcessingPostProcess;
  125092. /**
  125093. * Chromatic aberration post process which will shift rgb colors in the image
  125094. */
  125095. chromaticAberration: ChromaticAberrationPostProcess;
  125096. private _chromaticAberrationEffect;
  125097. /**
  125098. * Grain post process which add noise to the image
  125099. */
  125100. grain: GrainPostProcess;
  125101. private _grainEffect;
  125102. /**
  125103. * Glow post process which adds a glow to emissive areas of the image
  125104. */
  125105. private _glowLayer;
  125106. /**
  125107. * Animations which can be used to tweak settings over a period of time
  125108. */
  125109. animations: Animation[];
  125110. private _imageProcessingConfigurationObserver;
  125111. private _sharpenEnabled;
  125112. private _bloomEnabled;
  125113. private _depthOfFieldEnabled;
  125114. private _depthOfFieldBlurLevel;
  125115. private _fxaaEnabled;
  125116. private _imageProcessingEnabled;
  125117. private _defaultPipelineTextureType;
  125118. private _bloomScale;
  125119. private _chromaticAberrationEnabled;
  125120. private _grainEnabled;
  125121. private _buildAllowed;
  125122. /**
  125123. * Gets active scene
  125124. */
  125125. readonly scene: Scene;
  125126. /**
  125127. * Enable or disable the sharpen process from the pipeline
  125128. */
  125129. sharpenEnabled: boolean;
  125130. private _resizeObserver;
  125131. private _hardwareScaleLevel;
  125132. private _bloomKernel;
  125133. /**
  125134. * Specifies the size of the bloom blur kernel, relative to the final output size
  125135. */
  125136. bloomKernel: number;
  125137. /**
  125138. * Specifies the weight of the bloom in the final rendering
  125139. */
  125140. private _bloomWeight;
  125141. /**
  125142. * Specifies the luma threshold for the area that will be blurred by the bloom
  125143. */
  125144. private _bloomThreshold;
  125145. private _hdr;
  125146. /**
  125147. * The strength of the bloom.
  125148. */
  125149. bloomWeight: number;
  125150. /**
  125151. * The strength of the bloom.
  125152. */
  125153. bloomThreshold: number;
  125154. /**
  125155. * The scale of the bloom, lower value will provide better performance.
  125156. */
  125157. bloomScale: number;
  125158. /**
  125159. * Enable or disable the bloom from the pipeline
  125160. */
  125161. bloomEnabled: boolean;
  125162. private _rebuildBloom;
  125163. /**
  125164. * If the depth of field is enabled.
  125165. */
  125166. depthOfFieldEnabled: boolean;
  125167. /**
  125168. * Blur level of the depth of field effect. (Higher blur will effect performance)
  125169. */
  125170. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  125171. /**
  125172. * If the anti aliasing is enabled.
  125173. */
  125174. fxaaEnabled: boolean;
  125175. private _samples;
  125176. /**
  125177. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  125178. */
  125179. samples: number;
  125180. /**
  125181. * If image processing is enabled.
  125182. */
  125183. imageProcessingEnabled: boolean;
  125184. /**
  125185. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  125186. */
  125187. glowLayerEnabled: boolean;
  125188. /**
  125189. * Gets the glow layer (or null if not defined)
  125190. */
  125191. readonly glowLayer: Nullable<GlowLayer>;
  125192. /**
  125193. * Enable or disable the chromaticAberration process from the pipeline
  125194. */
  125195. chromaticAberrationEnabled: boolean;
  125196. /**
  125197. * Enable or disable the grain process from the pipeline
  125198. */
  125199. grainEnabled: boolean;
  125200. /**
  125201. * @constructor
  125202. * @param name - The rendering pipeline name (default: "")
  125203. * @param hdr - If high dynamic range textures should be used (default: true)
  125204. * @param scene - The scene linked to this pipeline (default: the last created scene)
  125205. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  125206. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  125207. */
  125208. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  125209. /**
  125210. * Get the class name
  125211. * @returns "DefaultRenderingPipeline"
  125212. */
  125213. getClassName(): string;
  125214. /**
  125215. * Force the compilation of the entire pipeline.
  125216. */
  125217. prepare(): void;
  125218. private _hasCleared;
  125219. private _prevPostProcess;
  125220. private _prevPrevPostProcess;
  125221. private _setAutoClearAndTextureSharing;
  125222. private _depthOfFieldSceneObserver;
  125223. private _buildPipeline;
  125224. private _disposePostProcesses;
  125225. /**
  125226. * Adds a camera to the pipeline
  125227. * @param camera the camera to be added
  125228. */
  125229. addCamera(camera: Camera): void;
  125230. /**
  125231. * Removes a camera from the pipeline
  125232. * @param camera the camera to remove
  125233. */
  125234. removeCamera(camera: Camera): void;
  125235. /**
  125236. * Dispose of the pipeline and stop all post processes
  125237. */
  125238. dispose(): void;
  125239. /**
  125240. * Serialize the rendering pipeline (Used when exporting)
  125241. * @returns the serialized object
  125242. */
  125243. serialize(): any;
  125244. /**
  125245. * Parse the serialized pipeline
  125246. * @param source Source pipeline.
  125247. * @param scene The scene to load the pipeline to.
  125248. * @param rootUrl The URL of the serialized pipeline.
  125249. * @returns An instantiated pipeline from the serialized object.
  125250. */
  125251. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  125252. }
  125253. }
  125254. declare module BABYLON {
  125255. /** @hidden */
  125256. export var lensHighlightsPixelShader: {
  125257. name: string;
  125258. shader: string;
  125259. };
  125260. }
  125261. declare module BABYLON {
  125262. /** @hidden */
  125263. export var depthOfFieldPixelShader: {
  125264. name: string;
  125265. shader: string;
  125266. };
  125267. }
  125268. declare module BABYLON {
  125269. /**
  125270. * BABYLON.JS Chromatic Aberration GLSL Shader
  125271. * Author: Olivier Guyot
  125272. * Separates very slightly R, G and B colors on the edges of the screen
  125273. * Inspired by Francois Tarlier & Martins Upitis
  125274. */
  125275. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  125276. /**
  125277. * @ignore
  125278. * The chromatic aberration PostProcess id in the pipeline
  125279. */
  125280. LensChromaticAberrationEffect: string;
  125281. /**
  125282. * @ignore
  125283. * The highlights enhancing PostProcess id in the pipeline
  125284. */
  125285. HighlightsEnhancingEffect: string;
  125286. /**
  125287. * @ignore
  125288. * The depth-of-field PostProcess id in the pipeline
  125289. */
  125290. LensDepthOfFieldEffect: string;
  125291. private _scene;
  125292. private _depthTexture;
  125293. private _grainTexture;
  125294. private _chromaticAberrationPostProcess;
  125295. private _highlightsPostProcess;
  125296. private _depthOfFieldPostProcess;
  125297. private _edgeBlur;
  125298. private _grainAmount;
  125299. private _chromaticAberration;
  125300. private _distortion;
  125301. private _highlightsGain;
  125302. private _highlightsThreshold;
  125303. private _dofDistance;
  125304. private _dofAperture;
  125305. private _dofDarken;
  125306. private _dofPentagon;
  125307. private _blurNoise;
  125308. /**
  125309. * @constructor
  125310. *
  125311. * Effect parameters are as follow:
  125312. * {
  125313. * chromatic_aberration: number; // from 0 to x (1 for realism)
  125314. * edge_blur: number; // from 0 to x (1 for realism)
  125315. * distortion: number; // from 0 to x (1 for realism)
  125316. * grain_amount: number; // from 0 to 1
  125317. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  125318. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  125319. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  125320. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  125321. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  125322. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  125323. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  125324. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  125325. * }
  125326. * Note: if an effect parameter is unset, effect is disabled
  125327. *
  125328. * @param name The rendering pipeline name
  125329. * @param parameters - An object containing all parameters (see above)
  125330. * @param scene The scene linked to this pipeline
  125331. * @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)
  125332. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125333. */
  125334. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  125335. /**
  125336. * Get the class name
  125337. * @returns "LensRenderingPipeline"
  125338. */
  125339. getClassName(): string;
  125340. /**
  125341. * Gets associated scene
  125342. */
  125343. readonly scene: Scene;
  125344. /**
  125345. * Gets or sets the edge blur
  125346. */
  125347. edgeBlur: number;
  125348. /**
  125349. * Gets or sets the grain amount
  125350. */
  125351. grainAmount: number;
  125352. /**
  125353. * Gets or sets the chromatic aberration amount
  125354. */
  125355. chromaticAberration: number;
  125356. /**
  125357. * Gets or sets the depth of field aperture
  125358. */
  125359. dofAperture: number;
  125360. /**
  125361. * Gets or sets the edge distortion
  125362. */
  125363. edgeDistortion: number;
  125364. /**
  125365. * Gets or sets the depth of field distortion
  125366. */
  125367. dofDistortion: number;
  125368. /**
  125369. * Gets or sets the darken out of focus amount
  125370. */
  125371. darkenOutOfFocus: number;
  125372. /**
  125373. * Gets or sets a boolean indicating if blur noise is enabled
  125374. */
  125375. blurNoise: boolean;
  125376. /**
  125377. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  125378. */
  125379. pentagonBokeh: boolean;
  125380. /**
  125381. * Gets or sets the highlight grain amount
  125382. */
  125383. highlightsGain: number;
  125384. /**
  125385. * Gets or sets the highlight threshold
  125386. */
  125387. highlightsThreshold: number;
  125388. /**
  125389. * Sets the amount of blur at the edges
  125390. * @param amount blur amount
  125391. */
  125392. setEdgeBlur(amount: number): void;
  125393. /**
  125394. * Sets edge blur to 0
  125395. */
  125396. disableEdgeBlur(): void;
  125397. /**
  125398. * Sets the amout of grain
  125399. * @param amount Amount of grain
  125400. */
  125401. setGrainAmount(amount: number): void;
  125402. /**
  125403. * Set grain amount to 0
  125404. */
  125405. disableGrain(): void;
  125406. /**
  125407. * Sets the chromatic aberration amount
  125408. * @param amount amount of chromatic aberration
  125409. */
  125410. setChromaticAberration(amount: number): void;
  125411. /**
  125412. * Sets chromatic aberration amount to 0
  125413. */
  125414. disableChromaticAberration(): void;
  125415. /**
  125416. * Sets the EdgeDistortion amount
  125417. * @param amount amount of EdgeDistortion
  125418. */
  125419. setEdgeDistortion(amount: number): void;
  125420. /**
  125421. * Sets edge distortion to 0
  125422. */
  125423. disableEdgeDistortion(): void;
  125424. /**
  125425. * Sets the FocusDistance amount
  125426. * @param amount amount of FocusDistance
  125427. */
  125428. setFocusDistance(amount: number): void;
  125429. /**
  125430. * Disables depth of field
  125431. */
  125432. disableDepthOfField(): void;
  125433. /**
  125434. * Sets the Aperture amount
  125435. * @param amount amount of Aperture
  125436. */
  125437. setAperture(amount: number): void;
  125438. /**
  125439. * Sets the DarkenOutOfFocus amount
  125440. * @param amount amount of DarkenOutOfFocus
  125441. */
  125442. setDarkenOutOfFocus(amount: number): void;
  125443. private _pentagonBokehIsEnabled;
  125444. /**
  125445. * Creates a pentagon bokeh effect
  125446. */
  125447. enablePentagonBokeh(): void;
  125448. /**
  125449. * Disables the pentagon bokeh effect
  125450. */
  125451. disablePentagonBokeh(): void;
  125452. /**
  125453. * Enables noise blur
  125454. */
  125455. enableNoiseBlur(): void;
  125456. /**
  125457. * Disables noise blur
  125458. */
  125459. disableNoiseBlur(): void;
  125460. /**
  125461. * Sets the HighlightsGain amount
  125462. * @param amount amount of HighlightsGain
  125463. */
  125464. setHighlightsGain(amount: number): void;
  125465. /**
  125466. * Sets the HighlightsThreshold amount
  125467. * @param amount amount of HighlightsThreshold
  125468. */
  125469. setHighlightsThreshold(amount: number): void;
  125470. /**
  125471. * Disables highlights
  125472. */
  125473. disableHighlights(): void;
  125474. /**
  125475. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  125476. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  125477. */
  125478. dispose(disableDepthRender?: boolean): void;
  125479. private _createChromaticAberrationPostProcess;
  125480. private _createHighlightsPostProcess;
  125481. private _createDepthOfFieldPostProcess;
  125482. private _createGrainTexture;
  125483. }
  125484. }
  125485. declare module BABYLON {
  125486. /** @hidden */
  125487. export var ssao2PixelShader: {
  125488. name: string;
  125489. shader: string;
  125490. };
  125491. }
  125492. declare module BABYLON {
  125493. /** @hidden */
  125494. export var ssaoCombinePixelShader: {
  125495. name: string;
  125496. shader: string;
  125497. };
  125498. }
  125499. declare module BABYLON {
  125500. /**
  125501. * Render pipeline to produce ssao effect
  125502. */
  125503. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  125504. /**
  125505. * @ignore
  125506. * The PassPostProcess id in the pipeline that contains the original scene color
  125507. */
  125508. SSAOOriginalSceneColorEffect: string;
  125509. /**
  125510. * @ignore
  125511. * The SSAO PostProcess id in the pipeline
  125512. */
  125513. SSAORenderEffect: string;
  125514. /**
  125515. * @ignore
  125516. * The horizontal blur PostProcess id in the pipeline
  125517. */
  125518. SSAOBlurHRenderEffect: string;
  125519. /**
  125520. * @ignore
  125521. * The vertical blur PostProcess id in the pipeline
  125522. */
  125523. SSAOBlurVRenderEffect: string;
  125524. /**
  125525. * @ignore
  125526. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125527. */
  125528. SSAOCombineRenderEffect: string;
  125529. /**
  125530. * The output strength of the SSAO post-process. Default value is 1.0.
  125531. */
  125532. totalStrength: number;
  125533. /**
  125534. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  125535. */
  125536. maxZ: number;
  125537. /**
  125538. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  125539. */
  125540. minZAspect: number;
  125541. private _samples;
  125542. /**
  125543. * Number of samples used for the SSAO calculations. Default value is 8
  125544. */
  125545. samples: number;
  125546. private _textureSamples;
  125547. /**
  125548. * Number of samples to use for antialiasing
  125549. */
  125550. textureSamples: number;
  125551. /**
  125552. * Ratio object used for SSAO ratio and blur ratio
  125553. */
  125554. private _ratio;
  125555. /**
  125556. * Dynamically generated sphere sampler.
  125557. */
  125558. private _sampleSphere;
  125559. /**
  125560. * Blur filter offsets
  125561. */
  125562. private _samplerOffsets;
  125563. private _expensiveBlur;
  125564. /**
  125565. * If bilateral blur should be used
  125566. */
  125567. expensiveBlur: boolean;
  125568. /**
  125569. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  125570. */
  125571. radius: number;
  125572. /**
  125573. * The base color of the SSAO post-process
  125574. * The final result is "base + ssao" between [0, 1]
  125575. */
  125576. base: number;
  125577. /**
  125578. * Support test.
  125579. */
  125580. static readonly IsSupported: boolean;
  125581. private _scene;
  125582. private _depthTexture;
  125583. private _normalTexture;
  125584. private _randomTexture;
  125585. private _originalColorPostProcess;
  125586. private _ssaoPostProcess;
  125587. private _blurHPostProcess;
  125588. private _blurVPostProcess;
  125589. private _ssaoCombinePostProcess;
  125590. private _firstUpdate;
  125591. /**
  125592. * Gets active scene
  125593. */
  125594. readonly scene: Scene;
  125595. /**
  125596. * @constructor
  125597. * @param name The rendering pipeline name
  125598. * @param scene The scene linked to this pipeline
  125599. * @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 }
  125600. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125601. */
  125602. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125603. /**
  125604. * Get the class name
  125605. * @returns "SSAO2RenderingPipeline"
  125606. */
  125607. getClassName(): string;
  125608. /**
  125609. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125610. */
  125611. dispose(disableGeometryBufferRenderer?: boolean): void;
  125612. private _createBlurPostProcess;
  125613. /** @hidden */
  125614. _rebuild(): void;
  125615. private _bits;
  125616. private _radicalInverse_VdC;
  125617. private _hammersley;
  125618. private _hemisphereSample_uniform;
  125619. private _generateHemisphere;
  125620. private _createSSAOPostProcess;
  125621. private _createSSAOCombinePostProcess;
  125622. private _createRandomTexture;
  125623. /**
  125624. * Serialize the rendering pipeline (Used when exporting)
  125625. * @returns the serialized object
  125626. */
  125627. serialize(): any;
  125628. /**
  125629. * Parse the serialized pipeline
  125630. * @param source Source pipeline.
  125631. * @param scene The scene to load the pipeline to.
  125632. * @param rootUrl The URL of the serialized pipeline.
  125633. * @returns An instantiated pipeline from the serialized object.
  125634. */
  125635. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  125636. }
  125637. }
  125638. declare module BABYLON {
  125639. /** @hidden */
  125640. export var ssaoPixelShader: {
  125641. name: string;
  125642. shader: string;
  125643. };
  125644. }
  125645. declare module BABYLON {
  125646. /**
  125647. * Render pipeline to produce ssao effect
  125648. */
  125649. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  125650. /**
  125651. * @ignore
  125652. * The PassPostProcess id in the pipeline that contains the original scene color
  125653. */
  125654. SSAOOriginalSceneColorEffect: string;
  125655. /**
  125656. * @ignore
  125657. * The SSAO PostProcess id in the pipeline
  125658. */
  125659. SSAORenderEffect: string;
  125660. /**
  125661. * @ignore
  125662. * The horizontal blur PostProcess id in the pipeline
  125663. */
  125664. SSAOBlurHRenderEffect: string;
  125665. /**
  125666. * @ignore
  125667. * The vertical blur PostProcess id in the pipeline
  125668. */
  125669. SSAOBlurVRenderEffect: string;
  125670. /**
  125671. * @ignore
  125672. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125673. */
  125674. SSAOCombineRenderEffect: string;
  125675. /**
  125676. * The output strength of the SSAO post-process. Default value is 1.0.
  125677. */
  125678. totalStrength: number;
  125679. /**
  125680. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  125681. */
  125682. radius: number;
  125683. /**
  125684. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  125685. * Must not be equal to fallOff and superior to fallOff.
  125686. * Default value is 0.0075
  125687. */
  125688. area: number;
  125689. /**
  125690. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  125691. * Must not be equal to area and inferior to area.
  125692. * Default value is 0.000001
  125693. */
  125694. fallOff: number;
  125695. /**
  125696. * The base color of the SSAO post-process
  125697. * The final result is "base + ssao" between [0, 1]
  125698. */
  125699. base: number;
  125700. private _scene;
  125701. private _depthTexture;
  125702. private _randomTexture;
  125703. private _originalColorPostProcess;
  125704. private _ssaoPostProcess;
  125705. private _blurHPostProcess;
  125706. private _blurVPostProcess;
  125707. private _ssaoCombinePostProcess;
  125708. private _firstUpdate;
  125709. /**
  125710. * Gets active scene
  125711. */
  125712. readonly scene: Scene;
  125713. /**
  125714. * @constructor
  125715. * @param name - The rendering pipeline name
  125716. * @param scene - The scene linked to this pipeline
  125717. * @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 }
  125718. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  125719. */
  125720. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125721. /**
  125722. * Get the class name
  125723. * @returns "SSAORenderingPipeline"
  125724. */
  125725. getClassName(): string;
  125726. /**
  125727. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125728. */
  125729. dispose(disableDepthRender?: boolean): void;
  125730. private _createBlurPostProcess;
  125731. /** @hidden */
  125732. _rebuild(): void;
  125733. private _createSSAOPostProcess;
  125734. private _createSSAOCombinePostProcess;
  125735. private _createRandomTexture;
  125736. }
  125737. }
  125738. declare module BABYLON {
  125739. /** @hidden */
  125740. export var standardPixelShader: {
  125741. name: string;
  125742. shader: string;
  125743. };
  125744. }
  125745. declare module BABYLON {
  125746. /**
  125747. * Standard rendering pipeline
  125748. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  125749. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  125750. */
  125751. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  125752. /**
  125753. * Public members
  125754. */
  125755. /**
  125756. * Post-process which contains the original scene color before the pipeline applies all the effects
  125757. */
  125758. originalPostProcess: Nullable<PostProcess>;
  125759. /**
  125760. * Post-process used to down scale an image x4
  125761. */
  125762. downSampleX4PostProcess: Nullable<PostProcess>;
  125763. /**
  125764. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  125765. */
  125766. brightPassPostProcess: Nullable<PostProcess>;
  125767. /**
  125768. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  125769. */
  125770. blurHPostProcesses: PostProcess[];
  125771. /**
  125772. * Post-process array storing all the vertical blur post-processes used by the pipeline
  125773. */
  125774. blurVPostProcesses: PostProcess[];
  125775. /**
  125776. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  125777. */
  125778. textureAdderPostProcess: Nullable<PostProcess>;
  125779. /**
  125780. * Post-process used to create volumetric lighting effect
  125781. */
  125782. volumetricLightPostProcess: Nullable<PostProcess>;
  125783. /**
  125784. * Post-process used to smooth the previous volumetric light post-process on the X axis
  125785. */
  125786. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  125787. /**
  125788. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  125789. */
  125790. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  125791. /**
  125792. * Post-process used to merge the volumetric light effect and the real scene color
  125793. */
  125794. volumetricLightMergePostProces: Nullable<PostProcess>;
  125795. /**
  125796. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  125797. */
  125798. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  125799. /**
  125800. * Base post-process used to calculate the average luminance of the final image for HDR
  125801. */
  125802. luminancePostProcess: Nullable<PostProcess>;
  125803. /**
  125804. * Post-processes used to create down sample post-processes in order to get
  125805. * the average luminance of the final image for HDR
  125806. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  125807. */
  125808. luminanceDownSamplePostProcesses: PostProcess[];
  125809. /**
  125810. * Post-process used to create a HDR effect (light adaptation)
  125811. */
  125812. hdrPostProcess: Nullable<PostProcess>;
  125813. /**
  125814. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  125815. */
  125816. textureAdderFinalPostProcess: Nullable<PostProcess>;
  125817. /**
  125818. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  125819. */
  125820. lensFlareFinalPostProcess: Nullable<PostProcess>;
  125821. /**
  125822. * Post-process used to merge the final HDR post-process and the real scene color
  125823. */
  125824. hdrFinalPostProcess: Nullable<PostProcess>;
  125825. /**
  125826. * Post-process used to create a lens flare effect
  125827. */
  125828. lensFlarePostProcess: Nullable<PostProcess>;
  125829. /**
  125830. * Post-process that merges the result of the lens flare post-process and the real scene color
  125831. */
  125832. lensFlareComposePostProcess: Nullable<PostProcess>;
  125833. /**
  125834. * Post-process used to create a motion blur effect
  125835. */
  125836. motionBlurPostProcess: Nullable<PostProcess>;
  125837. /**
  125838. * Post-process used to create a depth of field effect
  125839. */
  125840. depthOfFieldPostProcess: Nullable<PostProcess>;
  125841. /**
  125842. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  125843. */
  125844. fxaaPostProcess: Nullable<FxaaPostProcess>;
  125845. /**
  125846. * Represents the brightness threshold in order to configure the illuminated surfaces
  125847. */
  125848. brightThreshold: number;
  125849. /**
  125850. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  125851. */
  125852. blurWidth: number;
  125853. /**
  125854. * Sets if the blur for highlighted surfaces must be only horizontal
  125855. */
  125856. horizontalBlur: boolean;
  125857. /**
  125858. * Gets the overall exposure used by the pipeline
  125859. */
  125860. /**
  125861. * Sets the overall exposure used by the pipeline
  125862. */
  125863. exposure: number;
  125864. /**
  125865. * Texture used typically to simulate "dirty" on camera lens
  125866. */
  125867. lensTexture: Nullable<Texture>;
  125868. /**
  125869. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  125870. */
  125871. volumetricLightCoefficient: number;
  125872. /**
  125873. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  125874. */
  125875. volumetricLightPower: number;
  125876. /**
  125877. * Used the set the blur intensity to smooth the volumetric lights
  125878. */
  125879. volumetricLightBlurScale: number;
  125880. /**
  125881. * Light (spot or directional) used to generate the volumetric lights rays
  125882. * The source light must have a shadow generate so the pipeline can get its
  125883. * depth map
  125884. */
  125885. sourceLight: Nullable<SpotLight | DirectionalLight>;
  125886. /**
  125887. * For eye adaptation, represents the minimum luminance the eye can see
  125888. */
  125889. hdrMinimumLuminance: number;
  125890. /**
  125891. * For eye adaptation, represents the decrease luminance speed
  125892. */
  125893. hdrDecreaseRate: number;
  125894. /**
  125895. * For eye adaptation, represents the increase luminance speed
  125896. */
  125897. hdrIncreaseRate: number;
  125898. /**
  125899. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125900. */
  125901. /**
  125902. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125903. */
  125904. hdrAutoExposure: boolean;
  125905. /**
  125906. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  125907. */
  125908. lensColorTexture: Nullable<Texture>;
  125909. /**
  125910. * The overall strengh for the lens flare effect
  125911. */
  125912. lensFlareStrength: number;
  125913. /**
  125914. * Dispersion coefficient for lens flare ghosts
  125915. */
  125916. lensFlareGhostDispersal: number;
  125917. /**
  125918. * Main lens flare halo width
  125919. */
  125920. lensFlareHaloWidth: number;
  125921. /**
  125922. * Based on the lens distortion effect, defines how much the lens flare result
  125923. * is distorted
  125924. */
  125925. lensFlareDistortionStrength: number;
  125926. /**
  125927. * Configures the blur intensity used for for lens flare (halo)
  125928. */
  125929. lensFlareBlurWidth: number;
  125930. /**
  125931. * Lens star texture must be used to simulate rays on the flares and is available
  125932. * in the documentation
  125933. */
  125934. lensStarTexture: Nullable<Texture>;
  125935. /**
  125936. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  125937. * flare effect by taking account of the dirt texture
  125938. */
  125939. lensFlareDirtTexture: Nullable<Texture>;
  125940. /**
  125941. * Represents the focal length for the depth of field effect
  125942. */
  125943. depthOfFieldDistance: number;
  125944. /**
  125945. * Represents the blur intensity for the blurred part of the depth of field effect
  125946. */
  125947. depthOfFieldBlurWidth: number;
  125948. /**
  125949. * Gets how much the image is blurred by the movement while using the motion blur post-process
  125950. */
  125951. /**
  125952. * Sets how much the image is blurred by the movement while using the motion blur post-process
  125953. */
  125954. motionStrength: number;
  125955. /**
  125956. * Gets wether or not the motion blur post-process is object based or screen based.
  125957. */
  125958. /**
  125959. * Sets wether or not the motion blur post-process should be object based or screen based
  125960. */
  125961. objectBasedMotionBlur: boolean;
  125962. /**
  125963. * List of animations for the pipeline (IAnimatable implementation)
  125964. */
  125965. animations: Animation[];
  125966. /**
  125967. * Private members
  125968. */
  125969. private _scene;
  125970. private _currentDepthOfFieldSource;
  125971. private _basePostProcess;
  125972. private _fixedExposure;
  125973. private _currentExposure;
  125974. private _hdrAutoExposure;
  125975. private _hdrCurrentLuminance;
  125976. private _motionStrength;
  125977. private _isObjectBasedMotionBlur;
  125978. private _floatTextureType;
  125979. private _camerasToBeAttached;
  125980. private _ratio;
  125981. private _bloomEnabled;
  125982. private _depthOfFieldEnabled;
  125983. private _vlsEnabled;
  125984. private _lensFlareEnabled;
  125985. private _hdrEnabled;
  125986. private _motionBlurEnabled;
  125987. private _fxaaEnabled;
  125988. private _motionBlurSamples;
  125989. private _volumetricLightStepsCount;
  125990. private _samples;
  125991. /**
  125992. * @ignore
  125993. * Specifies if the bloom pipeline is enabled
  125994. */
  125995. BloomEnabled: boolean;
  125996. /**
  125997. * @ignore
  125998. * Specifies if the depth of field pipeline is enabed
  125999. */
  126000. DepthOfFieldEnabled: boolean;
  126001. /**
  126002. * @ignore
  126003. * Specifies if the lens flare pipeline is enabed
  126004. */
  126005. LensFlareEnabled: boolean;
  126006. /**
  126007. * @ignore
  126008. * Specifies if the HDR pipeline is enabled
  126009. */
  126010. HDREnabled: boolean;
  126011. /**
  126012. * @ignore
  126013. * Specifies if the volumetric lights scattering effect is enabled
  126014. */
  126015. VLSEnabled: boolean;
  126016. /**
  126017. * @ignore
  126018. * Specifies if the motion blur effect is enabled
  126019. */
  126020. MotionBlurEnabled: boolean;
  126021. /**
  126022. * Specifies if anti-aliasing is enabled
  126023. */
  126024. fxaaEnabled: boolean;
  126025. /**
  126026. * Specifies the number of steps used to calculate the volumetric lights
  126027. * Typically in interval [50, 200]
  126028. */
  126029. volumetricLightStepsCount: number;
  126030. /**
  126031. * Specifies the number of samples used for the motion blur effect
  126032. * Typically in interval [16, 64]
  126033. */
  126034. motionBlurSamples: number;
  126035. /**
  126036. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  126037. */
  126038. samples: number;
  126039. /**
  126040. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  126041. * @constructor
  126042. * @param name The rendering pipeline name
  126043. * @param scene The scene linked to this pipeline
  126044. * @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)
  126045. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  126046. * @param cameras The array of cameras that the rendering pipeline will be attached to
  126047. */
  126048. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  126049. private _buildPipeline;
  126050. private _createDownSampleX4PostProcess;
  126051. private _createBrightPassPostProcess;
  126052. private _createBlurPostProcesses;
  126053. private _createTextureAdderPostProcess;
  126054. private _createVolumetricLightPostProcess;
  126055. private _createLuminancePostProcesses;
  126056. private _createHdrPostProcess;
  126057. private _createLensFlarePostProcess;
  126058. private _createDepthOfFieldPostProcess;
  126059. private _createMotionBlurPostProcess;
  126060. private _getDepthTexture;
  126061. private _disposePostProcesses;
  126062. /**
  126063. * Dispose of the pipeline and stop all post processes
  126064. */
  126065. dispose(): void;
  126066. /**
  126067. * Serialize the rendering pipeline (Used when exporting)
  126068. * @returns the serialized object
  126069. */
  126070. serialize(): any;
  126071. /**
  126072. * Parse the serialized pipeline
  126073. * @param source Source pipeline.
  126074. * @param scene The scene to load the pipeline to.
  126075. * @param rootUrl The URL of the serialized pipeline.
  126076. * @returns An instantiated pipeline from the serialized object.
  126077. */
  126078. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  126079. /**
  126080. * Luminance steps
  126081. */
  126082. static LuminanceSteps: number;
  126083. }
  126084. }
  126085. declare module BABYLON {
  126086. /** @hidden */
  126087. export var tonemapPixelShader: {
  126088. name: string;
  126089. shader: string;
  126090. };
  126091. }
  126092. declare module BABYLON {
  126093. /** Defines operator used for tonemapping */
  126094. export enum TonemappingOperator {
  126095. /** Hable */
  126096. Hable = 0,
  126097. /** Reinhard */
  126098. Reinhard = 1,
  126099. /** HejiDawson */
  126100. HejiDawson = 2,
  126101. /** Photographic */
  126102. Photographic = 3
  126103. }
  126104. /**
  126105. * Defines a post process to apply tone mapping
  126106. */
  126107. export class TonemapPostProcess extends PostProcess {
  126108. private _operator;
  126109. /** Defines the required exposure adjustement */
  126110. exposureAdjustment: number;
  126111. /**
  126112. * Creates a new TonemapPostProcess
  126113. * @param name defines the name of the postprocess
  126114. * @param _operator defines the operator to use
  126115. * @param exposureAdjustment defines the required exposure adjustement
  126116. * @param camera defines the camera to use (can be null)
  126117. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  126118. * @param engine defines the hosting engine (can be ignore if camera is set)
  126119. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  126120. */
  126121. constructor(name: string, _operator: TonemappingOperator,
  126122. /** Defines the required exposure adjustement */
  126123. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  126124. }
  126125. }
  126126. declare module BABYLON {
  126127. /** @hidden */
  126128. export var depthVertexShader: {
  126129. name: string;
  126130. shader: string;
  126131. };
  126132. }
  126133. declare module BABYLON {
  126134. /** @hidden */
  126135. export var volumetricLightScatteringPixelShader: {
  126136. name: string;
  126137. shader: string;
  126138. };
  126139. }
  126140. declare module BABYLON {
  126141. /** @hidden */
  126142. export var volumetricLightScatteringPassVertexShader: {
  126143. name: string;
  126144. shader: string;
  126145. };
  126146. }
  126147. declare module BABYLON {
  126148. /** @hidden */
  126149. export var volumetricLightScatteringPassPixelShader: {
  126150. name: string;
  126151. shader: string;
  126152. };
  126153. }
  126154. declare module BABYLON {
  126155. /**
  126156. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  126157. */
  126158. export class VolumetricLightScatteringPostProcess extends PostProcess {
  126159. private _volumetricLightScatteringPass;
  126160. private _volumetricLightScatteringRTT;
  126161. private _viewPort;
  126162. private _screenCoordinates;
  126163. private _cachedDefines;
  126164. /**
  126165. * If not undefined, the mesh position is computed from the attached node position
  126166. */
  126167. attachedNode: {
  126168. position: Vector3;
  126169. };
  126170. /**
  126171. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  126172. */
  126173. customMeshPosition: Vector3;
  126174. /**
  126175. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  126176. */
  126177. useCustomMeshPosition: boolean;
  126178. /**
  126179. * If the post-process should inverse the light scattering direction
  126180. */
  126181. invert: boolean;
  126182. /**
  126183. * The internal mesh used by the post-process
  126184. */
  126185. mesh: Mesh;
  126186. /**
  126187. * @hidden
  126188. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  126189. */
  126190. useDiffuseColor: boolean;
  126191. /**
  126192. * Array containing the excluded meshes not rendered in the internal pass
  126193. */
  126194. excludedMeshes: AbstractMesh[];
  126195. /**
  126196. * Controls the overall intensity of the post-process
  126197. */
  126198. exposure: number;
  126199. /**
  126200. * Dissipates each sample's contribution in range [0, 1]
  126201. */
  126202. decay: number;
  126203. /**
  126204. * Controls the overall intensity of each sample
  126205. */
  126206. weight: number;
  126207. /**
  126208. * Controls the density of each sample
  126209. */
  126210. density: number;
  126211. /**
  126212. * @constructor
  126213. * @param name The post-process name
  126214. * @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)
  126215. * @param camera The camera that the post-process will be attached to
  126216. * @param mesh The mesh used to create the light scattering
  126217. * @param samples The post-process quality, default 100
  126218. * @param samplingModeThe post-process filtering mode
  126219. * @param engine The babylon engine
  126220. * @param reusable If the post-process is reusable
  126221. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  126222. */
  126223. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  126224. /**
  126225. * Returns the string "VolumetricLightScatteringPostProcess"
  126226. * @returns "VolumetricLightScatteringPostProcess"
  126227. */
  126228. getClassName(): string;
  126229. private _isReady;
  126230. /**
  126231. * Sets the new light position for light scattering effect
  126232. * @param position The new custom light position
  126233. */
  126234. setCustomMeshPosition(position: Vector3): void;
  126235. /**
  126236. * Returns the light position for light scattering effect
  126237. * @return Vector3 The custom light position
  126238. */
  126239. getCustomMeshPosition(): Vector3;
  126240. /**
  126241. * Disposes the internal assets and detaches the post-process from the camera
  126242. */
  126243. dispose(camera: Camera): void;
  126244. /**
  126245. * Returns the render target texture used by the post-process
  126246. * @return the render target texture used by the post-process
  126247. */
  126248. getPass(): RenderTargetTexture;
  126249. private _meshExcluded;
  126250. private _createPass;
  126251. private _updateMeshScreenCoordinates;
  126252. /**
  126253. * Creates a default mesh for the Volumeric Light Scattering post-process
  126254. * @param name The mesh name
  126255. * @param scene The scene where to create the mesh
  126256. * @return the default mesh
  126257. */
  126258. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  126259. }
  126260. }
  126261. declare module BABYLON {
  126262. interface Scene {
  126263. /** @hidden (Backing field) */
  126264. _boundingBoxRenderer: BoundingBoxRenderer;
  126265. /** @hidden (Backing field) */
  126266. _forceShowBoundingBoxes: boolean;
  126267. /**
  126268. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  126269. */
  126270. forceShowBoundingBoxes: boolean;
  126271. /**
  126272. * Gets the bounding box renderer associated with the scene
  126273. * @returns a BoundingBoxRenderer
  126274. */
  126275. getBoundingBoxRenderer(): BoundingBoxRenderer;
  126276. }
  126277. interface AbstractMesh {
  126278. /** @hidden (Backing field) */
  126279. _showBoundingBox: boolean;
  126280. /**
  126281. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  126282. */
  126283. showBoundingBox: boolean;
  126284. }
  126285. /**
  126286. * Component responsible of rendering the bounding box of the meshes in a scene.
  126287. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  126288. */
  126289. export class BoundingBoxRenderer implements ISceneComponent {
  126290. /**
  126291. * The component name helpfull to identify the component in the list of scene components.
  126292. */
  126293. readonly name: string;
  126294. /**
  126295. * The scene the component belongs to.
  126296. */
  126297. scene: Scene;
  126298. /**
  126299. * Color of the bounding box lines placed in front of an object
  126300. */
  126301. frontColor: Color3;
  126302. /**
  126303. * Color of the bounding box lines placed behind an object
  126304. */
  126305. backColor: Color3;
  126306. /**
  126307. * Defines if the renderer should show the back lines or not
  126308. */
  126309. showBackLines: boolean;
  126310. /**
  126311. * @hidden
  126312. */
  126313. renderList: SmartArray<BoundingBox>;
  126314. private _colorShader;
  126315. private _vertexBuffers;
  126316. private _indexBuffer;
  126317. private _fillIndexBuffer;
  126318. private _fillIndexData;
  126319. /**
  126320. * Instantiates a new bounding box renderer in a scene.
  126321. * @param scene the scene the renderer renders in
  126322. */
  126323. constructor(scene: Scene);
  126324. /**
  126325. * Registers the component in a given scene
  126326. */
  126327. register(): void;
  126328. private _evaluateSubMesh;
  126329. private _activeMesh;
  126330. private _prepareRessources;
  126331. private _createIndexBuffer;
  126332. /**
  126333. * Rebuilds the elements related to this component in case of
  126334. * context lost for instance.
  126335. */
  126336. rebuild(): void;
  126337. /**
  126338. * @hidden
  126339. */
  126340. reset(): void;
  126341. /**
  126342. * Render the bounding boxes of a specific rendering group
  126343. * @param renderingGroupId defines the rendering group to render
  126344. */
  126345. render(renderingGroupId: number): void;
  126346. /**
  126347. * In case of occlusion queries, we can render the occlusion bounding box through this method
  126348. * @param mesh Define the mesh to render the occlusion bounding box for
  126349. */
  126350. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  126351. /**
  126352. * Dispose and release the resources attached to this renderer.
  126353. */
  126354. dispose(): void;
  126355. }
  126356. }
  126357. declare module BABYLON {
  126358. /** @hidden */
  126359. export var depthPixelShader: {
  126360. name: string;
  126361. shader: string;
  126362. };
  126363. }
  126364. declare module BABYLON {
  126365. /**
  126366. * This represents a depth renderer in Babylon.
  126367. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  126368. */
  126369. export class DepthRenderer {
  126370. private _scene;
  126371. private _depthMap;
  126372. private _effect;
  126373. private readonly _storeNonLinearDepth;
  126374. private readonly _clearColor;
  126375. /** Get if the depth renderer is using packed depth or not */
  126376. readonly isPacked: boolean;
  126377. private _cachedDefines;
  126378. private _camera;
  126379. /**
  126380. * Specifiess that the depth renderer will only be used within
  126381. * the camera it is created for.
  126382. * This can help forcing its rendering during the camera processing.
  126383. */
  126384. useOnlyInActiveCamera: boolean;
  126385. /** @hidden */
  126386. static _SceneComponentInitialization: (scene: Scene) => void;
  126387. /**
  126388. * Instantiates a depth renderer
  126389. * @param scene The scene the renderer belongs to
  126390. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  126391. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  126392. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126393. */
  126394. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  126395. /**
  126396. * Creates the depth rendering effect and checks if the effect is ready.
  126397. * @param subMesh The submesh to be used to render the depth map of
  126398. * @param useInstances If multiple world instances should be used
  126399. * @returns if the depth renderer is ready to render the depth map
  126400. */
  126401. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126402. /**
  126403. * Gets the texture which the depth map will be written to.
  126404. * @returns The depth map texture
  126405. */
  126406. getDepthMap(): RenderTargetTexture;
  126407. /**
  126408. * Disposes of the depth renderer.
  126409. */
  126410. dispose(): void;
  126411. }
  126412. }
  126413. declare module BABYLON {
  126414. interface Scene {
  126415. /** @hidden (Backing field) */
  126416. _depthRenderer: {
  126417. [id: string]: DepthRenderer;
  126418. };
  126419. /**
  126420. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  126421. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  126422. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126423. * @returns the created depth renderer
  126424. */
  126425. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  126426. /**
  126427. * Disables a depth renderer for a given camera
  126428. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  126429. */
  126430. disableDepthRenderer(camera?: Nullable<Camera>): void;
  126431. }
  126432. /**
  126433. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  126434. * in several rendering techniques.
  126435. */
  126436. export class DepthRendererSceneComponent implements ISceneComponent {
  126437. /**
  126438. * The component name helpfull to identify the component in the list of scene components.
  126439. */
  126440. readonly name: string;
  126441. /**
  126442. * The scene the component belongs to.
  126443. */
  126444. scene: Scene;
  126445. /**
  126446. * Creates a new instance of the component for the given scene
  126447. * @param scene Defines the scene to register the component in
  126448. */
  126449. constructor(scene: Scene);
  126450. /**
  126451. * Registers the component in a given scene
  126452. */
  126453. register(): void;
  126454. /**
  126455. * Rebuilds the elements related to this component in case of
  126456. * context lost for instance.
  126457. */
  126458. rebuild(): void;
  126459. /**
  126460. * Disposes the component and the associated ressources
  126461. */
  126462. dispose(): void;
  126463. private _gatherRenderTargets;
  126464. private _gatherActiveCameraRenderTargets;
  126465. }
  126466. }
  126467. declare module BABYLON {
  126468. /** @hidden */
  126469. export var outlinePixelShader: {
  126470. name: string;
  126471. shader: string;
  126472. };
  126473. }
  126474. declare module BABYLON {
  126475. /** @hidden */
  126476. export var outlineVertexShader: {
  126477. name: string;
  126478. shader: string;
  126479. };
  126480. }
  126481. declare module BABYLON {
  126482. interface Scene {
  126483. /** @hidden */
  126484. _outlineRenderer: OutlineRenderer;
  126485. /**
  126486. * Gets the outline renderer associated with the scene
  126487. * @returns a OutlineRenderer
  126488. */
  126489. getOutlineRenderer(): OutlineRenderer;
  126490. }
  126491. interface AbstractMesh {
  126492. /** @hidden (Backing field) */
  126493. _renderOutline: boolean;
  126494. /**
  126495. * Gets or sets a boolean indicating if the outline must be rendered as well
  126496. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  126497. */
  126498. renderOutline: boolean;
  126499. /** @hidden (Backing field) */
  126500. _renderOverlay: boolean;
  126501. /**
  126502. * Gets or sets a boolean indicating if the overlay must be rendered as well
  126503. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  126504. */
  126505. renderOverlay: boolean;
  126506. }
  126507. /**
  126508. * This class is responsible to draw bothe outline/overlay of meshes.
  126509. * It should not be used directly but through the available method on mesh.
  126510. */
  126511. export class OutlineRenderer implements ISceneComponent {
  126512. /**
  126513. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  126514. */
  126515. private static _StencilReference;
  126516. /**
  126517. * The name of the component. Each component must have a unique name.
  126518. */
  126519. name: string;
  126520. /**
  126521. * The scene the component belongs to.
  126522. */
  126523. scene: Scene;
  126524. /**
  126525. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  126526. */
  126527. zOffset: number;
  126528. private _engine;
  126529. private _effect;
  126530. private _cachedDefines;
  126531. private _savedDepthWrite;
  126532. /**
  126533. * Instantiates a new outline renderer. (There could be only one per scene).
  126534. * @param scene Defines the scene it belongs to
  126535. */
  126536. constructor(scene: Scene);
  126537. /**
  126538. * Register the component to one instance of a scene.
  126539. */
  126540. register(): void;
  126541. /**
  126542. * Rebuilds the elements related to this component in case of
  126543. * context lost for instance.
  126544. */
  126545. rebuild(): void;
  126546. /**
  126547. * Disposes the component and the associated ressources.
  126548. */
  126549. dispose(): void;
  126550. /**
  126551. * Renders the outline in the canvas.
  126552. * @param subMesh Defines the sumesh to render
  126553. * @param batch Defines the batch of meshes in case of instances
  126554. * @param useOverlay Defines if the rendering is for the overlay or the outline
  126555. */
  126556. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  126557. /**
  126558. * Returns whether or not the outline renderer is ready for a given submesh.
  126559. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  126560. * @param subMesh Defines the submesh to check readyness for
  126561. * @param useInstances Defines wheter wee are trying to render instances or not
  126562. * @returns true if ready otherwise false
  126563. */
  126564. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126565. private _beforeRenderingMesh;
  126566. private _afterRenderingMesh;
  126567. }
  126568. }
  126569. declare module BABYLON {
  126570. /**
  126571. * Class used to manage multiple sprites of different sizes on the same spritesheet
  126572. * @see http://doc.babylonjs.com/babylon101/sprites
  126573. */
  126574. export class SpritePackedManager extends SpriteManager {
  126575. /** defines the packed manager's name */
  126576. name: string;
  126577. /**
  126578. * Creates a new sprite manager from a packed sprite sheet
  126579. * @param name defines the manager's name
  126580. * @param imgUrl defines the sprite sheet url
  126581. * @param capacity defines the maximum allowed number of sprites
  126582. * @param scene defines the hosting scene
  126583. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  126584. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  126585. * @param samplingMode defines the smapling mode to use with spritesheet
  126586. * @param fromPacked set to true; do not alter
  126587. */
  126588. constructor(
  126589. /** defines the packed manager's name */
  126590. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  126591. }
  126592. }
  126593. declare module BABYLON {
  126594. /**
  126595. * Defines the list of states available for a task inside a AssetsManager
  126596. */
  126597. export enum AssetTaskState {
  126598. /**
  126599. * Initialization
  126600. */
  126601. INIT = 0,
  126602. /**
  126603. * Running
  126604. */
  126605. RUNNING = 1,
  126606. /**
  126607. * Done
  126608. */
  126609. DONE = 2,
  126610. /**
  126611. * Error
  126612. */
  126613. ERROR = 3
  126614. }
  126615. /**
  126616. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  126617. */
  126618. export abstract class AbstractAssetTask {
  126619. /**
  126620. * Task name
  126621. */ name: string;
  126622. /**
  126623. * Callback called when the task is successful
  126624. */
  126625. onSuccess: (task: any) => void;
  126626. /**
  126627. * Callback called when the task is not successful
  126628. */
  126629. onError: (task: any, message?: string, exception?: any) => void;
  126630. /**
  126631. * Creates a new AssetsManager
  126632. * @param name defines the name of the task
  126633. */
  126634. constructor(
  126635. /**
  126636. * Task name
  126637. */ name: string);
  126638. private _isCompleted;
  126639. private _taskState;
  126640. private _errorObject;
  126641. /**
  126642. * Get if the task is completed
  126643. */
  126644. readonly isCompleted: boolean;
  126645. /**
  126646. * Gets the current state of the task
  126647. */
  126648. readonly taskState: AssetTaskState;
  126649. /**
  126650. * Gets the current error object (if task is in error)
  126651. */
  126652. readonly errorObject: {
  126653. message?: string;
  126654. exception?: any;
  126655. };
  126656. /**
  126657. * Internal only
  126658. * @hidden
  126659. */
  126660. _setErrorObject(message?: string, exception?: any): void;
  126661. /**
  126662. * Execute the current task
  126663. * @param scene defines the scene where you want your assets to be loaded
  126664. * @param onSuccess is a callback called when the task is successfully executed
  126665. * @param onError is a callback called if an error occurs
  126666. */
  126667. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126668. /**
  126669. * Execute the current task
  126670. * @param scene defines the scene where you want your assets to be loaded
  126671. * @param onSuccess is a callback called when the task is successfully executed
  126672. * @param onError is a callback called if an error occurs
  126673. */
  126674. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126675. /**
  126676. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  126677. * This can be used with failed tasks that have the reason for failure fixed.
  126678. */
  126679. reset(): void;
  126680. private onErrorCallback;
  126681. private onDoneCallback;
  126682. }
  126683. /**
  126684. * Define the interface used by progress events raised during assets loading
  126685. */
  126686. export interface IAssetsProgressEvent {
  126687. /**
  126688. * Defines the number of remaining tasks to process
  126689. */
  126690. remainingCount: number;
  126691. /**
  126692. * Defines the total number of tasks
  126693. */
  126694. totalCount: number;
  126695. /**
  126696. * Defines the task that was just processed
  126697. */
  126698. task: AbstractAssetTask;
  126699. }
  126700. /**
  126701. * Class used to share progress information about assets loading
  126702. */
  126703. export class AssetsProgressEvent implements IAssetsProgressEvent {
  126704. /**
  126705. * Defines the number of remaining tasks to process
  126706. */
  126707. remainingCount: number;
  126708. /**
  126709. * Defines the total number of tasks
  126710. */
  126711. totalCount: number;
  126712. /**
  126713. * Defines the task that was just processed
  126714. */
  126715. task: AbstractAssetTask;
  126716. /**
  126717. * Creates a AssetsProgressEvent
  126718. * @param remainingCount defines the number of remaining tasks to process
  126719. * @param totalCount defines the total number of tasks
  126720. * @param task defines the task that was just processed
  126721. */
  126722. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  126723. }
  126724. /**
  126725. * Define a task used by AssetsManager to load meshes
  126726. */
  126727. export class MeshAssetTask extends AbstractAssetTask {
  126728. /**
  126729. * Defines the name of the task
  126730. */
  126731. name: string;
  126732. /**
  126733. * Defines the list of mesh's names you want to load
  126734. */
  126735. meshesNames: any;
  126736. /**
  126737. * Defines the root url to use as a base to load your meshes and associated resources
  126738. */
  126739. rootUrl: string;
  126740. /**
  126741. * Defines the filename of the scene to load from
  126742. */
  126743. sceneFilename: string;
  126744. /**
  126745. * Gets the list of loaded meshes
  126746. */
  126747. loadedMeshes: Array<AbstractMesh>;
  126748. /**
  126749. * Gets the list of loaded particle systems
  126750. */
  126751. loadedParticleSystems: Array<IParticleSystem>;
  126752. /**
  126753. * Gets the list of loaded skeletons
  126754. */
  126755. loadedSkeletons: Array<Skeleton>;
  126756. /**
  126757. * Gets the list of loaded animation groups
  126758. */
  126759. loadedAnimationGroups: Array<AnimationGroup>;
  126760. /**
  126761. * Callback called when the task is successful
  126762. */
  126763. onSuccess: (task: MeshAssetTask) => void;
  126764. /**
  126765. * Callback called when the task is successful
  126766. */
  126767. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  126768. /**
  126769. * Creates a new MeshAssetTask
  126770. * @param name defines the name of the task
  126771. * @param meshesNames defines the list of mesh's names you want to load
  126772. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  126773. * @param sceneFilename defines the filename of the scene to load from
  126774. */
  126775. constructor(
  126776. /**
  126777. * Defines the name of the task
  126778. */
  126779. name: string,
  126780. /**
  126781. * Defines the list of mesh's names you want to load
  126782. */
  126783. meshesNames: any,
  126784. /**
  126785. * Defines the root url to use as a base to load your meshes and associated resources
  126786. */
  126787. rootUrl: string,
  126788. /**
  126789. * Defines the filename of the scene to load from
  126790. */
  126791. sceneFilename: string);
  126792. /**
  126793. * Execute the current task
  126794. * @param scene defines the scene where you want your assets to be loaded
  126795. * @param onSuccess is a callback called when the task is successfully executed
  126796. * @param onError is a callback called if an error occurs
  126797. */
  126798. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126799. }
  126800. /**
  126801. * Define a task used by AssetsManager to load text content
  126802. */
  126803. export class TextFileAssetTask extends AbstractAssetTask {
  126804. /**
  126805. * Defines the name of the task
  126806. */
  126807. name: string;
  126808. /**
  126809. * Defines the location of the file to load
  126810. */
  126811. url: string;
  126812. /**
  126813. * Gets the loaded text string
  126814. */
  126815. text: string;
  126816. /**
  126817. * Callback called when the task is successful
  126818. */
  126819. onSuccess: (task: TextFileAssetTask) => void;
  126820. /**
  126821. * Callback called when the task is successful
  126822. */
  126823. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  126824. /**
  126825. * Creates a new TextFileAssetTask object
  126826. * @param name defines the name of the task
  126827. * @param url defines the location of the file to load
  126828. */
  126829. constructor(
  126830. /**
  126831. * Defines the name of the task
  126832. */
  126833. name: string,
  126834. /**
  126835. * Defines the location of the file to load
  126836. */
  126837. url: string);
  126838. /**
  126839. * Execute the current task
  126840. * @param scene defines the scene where you want your assets to be loaded
  126841. * @param onSuccess is a callback called when the task is successfully executed
  126842. * @param onError is a callback called if an error occurs
  126843. */
  126844. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126845. }
  126846. /**
  126847. * Define a task used by AssetsManager to load binary data
  126848. */
  126849. export class BinaryFileAssetTask extends AbstractAssetTask {
  126850. /**
  126851. * Defines the name of the task
  126852. */
  126853. name: string;
  126854. /**
  126855. * Defines the location of the file to load
  126856. */
  126857. url: string;
  126858. /**
  126859. * Gets the lodaded data (as an array buffer)
  126860. */
  126861. data: ArrayBuffer;
  126862. /**
  126863. * Callback called when the task is successful
  126864. */
  126865. onSuccess: (task: BinaryFileAssetTask) => void;
  126866. /**
  126867. * Callback called when the task is successful
  126868. */
  126869. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  126870. /**
  126871. * Creates a new BinaryFileAssetTask object
  126872. * @param name defines the name of the new task
  126873. * @param url defines the location of the file to load
  126874. */
  126875. constructor(
  126876. /**
  126877. * Defines the name of the task
  126878. */
  126879. name: string,
  126880. /**
  126881. * Defines the location of the file to load
  126882. */
  126883. url: string);
  126884. /**
  126885. * Execute the current task
  126886. * @param scene defines the scene where you want your assets to be loaded
  126887. * @param onSuccess is a callback called when the task is successfully executed
  126888. * @param onError is a callback called if an error occurs
  126889. */
  126890. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126891. }
  126892. /**
  126893. * Define a task used by AssetsManager to load images
  126894. */
  126895. export class ImageAssetTask extends AbstractAssetTask {
  126896. /**
  126897. * Defines the name of the task
  126898. */
  126899. name: string;
  126900. /**
  126901. * Defines the location of the image to load
  126902. */
  126903. url: string;
  126904. /**
  126905. * Gets the loaded images
  126906. */
  126907. image: HTMLImageElement;
  126908. /**
  126909. * Callback called when the task is successful
  126910. */
  126911. onSuccess: (task: ImageAssetTask) => void;
  126912. /**
  126913. * Callback called when the task is successful
  126914. */
  126915. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  126916. /**
  126917. * Creates a new ImageAssetTask
  126918. * @param name defines the name of the task
  126919. * @param url defines the location of the image to load
  126920. */
  126921. constructor(
  126922. /**
  126923. * Defines the name of the task
  126924. */
  126925. name: string,
  126926. /**
  126927. * Defines the location of the image to load
  126928. */
  126929. url: string);
  126930. /**
  126931. * Execute the current task
  126932. * @param scene defines the scene where you want your assets to be loaded
  126933. * @param onSuccess is a callback called when the task is successfully executed
  126934. * @param onError is a callback called if an error occurs
  126935. */
  126936. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126937. }
  126938. /**
  126939. * Defines the interface used by texture loading tasks
  126940. */
  126941. export interface ITextureAssetTask<TEX extends BaseTexture> {
  126942. /**
  126943. * Gets the loaded texture
  126944. */
  126945. texture: TEX;
  126946. }
  126947. /**
  126948. * Define a task used by AssetsManager to load 2D textures
  126949. */
  126950. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  126951. /**
  126952. * Defines the name of the task
  126953. */
  126954. name: string;
  126955. /**
  126956. * Defines the location of the file to load
  126957. */
  126958. url: string;
  126959. /**
  126960. * Defines if mipmap should not be generated (default is false)
  126961. */
  126962. noMipmap?: boolean | undefined;
  126963. /**
  126964. * Defines if texture must be inverted on Y axis (default is false)
  126965. */
  126966. invertY?: boolean | undefined;
  126967. /**
  126968. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126969. */
  126970. samplingMode: number;
  126971. /**
  126972. * Gets the loaded texture
  126973. */
  126974. texture: Texture;
  126975. /**
  126976. * Callback called when the task is successful
  126977. */
  126978. onSuccess: (task: TextureAssetTask) => void;
  126979. /**
  126980. * Callback called when the task is successful
  126981. */
  126982. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  126983. /**
  126984. * Creates a new TextureAssetTask object
  126985. * @param name defines the name of the task
  126986. * @param url defines the location of the file to load
  126987. * @param noMipmap defines if mipmap should not be generated (default is false)
  126988. * @param invertY defines if texture must be inverted on Y axis (default is false)
  126989. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126990. */
  126991. constructor(
  126992. /**
  126993. * Defines the name of the task
  126994. */
  126995. name: string,
  126996. /**
  126997. * Defines the location of the file to load
  126998. */
  126999. url: string,
  127000. /**
  127001. * Defines if mipmap should not be generated (default is false)
  127002. */
  127003. noMipmap?: boolean | undefined,
  127004. /**
  127005. * Defines if texture must be inverted on Y axis (default is false)
  127006. */
  127007. invertY?: boolean | undefined,
  127008. /**
  127009. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  127010. */
  127011. samplingMode?: number);
  127012. /**
  127013. * Execute the current task
  127014. * @param scene defines the scene where you want your assets to be loaded
  127015. * @param onSuccess is a callback called when the task is successfully executed
  127016. * @param onError is a callback called if an error occurs
  127017. */
  127018. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127019. }
  127020. /**
  127021. * Define a task used by AssetsManager to load cube textures
  127022. */
  127023. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  127024. /**
  127025. * Defines the name of the task
  127026. */
  127027. name: string;
  127028. /**
  127029. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  127030. */
  127031. url: string;
  127032. /**
  127033. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  127034. */
  127035. extensions?: string[] | undefined;
  127036. /**
  127037. * Defines if mipmaps should not be generated (default is false)
  127038. */
  127039. noMipmap?: boolean | undefined;
  127040. /**
  127041. * Defines the explicit list of files (undefined by default)
  127042. */
  127043. files?: string[] | undefined;
  127044. /**
  127045. * Gets the loaded texture
  127046. */
  127047. texture: CubeTexture;
  127048. /**
  127049. * Callback called when the task is successful
  127050. */
  127051. onSuccess: (task: CubeTextureAssetTask) => void;
  127052. /**
  127053. * Callback called when the task is successful
  127054. */
  127055. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  127056. /**
  127057. * Creates a new CubeTextureAssetTask
  127058. * @param name defines the name of the task
  127059. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  127060. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  127061. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127062. * @param files defines the explicit list of files (undefined by default)
  127063. */
  127064. constructor(
  127065. /**
  127066. * Defines the name of the task
  127067. */
  127068. name: string,
  127069. /**
  127070. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  127071. */
  127072. url: string,
  127073. /**
  127074. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  127075. */
  127076. extensions?: string[] | undefined,
  127077. /**
  127078. * Defines if mipmaps should not be generated (default is false)
  127079. */
  127080. noMipmap?: boolean | undefined,
  127081. /**
  127082. * Defines the explicit list of files (undefined by default)
  127083. */
  127084. files?: string[] | undefined);
  127085. /**
  127086. * Execute the current task
  127087. * @param scene defines the scene where you want your assets to be loaded
  127088. * @param onSuccess is a callback called when the task is successfully executed
  127089. * @param onError is a callback called if an error occurs
  127090. */
  127091. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127092. }
  127093. /**
  127094. * Define a task used by AssetsManager to load HDR cube textures
  127095. */
  127096. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  127097. /**
  127098. * Defines the name of the task
  127099. */
  127100. name: string;
  127101. /**
  127102. * Defines the location of the file to load
  127103. */
  127104. url: string;
  127105. /**
  127106. * Defines the desired size (the more it increases the longer the generation will be)
  127107. */
  127108. size: number;
  127109. /**
  127110. * Defines if mipmaps should not be generated (default is false)
  127111. */
  127112. noMipmap: boolean;
  127113. /**
  127114. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127115. */
  127116. generateHarmonics: boolean;
  127117. /**
  127118. * 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)
  127119. */
  127120. gammaSpace: boolean;
  127121. /**
  127122. * Internal Use Only
  127123. */
  127124. reserved: boolean;
  127125. /**
  127126. * Gets the loaded texture
  127127. */
  127128. texture: HDRCubeTexture;
  127129. /**
  127130. * Callback called when the task is successful
  127131. */
  127132. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  127133. /**
  127134. * Callback called when the task is successful
  127135. */
  127136. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  127137. /**
  127138. * Creates a new HDRCubeTextureAssetTask object
  127139. * @param name defines the name of the task
  127140. * @param url defines the location of the file to load
  127141. * @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.
  127142. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127143. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127144. * @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)
  127145. * @param reserved Internal use only
  127146. */
  127147. constructor(
  127148. /**
  127149. * Defines the name of the task
  127150. */
  127151. name: string,
  127152. /**
  127153. * Defines the location of the file to load
  127154. */
  127155. url: string,
  127156. /**
  127157. * Defines the desired size (the more it increases the longer the generation will be)
  127158. */
  127159. size: number,
  127160. /**
  127161. * Defines if mipmaps should not be generated (default is false)
  127162. */
  127163. noMipmap?: boolean,
  127164. /**
  127165. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127166. */
  127167. generateHarmonics?: boolean,
  127168. /**
  127169. * 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)
  127170. */
  127171. gammaSpace?: boolean,
  127172. /**
  127173. * Internal Use Only
  127174. */
  127175. reserved?: boolean);
  127176. /**
  127177. * Execute the current task
  127178. * @param scene defines the scene where you want your assets to be loaded
  127179. * @param onSuccess is a callback called when the task is successfully executed
  127180. * @param onError is a callback called if an error occurs
  127181. */
  127182. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127183. }
  127184. /**
  127185. * Define a task used by AssetsManager to load Equirectangular cube textures
  127186. */
  127187. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  127188. /**
  127189. * Defines the name of the task
  127190. */
  127191. name: string;
  127192. /**
  127193. * Defines the location of the file to load
  127194. */
  127195. url: string;
  127196. /**
  127197. * Defines the desired size (the more it increases the longer the generation will be)
  127198. */
  127199. size: number;
  127200. /**
  127201. * Defines if mipmaps should not be generated (default is false)
  127202. */
  127203. noMipmap: boolean;
  127204. /**
  127205. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  127206. * but the standard material would require them in Gamma space) (default is true)
  127207. */
  127208. gammaSpace: boolean;
  127209. /**
  127210. * Gets the loaded texture
  127211. */
  127212. texture: EquiRectangularCubeTexture;
  127213. /**
  127214. * Callback called when the task is successful
  127215. */
  127216. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  127217. /**
  127218. * Callback called when the task is successful
  127219. */
  127220. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  127221. /**
  127222. * Creates a new EquiRectangularCubeTextureAssetTask object
  127223. * @param name defines the name of the task
  127224. * @param url defines the location of the file to load
  127225. * @param size defines the desired size (the more it increases the longer the generation will be)
  127226. * If the size is omitted this implies you are using a preprocessed cubemap.
  127227. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127228. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  127229. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  127230. * (default is true)
  127231. */
  127232. constructor(
  127233. /**
  127234. * Defines the name of the task
  127235. */
  127236. name: string,
  127237. /**
  127238. * Defines the location of the file to load
  127239. */
  127240. url: string,
  127241. /**
  127242. * Defines the desired size (the more it increases the longer the generation will be)
  127243. */
  127244. size: number,
  127245. /**
  127246. * Defines if mipmaps should not be generated (default is false)
  127247. */
  127248. noMipmap?: boolean,
  127249. /**
  127250. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  127251. * but the standard material would require them in Gamma space) (default is true)
  127252. */
  127253. gammaSpace?: boolean);
  127254. /**
  127255. * Execute the current task
  127256. * @param scene defines the scene where you want your assets to be loaded
  127257. * @param onSuccess is a callback called when the task is successfully executed
  127258. * @param onError is a callback called if an error occurs
  127259. */
  127260. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127261. }
  127262. /**
  127263. * This class can be used to easily import assets into a scene
  127264. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  127265. */
  127266. export class AssetsManager {
  127267. private _scene;
  127268. private _isLoading;
  127269. protected _tasks: AbstractAssetTask[];
  127270. protected _waitingTasksCount: number;
  127271. protected _totalTasksCount: number;
  127272. /**
  127273. * Callback called when all tasks are processed
  127274. */
  127275. onFinish: (tasks: AbstractAssetTask[]) => void;
  127276. /**
  127277. * Callback called when a task is successful
  127278. */
  127279. onTaskSuccess: (task: AbstractAssetTask) => void;
  127280. /**
  127281. * Callback called when a task had an error
  127282. */
  127283. onTaskError: (task: AbstractAssetTask) => void;
  127284. /**
  127285. * Callback called when a task is done (whatever the result is)
  127286. */
  127287. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  127288. /**
  127289. * Observable called when all tasks are processed
  127290. */
  127291. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  127292. /**
  127293. * Observable called when a task had an error
  127294. */
  127295. onTaskErrorObservable: Observable<AbstractAssetTask>;
  127296. /**
  127297. * Observable called when all tasks were executed
  127298. */
  127299. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  127300. /**
  127301. * Observable called when a task is done (whatever the result is)
  127302. */
  127303. onProgressObservable: Observable<IAssetsProgressEvent>;
  127304. /**
  127305. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  127306. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127307. */
  127308. useDefaultLoadingScreen: boolean;
  127309. /**
  127310. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  127311. * when all assets have been downloaded.
  127312. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  127313. */
  127314. autoHideLoadingUI: boolean;
  127315. /**
  127316. * Creates a new AssetsManager
  127317. * @param scene defines the scene to work on
  127318. */
  127319. constructor(scene: Scene);
  127320. /**
  127321. * Add a MeshAssetTask to the list of active tasks
  127322. * @param taskName defines the name of the new task
  127323. * @param meshesNames defines the name of meshes to load
  127324. * @param rootUrl defines the root url to use to locate files
  127325. * @param sceneFilename defines the filename of the scene file
  127326. * @returns a new MeshAssetTask object
  127327. */
  127328. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  127329. /**
  127330. * Add a TextFileAssetTask to the list of active tasks
  127331. * @param taskName defines the name of the new task
  127332. * @param url defines the url of the file to load
  127333. * @returns a new TextFileAssetTask object
  127334. */
  127335. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  127336. /**
  127337. * Add a BinaryFileAssetTask to the list of active tasks
  127338. * @param taskName defines the name of the new task
  127339. * @param url defines the url of the file to load
  127340. * @returns a new BinaryFileAssetTask object
  127341. */
  127342. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  127343. /**
  127344. * Add a ImageAssetTask to the list of active tasks
  127345. * @param taskName defines the name of the new task
  127346. * @param url defines the url of the file to load
  127347. * @returns a new ImageAssetTask object
  127348. */
  127349. addImageTask(taskName: string, url: string): ImageAssetTask;
  127350. /**
  127351. * Add a TextureAssetTask to the list of active tasks
  127352. * @param taskName defines the name of the new task
  127353. * @param url defines the url of the file to load
  127354. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127355. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  127356. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  127357. * @returns a new TextureAssetTask object
  127358. */
  127359. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  127360. /**
  127361. * Add a CubeTextureAssetTask to the list of active tasks
  127362. * @param taskName defines the name of the new task
  127363. * @param url defines the url of the file to load
  127364. * @param extensions defines the extension to use to load the cube map (can be null)
  127365. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127366. * @param files defines the list of files to load (can be null)
  127367. * @returns a new CubeTextureAssetTask object
  127368. */
  127369. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  127370. /**
  127371. *
  127372. * Add a HDRCubeTextureAssetTask to the list of active tasks
  127373. * @param taskName defines the name of the new task
  127374. * @param url defines the url of the file to load
  127375. * @param size defines the size you want for the cubemap (can be null)
  127376. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127377. * @param generateHarmonics defines if you want to automatically generate (true by default)
  127378. * @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)
  127379. * @param reserved Internal use only
  127380. * @returns a new HDRCubeTextureAssetTask object
  127381. */
  127382. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  127383. /**
  127384. *
  127385. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  127386. * @param taskName defines the name of the new task
  127387. * @param url defines the url of the file to load
  127388. * @param size defines the size you want for the cubemap (can be null)
  127389. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127390. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  127391. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  127392. * @returns a new EquiRectangularCubeTextureAssetTask object
  127393. */
  127394. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  127395. /**
  127396. * Remove a task from the assets manager.
  127397. * @param task the task to remove
  127398. */
  127399. removeTask(task: AbstractAssetTask): void;
  127400. private _decreaseWaitingTasksCount;
  127401. private _runTask;
  127402. /**
  127403. * Reset the AssetsManager and remove all tasks
  127404. * @return the current instance of the AssetsManager
  127405. */
  127406. reset(): AssetsManager;
  127407. /**
  127408. * Start the loading process
  127409. * @return the current instance of the AssetsManager
  127410. */
  127411. load(): AssetsManager;
  127412. /**
  127413. * Start the loading process as an async operation
  127414. * @return a promise returning the list of failed tasks
  127415. */
  127416. loadAsync(): Promise<void>;
  127417. }
  127418. }
  127419. declare module BABYLON {
  127420. /**
  127421. * Wrapper class for promise with external resolve and reject.
  127422. */
  127423. export class Deferred<T> {
  127424. /**
  127425. * The promise associated with this deferred object.
  127426. */
  127427. readonly promise: Promise<T>;
  127428. private _resolve;
  127429. private _reject;
  127430. /**
  127431. * The resolve method of the promise associated with this deferred object.
  127432. */
  127433. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  127434. /**
  127435. * The reject method of the promise associated with this deferred object.
  127436. */
  127437. readonly reject: (reason?: any) => void;
  127438. /**
  127439. * Constructor for this deferred object.
  127440. */
  127441. constructor();
  127442. }
  127443. }
  127444. declare module BABYLON {
  127445. /**
  127446. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  127447. */
  127448. export class MeshExploder {
  127449. private _centerMesh;
  127450. private _meshes;
  127451. private _meshesOrigins;
  127452. private _toCenterVectors;
  127453. private _scaledDirection;
  127454. private _newPosition;
  127455. private _centerPosition;
  127456. /**
  127457. * Explodes meshes from a center mesh.
  127458. * @param meshes The meshes to explode.
  127459. * @param centerMesh The mesh to be center of explosion.
  127460. */
  127461. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  127462. private _setCenterMesh;
  127463. /**
  127464. * Get class name
  127465. * @returns "MeshExploder"
  127466. */
  127467. getClassName(): string;
  127468. /**
  127469. * "Exploded meshes"
  127470. * @returns Array of meshes with the centerMesh at index 0.
  127471. */
  127472. getMeshes(): Array<Mesh>;
  127473. /**
  127474. * Explodes meshes giving a specific direction
  127475. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  127476. */
  127477. explode(direction?: number): void;
  127478. }
  127479. }
  127480. declare module BABYLON {
  127481. /**
  127482. * Class used to help managing file picking and drag'n'drop
  127483. */
  127484. export class FilesInput {
  127485. /**
  127486. * List of files ready to be loaded
  127487. */
  127488. static readonly FilesToLoad: {
  127489. [key: string]: File;
  127490. };
  127491. /**
  127492. * Callback called when a file is processed
  127493. */
  127494. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  127495. private _engine;
  127496. private _currentScene;
  127497. private _sceneLoadedCallback;
  127498. private _progressCallback;
  127499. private _additionalRenderLoopLogicCallback;
  127500. private _textureLoadingCallback;
  127501. private _startingProcessingFilesCallback;
  127502. private _onReloadCallback;
  127503. private _errorCallback;
  127504. private _elementToMonitor;
  127505. private _sceneFileToLoad;
  127506. private _filesToLoad;
  127507. /**
  127508. * Creates a new FilesInput
  127509. * @param engine defines the rendering engine
  127510. * @param scene defines the hosting scene
  127511. * @param sceneLoadedCallback callback called when scene is loaded
  127512. * @param progressCallback callback called to track progress
  127513. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  127514. * @param textureLoadingCallback callback called when a texture is loading
  127515. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  127516. * @param onReloadCallback callback called when a reload is requested
  127517. * @param errorCallback callback call if an error occurs
  127518. */
  127519. 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);
  127520. private _dragEnterHandler;
  127521. private _dragOverHandler;
  127522. private _dropHandler;
  127523. /**
  127524. * Calls this function to listen to drag'n'drop events on a specific DOM element
  127525. * @param elementToMonitor defines the DOM element to track
  127526. */
  127527. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  127528. /**
  127529. * Release all associated resources
  127530. */
  127531. dispose(): void;
  127532. private renderFunction;
  127533. private drag;
  127534. private drop;
  127535. private _traverseFolder;
  127536. private _processFiles;
  127537. /**
  127538. * Load files from a drop event
  127539. * @param event defines the drop event to use as source
  127540. */
  127541. loadFiles(event: any): void;
  127542. private _processReload;
  127543. /**
  127544. * Reload the current scene from the loaded files
  127545. */
  127546. reload(): void;
  127547. }
  127548. }
  127549. declare module BABYLON {
  127550. /**
  127551. * Defines the root class used to create scene optimization to use with SceneOptimizer
  127552. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127553. */
  127554. export class SceneOptimization {
  127555. /**
  127556. * Defines the priority of this optimization (0 by default which means first in the list)
  127557. */
  127558. priority: number;
  127559. /**
  127560. * Gets a string describing the action executed by the current optimization
  127561. * @returns description string
  127562. */
  127563. getDescription(): string;
  127564. /**
  127565. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127566. * @param scene defines the current scene where to apply this optimization
  127567. * @param optimizer defines the current optimizer
  127568. * @returns true if everything that can be done was applied
  127569. */
  127570. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127571. /**
  127572. * Creates the SceneOptimization object
  127573. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127574. * @param desc defines the description associated with the optimization
  127575. */
  127576. constructor(
  127577. /**
  127578. * Defines the priority of this optimization (0 by default which means first in the list)
  127579. */
  127580. priority?: number);
  127581. }
  127582. /**
  127583. * Defines an optimization used to reduce the size of render target textures
  127584. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127585. */
  127586. export class TextureOptimization extends SceneOptimization {
  127587. /**
  127588. * Defines the priority of this optimization (0 by default which means first in the list)
  127589. */
  127590. priority: number;
  127591. /**
  127592. * 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
  127593. */
  127594. maximumSize: number;
  127595. /**
  127596. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127597. */
  127598. step: number;
  127599. /**
  127600. * Gets a string describing the action executed by the current optimization
  127601. * @returns description string
  127602. */
  127603. getDescription(): string;
  127604. /**
  127605. * Creates the TextureOptimization object
  127606. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127607. * @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
  127608. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127609. */
  127610. constructor(
  127611. /**
  127612. * Defines the priority of this optimization (0 by default which means first in the list)
  127613. */
  127614. priority?: number,
  127615. /**
  127616. * 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
  127617. */
  127618. maximumSize?: number,
  127619. /**
  127620. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127621. */
  127622. step?: number);
  127623. /**
  127624. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127625. * @param scene defines the current scene where to apply this optimization
  127626. * @param optimizer defines the current optimizer
  127627. * @returns true if everything that can be done was applied
  127628. */
  127629. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127630. }
  127631. /**
  127632. * Defines an optimization used to increase or decrease the rendering resolution
  127633. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127634. */
  127635. export class HardwareScalingOptimization extends SceneOptimization {
  127636. /**
  127637. * Defines the priority of this optimization (0 by default which means first in the list)
  127638. */
  127639. priority: number;
  127640. /**
  127641. * Defines the maximum scale to use (2 by default)
  127642. */
  127643. maximumScale: number;
  127644. /**
  127645. * Defines the step to use between two passes (0.5 by default)
  127646. */
  127647. step: number;
  127648. private _currentScale;
  127649. private _directionOffset;
  127650. /**
  127651. * Gets a string describing the action executed by the current optimization
  127652. * @return description string
  127653. */
  127654. getDescription(): string;
  127655. /**
  127656. * Creates the HardwareScalingOptimization object
  127657. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127658. * @param maximumScale defines the maximum scale to use (2 by default)
  127659. * @param step defines the step to use between two passes (0.5 by default)
  127660. */
  127661. constructor(
  127662. /**
  127663. * Defines the priority of this optimization (0 by default which means first in the list)
  127664. */
  127665. priority?: number,
  127666. /**
  127667. * Defines the maximum scale to use (2 by default)
  127668. */
  127669. maximumScale?: number,
  127670. /**
  127671. * Defines the step to use between two passes (0.5 by default)
  127672. */
  127673. step?: number);
  127674. /**
  127675. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127676. * @param scene defines the current scene where to apply this optimization
  127677. * @param optimizer defines the current optimizer
  127678. * @returns true if everything that can be done was applied
  127679. */
  127680. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127681. }
  127682. /**
  127683. * Defines an optimization used to remove shadows
  127684. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127685. */
  127686. export class ShadowsOptimization extends SceneOptimization {
  127687. /**
  127688. * Gets a string describing the action executed by the current optimization
  127689. * @return description string
  127690. */
  127691. getDescription(): string;
  127692. /**
  127693. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127694. * @param scene defines the current scene where to apply this optimization
  127695. * @param optimizer defines the current optimizer
  127696. * @returns true if everything that can be done was applied
  127697. */
  127698. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127699. }
  127700. /**
  127701. * Defines an optimization used to turn post-processes off
  127702. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127703. */
  127704. export class PostProcessesOptimization extends SceneOptimization {
  127705. /**
  127706. * Gets a string describing the action executed by the current optimization
  127707. * @return description string
  127708. */
  127709. getDescription(): string;
  127710. /**
  127711. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127712. * @param scene defines the current scene where to apply this optimization
  127713. * @param optimizer defines the current optimizer
  127714. * @returns true if everything that can be done was applied
  127715. */
  127716. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127717. }
  127718. /**
  127719. * Defines an optimization used to turn lens flares off
  127720. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127721. */
  127722. export class LensFlaresOptimization extends SceneOptimization {
  127723. /**
  127724. * Gets a string describing the action executed by the current optimization
  127725. * @return description string
  127726. */
  127727. getDescription(): string;
  127728. /**
  127729. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127730. * @param scene defines the current scene where to apply this optimization
  127731. * @param optimizer defines the current optimizer
  127732. * @returns true if everything that can be done was applied
  127733. */
  127734. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127735. }
  127736. /**
  127737. * Defines an optimization based on user defined callback.
  127738. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127739. */
  127740. export class CustomOptimization extends SceneOptimization {
  127741. /**
  127742. * Callback called to apply the custom optimization.
  127743. */
  127744. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  127745. /**
  127746. * Callback called to get custom description
  127747. */
  127748. onGetDescription: () => string;
  127749. /**
  127750. * Gets a string describing the action executed by the current optimization
  127751. * @returns description string
  127752. */
  127753. getDescription(): string;
  127754. /**
  127755. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127756. * @param scene defines the current scene where to apply this optimization
  127757. * @param optimizer defines the current optimizer
  127758. * @returns true if everything that can be done was applied
  127759. */
  127760. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127761. }
  127762. /**
  127763. * Defines an optimization used to turn particles off
  127764. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127765. */
  127766. export class ParticlesOptimization extends SceneOptimization {
  127767. /**
  127768. * Gets a string describing the action executed by the current optimization
  127769. * @return description string
  127770. */
  127771. getDescription(): string;
  127772. /**
  127773. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127774. * @param scene defines the current scene where to apply this optimization
  127775. * @param optimizer defines the current optimizer
  127776. * @returns true if everything that can be done was applied
  127777. */
  127778. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127779. }
  127780. /**
  127781. * Defines an optimization used to turn render targets off
  127782. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127783. */
  127784. export class RenderTargetsOptimization extends SceneOptimization {
  127785. /**
  127786. * Gets a string describing the action executed by the current optimization
  127787. * @return description string
  127788. */
  127789. getDescription(): string;
  127790. /**
  127791. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127792. * @param scene defines the current scene where to apply this optimization
  127793. * @param optimizer defines the current optimizer
  127794. * @returns true if everything that can be done was applied
  127795. */
  127796. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127797. }
  127798. /**
  127799. * Defines an optimization used to merge meshes with compatible materials
  127800. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127801. */
  127802. export class MergeMeshesOptimization extends SceneOptimization {
  127803. private static _UpdateSelectionTree;
  127804. /**
  127805. * Gets or sets a boolean which defines if optimization octree has to be updated
  127806. */
  127807. /**
  127808. * Gets or sets a boolean which defines if optimization octree has to be updated
  127809. */
  127810. static UpdateSelectionTree: boolean;
  127811. /**
  127812. * Gets a string describing the action executed by the current optimization
  127813. * @return description string
  127814. */
  127815. getDescription(): string;
  127816. private _canBeMerged;
  127817. /**
  127818. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127819. * @param scene defines the current scene where to apply this optimization
  127820. * @param optimizer defines the current optimizer
  127821. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  127822. * @returns true if everything that can be done was applied
  127823. */
  127824. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  127825. }
  127826. /**
  127827. * Defines a list of options used by SceneOptimizer
  127828. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127829. */
  127830. export class SceneOptimizerOptions {
  127831. /**
  127832. * Defines the target frame rate to reach (60 by default)
  127833. */
  127834. targetFrameRate: number;
  127835. /**
  127836. * Defines the interval between two checkes (2000ms by default)
  127837. */
  127838. trackerDuration: number;
  127839. /**
  127840. * Gets the list of optimizations to apply
  127841. */
  127842. optimizations: SceneOptimization[];
  127843. /**
  127844. * Creates a new list of options used by SceneOptimizer
  127845. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  127846. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  127847. */
  127848. constructor(
  127849. /**
  127850. * Defines the target frame rate to reach (60 by default)
  127851. */
  127852. targetFrameRate?: number,
  127853. /**
  127854. * Defines the interval between two checkes (2000ms by default)
  127855. */
  127856. trackerDuration?: number);
  127857. /**
  127858. * Add a new optimization
  127859. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  127860. * @returns the current SceneOptimizerOptions
  127861. */
  127862. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  127863. /**
  127864. * Add a new custom optimization
  127865. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  127866. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  127867. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127868. * @returns the current SceneOptimizerOptions
  127869. */
  127870. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  127871. /**
  127872. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  127873. * @param targetFrameRate defines the target frame rate (60 by default)
  127874. * @returns a SceneOptimizerOptions object
  127875. */
  127876. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127877. /**
  127878. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  127879. * @param targetFrameRate defines the target frame rate (60 by default)
  127880. * @returns a SceneOptimizerOptions object
  127881. */
  127882. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127883. /**
  127884. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  127885. * @param targetFrameRate defines the target frame rate (60 by default)
  127886. * @returns a SceneOptimizerOptions object
  127887. */
  127888. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127889. }
  127890. /**
  127891. * Class used to run optimizations in order to reach a target frame rate
  127892. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127893. */
  127894. export class SceneOptimizer implements IDisposable {
  127895. private _isRunning;
  127896. private _options;
  127897. private _scene;
  127898. private _currentPriorityLevel;
  127899. private _targetFrameRate;
  127900. private _trackerDuration;
  127901. private _currentFrameRate;
  127902. private _sceneDisposeObserver;
  127903. private _improvementMode;
  127904. /**
  127905. * Defines an observable called when the optimizer reaches the target frame rate
  127906. */
  127907. onSuccessObservable: Observable<SceneOptimizer>;
  127908. /**
  127909. * Defines an observable called when the optimizer enables an optimization
  127910. */
  127911. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  127912. /**
  127913. * Defines an observable called when the optimizer is not able to reach the target frame rate
  127914. */
  127915. onFailureObservable: Observable<SceneOptimizer>;
  127916. /**
  127917. * Gets a boolean indicating if the optimizer is in improvement mode
  127918. */
  127919. readonly isInImprovementMode: boolean;
  127920. /**
  127921. * Gets the current priority level (0 at start)
  127922. */
  127923. readonly currentPriorityLevel: number;
  127924. /**
  127925. * Gets the current frame rate checked by the SceneOptimizer
  127926. */
  127927. readonly currentFrameRate: number;
  127928. /**
  127929. * Gets or sets the current target frame rate (60 by default)
  127930. */
  127931. /**
  127932. * Gets or sets the current target frame rate (60 by default)
  127933. */
  127934. targetFrameRate: number;
  127935. /**
  127936. * Gets or sets the current interval between two checks (every 2000ms by default)
  127937. */
  127938. /**
  127939. * Gets or sets the current interval between two checks (every 2000ms by default)
  127940. */
  127941. trackerDuration: number;
  127942. /**
  127943. * Gets the list of active optimizations
  127944. */
  127945. readonly optimizations: SceneOptimization[];
  127946. /**
  127947. * Creates a new SceneOptimizer
  127948. * @param scene defines the scene to work on
  127949. * @param options defines the options to use with the SceneOptimizer
  127950. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  127951. * @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)
  127952. */
  127953. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  127954. /**
  127955. * Stops the current optimizer
  127956. */
  127957. stop(): void;
  127958. /**
  127959. * Reset the optimizer to initial step (current priority level = 0)
  127960. */
  127961. reset(): void;
  127962. /**
  127963. * Start the optimizer. By default it will try to reach a specific framerate
  127964. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  127965. */
  127966. start(): void;
  127967. private _checkCurrentState;
  127968. /**
  127969. * Release all resources
  127970. */
  127971. dispose(): void;
  127972. /**
  127973. * Helper function to create a SceneOptimizer with one single line of code
  127974. * @param scene defines the scene to work on
  127975. * @param options defines the options to use with the SceneOptimizer
  127976. * @param onSuccess defines a callback to call on success
  127977. * @param onFailure defines a callback to call on failure
  127978. * @returns the new SceneOptimizer object
  127979. */
  127980. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  127981. }
  127982. }
  127983. declare module BABYLON {
  127984. /**
  127985. * Class used to serialize a scene into a string
  127986. */
  127987. export class SceneSerializer {
  127988. /**
  127989. * Clear cache used by a previous serialization
  127990. */
  127991. static ClearCache(): void;
  127992. /**
  127993. * Serialize a scene into a JSON compatible object
  127994. * @param scene defines the scene to serialize
  127995. * @returns a JSON compatible object
  127996. */
  127997. static Serialize(scene: Scene): any;
  127998. /**
  127999. * Serialize a mesh into a JSON compatible object
  128000. * @param toSerialize defines the mesh to serialize
  128001. * @param withParents defines if parents must be serialized as well
  128002. * @param withChildren defines if children must be serialized as well
  128003. * @returns a JSON compatible object
  128004. */
  128005. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  128006. }
  128007. }
  128008. declare module BABYLON {
  128009. /**
  128010. * Class used to host texture specific utilities
  128011. */
  128012. export class TextureTools {
  128013. /**
  128014. * Uses the GPU to create a copy texture rescaled at a given size
  128015. * @param texture Texture to copy from
  128016. * @param width defines the desired width
  128017. * @param height defines the desired height
  128018. * @param useBilinearMode defines if bilinear mode has to be used
  128019. * @return the generated texture
  128020. */
  128021. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  128022. }
  128023. }
  128024. declare module BABYLON {
  128025. /**
  128026. * This represents the different options available for the video capture.
  128027. */
  128028. export interface VideoRecorderOptions {
  128029. /** Defines the mime type of the video. */
  128030. mimeType: string;
  128031. /** Defines the FPS the video should be recorded at. */
  128032. fps: number;
  128033. /** Defines the chunk size for the recording data. */
  128034. recordChunckSize: number;
  128035. /** The audio tracks to attach to the recording. */
  128036. audioTracks?: MediaStreamTrack[];
  128037. }
  128038. /**
  128039. * This can help with recording videos from BabylonJS.
  128040. * This is based on the available WebRTC functionalities of the browser.
  128041. *
  128042. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  128043. */
  128044. export class VideoRecorder {
  128045. private static readonly _defaultOptions;
  128046. /**
  128047. * Returns whether or not the VideoRecorder is available in your browser.
  128048. * @param engine Defines the Babylon Engine.
  128049. * @returns true if supported otherwise false.
  128050. */
  128051. static IsSupported(engine: Engine): boolean;
  128052. private readonly _options;
  128053. private _canvas;
  128054. private _mediaRecorder;
  128055. private _recordedChunks;
  128056. private _fileName;
  128057. private _resolve;
  128058. private _reject;
  128059. /**
  128060. * True when a recording is already in progress.
  128061. */
  128062. readonly isRecording: boolean;
  128063. /**
  128064. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  128065. * @param engine Defines the BabylonJS Engine you wish to record.
  128066. * @param options Defines options that can be used to customize the capture.
  128067. */
  128068. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  128069. /**
  128070. * Stops the current recording before the default capture timeout passed in the startRecording function.
  128071. */
  128072. stopRecording(): void;
  128073. /**
  128074. * Starts recording the canvas for a max duration specified in parameters.
  128075. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  128076. * If null no automatic download will start and you can rely on the promise to get the data back.
  128077. * @param maxDuration Defines the maximum recording time in seconds.
  128078. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  128079. * @return A promise callback at the end of the recording with the video data in Blob.
  128080. */
  128081. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  128082. /**
  128083. * Releases internal resources used during the recording.
  128084. */
  128085. dispose(): void;
  128086. private _handleDataAvailable;
  128087. private _handleError;
  128088. private _handleStop;
  128089. }
  128090. }
  128091. declare module BABYLON {
  128092. /**
  128093. * Class containing a set of static utilities functions for screenshots
  128094. */
  128095. export class ScreenshotTools {
  128096. /**
  128097. * Captures a screenshot of the current rendering
  128098. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128099. * @param engine defines the rendering engine
  128100. * @param camera defines the source camera
  128101. * @param size This parameter can be set to a single number or to an object with the
  128102. * following (optional) properties: precision, width, height. If a single number is passed,
  128103. * it will be used for both width and height. If an object is passed, the screenshot size
  128104. * will be derived from the parameters. The precision property is a multiplier allowing
  128105. * rendering at a higher or lower resolution
  128106. * @param successCallback defines the callback receives a single parameter which contains the
  128107. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  128108. * src parameter of an <img> to display it
  128109. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  128110. * Check your browser for supported MIME types
  128111. */
  128112. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  128113. /**
  128114. * Captures a screenshot of the current rendering
  128115. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128116. * @param engine defines the rendering engine
  128117. * @param camera defines the source camera
  128118. * @param size This parameter can be set to a single number or to an object with the
  128119. * following (optional) properties: precision, width, height. If a single number is passed,
  128120. * it will be used for both width and height. If an object is passed, the screenshot size
  128121. * will be derived from the parameters. The precision property is a multiplier allowing
  128122. * rendering at a higher or lower resolution
  128123. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  128124. * Check your browser for supported MIME types
  128125. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128126. * to the src parameter of an <img> to display it
  128127. */
  128128. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  128129. /**
  128130. * Generates an image screenshot from the specified camera.
  128131. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128132. * @param engine The engine to use for rendering
  128133. * @param camera The camera to use for rendering
  128134. * @param size This parameter can be set to a single number or to an object with the
  128135. * following (optional) properties: precision, width, height. If a single number is passed,
  128136. * it will be used for both width and height. If an object is passed, the screenshot size
  128137. * will be derived from the parameters. The precision property is a multiplier allowing
  128138. * rendering at a higher or lower resolution
  128139. * @param successCallback The callback receives a single parameter which contains the
  128140. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  128141. * src parameter of an <img> to display it
  128142. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128143. * Check your browser for supported MIME types
  128144. * @param samples Texture samples (default: 1)
  128145. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128146. * @param fileName A name for for the downloaded file.
  128147. */
  128148. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  128149. /**
  128150. * Generates an image screenshot from the specified camera.
  128151. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128152. * @param engine The engine to use for rendering
  128153. * @param camera The camera to use for rendering
  128154. * @param size This parameter can be set to a single number or to an object with the
  128155. * following (optional) properties: precision, width, height. If a single number is passed,
  128156. * it will be used for both width and height. If an object is passed, the screenshot size
  128157. * will be derived from the parameters. The precision property is a multiplier allowing
  128158. * rendering at a higher or lower resolution
  128159. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128160. * Check your browser for supported MIME types
  128161. * @param samples Texture samples (default: 1)
  128162. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128163. * @param fileName A name for for the downloaded file.
  128164. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128165. * to the src parameter of an <img> to display it
  128166. */
  128167. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  128168. /**
  128169. * Gets height and width for screenshot size
  128170. * @private
  128171. */
  128172. private static _getScreenshotSize;
  128173. }
  128174. }
  128175. declare module BABYLON {
  128176. /**
  128177. * A cursor which tracks a point on a path
  128178. */
  128179. export class PathCursor {
  128180. private path;
  128181. /**
  128182. * Stores path cursor callbacks for when an onchange event is triggered
  128183. */
  128184. private _onchange;
  128185. /**
  128186. * The value of the path cursor
  128187. */
  128188. value: number;
  128189. /**
  128190. * The animation array of the path cursor
  128191. */
  128192. animations: Animation[];
  128193. /**
  128194. * Initializes the path cursor
  128195. * @param path The path to track
  128196. */
  128197. constructor(path: Path2);
  128198. /**
  128199. * Gets the cursor point on the path
  128200. * @returns A point on the path cursor at the cursor location
  128201. */
  128202. getPoint(): Vector3;
  128203. /**
  128204. * Moves the cursor ahead by the step amount
  128205. * @param step The amount to move the cursor forward
  128206. * @returns This path cursor
  128207. */
  128208. moveAhead(step?: number): PathCursor;
  128209. /**
  128210. * Moves the cursor behind by the step amount
  128211. * @param step The amount to move the cursor back
  128212. * @returns This path cursor
  128213. */
  128214. moveBack(step?: number): PathCursor;
  128215. /**
  128216. * Moves the cursor by the step amount
  128217. * If the step amount is greater than one, an exception is thrown
  128218. * @param step The amount to move the cursor
  128219. * @returns This path cursor
  128220. */
  128221. move(step: number): PathCursor;
  128222. /**
  128223. * Ensures that the value is limited between zero and one
  128224. * @returns This path cursor
  128225. */
  128226. private ensureLimits;
  128227. /**
  128228. * Runs onchange callbacks on change (used by the animation engine)
  128229. * @returns This path cursor
  128230. */
  128231. private raiseOnChange;
  128232. /**
  128233. * Executes a function on change
  128234. * @param f A path cursor onchange callback
  128235. * @returns This path cursor
  128236. */
  128237. onchange(f: (cursor: PathCursor) => void): PathCursor;
  128238. }
  128239. }
  128240. declare module BABYLON {
  128241. /** @hidden */
  128242. export var blurPixelShader: {
  128243. name: string;
  128244. shader: string;
  128245. };
  128246. }
  128247. declare module BABYLON {
  128248. /** @hidden */
  128249. export var pointCloudVertexDeclaration: {
  128250. name: string;
  128251. shader: string;
  128252. };
  128253. }
  128254. // Mixins
  128255. interface Window {
  128256. mozIndexedDB: IDBFactory;
  128257. webkitIndexedDB: IDBFactory;
  128258. msIndexedDB: IDBFactory;
  128259. webkitURL: typeof URL;
  128260. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  128261. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  128262. WebGLRenderingContext: WebGLRenderingContext;
  128263. MSGesture: MSGesture;
  128264. CANNON: any;
  128265. AudioContext: AudioContext;
  128266. webkitAudioContext: AudioContext;
  128267. PointerEvent: any;
  128268. Math: Math;
  128269. Uint8Array: Uint8ArrayConstructor;
  128270. Float32Array: Float32ArrayConstructor;
  128271. mozURL: typeof URL;
  128272. msURL: typeof URL;
  128273. VRFrameData: any; // WebVR, from specs 1.1
  128274. DracoDecoderModule: any;
  128275. setImmediate(handler: (...args: any[]) => void): number;
  128276. }
  128277. interface HTMLCanvasElement {
  128278. requestPointerLock(): void;
  128279. msRequestPointerLock?(): void;
  128280. mozRequestPointerLock?(): void;
  128281. webkitRequestPointerLock?(): void;
  128282. /** Track wether a record is in progress */
  128283. isRecording: boolean;
  128284. /** Capture Stream method defined by some browsers */
  128285. captureStream(fps?: number): MediaStream;
  128286. }
  128287. interface CanvasRenderingContext2D {
  128288. msImageSmoothingEnabled: boolean;
  128289. }
  128290. interface MouseEvent {
  128291. mozMovementX: number;
  128292. mozMovementY: number;
  128293. webkitMovementX: number;
  128294. webkitMovementY: number;
  128295. msMovementX: number;
  128296. msMovementY: number;
  128297. }
  128298. interface Navigator {
  128299. mozGetVRDevices: (any: any) => any;
  128300. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128301. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128302. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128303. webkitGetGamepads(): Gamepad[];
  128304. msGetGamepads(): Gamepad[];
  128305. webkitGamepads(): Gamepad[];
  128306. }
  128307. interface HTMLVideoElement {
  128308. mozSrcObject: any;
  128309. }
  128310. interface Math {
  128311. fround(x: number): number;
  128312. imul(a: number, b: number): number;
  128313. }
  128314. interface WebGLRenderingContext {
  128315. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  128316. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  128317. vertexAttribDivisor(index: number, divisor: number): void;
  128318. createVertexArray(): any;
  128319. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  128320. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  128321. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  128322. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  128323. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  128324. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  128325. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  128326. // Queries
  128327. createQuery(): WebGLQuery;
  128328. deleteQuery(query: WebGLQuery): void;
  128329. beginQuery(target: number, query: WebGLQuery): void;
  128330. endQuery(target: number): void;
  128331. getQueryParameter(query: WebGLQuery, pname: number): any;
  128332. getQuery(target: number, pname: number): any;
  128333. MAX_SAMPLES: number;
  128334. RGBA8: number;
  128335. READ_FRAMEBUFFER: number;
  128336. DRAW_FRAMEBUFFER: number;
  128337. UNIFORM_BUFFER: number;
  128338. HALF_FLOAT_OES: number;
  128339. RGBA16F: number;
  128340. RGBA32F: number;
  128341. R32F: number;
  128342. RG32F: number;
  128343. RGB32F: number;
  128344. R16F: number;
  128345. RG16F: number;
  128346. RGB16F: number;
  128347. RED: number;
  128348. RG: number;
  128349. R8: number;
  128350. RG8: number;
  128351. UNSIGNED_INT_24_8: number;
  128352. DEPTH24_STENCIL8: number;
  128353. MIN: number;
  128354. MAX: number;
  128355. /* Multiple Render Targets */
  128356. drawBuffers(buffers: number[]): void;
  128357. readBuffer(src: number): void;
  128358. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  128359. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  128360. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  128361. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  128362. // Occlusion Query
  128363. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  128364. ANY_SAMPLES_PASSED: number;
  128365. QUERY_RESULT_AVAILABLE: number;
  128366. QUERY_RESULT: number;
  128367. }
  128368. interface WebGLProgram {
  128369. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  128370. }
  128371. interface EXT_disjoint_timer_query {
  128372. QUERY_COUNTER_BITS_EXT: number;
  128373. TIME_ELAPSED_EXT: number;
  128374. TIMESTAMP_EXT: number;
  128375. GPU_DISJOINT_EXT: number;
  128376. QUERY_RESULT_EXT: number;
  128377. QUERY_RESULT_AVAILABLE_EXT: number;
  128378. queryCounterEXT(query: WebGLQuery, target: number): void;
  128379. createQueryEXT(): WebGLQuery;
  128380. beginQueryEXT(target: number, query: WebGLQuery): void;
  128381. endQueryEXT(target: number): void;
  128382. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  128383. deleteQueryEXT(query: WebGLQuery): void;
  128384. }
  128385. interface WebGLUniformLocation {
  128386. _currentState: any;
  128387. }
  128388. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  128389. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  128390. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  128391. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128392. interface WebGLRenderingContext {
  128393. readonly RASTERIZER_DISCARD: number;
  128394. readonly DEPTH_COMPONENT24: number;
  128395. readonly TEXTURE_3D: number;
  128396. readonly TEXTURE_2D_ARRAY: number;
  128397. readonly TEXTURE_COMPARE_FUNC: number;
  128398. readonly TEXTURE_COMPARE_MODE: number;
  128399. readonly COMPARE_REF_TO_TEXTURE: number;
  128400. readonly TEXTURE_WRAP_R: number;
  128401. readonly HALF_FLOAT: number;
  128402. readonly RGB8: number;
  128403. readonly RED_INTEGER: number;
  128404. readonly RG_INTEGER: number;
  128405. readonly RGB_INTEGER: number;
  128406. readonly RGBA_INTEGER: number;
  128407. readonly R8_SNORM: number;
  128408. readonly RG8_SNORM: number;
  128409. readonly RGB8_SNORM: number;
  128410. readonly RGBA8_SNORM: number;
  128411. readonly R8I: number;
  128412. readonly RG8I: number;
  128413. readonly RGB8I: number;
  128414. readonly RGBA8I: number;
  128415. readonly R8UI: number;
  128416. readonly RG8UI: number;
  128417. readonly RGB8UI: number;
  128418. readonly RGBA8UI: number;
  128419. readonly R16I: number;
  128420. readonly RG16I: number;
  128421. readonly RGB16I: number;
  128422. readonly RGBA16I: number;
  128423. readonly R16UI: number;
  128424. readonly RG16UI: number;
  128425. readonly RGB16UI: number;
  128426. readonly RGBA16UI: number;
  128427. readonly R32I: number;
  128428. readonly RG32I: number;
  128429. readonly RGB32I: number;
  128430. readonly RGBA32I: number;
  128431. readonly R32UI: number;
  128432. readonly RG32UI: number;
  128433. readonly RGB32UI: number;
  128434. readonly RGBA32UI: number;
  128435. readonly RGB10_A2UI: number;
  128436. readonly R11F_G11F_B10F: number;
  128437. readonly RGB9_E5: number;
  128438. readonly RGB10_A2: number;
  128439. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  128440. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  128441. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  128442. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  128443. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  128444. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  128445. 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;
  128446. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  128447. readonly TRANSFORM_FEEDBACK: number;
  128448. readonly INTERLEAVED_ATTRIBS: number;
  128449. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  128450. createTransformFeedback(): WebGLTransformFeedback;
  128451. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  128452. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  128453. beginTransformFeedback(primitiveMode: number): void;
  128454. endTransformFeedback(): void;
  128455. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  128456. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128457. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128458. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128459. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  128460. }
  128461. interface ImageBitmap {
  128462. readonly width: number;
  128463. readonly height: number;
  128464. close(): void;
  128465. }
  128466. interface WebGLQuery extends WebGLObject {
  128467. }
  128468. declare var WebGLQuery: {
  128469. prototype: WebGLQuery;
  128470. new(): WebGLQuery;
  128471. };
  128472. interface WebGLSampler extends WebGLObject {
  128473. }
  128474. declare var WebGLSampler: {
  128475. prototype: WebGLSampler;
  128476. new(): WebGLSampler;
  128477. };
  128478. interface WebGLSync extends WebGLObject {
  128479. }
  128480. declare var WebGLSync: {
  128481. prototype: WebGLSync;
  128482. new(): WebGLSync;
  128483. };
  128484. interface WebGLTransformFeedback extends WebGLObject {
  128485. }
  128486. declare var WebGLTransformFeedback: {
  128487. prototype: WebGLTransformFeedback;
  128488. new(): WebGLTransformFeedback;
  128489. };
  128490. interface WebGLVertexArrayObject extends WebGLObject {
  128491. }
  128492. declare var WebGLVertexArrayObject: {
  128493. prototype: WebGLVertexArrayObject;
  128494. new(): WebGLVertexArrayObject;
  128495. };
  128496. // Type definitions for WebVR API
  128497. // Project: https://w3c.github.io/webvr/
  128498. // Definitions by: six a <https://github.com/lostfictions>
  128499. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128500. interface VRDisplay extends EventTarget {
  128501. /**
  128502. * Dictionary of capabilities describing the VRDisplay.
  128503. */
  128504. readonly capabilities: VRDisplayCapabilities;
  128505. /**
  128506. * z-depth defining the far plane of the eye view frustum
  128507. * enables mapping of values in the render target depth
  128508. * attachment to scene coordinates. Initially set to 10000.0.
  128509. */
  128510. depthFar: number;
  128511. /**
  128512. * z-depth defining the near plane of the eye view frustum
  128513. * enables mapping of values in the render target depth
  128514. * attachment to scene coordinates. Initially set to 0.01.
  128515. */
  128516. depthNear: number;
  128517. /**
  128518. * An identifier for this distinct VRDisplay. Used as an
  128519. * association point in the Gamepad API.
  128520. */
  128521. readonly displayId: number;
  128522. /**
  128523. * A display name, a user-readable name identifying it.
  128524. */
  128525. readonly displayName: string;
  128526. readonly isConnected: boolean;
  128527. readonly isPresenting: boolean;
  128528. /**
  128529. * If this VRDisplay supports room-scale experiences, the optional
  128530. * stage attribute contains details on the room-scale parameters.
  128531. */
  128532. readonly stageParameters: VRStageParameters | null;
  128533. /**
  128534. * Passing the value returned by `requestAnimationFrame` to
  128535. * `cancelAnimationFrame` will unregister the callback.
  128536. * @param handle Define the hanle of the request to cancel
  128537. */
  128538. cancelAnimationFrame(handle: number): void;
  128539. /**
  128540. * Stops presenting to the VRDisplay.
  128541. * @returns a promise to know when it stopped
  128542. */
  128543. exitPresent(): Promise<void>;
  128544. /**
  128545. * Return the current VREyeParameters for the given eye.
  128546. * @param whichEye Define the eye we want the parameter for
  128547. * @returns the eye parameters
  128548. */
  128549. getEyeParameters(whichEye: string): VREyeParameters;
  128550. /**
  128551. * Populates the passed VRFrameData with the information required to render
  128552. * the current frame.
  128553. * @param frameData Define the data structure to populate
  128554. * @returns true if ok otherwise false
  128555. */
  128556. getFrameData(frameData: VRFrameData): boolean;
  128557. /**
  128558. * Get the layers currently being presented.
  128559. * @returns the list of VR layers
  128560. */
  128561. getLayers(): VRLayer[];
  128562. /**
  128563. * Return a VRPose containing the future predicted pose of the VRDisplay
  128564. * when the current frame will be presented. The value returned will not
  128565. * change until JavaScript has returned control to the browser.
  128566. *
  128567. * The VRPose will contain the position, orientation, velocity,
  128568. * and acceleration of each of these properties.
  128569. * @returns the pose object
  128570. */
  128571. getPose(): VRPose;
  128572. /**
  128573. * Return the current instantaneous pose of the VRDisplay, with no
  128574. * prediction applied.
  128575. * @returns the current instantaneous pose
  128576. */
  128577. getImmediatePose(): VRPose;
  128578. /**
  128579. * The callback passed to `requestAnimationFrame` will be called
  128580. * any time a new frame should be rendered. When the VRDisplay is
  128581. * presenting the callback will be called at the native refresh
  128582. * rate of the HMD. When not presenting this function acts
  128583. * identically to how window.requestAnimationFrame acts. Content should
  128584. * make no assumptions of frame rate or vsync behavior as the HMD runs
  128585. * asynchronously from other displays and at differing refresh rates.
  128586. * @param callback Define the eaction to run next frame
  128587. * @returns the request handle it
  128588. */
  128589. requestAnimationFrame(callback: FrameRequestCallback): number;
  128590. /**
  128591. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  128592. * Repeat calls while already presenting will update the VRLayers being displayed.
  128593. * @param layers Define the list of layer to present
  128594. * @returns a promise to know when the request has been fulfilled
  128595. */
  128596. requestPresent(layers: VRLayer[]): Promise<void>;
  128597. /**
  128598. * Reset the pose for this display, treating its current position and
  128599. * orientation as the "origin/zero" values. VRPose.position,
  128600. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  128601. * updated when calling resetPose(). This should be called in only
  128602. * sitting-space experiences.
  128603. */
  128604. resetPose(): void;
  128605. /**
  128606. * The VRLayer provided to the VRDisplay will be captured and presented
  128607. * in the HMD. Calling this function has the same effect on the source
  128608. * canvas as any other operation that uses its source image, and canvases
  128609. * created without preserveDrawingBuffer set to true will be cleared.
  128610. * @param pose Define the pose to submit
  128611. */
  128612. submitFrame(pose?: VRPose): void;
  128613. }
  128614. declare var VRDisplay: {
  128615. prototype: VRDisplay;
  128616. new(): VRDisplay;
  128617. };
  128618. interface VRLayer {
  128619. leftBounds?: number[] | Float32Array | null;
  128620. rightBounds?: number[] | Float32Array | null;
  128621. source?: HTMLCanvasElement | null;
  128622. }
  128623. interface VRDisplayCapabilities {
  128624. readonly canPresent: boolean;
  128625. readonly hasExternalDisplay: boolean;
  128626. readonly hasOrientation: boolean;
  128627. readonly hasPosition: boolean;
  128628. readonly maxLayers: number;
  128629. }
  128630. interface VREyeParameters {
  128631. /** @deprecated */
  128632. readonly fieldOfView: VRFieldOfView;
  128633. readonly offset: Float32Array;
  128634. readonly renderHeight: number;
  128635. readonly renderWidth: number;
  128636. }
  128637. interface VRFieldOfView {
  128638. readonly downDegrees: number;
  128639. readonly leftDegrees: number;
  128640. readonly rightDegrees: number;
  128641. readonly upDegrees: number;
  128642. }
  128643. interface VRFrameData {
  128644. readonly leftProjectionMatrix: Float32Array;
  128645. readonly leftViewMatrix: Float32Array;
  128646. readonly pose: VRPose;
  128647. readonly rightProjectionMatrix: Float32Array;
  128648. readonly rightViewMatrix: Float32Array;
  128649. readonly timestamp: number;
  128650. }
  128651. interface VRPose {
  128652. readonly angularAcceleration: Float32Array | null;
  128653. readonly angularVelocity: Float32Array | null;
  128654. readonly linearAcceleration: Float32Array | null;
  128655. readonly linearVelocity: Float32Array | null;
  128656. readonly orientation: Float32Array | null;
  128657. readonly position: Float32Array | null;
  128658. readonly timestamp: number;
  128659. }
  128660. interface VRStageParameters {
  128661. sittingToStandingTransform?: Float32Array;
  128662. sizeX?: number;
  128663. sizeY?: number;
  128664. }
  128665. interface Navigator {
  128666. getVRDisplays(): Promise<VRDisplay[]>;
  128667. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  128668. }
  128669. interface Window {
  128670. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  128671. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  128672. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  128673. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  128674. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  128675. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  128676. }
  128677. interface Gamepad {
  128678. readonly displayId: number;
  128679. }
  128680. type XRSessionMode =
  128681. | "inline"
  128682. | "immersive-vr"
  128683. | "immersive-ar";
  128684. type XRReferenceSpaceType =
  128685. | "viewer"
  128686. | "local"
  128687. | "local-floor"
  128688. | "bounded-floor"
  128689. | "unbounded";
  128690. type XREnvironmentBlendMode =
  128691. | "opaque"
  128692. | "additive"
  128693. | "alpha-blend";
  128694. type XRVisibilityState =
  128695. | "visible"
  128696. | "visible-blurred"
  128697. | "hidden";
  128698. type XRHandedness =
  128699. | "none"
  128700. | "left"
  128701. | "right";
  128702. type XRTargetRayMode =
  128703. | "gaze"
  128704. | "tracked-pointer"
  128705. | "screen";
  128706. type XREye =
  128707. | "none"
  128708. | "left"
  128709. | "right";
  128710. interface XRSpace extends EventTarget {
  128711. }
  128712. interface XRRenderState {
  128713. depthNear?: number;
  128714. depthFar?: number;
  128715. inlineVerticalFieldOfView?: number;
  128716. baseLayer?: XRWebGLLayer;
  128717. }
  128718. interface XRInputSource {
  128719. handedness: XRHandedness;
  128720. targetRayMode: XRTargetRayMode;
  128721. targetRaySpace: XRSpace;
  128722. gripSpace: XRSpace | undefined;
  128723. gamepad: Gamepad | undefined;
  128724. profiles: Array<string>;
  128725. }
  128726. interface XRSession {
  128727. addEventListener: Function;
  128728. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  128729. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  128730. requestAnimationFrame: Function;
  128731. end(): Promise<void>;
  128732. renderState: XRRenderState;
  128733. inputSources: Array<XRInputSource>;
  128734. }
  128735. interface XRReferenceSpace extends XRSpace {
  128736. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  128737. onreset: any;
  128738. }
  128739. interface XRFrame {
  128740. session: XRSession;
  128741. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  128742. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  128743. }
  128744. interface XRViewerPose extends XRPose {
  128745. views: Array<XRView>;
  128746. }
  128747. interface XRPose {
  128748. transform: XRRigidTransform;
  128749. emulatedPosition: boolean;
  128750. }
  128751. declare var XRWebGLLayer: {
  128752. prototype: XRWebGLLayer;
  128753. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  128754. };
  128755. interface XRWebGLLayer {
  128756. framebuffer: WebGLFramebuffer;
  128757. framebufferWidth: number;
  128758. framebufferHeight: number;
  128759. getViewport: Function;
  128760. }
  128761. interface XRRigidTransform {
  128762. position: DOMPointReadOnly;
  128763. orientation: DOMPointReadOnly;
  128764. matrix: Float32Array;
  128765. inverse: XRRigidTransform;
  128766. }
  128767. interface XRView {
  128768. eye: XREye;
  128769. projectionMatrix: Float32Array;
  128770. transform: XRRigidTransform;
  128771. }
  128772. interface XRInputSourceChangeEvent {
  128773. session: XRSession;
  128774. removed: Array<XRInputSource>;
  128775. added: Array<XRInputSource>;
  128776. }